Skip to main content



      Home
Home » Archived » Sapphire » Dynamically enable Action
Dynamically enable Action [message #1229444] Thu, 09 January 2014 08:08 Go to next message
Eclipse UserFriend
I have an Action incl. ActionHandler on a ListProperty, that is displayed next to the AddButton of that List.

Now the Action needs to be enabled depending on:
1. the selection of an item in the list (like the Delete button is only enabled when an item is selected)
2. the value of a property in the model.

I override the org.eclipse.sapphire.ui.SapphireActionSystemPart.isEnabled() method in my action handler, but that is only evaluated the first time the editor open. Also a refresh() of the model element (that contains the action) does not refresh the enabled state.

I also tried adding a Condition inside the action handler, but the evaluate() method is also only invoked when the editor opens, and not upon refresh() of the model element.

Is their a way to manipulate the action at runtime dynamically?

For programming against the selection of the table, I think I require access to the presentation (more specifically TablePropertyEditorPresentation). Is that correct? If yes, is it possible to get the presentation from a SapphirePart object?

Thanks you in advance.
Andreas

Re: Dynamically enable Action [message #1229489 is a reply to message #1229444] Thu, 09 January 2014 09:53 Go to previous messageGo to next message
Eclipse UserFriend
To change action handler enablement, you need to end up calling setEnabled() method rather than overriding isEnabled(). That will ensure that the change is broadcast to interested parties.

To track list selection, you should use ListSelectionService, which you can get from the part.

part.service( ListSelectionService.class )


You can take a look at how this works in TablePropertyEditorPresentation.DeleteActionHandler class.
Re: Dynamically enable Action [message #1229549 is a reply to message #1229489] Thu, 09 January 2014 12:37 Go to previous messageGo to next message
Eclipse UserFriend
setEnabled() did the magic. Thank you also for the ListSelectionService hint! Much appreciated.

Re: Dynamically enable Action [message #1229553 is a reply to message #1229549] Thu, 09 January 2014 12:46 Go to previous messageGo to next message
Eclipse UserFriend
You are welcome. If you are able to share a bit of what you've been able to accomplish with Sapphire for the benefit of potential adopters, you can showcase your work on the adopters wiki.

http://wiki.eclipse.org/Sapphire/Adopters
Re: Dynamically enable Action [message #1229790 is a reply to message #1229553] Fri, 10 January 2014 03:17 Go to previous message
Eclipse UserFriend
Yes, we've already discussed that. That's fine and I will contribute details asap.
Previous Topic:Approach for Attaching/Detaching Listeners
Next Topic:Accessing CustomPart from SapphireWizard subclass
Goto Forum:
  


Current Time: Sun Jul 13 08:30:46 EDT 2025

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

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

Back to the top