Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Popup menu not refreshed when no new selection
Popup menu not refreshed when no new selection [message #517877] Tue, 02 March 2010 07:23 Go to next message
Johan Asterholm is currently offline Johan Asterholm
Messages: 3
Registered: March 2010
Junior Member
Hi,

I have a problem with a tableviewer and a popup menu. the menu consists of a couple of commands which has activeWhen set on the handlers. Each of these activeWhen checks for different states in the object shown in the tableviewer.

Example:

the handler setToPending sets pending in the model object but its not active when the state is pending in the model object


My problem is that the popup menu is not refreshed unless i make a new selection in the tableviewer. So if im standing on a row, right-click and run the setToPending command, this works fine. If right-clicking on the same row again no new selection is sent and the handler setToPending is still shown as active in the menu, but throws an exception when its run since the handler is not active.

Is there a way which i can refresh the popup menu ( i have tried to send the same selection again but this dosen't work), or make the popup menu recheck the state of all the handlers on activation?
Re: Popup menu not refreshed when no new selection [message #518035 is a reply to message #517877] Tue, 02 March 2010 10:18 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Johan Asterholm wrote:
> Hi,
>
> I have a problem with a tableviewer and a popup menu. the menu consists
> of a couple of commands which has activeWhen set on the handlers. Each
> of these activeWhen checks for different states in the object shown in
> the tableviewer.
>
> Example:
>
> the handler setToPending sets pending in the model object but its not
> active when the state is pending in the model object
>
>
> My problem is that the popup menu is not refreshed unless i make a new
> selection in the tableviewer.

Refreshed in what way? What visibleWhen are you using to add the
setToPending menu item?

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Popup menu not refreshed when no new selection [message #518140 is a reply to message #517877] Wed, 03 March 2010 04:11 Go to previous messageGo to next message
Johan Asterholm is currently offline Johan Asterholm
Messages: 3
Registered: March 2010
Junior Member
Hi Paul,

I'm using a propertyTester to check the condition of the currently selected row, and i think that this is the problem, that they do not get rechecked if i don't make a new selection.

Here is the handler enabledWhen logic

<handler
class="se.capana.selection.ChangeStateToFalseHandler"
commandId="se.capana.selection.toFalse">
<enabledWhen>
<iterate
ifEmpty="false"
operator="and">
<test
forcePluginActivation="true"
property="se.capana.selection.tester.isTrue">
</test>
</iterate>
</enabledWhen>
</handler>

I have created a quick and dirty rcpproject which recreates the problem its exported as an eclipse export. Start the program select a row and show the menu. select toTrue, and then right click on the same row again to see the problem.

The project can be downloaded from:

http://atlas.sputnic.se/~aster/rcpproject.zip


Regards Johan
Re: Popup menu not refreshed when no new selection [message #518266 is a reply to message #518140] Wed, 03 March 2010 06:00 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Johan Asterholm wrote:
> Hi Paul,
> I'm using a propertyTester to check the condition of the currently
> selected row, and i think that this is the problem, that they do not get
> rechecked if i don't make a new selection.

Property testers do not get re-checked (nothing tells the framework that
the property has changed, it's opaque). It's the responsibility of the
property provider to request a re-evaluation. See
org.eclipse.ui.services.IEvaluationService.requestEvaluation (String)


PW



--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Popup menu not refreshed when no new selection [message #518283 is a reply to message #518266] Wed, 03 March 2010 11:41 Go to previous message
Johan Asterholm is currently offline Johan Asterholm
Messages: 3
Registered: March 2010
Junior Member
Works great!

Thanks allot.

regards Johan
Previous Topic:How to add views from other plugins to perspective
Next Topic:Context menu for a MultipageEditorPart
Goto Forum:
  


Current Time: Fri Aug 01 11:54:44 EDT 2014

Powered by FUDForum. Page generated in 0.01669 seconds