Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Problem using activeEditorInput with Commands
Problem using activeEditorInput with Commands [message #504977] Wed, 23 December 2009 23:18 Go to next message
Michael Schmidt is currently offline Michael SchmidtFriend
Messages: 45
Registered: July 2009
Member
Confused I'm migrating an application to eclipse 3.6 and converting the Actions to Commands. I'm setting up visiblewhen and enabledWhen conditions in the plugin.xml. I want some commands enabled with specific activeEditorInput, and have figured out this variable is actually the IEditorPart toString() value. I've tried to set up the xml code for a test definition like

<definition
id="us.mschmidt.akinoowin.editable">
<with
variable="activeEditorInput">
<equals
value="MyEditor">
</equals>
</with>
</definition>

This doesn't work. In my command execute(), I've done System.out.println() to get HandlerUtil.getVariables(event, ISources.ACTIVE_EDITOR_INPUT_NAME) and cut-and-pasted the result into the value field of the xml code expression. Even doing that, it doesn't work. If it were java code, it would be easy to step through and troubleshoot, but I'm stuck on how to troubleshoot this xml. Any thoughts would be much appreciated.
Re: Problem using activeEditorInput with Commands [message #504990 is a reply to message #504977] Thu, 24 December 2009 06:54 Go to previous messageGo to next message
Michael Golovanov is currently offline Michael GolovanovFriend
Messages: 37
Registered: October 2009
Member
Hi, Michael

Your definition use variable activeEditorInput, its seems that this variable is not supported out of the box. See supported variables

http://wiki.eclipse.org/Command_Core_Expressions

New variables can be provided using ISourceProvider

http:// blog.eclipse-tips.com/2009/02/commands-part-5-authentication -in-rcp.html

Helpful debug options:

http://wiki.eclipse.org/Platform_Command_Framework#Tracing_Option

Hope this help

With best regards, Michael
Re: Problem using activeEditorInput with Commands [message #505001 is a reply to message #504990] Thu, 24 December 2009 05:22 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
On 24/12/09 12:24 PM, Michael Golovanov wrote:
> Hi, Michael
>
> Your definition use variable activeEditorInput, its seems that this
> variable is not supported out of the box. See supported variables
> http://wiki.eclipse.org/Command_Core_Expressions

activeEditorInput is supported by the Platform. Look at ISources class
(http://bit.ly/7QEEsz) for the supported variables


- Prakash
Platform UI Team, IBM

Blog <http://blog.eclipse-tips.com>
Twitter <http://www.twitter.com/Eclipse_Tips>
Re: Problem using activeEditorInput with Commands [message #505004 is a reply to message #504977] Thu, 24 December 2009 10:30 Go to previous messageGo to next message
Michael Golovanov is currently offline Michael GolovanovFriend
Messages: 37
Registered: October 2009
Member
Ups, i am sorry Embarrassed
Re: Problem using activeEditorInput with Commands [message #505028 is a reply to message #504977] Thu, 24 December 2009 18:06 Go to previous messageGo to next message
Michael Schmidt is currently offline Michael SchmidtFriend
Messages: 45
Registered: July 2009
Member
Thanks for the ideas. I did a debug with the tracings options and this provided interesting information. Still, the problem persists and I wonder if there is a bug.

From the tracings, the activePart and activeEditor values are from the editor's toString() method. I confirmed this with a dummy command using the following code in the execute method.

System.out.println("1 " + ISources.ACTIVE_EDITOR_ID_NAME + " " + HandlerUtil.getVariable(event, ISources.ACTIVE_EDITOR_ID_NAME));

System.out.println("2 " + ISources.ACTIVE_EDITOR_INPUT_NAME + " " + HandlerUtil.getVariable(event, ISources.ACTIVE_EDITOR_INPUT_NAME));

System.out.println("3 " + ISources.ACTIVE_EDITOR_NAME + " " + HandlerUtil.getVariable(event, ISources.ACTIVE_EDITOR_NAME));

System.out.println("4 " + ISources.ACTIVE_PART_ID_NAME + " " + HandlerUtil.getVariable(event, ISources.ACTIVE_PART_ID_NAME));

System.out.println("5 " + ISources.ACTIVE_PART_NAME + " " + HandlerUtil.getVariable(event, ISources.ACTIVE_PART_NAME));

This results in the following console output
1 activeEditorId us.mschmidt.akinoowin.dbeditors.DbEditor
2 activeEditorInput By Lead Author
3 activeEditor Table Editor By Lead Author
4 activePartId us.mschmidt.akinoowin.dbeditors.DbEditor
5 activePart Table Editor By Lead Author

I then create a visibleWhen <with> <equals> condition and cut-and-paste the values from the console into the xml (to avoid typos). The command is visible with conditions 1 and 4 but not 2, 3, or 5. So, apparently it evaluates correctly for the class references but not for the toString() values. Any thoughts?
Re: Problem using activeEditorInput with Commands [message #505937 is a reply to message #505028] Tue, 05 January 2010 15:26 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Michael Schmidt wrote:
>
> I then create a visibleWhen <with> <equals> condition and cut-and-paste
> the values from the console into the xml (to avoid typos). The command
> is visible with conditions 1 and 4 but not 2, 3, or 5. So, apparently
> it evaluates correctly for the class references but not for the
> toString() values. Any thoughts?

In ISources, _NAME means that the constant value (i.e.
activeEditorInput) is the name that can be used in "with" core expressions.

ACTIVE_EDITOR_NAME returns an IEditorPart. ACTIVE_PART_NAME returns an
IWorkbenchPart. ACTIVE_EDITOR_INPUT_NAME returns an IEditorInput.

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


Previous Topic:PropertyTester
Next Topic:How to close a view?
Goto Forum:
  


Current Time: Thu Apr 25 16:03:11 GMT 2024

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

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

Back to the top