We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProcessing DevelopmentLibraries,  Tool Development › Touching Base with Tools
Page Index Toggle Pages: 1
Touching Base with Tools (Read 1036 times)
Touching Base with Tools
Feb 12th, 2010, 8:24pm
 
Hi Everyone,
I'm working on a Tool. This tool will help you save a thumbnail that represents your sketch. When you open this tool from the Tools menu, a frame will pop up and let you browse the sketchbook folder interactively using the thumbnails of the sketches - and when you select a processing sketch, it will load the sketch into the processing app.

Only problem is, the processing.app.tools.Tool interface only guarantees that a tool can know about it's parent window's processing.app.Editor class, and the Editor class lacks a counterpart method to the handleOpenReplace(String path) method in processing.app.Base.  So I can instantiate a new Base object - and create a new Processing window in the process - but I can't seem to figure out how to use the Tools interface to load a new sketch without cluttering the screen with more windows (which I refuse to do, fearing the wrath of John Medea).  Any ideas? Aren't I cool cats enough get a reference to the Base class that spawned my Tool? Why isn't there a getBase() method in the Editor, or perhaps an accessible global variable, or perhaps a loadSketch(String path) in Editor that defers to a loadSketchImpl in Base? Is Processing really about to ... school me in the law of demeter?
Re: Touching Base with Tools
Reply #1 - Feb 13th, 2010, 12:44am
 
Looks like the default behavior. Whether you use the File / Sketchbook menu or the other File / Open... menu, it always brings on a new window. That's not so bad, is it? :-)
Re: Touching Base with Tools
Reply #2 - Feb 13th, 2010, 5:41am
 
"I want to go to that one sketch - which one was it? It looks like green diamonds." There are two competing user stories for my program here:

1.) If I'm not allowed to close the editor, the response to the script is [press an accelerator][browser pops up][click thumbnail][new editor pops up][move editor out of the way][close old editor][click on new editor to return focus].

2.) If I'm allowed to close the editor, the response is [press an accelerator][browser pops up][click thumbnail][sketch loads in editor and pop up closes].

One of these is appropriate for browsing and one one isn't - that's why Firefox, Opera, Safari, Konquerer, Internet Explorer, and all Microsoft and Apple file browsers made after 1995 don't open up a new tab but open in the same tab when you click on a link.

After peeling through the source code, though, I see that though most fields are static in Base, the list of editors isn't -

java.util.List<Editor> editors =
   Collections.synchronizedList(new ArrayList<Editor>());

I'm not sure why this isn't static - that must be the reason why handleClose( Editor editor ) isn't static.
Re: Touching Base with Tools
Reply #3 - Feb 13th, 2010, 5:49am
 
But why not init( Editor ed, Base base )? Not sure
Page Index Toggle Pages: 1