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.
Related
I want to remove move command for specific resource type. To achieve it, I thought to using org.eclipse.ui.activities
I tried below configuration, but it didn't work.
<extension
point="org.eclipse.ui.activities">
<activity
id="refactormovehiding.id"
name="refactormovehiding">
<enabledWhen>
<not>
<instanceof
value="com.shashwat.resource.PResource">
</instanceof>
</not>
</enabledWhen>
</activity>
<activityPatternBinding
activityId="refactormovehiding.id"
pattern=".*/org.eclipse.jdt.ui.actions.Move">
</activityPatternBinding>
</extension>
I even used different pattern thinking pattern which I am providing is incorrect
<extension
point="org.eclipse.ui.activities">
<activity
id="refactormovehiding.id"
name="refactormovehiding">
<enabledWhen>
<not>
<instanceof
value="com.shashwat.resource.PResource">
</instanceof>
</not>
</enabledWhen>
</activity>
<activityPatternBinding
activityId="refactormovehiding.id"
pattern=".*/org.eclipse.ltk.ui.refactoring.commands.moveResources">
</activityPatternBinding>
</extension>
I even tried without enabledWhen configuration, but no luck.
I am trying to apply a persistence framework to an eclipse rcp e4 application. For this purpose, I created an example of a feature project, almost following the tutorial https://www.vogella.com/tutorials/JavaPersistenceAPI/article.html, but adapting for rcp. However I got the error "Persistence provider for EntityManager named xxx not found". I have searched for a week but found no solution. Could someone please tell me, what the error really is and how to resolve it?
The persistence.xml is located in project tasks.model folder META-INF. The eclipse.jar and javax.persistence.jar are in another plugin project (Earlier I defined maven dependencies in pom.xml. Although eclipse reports no compilation errors, but running rcp product would result in an error that ClassDefNotFoundException for persistence, so putting javax.persistence.jar in a separate plugin removed this error). Some answers suggested that the persistence.xml should be in the folder src/resources/META-INF. But in a plugin project the folder META-INF is already in its default place. I even created an extra folder resources/META-INF and put the persistence.xml in that, but it did not help. If I created a normal maven project, then things work properly, also when I change the database to mysql in localhost. The errors appear when I convert the project into a plugin project for building rcp applications.
The error "No Persistence provider for EntityManager" occurs when I invoke the command:
factory = Persistence.createEntityManagerFactory("todos");
My persistence.xml file looks like:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="todos" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>tasks.model.Todo</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:derby:/tempGeo/simpleDB" />
<property name="javax.persistence.jdbc.user" value="test" />
<property name="javax.persistence.jdbc.password" value="test" />
<!-- EclipseLink should create the database schema automatically -->
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
</properties>
</persistence-unit>
</persistence>
Here is my modules.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/../...iml" filepath="$PROJECT_DIR$/../...iml" />
<module fileurl="file://$PROJECT_DIR$/7Wonders.iml" filepath="$PROJECT_DIR$/7Wonders.iml" />
<module fileurl="file://$PROJECT_DIR$/../AFLib/AFLib.iml" filepath="$PROJECT_DIR$/../AFLib/AFLib.iml" />
<module fileurl="file://$USER_HOME$/Documents.iml" filepath="$USER_HOME$/Documents.iml" />
<module fileurl="file://$USER_HOME$/Documents.iml" filepath="$USER_HOME$/Documents.iml" />
<module fileurl="file://$USER_HOME$/Documents.iml" filepath="$USER_HOME$/Documents.iml" />
<module fileurl="file://$PROJECT_DIR$/../MultiConnect/MultiConnect.iml" filepath="$PROJECT_DIR$/../MultiConnect/MultiConnect.iml" />
<module fileurl="file://$PROJECT_DIR$/../MultiConnect/lib/MultiConnect-lib.iml" filepath="$PROJECT_DIR$/../MultiConnect/lib/MultiConnect-lib.iml" />
<module fileurl="file://$PROJECT_DIR$/_7Wonders/_7Wonders.iml" filepath="$PROJECT_DIR$/_7Wonders/_7Wonders.iml" />
<module fileurl="file://$PROJECT_DIR$/../AFLib/lib/lib.iml" filepath="$PROJECT_DIR$/../AFLib/lib/lib.iml" />
</modules>
</component>
</project>
"7 Wonders" is the app, "MultiConnect" and "AFLib" are my libraries.
The stuff starting with $USER_HOME is completely unneeded: there is no Documents.iml file. I delete these lines, Android Studio adds them back. Then it complains that it can't open a module... 2 modules... 3 modules... and so on, until I delete those lines manually again. If I click on "Details" in the error message, it offers to remove those modules from the project, but that doesn't seem to have any effect. I even tried to make the modules.xml file read-only, but Android Studio complains and refuses to work.
This issue does not affect usability, but seeing that "Error Loading Project" every single time is rather annoying.
I don't need the ...iml file (the 1st line) either, but at least the Studio doesn't complain about it, and doesn't add several copies of it.
Can anyone explain what's going on?
There could be many reasons why this is happening.
1. Uninstall plugin "Markdown support" from plugins in settings.
Try compiling the whole project before gradle refresh is done. And set gradle settings as "Offline Work".
This will save a lot of time and will also save on re-installation of gradle dependencies. This re-install probably will cause refresh in modules.xml
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.
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.