Hei Volker, you may have a look at exiting editing tools? e.g. check the tools in org.openjump.core.ui.plugin.edittoolbox.* in "curosortools" you could look at AutoCompletePolygon or ConstrainedWhateverTool
but I wonder why you would need to bound this to a layer and not just as general action for your tool, so you would avoid the layerlistener stuff just a thought stefan [email protected] wrote: > Hello "The Sunburned Surveyor", > > thanks for your answer. I guess this list make more sense :-) ( wasn't > aware of this ) > > as explained I'm already using a LayerListener. Let me try to explain > with an example: > > - I've added a Layerlistener and get informed by its featureChanged-Method > - The user adds an simple empty ( just with the geometry ) feature to > the selected layer with the *DrawPointTool*. > - If the new feature doesn't match to given rules I would like to cancel > the current UndoableCommand created by *DrawPointTool *within my > LayerListener-Implementation > > something inside the featureChanged like: > > if( isUgly(feature)){ > frame.warnUser("Don't add ugly features!"); > stopExecutionAndRemoveUndoableCommand(); > } > > Regards, > > Volker > > > -----Ursprüngliche Mitteilung----- > Von: Sunburned Surveyor <[email protected]> > An: [email protected] > Cc: OpenJump develop and use <[email protected]> > Verschickt: Di., 2. Feb. 2010, 16:45 > Thema: Re: [openjump-users] cancel CursorTool-Command > > Volker, > > > > > > > > You should be able to do it in the same LayerListener. For example: If > > > > you want to write a couple lines of text to a text file everytime > > > > nodes are deleted from a feature, you would implement LayerListener. > > > > In the LayerListener.featureChanged method you would need to test the > > > > modified feature for deleted nodes. > > > > > > > > In summary, test for your "rules" or conditions in the implementation > > > > of the featureChanged method. If the modifications meet your set of > > > > rules, then take the desired action. It is probably good design to > > > > have two private methods in your LayerListener implementation. The > > > > first private method would conduct the test to see if the feature > > > > modification met your criteria. The second private method would > > > > perform the desired action if the criteria was met. > > > > > > > > Note: The ability to listen for feature changes is handy, but it can > > > > be over used. To much "listening" can really slow down the execution > > > > of the program, so use it judiciously. > > > > > > > > The Sunburned Surveyor > > > > > > > > P.S. - This discussion should really be moved to the JPP developer's > > > > mailing list. I am going to copy that list on this response. > > > > > > > > On Tue, Feb 2, 2010 at 5:48 AM, Volker <[email protected]> wrote: > > > >> Hello, > > > >> > > > >> I added a LayerListener so that I can do a specific action when a > > > >> feature was added to the layer by any CursorTool (e.g. > > > >> DrawPointTool). > > > >> > > > >> If given Rules are not fulFilled I would like to cancel this > > > >> CursorTool-Command? > > > >> > > > >> Any idea how or do I have to use an other Listener? > > > >> > > > >> Thanks in advance :-) > > > >> > > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > The Planet: dedicated and managed hosting, cloud storage, colocation > Stay online with enterprise data centers and the best network in the business > Choose flexible plans and management services without long-term contracts > Personal 24x7 support from experience hosting pros just a phone call away. > http://p.sf.net/sfu/theplanet-com > > > ------------------------------------------------------------------------ > > _______________________________________________ > Jump-pilot-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ Jump-pilot-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
