Invoke my plugin by a draw action?


#1

Hi every body,

Is there any way to invoke your plugin when you drop a shape on a diagram ?


#2

Any idea ???


#3

My guess is as good as yours but I don’t think you can. According to the manual you can only activate a plugin through means of an ActionController class and that has two main options which it can use: the toolbar or the pop-up menu.

But solely basing myself on going over the API documentation I don’t think it allows for registering any custom (event) handlers and all that.


#4

assume drop a shape on a diagram means a shape is added into the diagram.
You can add a listener to the diagram, your listener will receive the event when a shape is added into the diagram.

// implements your listener 
com.vp.plugin.diagram.IDiagramListener lMyDiagramListener = ... {
	@Override
	public void diagramElementAdded(IDiagramUIModel aDiagram, IDiagramElement aDiagramElement) {
		// do somethings
	}
	...
}

IDiagramUIModel lDiagram = ...
lDiagram.addDiagramListener(lMyDiagramListener);

PS: the diagramElementAdded(…) event will be triggered when a shape is added (no matter the shape is added by Drag&Drop, or Duplicate a Shape, etc…)


#5

OK,Thank you :pray::pray: