Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Test for file extension in the active editor via expression definition in plugin.xml
Test for file extension in the active editor via expression definition in plugin.xml [message #552943] Sat, 14 August 2010 23:37 Go to next message
Alex Molochnikov is currently offline Alex MolochnikovFriend
Messages: 25
Registered: July 2009
Junior Member
I am trying to make the display of a toolbar button conditional upon the
type (extension) of the input file in the currently active editor. For
this I set the following expression:


<definition
id="com.kelman.basemap.ui.selectedGeometrySingleFile">
<and>
<reference

definitionId="com.kelman.database.kismet.ui.view.activeEditor ">
</reference>
<with
variable="activeEditor">
<adapt
type="org.eclipse.core.resources.IResource">
<test
property="org.eclipse.core.resources.name"
value="*.gdb">
</test>
</adapt>
</with>
</and>
</definition>

hoping to get the active editor adapt to the IResource and then test the
file name for the desired extension ("gdb").

But the getAdapter() method of the editor is never called. I guess, I am
using the wrong setup. What variable should I use to make the framework
use the editor as the target for adapter?

Thanks for any guidance.

Alex Molochnikov
Kelman Technologies Inc.
Re: Test for file extension in the active editor via expression definition in plugin.xml [message #553146 is a reply to message #552943] Mon, 16 August 2010 14:44 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You need activeEditorInput to get the active editor input.

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: Test for file extension in the active editor via expression definition in plugin.xml [message #553191 is a reply to message #553146] Mon, 16 August 2010 15:21 Go to previous message
Alex Molochnikov is currently offline Alex MolochnikovFriend
Messages: 25
Registered: July 2009
Junior Member
Paul Webster wrote:
> You need activeEditorInput to get the active editor input.
>
> PW
>
>
Thanks you. It worked:

<definition
id="com.kelman.basemap.ui.selectedGeometrySingleFile">
<with
variable="activeEditorInput">
<adapt
type="org.eclipse.core.resources.IResource">
<test
property="org.eclipse.core.resources.extension"
value="gdb">
</test>
</adapt>
</with>
</definition>
Previous Topic:Is there a way to override an existing adapterfactory / avoid it from adapting
Next Topic:Re: Key bindings not working in Eclipse
Goto Forum:
  


Current Time: Thu Apr 25 15:37:08 GMT 2024

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

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

Back to the top