Save as menu is disable for custom graph editor - eclipse-plugin

I have added two menu in my RCP application Save and Save As. If my custom editor is dirty then save option is enable but save as option is disable. Save As option is enable for other .java, .properties etc file but not for custom graph editor. Observe for manifest custom editor also it is disable in eclipse. So may be Save As is disable for custom editor.
So how to enable this option i have tried registering this action into graph but this wont work.
Extension Added as below:
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="menu:org.eclipse.ui.main.menu">
<menu
id="hg.ui.graphbuilder.menus.file"
label="File">
--------
--------
<command
commandId="org.eclipse.ui.file.save"
icon="icons/save_o.png"
label="Save"
style="push">
</command>
<command
commandId="org.eclipse.ui.file.saveAs"
icon="icons/saveAs_o.png"
label="Save As..."
style="push">
</command>
-----------
-----------
</extension>

Related

IntelliJ plugin localization

I'm creating a plugin for Intellij IDEA. Following found tutorial now I have pretty simple working plugin. But my problem is the fact I don't know how to maintain localization for my actions.
Now I've got plugin.xml file with following actions tag:
<actions>
<group id="MyPlugin.TopMenu"
text="_MyPlugin"
description="My plugin toolbar menu">
<add-to-group group-id="MainMenu" anchor="last"/>
<action id="MyAction"
class="actions.MyAction"
text="_MyAction"
description="MyAction"/>
</group>
</actions>
This code means that my group and action will be shown as "_MyPlugin" and "_MyAction" regardless localization.
I found how to create resouces bundle and did it. Now I have strings.xml (as I used to for Android) with following content:
<properties>
<entry key="ActionName">_MyAction</entry>
</properties>
Another resource file called strings_ru.xml is combined with it into Resource Bundle, so I don't think I did something wrong with it.
I want to use resource reference to set text tag for my group and its actions. Is it even possible? If not should I create and register actions in runtime?

Why is this Eclipse RCP plugin missing a view?

I am experimenting with the way an Eclipse RCP application is dealing with its plugins. In Eclipse IDE I created an Eclipse RCP 3.x project with a view that generated all the necessary files and worked just fine.
Assuming that I can transform this application into one that only holds an empty perspective just by removing the respective parts of the plugin.xml file, I commented out all the lines that deal with the view like so:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="application"
point="org.eclipse.core.runtime.applications">
<application>
<run
class="pluginwithview.Application">
</run>
</application>
</extension>
<extension
point="org.eclipse.ui.perspectives">
<perspective
name="Perspective"
class="pluginwithview.Perspective"
id="PluginWithView.perspective">
</perspective>
</extension>
<!--
even without these lines
there's an Exception thrown saying:
"Could not create the view: PluginWithView.view
-->
<!-- <extension
point="org.eclipse.ui.views">
<view
name="View"
inject="true"
class="pluginwithview.View"
id="PluginWithView.view">
</view>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="*">
<view
standalone="true"
minimized="false"
relative="org.eclipse.ui.editorss"
relationship="left"
id="PluginWithView.view">
</view>
</perspectiveExtension>
</extension> -->
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu">
<menu
label="File">
<command
commandId="org.eclipse.ui.file.exit"
label="Exit">
</command>
</menu>
</menuContribution>
</extension>
</plugin>
But instead of displaying an empty perspective, the app now looks like so:
What must I do to not have the application search for the view ? Is there a config file that I am missing ? (I know there a few reasons to not have a view , but right now I am mainly interested in the inner workings of an Eclipse RCP application)
Perspectives remember the views they contained. If you change the perspective definition you will have to do a perspective reset ('Window > Perspective > Reset Perspective') to get it to read the updated definition.
For testing you can also specify the -clean and -clearPersistedState options in the 'Program Arguments' section of the RCP Run Configuration to discard all saved information.

delete popup working fine over project explorer view but not working over navigator view

I am trying to hide 'delete' popup-menu for some files. I used following plugin.xml entry.
<extension point="org.eclipse.ui.activities">
<activity id="hidedeletepopupmenuID" name="hidedeletepopupmenu">
<enabledWhen>
<with variable="selection">
<iterate operator="and">
<adapt type="org.eclipse.core.resources.IResource" >
<or>
<test property="org.eclipse.core.resources.name" value="*.java"/>
</or>
</adapt>
</iterate>
</with>
</enabledWhen>
</activity>
<activityPatternBinding activityId="hidedeletepopupmenuID"
isEqualityPattern="false" pattern="org.eclipse.ui.edit.delete">
</activityPatternBinding>
</extension>
This seems to be working fine over project explorer view, but navigator view its not wokring. Can anyone help on this?
Thanks,
darshan
Actions in Navigator view context menu are hard-coded, see ResourceNavigator.fillContextMenu(IMenuManager menu).
Note that the action in popup menu is not the only way to delete a resource (there's also a menu item in Edit menu and key-binding).

popup plugin development eclipse 3.6.2

I'm trying to develop an eclipse plugin, but, seeing the steps, or using the template Eclipse gives, I can't see the menu item.
Mi Eclipse version is 3.6.2 and mi plugin.xml file has this content:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.core.resources.IFile"
id="Test.contribution1">
<menu
label="Test Submenu"
path="additions"
id="Test.menu1">
<separator
name="group1">
</separator>
</menu>
<action
label="Test Action"
class="test.popup.actions.TestNewAction"
menubarPath="Test.menu1/group1"
enablesFor="1"
id="Test.newAction">
</action>
</objectContribution>
</extension>
</plugin>
This is the sample template Eclipse gives, but it doesn't work.
It's supposed that this kind of menu shows the option when you right click on a Java element (like a constant or something like that). Am I wrong?
Indeed, the code you posted should show a menu and a submenu when you make a right click on a file in the Project Explorer/Package Explorer view.
If you don't see any menu or submenu, try to add adaptable="true" and nameFilter="*", like this :
<objectContribution
adaptable="true"
nameFilter="*"
objectClass="org.eclipse.core.resources.IFile"
id="Test.contribution1">
It should work now and you should have this output.

Eclipse Plugin Development : How to add option in Right Click Menu

I have created an eclipse plugin. I am able to add a menu and submenu.
However, I am not able to add an option in the Right Click menu. Does anyone have any idea how to do that?
Here's an example (this code has filled with your preferences and classes and to be added to the plugin.xml):
<extension point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="true"
id=""
nameFilter=""
objectClass="org.eclipse.core.resources.IFile">
<action
id="org.eclipse.ui.articles.action.contribution.object.action1"
label=""
icon=""
menubarPath="additions"
class="">
</action>
</objectContribution>
</extension>
The provided solution using org.eclipse.ui.popupMenus is deprecated.
One should use the org.eclipse.ui.menus extension point.
In general you can configure a menuContribution using the plugin GUI, which will generate the plugin.xml for you. As you requested the menu to be available in the "Right Click menu" you can use popup:org.eclipse.ui.popup.any as locationURI. With additional configuration you can control under which circumstances the menu should be visible.
You can also edit the plugin.xml directly in the plugin.xml tab.
The generated plugin.xml will look similar to this:
<extension
id="menuid"
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="popup:org.eclipse.ui.popup.any">
.
.
.
</menuContribution>
</extension>
See Custom Popup menu in eclipse plugin for a similar problem.