Is there a way right now to execute an action after a user has dropped a palette action but before the diagram model is modified? Here is my use case, I have several different types of nodes. Some of these nodes are quite complex and just dropping a new node that creates a new <task> element in the source is not productive enough. I would like to be able to attached a "pre-action" for the drop of the palette item so that I could potentially show a dialog or wizard to create something as complex as a "<task>" on my diagram.
There might be enough in place already for Greg to accomplish what he is after. Both palette drop and add via the context menu, should be invoking the add action. Greg should be able to (in sdef) to filter our system-provided add action handlers and replace them with his own. The only piece that might be necessary (I haven't looked) is to expose the system-provided add action handler class as API so that it can be subclassed to customize its behavior instead of starting from scratch.
I did a little looking and I don't see a Sapphire action ID for palette drop, is this what you mean by it isn't API yet?
After thinking about this a bit more, if I were to override the default "drop from palette > add" action to invoke a wizard, that would be annoying to power users who don't need or want the wizard. What I think I would rather do is leave the default node palette tools that are created by sapphire diagram editor and instead be able to contribute new palette entries that would be called something else like "guided nodes" or "templates" and when the user drops these I could invoke a wizard and then modify the model accordingly.
I just tried to look at the API and I can't simply do this myself with a subclass of SapphireDiagramEditor without copying lots of code. Thoughts?
Really what I'm trying to accomplish is give the user a way to toggle the "guided drop" versus the default drop of new nodes. That was why I was wanting to add some additional palette nodes without having to redefine them in diagramEditor sdef. However, since I could easily add a toggle action to the content menu of the canvas I could have a option for "Use Node Wizards" or something like that.
I'm trying to add my override version of the DiagramNodeAddActionHandler so that I can do my "guided drop" to invoke a wizard prior to drop, etc. I see that the existing DiagramNodeAddActionHandlers are added via a factory. How should I override these? Do I declare something on the nodes themselves in the diagram sdef or do I specify something in sapphire-extension.xml ?
I've tried a couple of things already but I don't yet see how to ensure the handlers from gef.diagram plugin get overridden.
To suppress system-contributed action handlers, you need to write a filter. The filter would be registered in sdef at editor page level (not diagram node level). Typically, action filters are implemented to look for certain action handler id that's undesired. Unfortunately it doesn't look that DiagramNodeAddActionHandlerFactory/DiagramNodeAddActionHandler is setting the id. I've opened a bug for that. In the meantime, you can check for class name.
Thanks Konstantin, so in the sdef for Diagram Editor Page, can I set the <action-handler-filter></action-handler-filter> there? In the SDEF editor I don't see a way to do this, but will it work if I just do it in the source?
Just updated to 0.5.160 and wanted to make sure that for me to properly override the default DiagramNodeAddActionHandlerFactory handlers, I need to register my own handlerFactory for Sapphire.Add and then add an action Filter to filter out the system provided DiagramNodeAddActionHandlers? That is what I'm doing and it is working just fine but wanted to make sure that the filter was indeed needed.