Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to detect a tool has changed or a click on a palette entry has occured?
How to detect a tool has changed or a click on a palette entry has occured? [message #524647] Thu, 01 April 2010 16:30
TL is currently offline TLFriend
Messages: 22
Registered: July 2009
Junior Member
Hi,

I would like to detect when a tool in my editor is changed (e.g., the
create Node tool is being activated) and react to that with some custom
code. The alternative would be to detect a click on the palette or even
the event that the palette has received focus. Can someone help me?

The underlying motivation for this is developing an editor with a super
and some sub diagrams that share an editing domain. Currently when I
save any of a diagram and directly use a create node tool I receive a
NullPointerException (NPE) which is shown in [1]. I resolved my NPEs for
other scenarios by overriding the setFocus() method of my editor, which
refreshes the model elements if they were unloaded (which they usually
do). However when I save my diagram and directly select the Create node
tool and try to click on the canvas I get the NPE in [], since the
setFocus() method of the current page (which holds the editor) is not called

Any suggestions are welcome.
Thomas L.

[1] execute
org.eclipse.core.commands.ExecutionException: While executing the
operation, an exception occurred
at
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:519)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:205)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:168)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:155)
at org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTo ol.java:399)
at
org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(Abs tractTool.java:411)
at
org.eclipse.gmf.runtime.diagram.ui.tools.CreationTool.perfor mCreation(CreationTool.java:133)
at org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTo ol.java:178)
at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java :1064)
at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:263)
at
org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouse Released(DomainEventDispatcher.java:374)
at
org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(Li ghtweightSystem.java:538)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:207)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:386)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Caused by: java.lang.NullPointerException
at
org.eclipse.emf.workspace.AbstractEMFOperation.inheritedOpti ons(AbstractEMFOperation.java:240)
at
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:149)
at
org.eclipse.gmf.runtime.diagram.ui.commands.SemanticCreateCo mmand.doExecuteWithResult(SemanticCreateCommand.java:71)
at
org.eclipse.gmf.runtime.common.core.command.AbstractCommand. execute(AbstractCommand.java:135)
at
org.eclipse.gmf.runtime.common.core.command.CompositeCommand .doExecuteWithResult(CompositeCommand.java:403)
at
org.eclipse.gmf.runtime.common.core.command.AbstractCommand. execute(AbstractCommand.java:135)
at
org.eclipse.gmf.runtime.common.core.command.CompositeCommand .doExecuteWithResult(CompositeCommand.java:403)
at
org.eclipse.gmf.runtime.common.core.command.AbstractCommand. execute(AbstractCommand.java:135)
at
org.eclipse.gmf.runtime.common.core.command.CompositeCommand .doExecuteWithResult(CompositeCommand.java:403)
at
org.eclipse.gmf.runtime.common.core.command.AbstractCommand. execute(AbstractCommand.java:135)
at
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:511)
... 37 more
Previous Topic:Double-click on whitespace/canvas
Next Topic:Slow performance of programmatic element creation via editDomain.
Goto Forum:
  


Current Time: Thu Apr 25 08:12:54 GMT 2024

Powered by FUDForum. Page generated in 0.03315 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top