I am building an Eclipse RCP application that contains some org.eclipse plug-ins in it as well, including the Project Explorer view plugin.
Currently in one of my plugins I've implemented a StartupHook where I add a listener on the SelectionService on the Project Explorer view. When my plugin is active, I would like to get the latest selected project
Check this tutorial for some details on the SelectionService
I would like to NOT use a StartupHook for this, because it doesn't really respect the lazy loading principle.
Does the SelectionService have a history I could refer to, and search AFTER my plugin has loaded (without prior adding of a listener?)
The SelectionService has no history.
You will either have to load your plug-in early (and give up on lazy loading as you already said) or you can track the selection changes only as soon as your plug-in is activated (if ever).
Related
I created a simple eclipse plugin that just opens a new view from a command in the menu. I am using Eclipse RCP 2018 and when I run the plugin as an application everything looks exactly the same as the java perspective with the menu option added (which is what I want).
When I create a product and run, it looks like a lot of options are gone (e.g no java perspective, can't make a java project, no source option, no refactor, no run, can't change it to dark theme, etc). My custom view/menu is still there but I want it to basically be an addition to what was already there like when I launch it as an application. Is there certain settings or files I can edit to accomplish this?
Probably you do not need your own product definition but just want to add your plugins to Eclipse IDE product. In that case you need to select "org.eclipse.sdk.ide" product to run and ensure your plugins are selected in launch configuration.
If you do need your own product definition for some reason (to show your own branding for example) and still need some functionality from Eclipse IDE - you need to add either features (preferable) or bundles to your product definition.
More details here
I use eclipse with maven integration for my java web application project. When you right click the project you can "refresh" the project. You can also use "maven -> update project". What is the difference between refresh and update?
Sometimes I got a red-x sign in my pom file (I don't think there is any error). When I use the "refresh", the red-x sign disappears. Any idea?
Another question is that when I update the project, in the property -> deployment assembly, the maven dependencies was removed (I manually added them when I created the project). How can I fix this?
Thanks
A quick google search yielded this result: What does Maven Update Project do in Eclipse?
The correct answer states:
It syncs the Eclipse project settings with that of the pom. If you for example change important plugin settings, such as the output java version, you will find that Eclipse will ask you to update the project and afterwards the configured Java runtime in the project will have changed to reflect what your Maven pom indicates. That is an important thing to keep in mind: the Maven pom is the lead in this kind of project setup. If you want settings to change, try to do that through the pom and not through Eclipse project settings directly or doing a project update might revert what you have changed. There are usually some things I have to correct myself anyway though, such as build path exclusions that m2eclipse likes to put in and strange deployment assembly configurations.
So in short,
Updating your project through maven synchronizes the settings with that of pom and keeps all the settings synchronized between the pom and the project.
Refreshing your project through eclipse will reload the project - that is reload all the files and apply any external changes from the files to the project.
Note that a maven update will cause a refresh of the project in eclipse.
FYI, here's what the official documentation states:
Refresh command
The official Eclipse Oxygen documentation has two distinct (yet similar) definitions:
In Workbench User Guide > Reference > User interface information > Workbench menus > File menu it reads
Refresh (F5)
Refreshes the resource with the contents in the file system.
In Java development user guide > Reference > Menus and Actions > File actions it reads
Refresh
Refreshes the content of the selected element with the local file system. When launched from no specific selection, this command refreshes all projects.
F5
Update Project command
Unfortunately, the only documented occurrence I have found in m2e documentation (see m2e 1.5 release notes) is utterly insufficient and barely related:
The Update Maven Project dialog (launched via Right-click project menu:Maven[Update Project…] or via kbd:[Alt-F5]), now shows a dirty overlay on projects which need updating.
Additionally, an “Add out-of-date” button adds all out-of-date (OOD) projects to the current selection. If an OOD project has not been selected, a warning is shown underneath the selection table with a link equivalent to “Add out-of-date”. Warning text and “Add out-of-date” button tooltip show a count of unselected OOD projects.
Related questions on the 'Update Project' command (or the 'Update Maven Project' dialog):
(Which, alas, however insightful the best answers are, still provide no official statement from m2e developers.)
https://stackoverflow.com/a/20547404/4883320
https://stackoverflow.com/a/42562054/4883320
I want to create an Eclipse RCP from our collection of already existing Eclipse plugins.
We have the pecularity that in our RCP we want the user to be able to open ("import") Eclipse projects (we distribute some of our features in bundles which come in the form of Eclipse projects. These should be registered in the workspace because a model server scans for the opened projects and loads them). Also, when I open files via File->open an exception is thrown from our internal editors: File opening intentionally only is possible if you load an imported resource.
For the moment, I have gotten the RCP to work by depending on org.eclipse.core.resources and org.eclipse.ui.navigator.resources. Thereby, I can import complete Eclipse projects. However, I am unsure[1] this is the correct/"intented" way of doing it (e.g. the navigator view is lacking icons per default) should I rather use the CNF?
The main thing is, we have to support loading/importing Eclipse projects in our RCP. Your answer is even helpful if you know other RCPs which allow to import Eclipse projects.
Regards
SuperUser
[1] http://wiki.eclipse.org/RCP_FAQ#Is_the_resources_plug-in_.28org.eclipse.core.resources.29_considered_part_of_the_Rich_Client_Platform.3F
If you are using org.eclipse.ui.navigator.resources then you are using the CNF (it's org.eclipse.ui.navigator).
The link you have is pretty outdated information, using the Eclipse Resources support in an RCP application will work fine (our product does it). And then if you want to package the application to work either as RCP or in an IDE environment you are one step closer. Also, despite what the link you provided says, don't be afraid to use stuff in org.eclipse.ui.ide if you need them. All you really need to be concerned about is to make sure you are only using classes that are actual Eclipse API, if you do that, then everything will work on future Eclipse versions. Anything that's public is Eclipse API unless it's marked in the Javadoc that it's not intended to be used by clients.
You should not be using the Resource Navigator as that has been deprecated and is not as general as the CNF.
As far as importing and exporting Eclipse projects with RCP, our product does that as well and it works fine.
I would say you are on the right track.
I'm using RTC and Eclipse Helios. I have a project loaded in my workspace, I can browse it manually just fine, but I can't use the [Ctrl]+[Shift]+T (open type) feature.
I recently deleted a clone project, loaded into another RTC workspace. It might have something to do with that.
So basically, how do I get Eclipse to browse through my project properly?
[EDIT 1]: I am in the java perspective. If i reload my ex-project, I can browse the classes in that one, but not in my new project.
Try right-clicking on your project and clicking Refresh. I occasionally have this problem (nothing is returned in the Type view) and this resolves it for me. I don't use RTC though, so your issue may be different. I don't know what the underlying cause is.
You must be in the Java perspective to access the Ctrl+Shift+T shortcut.
With RTC (IBM Rational Team Concert), your default perspective is "Work Items".
In that perspective, the shortcut for "Open Type" isn't active.
Solution:
switch back to the Java perspective.
display the view (from RTC) "Team Artifacts" and "Pending Changes"
That way, you still benefit from the RTC features while accessing all the usual Java features.
I have a java application that have different settings and dependency versions depending on the company branch it is install in.
So what I did is to create a plugin that create an item in the right click context menu of the project in eclipse to make these changes.
However I am wondering if its possible to catch the OnExport event of eclispe (if it exists) and do this automatically everytime the solution is exported.
Would this be possible?
Many thanks
If I understand what you're asking correctly, the Eclipse way to do this would be to write a Builder and add it to the project; then the settings file would be rebuilt whenever it's appropriate, making an up-to-date version always available to export. Here is a good place to start learning about how to do this.