So there are two sides to this:

a) The GEF palette does not appear to support "enablement" out of the box; need 
some more research to double check this
b) Wander into uDig and figure out how enablement works

 Sorted out the uDig side of this 

1) ModalItems are actually set up to handle enablement (seems to be their main 
value add)
2) They already keep a list of "contributions" that they update - so they can 
kick menus and toolbar contributions with a new value of setEnabled
3) Added a list of MapToolEntry; and during the creation of MapToolEntry we add 
ourself to this list

item.getMapToolEntries().add( this ); // register for enablement

4) Also added a MapToolEntry.dispose() to remove ourselves from the list

5) Thought a bit about who should call dispose; and caught myself adding 
complicated code to MapEditorWithPalette to traverse the palette and hunt down 
things to dispose()

And then had a good idea ...

MapToolPaletteFactory.dispose( paletteRoot ); 
paletteRoot = null;

That is a static method; implemented by the same class that creates the Palette 
(so if it built it, it knows the structure; and thus can take it apart and 
clean up after it). Resulting in nice clean code. The method also does a null 
check so it is trouble free to call...

_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to