Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » Dynamically enable Action
Dynamically enable Action [message #1229444] Thu, 09 January 2014 13:08 Go to next message
Andreas Weise is currently offline Andreas WeiseFriend
Messages: 37
Registered: January 2014
Member
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 14:53 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 952
Registered: July 2009
Senior Member
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 17:37 Go to previous messageGo to next message
Andreas Weise is currently offline Andreas WeiseFriend
Messages: 37
Registered: January 2014
Member
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 17:46 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 952
Registered: July 2009
Senior Member
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 08:17 Go to previous message
Andreas Weise is currently offline Andreas WeiseFriend
Messages: 37
Registered: January 2014
Member
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: Thu Nov 27 23:19:39 GMT 2014

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

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