Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Inactive save button wiht new handler to save command
Inactive save button wiht new handler to save command [message #892305] Wed, 27 June 2012 16:49 Go to next message
jpfse   is currently offline jpfse Friend
Messages: 18
Registered: December 2011
Junior Member
Hello,

I need to run a routine everytime the "save button" is pressed. To do that, I created a handler to the org.eclipse.ui.file.save command (see extension element detains.JPG).
I'm able to launch an eclipse application, but the save button is not enable, even when the file is edited (see inactiveSaveButton.JPG).

I will include also de handler file (OKInitializerSaveHandler.java).

I'm new to eclipse rcp, so I am finding it dificult to figure what the problem could be. Am I on the right path, at least?

Tanks!

[Updated on: Wed, 27 June 2012 16:50]

Report message to a moderator

Re: Inactive save button wiht new handler to save command [message #892453 is a reply to message #892305] Thu, 28 June 2012 09:41 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 312
Registered: February 2012
Location: Düsseldorf
Senior Member
Hi,
sounds like your handler is not enabled. Did you specify an enabledWhen expression with your handler extension?

Regards,
Thorsten
Re: Inactive save button wiht new handler to save command [message #892488 is a reply to message #892453] Thu, 28 June 2012 12:34 Go to previous messageGo to next message
jpfse   is currently offline jpfse Friend
Messages: 18
Registered: December 2011
Junior Member
I did not...

if I don't enable the handler, the save button will not enable?
Re: Inactive save button wiht new handler to save command [message #892489 is a reply to message #892488] Thu, 28 June 2012 12:38 Go to previous messageGo to next message
jpfse   is currently offline jpfse Friend
Messages: 18
Registered: December 2011
Junior Member
Actualy, I would like the button to have it's normal behavior plus my handler when I'm saving an ecore model, and just the normal behavior in every other case. Is it possible?

Re: Inactive save button wiht new handler to save command [message #892491 is a reply to message #892305] Thu, 28 June 2012 12:45 Go to previous messageGo to next message
Simon Scholz is currently offline Simon ScholzFriend
Messages: 73
Registered: April 2012
Location: Germany
Member
Hi João,

this is possible, I think that Eclipse ignores your own handler and uses the handler, which is defined by Default in Eclipse for the org.eclipse.ui.file.save command.

In order to tell Eclipse that it shall use your own handler, you´ll have to define an activeWhen for your handler, so that Eclipse knows when to use it´s own handler or your own handler.

The following page gives you a good overview concerning the Command Core Expressions:

wiki.eclipse.org/Command_Core_Expressions

By the way:

Quote:
if I don't enable the handler, the save button will not enable?


The handler is enabled by default, so it is not necessary to enable it, you´ll just have to define when your handler should be active Smile

Best regards,

Simon

[Updated on: Thu, 28 June 2012 12:48]

Report message to a moderator

Re: Inactive save button wiht new handler to save command [message #892511 is a reply to message #892491] Thu, 28 June 2012 13:51 Go to previous messageGo to next message
jpfse   is currently offline jpfse Friend
Messages: 18
Registered: December 2011
Junior Member
hum, ok...

So when I make my handler active, the default eclipse handler is disabled?
Re: Inactive save button wiht new handler to save command [message #892519 is a reply to message #892511] Thu, 28 June 2012 14:16 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

The default save handler (wraps an action, I think) works at the IWorkbenchWindow level. That has a higher priority than a default handler.

if you are in an RCP app, you control the ActionBarAdvisor and could in theory register your own save handler that does what you want and delegates to the regular save handler, no?

PW


Re: Inactive save button wiht new handler to save command [message #892819 is a reply to message #892305] Fri, 29 June 2012 21:21 Go to previous message
Simon Scholz is currently offline Simon ScholzFriend
Messages: 73
Registered: April 2012
Location: Germany
Member
Hi João,

take a look at the JavaDoc concerning the Handler:
help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_handlers.html

"handlers javadoc"

[...]
A handler that specifies no conditions is a default handler. A default handler is only active if no other handler has all of its conditions satisfied. If two handlers still have conditions that are satisfied, then the conditions are compared. The idea is to select a handler whose condition is more specific or more local. To do this, the variables referred to by the condition are looked at. The condition that refers to the most specific variable "wins". The order of specificity (from least specific to most specific) is suggested in org.eclipse.ui.ISources.
[...]


So if your activeWhen definition "wins", your own handler will be invoked.

"João"
So when I make my handler active, the default eclipse handler is disabled?

Yes the eclipse handler wont be invoked, if your activeWhen definition "wins" and therefore your own handler is invoked.

Best regards,

Simon
Previous Topic:How to update view Secondary Id
Next Topic:can not deactivate handler (only toolbar)
Goto Forum:
  


Current Time: Thu Mar 28 18:44:44 GMT 2024

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

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

Back to the top