Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » tool palette action override
tool palette action override [message #788618] Thu, 02 February 2012 02:16 Go to next message
Greg Amerson is currently offline Greg AmersonFriend
Messages: 119
Registered: March 2010
Senior Member
// conversation continued from mailing list

Greg
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.


Konstantin
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?
Re: tool palette action override [message #788638 is a reply to message #788618] Thu, 02 February 2012 02:52 Go to previous messageGo to next message
Greg Amerson is currently offline Greg AmersonFriend
Messages: 119
Registered: March 2010
Senior Member
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?
Re: tool palette action override [message #790056 is a reply to message #788638] Fri, 03 February 2012 19:14 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Palette isn't exposed for contribution of arbitrary actions. Have you considered adding your wizard as an action at diagram editor page level? It will show up when user right-clicks on the canvas.

- Konstantin
Re: tool palette action override [message #790194 is a reply to message #790056] Fri, 03 February 2012 23:32 Go to previous messageGo to next message
Greg Amerson is currently offline Greg AmersonFriend
Messages: 119
Registered: March 2010
Senior Member
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.
Re: tool palette action override [message #790283 is a reply to message #790194] Sat, 04 February 2012 02:40 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Yeah. That sounds like a pretty good approach... A series of toggles for controlling how much guidance the user would like. Let us know if you run into issues implementing this.
Re: tool palette action override [message #821330 is a reply to message #790283] Thu, 15 March 2012 07:56 Go to previous messageGo to next message
Greg Amerson is currently offline Greg AmersonFriend
Messages: 119
Registered: March 2010
Senior Member
Hey guys,

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.
Re: tool palette action override [message #821750 is a reply to message #821330] Thu, 15 March 2012 19:31 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
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.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=374433
Re: tool palette action override [message #821925 is a reply to message #821750] Fri, 16 March 2012 00:44 Go to previous messageGo to next message
Greg Amerson is currently offline Greg AmersonFriend
Messages: 119
Registered: March 2010
Senior Member
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?
Re: tool palette action override [message #821926 is a reply to message #821925] Fri, 16 March 2012 00:47 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
It should work. Let us know if that's not the case. Please open a bug for the missing "Actions and Handlers" node for diagram editor page in sdef editor.
Re: tool palette action override [message #825595 is a reply to message #821926] Wed, 21 March 2012 02:31 Go to previous messageGo to next message
Greg Amerson is currently offline Greg AmersonFriend
Messages: 119
Registered: March 2010
Senior Member
Hi Konstantin,

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.

Also I can confirm that adding the filter in the source for the diagram-editor element does work but it is missing this node in the SDEF editor, so I've opened a bug for that: https://bugs.eclipse.org/bugs/show_bug.cgi?id=374847
Re: tool palette action override [message #825645 is a reply to message #825595] Wed, 21 March 2012 04:21 Go to previous message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Quote:
That is what I'm doing and it is working just fine but wanted to make sure that the filter was indeed needed.


Yes, adding the filter is necessary in this scenario. There is no concept of an override in actions API. Just contribute and filter. You put the two together to do an override.

Quote:
Also I can confirm that adding the filter in the source for the diagram-editor element does work but it is missing this node in the SDEF editor


Thanks for the bug and the patch.
Previous Topic:Group UI element suggestions
Next Topic:2-element XSD sequence model implementation
Goto Forum:
  


Current Time: Fri Mar 29 13:27:14 GMT 2024

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

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

Back to the top