open my editor only on .css files in PlugIn projects [message #330474] |
Tue, 29 July 2008 15:35 |
Eclipse User |
|
|
|
Hi,
I'm working on a multi page editor that handles .css files.
But my editor should only open if the .css file is located in a certain
project nature (PlugIn projects).
I tried lot of things, but without success.
So I appreciate any help.
My plugin.xml looks like:
<plugin>
<extension
point="org.eclipse.ui.editors">
<editor
class="org.eclipse.rap.themeeditor.editor.ThemeEditor"
icon="icons/file_obj.gif"
id="org.eclipse.rap.themeeditor.editor.ThemeEditor"
name="RAP Theme Editor">
</editor>
</extension>
<extension point="org.eclipse.ui.navigator.navigatorContent">
<actionProvider
class="org.eclipse.rap.themeeditor.editor.OpenActionProvider "
id="org.eclipse.rap.themeeditor.editor.OpenActionProvider"
priority="highest">
<enablement>
<or>
<and>
<adapt type="org.eclipse.core.resources.IFile" />
<test
property="org.eclipse.core.resources.projectNature"
value="org.eclipse.pde.PluginNature">
</test>
</and>
</or>
</enablement>
</actionProvider>
</extension>
<extension point="org.eclipse.ui.navigator.viewer">
<viewerActionBinding
viewerId="org.eclipse.jdt.ui.PackageExplorer">
<includes>
<actionExtension
pattern="org.eclipse.rap.themeeditor.editor.OpenActionProvider ">
</actionExtension>
</includes>
</viewerActionBinding>
<viewerActionBinding
viewerId="org.eclipse.ui.navigator.ProjectExplorer">
<includes>
<actionExtension
pattern="org.eclipse.rap.themeeditor.editor.OpenActionProvider ">
</actionExtension>
</includes>
</viewerActionBinding>
</extension>
</plugin>
And the class OpenActionProvider is this one:
public class OpenActionProvider extends CommonActionProvider {
private OpenPropertyAction openAction;
public OpenActionProvider() {
}
public void init( ICommonActionExtensionSite aSite ) {
ICommonViewerSite viewSite = aSite.getViewSite();
if ( viewSite instanceof ICommonViewerWorkbenchSite ) {
ICommonViewerWorkbenchSite workbenchSite = (
ICommonViewerWorkbenchSite )viewSite;
openAction = new OpenPropertyAction( workbenchSite.getPage(),
workbenchSite.getSelectionProvider() );
}
}
public void fillActionBars( IActionBars actionBars ) {
if ( openAction.isEnabled() ) {
actionBars.setGlobalActionHandler( ICommonActionConstants.OPEN,
openAction );
}
}
public void fillContextMenu( IMenuManager menu ) {
if ( openAction.isEnabled() ) {
menu.appendToGroup( ICommonMenuConstants.GROUP_OPEN_WITH, openAction
);
}
}
}
The class OpenPropertyAction extends the class
org.eclipse.jface.action.Action,
and in its run() method it will open my editor.
So I wanted to contribute to the menu item OPEN/OPEN_WITH.
But unfortunately, it doesn't work.
In Package Explorer there absolutely nothing.
And in Project Explorer there appears my OpenPropertyAction but under the
"Open With" item, and not part of it.
And I dont know exactly where to put the file extension setting.
If I do this inside org.eclipse.ui.editors then all .css files are opened
with my editor without respect to the project nature.
So could anybody give me a hint how to fix it?
Or is there even a better solution in solving this kind of issue?
Let me say again what I need precicely:
If the file extension is .css and this file is located in a certain
project nature (PlugIn project),
then and only then it should use my own editor!
Thanks a lot.
|
|
|
Powered by
FUDForum. Page generated in 0.02389 seconds