How to get Java perspective on custom Eclipse product - java

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

Related

Eclipse RCP application - how to create a executable

I've created an Eclipse Plugin clicking New > Plug-in Development > Plug-in Project.
In this project, I've modified the plugin.xml file and added new Views to create an example, and it works succesfully when I press Run button, loading a new Eclipse instance in which I can show my example perspective whit its views. It looks like this, with my additions marked:
MyPerspectiveAndViews
Now I want to create (I don't know what I need exactly) something to execute it without pressing the Run button, something like a Jar file.
I've been taking a look on Internet and I learned that Eclipse provides a tool call Oomph (also called Eclipse Intaller), and with Oomph I should create:
Product Setup Model
Project Setup Model
It seems like de Project Setup Model file can be added to an installation process. So I search for tutorials to do it, like https: / / eclipsesource.com/blogs/tutorials/oomph-basic-tutorial/, getting the setup file, like this:
MySetupFileCreated
But when I create the project setup model, I don't know how to include my example project, so I can't show my perspective with my views.
Anyone knows how to create it in an Eclipse RCP application like this example?
Thanks :)

Eclipse RCP - SelectionService - History?

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).

Google-Eclipse Plugin: Adding entry points to project

Using the Google-Eclipse plugin, I have successfully created, built and deployed (locally) a very basic GWT Web Application.
The thing is: I'm not a huge fan of the project structure GWT (or the Google-Eclipse plugin) set up by default. So I'm trying to set things up in a way that makes logical sense for me, but that still is able to run in DevMode and deploy locally.
So I created a 2nd project but did not set it up as a Web Application; instead I used a normal Java Application. I created my source directories, my EntryPoint implementation (TestModule implements EntryPoint), my TestModule.gwt.xml, my host page HTML, etc. All the artifacts that I did in the first (successful) project.
But now I am in Run Configurations trying to manually set up a run config similar to how the Web Application Wizard created one for me with the first app I built.
In the Run Configurations >> GWT tab it gives me a window where I can add Available Modules. When I click the "Add" button, no matter what I type, it doesn't provide me with an available list of options to choose from.
So I exited out of the Run Configurations dialog, assuming that I need to set up my project properties differently. So I right-clicked my project, went to Properties >> Goodle >> Web Toolkit, and sure enough, see a similar panel that allows me to add Available Modules. It is my belief that if I configure this section correctly, then a list of Available Modules will become available to me when inside the Run Configurations dialog, and I should be able to continue.
Here's what I'm seeing:
Any ideas as to how I can configure my project correctly so that this Available Modules dialog actually presents me with options? Thanks in advance!
Please note: I anticipate many answers to be along the lines of "just use the Web Application wizard, it's so much easier", etc. I understand this and am (temporarily) accepting the caveats of trying to configure my own GWT app without the help of the plugin's Web Application wizard. If I find it to be really, really difficult to "roll my own" here, then I'll cave in and go back to the wizard. But I want to give this my best shot before doing so!
Feel free not to use the Google Plugin for Eclipse (hereafter GPE)! There is no need - its all Java, or at least self contained enough to act like Java as far as Eclipse can tell. If you don't want the wizards, the JSNI autocomplete, UiBinder autocomplete, by all means, you can even leave the plugin out.
To run a GWT project in dev mode, you just need the basic moving parts of the SDK:
* gwt-dev.jar - Dev mode (code server and simply HTTP server), the compiler, and assorted other tools
* gwt-user.jar - GWT language runtime (JavaScriptObject, GWT, etc) and standard events, widgets, and other bits
* optional: gwt-servlet.jar - classes to run in a servlet container for some basic GWT servlets
* optional: requestfactory-*.jar - if you don't use RequestFactory, don't worry about it
You may also need a json.jar and the valdation-api.jar as well as its sources.
This gives you enough to have any project compile in plain Java. The gwt-user.jar and gwt-dev.jar do not belong in your server classpath - don't put them in a WEB-INF/lib/ dir, just keep them on hand to compile your code to JavaScript.
Both Dev Mode and the compiler itself are just classes with a main method, so a standard Eclipse Run/Debug Configuration can start either. Each will have its own options to get going, such as 'where do i find your sources', 'what module are you starting', and in the case of Dev Mode, 'where is the war/ dir for me to serve'.
Avoid GPE entirely:
DevMode:
Make a new Java Run Configuration, and verify that the above classes are on the classpath, as well as your source directories. Set the main class to com.google.gwt.dev.DevMode, add a few params:
-war path/to/war/dir/ my.package.to.ModuleToRun
Everything else is just extra flags to change out it works, and hints for where to start. Take a look at https://developers.google.com/web-toolkit/doc/latest/DevGuideCompilingAndDebugging#What_options_can_be_passed_to_development_mode for other options available to you
To debug this, run it as a Debug Configuration - Eclipse will complain a bit about how it can't hot swap classes, but ignore these and hit continue. When you make a change in a .java file, save, and refresh the browser - GWT's specialized Dev Mode classloader will pick up the changes.
Compiling:
As above, make a run config with the important classes and jars on the classpath. This time, use the com.google.gwt.dev.Compiler main class, and specify the module(s) to build under the program arguments. Again, there are many options at your disposal to change how it compiles and what additional output it provides, see https://developers.google.com/web-toolkit/doc/latest/DevGuideCompilingAndDebugging#DevGuideCompilerOptions for more options
Using GPE without the wizards:
The important thing to remember here is that GPE is just papering over a few details - you don't need to use the wizards, but at some level, its all wizards until you are just working in raw Java. Classpath, imports, etc - these are all Java concepts that more or less apply to GWT development, though it adds Modules to help set up deferred binding rules, etc.
The module selection dialog is not necessary, though two other pieces are. First, as you've done, under Google > Web Toolkit turn on "Use Google Web Toolkit", and ensure a valid SDK is selected. This does two things - it adds the necessary jars to the classpath (under 'GWT SDK'), and enables a few other options throughout the project - JSNI autocomplete, Dev Mode, assorted wizards (that we'll ignore). The other piece that is necessary is to go to Google > Web Application, indicate that "This project has a WAR directory", and give it the path to that directory so Dev Mode knows where to start Jetty.
Once this is done, the plugin should be able to let you start from an html file that points at a module with an entrypoint. I'm going to gloss over these details, as this is basic project setup - things that the wizards are good at, examples are full of, and you presumably have read these directions (else you wouldn't be skipping wizards...). From within the previously selected WAR folder, pick such an html file, right click it and select Run As... > Web Application. It is possible that GPE will ask once again for the WAR folder - help it out, and you'll be on your way. Dev Mode will add a View to eclipse rather than a standalone window, and you'll be able to monitor progress from there.
Compiling is then a matter of going to the G icon in your toolbar and selecting "GWT Compile Project...". A dialog will appear asking for the project to use, and the entrypoint(s) to start with, as well as a few other options. Note that if you compile into the war folder then start Dev Mode, you may find that Dev Mode overwrites part of your compiled output for easier Java debugging, thus requiring an additional compile.

Handling the export in eclipse thru a plugin

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.

Configure Eclipse to launch a fixed project in a workspace?

I have a small workspace with 3 projects. One main (Swing) application, two other projects that are just libraries.
Now, whenever I change stuff in my library project and want to execute i.e. run with Ctrl+F11) or debug , I have to select my main project first and run that.
Is there any way to set this up more smoothly, so I can just run my program regardless of which of my 3 project that is selected ?
Have a look at the "Launching" preference page. At the botton you can select *Always launch the previously launched application. That should do the trick...
If you are using Maven you can create hierarchical structure of projects, i.e. head and child projects. In this case try to define Run/Debug profile on the parent's project level. Probably it will work from any other child project.
I personally have never try this and unfortunately cannot try this right now but I hope it will work for you.
If it does not work it seem you have to create your own eclipse plugin.
Good luck.

Categories