Eclipse 4 RCP How to launch another plug in in a new window - eclipse

I have an e4 RCP which needs all the screen real estate. I have developed a second RCP that is in effect a relatively simple single-function plug-in, with currently only one part. I want the user to be able to launch the second from the first, then terminate it, all on demand.
As I understand it, I have 3 options:
Launch a new workbench for the second, written as a plug-in. I assume this uses more resources and also has the problem that I need to track and distinguish events which will go to both.
Write the second as a model fragment plug-in that extends the first. This has the advantage that I can keep on adding to the second plug-in by declaration in the model editor. However, I believe this requires attaching to an existing container in the main model. I could add a new container to the main model and write code to flip containers in and out but it is all done in the model editor currently, and more importantly the functions carried out by the second plug-in are quite different from those of the first (main) RCP, so I fear the user will find the UI change confusing.
Use EModelService and write code to create a new TrimmedWindow and then child PartStack, and Part, and all the Handlers. I have not yet found enough documentation to fully understand the implications, advantages and disadvantages of this - aside from the obvious ones that the former declarations now have to be programmed and coupling is tighter.
It looks to me like Eclipse itself uses approach 1 for two of its menu items:
Help Contents
Eclipse Marketplace
From the UI perspective, the kind of UI separation of functions that I want to achieve is very much like these two items. Hence I am leaning to option 1.
Any corrections or alternatives?

You could possibly use a PerspectiveStack with two perspectives containing the windows for your two apps. The second app can be in model fragment.
You can then just use EPartService.switchPerspective to switch between them.

Related

Can you include GwtBootstrap3 in an existing GWT project

I have a project that has taken me 2 years, in my spare time, to develop (I am not a developer by trade) and has over 50 views. I have been told that to produce a better user experience and speed up my development I should use GwtBootstrap3. At this time I do not have time to rewrite the whole project so is it possible to include GwtBootstrap3 in the existing project, build new views using GwtBootstrap3 and slowly converting existing views to GwtBootstrap3?
Technically speaking the answer is Yes, follow setup guide of gwtbootstrap3. But, gwtbootstrap3 inject few default css in application on load which might can affect few of your current views. Hope you are following some kind of mvp patterns, if not first start use of it and then go for modifying existing views.

How to refresh the Eclipse main menu programmatically on runtime

I am looking for a way to to force Eclipse to refresh/rebuild its own main menu or even the whole view on runtime programmatically.
The reason why i need it this way is, because i have a plugin that iterates through a project and depending on the configuration of the selected project it loads a project specific plugin at runtime with:
FrameworkUtil.getBundle(this.getClass()).getBundleContext().installBundle(String).start()
Now the loaded plugin contributes to the org.eclipse.ui.main.menu extension point and even though the plugin is installed I don't see the new menu entry.
FYI: I am using Eclipse 3.x and E4 Tools
Now my questions are:
Is there acutally a way to refresh/rebuild parts of the Eclipse ui or maybe even the whole ui?
If not, can someone think of another approach? I thought of having a plugin which contributes only the menu and add the menu items programmatically.
But i couldn't believe that there is no way to refresh the view so i am asking this question.
I checked whether MMenu had a refresh method itself so i could get the object and just call the refresh method.
But in the end i didn't find a way to do this.
P.S. I am pretty new to Plugin Development and RCP so please don't blame me if the solution was obvious but i didn't realize it
Refresh/Rebuild UI
Short answer: no
In many places Eclipse extension points are loaded and information is stored in static fields (often in a Singleton). The plugin.xml data is not reloaded during the lifetime of the application, and certainly these bundles do not listen bundle events that would allow them to detect such changes.
Therefore, even if there were some method to call refresh on the whole UI, at least some (most?) of the code handling extension points would not see the effects of the new plugin.xmls.
Another Approach
To answer what you are trying to do, the "normal" thing to do would be to have each menu contribution's visibility be dependent on some expression, e.g. if the current selection adapts to MySpecialProject you could have it visible.
When you do it the normal way, and you leave everything to be lazily loaded, the java code for all those project type plug-ins will not be loaded until the commands are actually invoked for the first time.
To go the next step, you would probably have a main ui plug-in that defined a bunch of commands (e.g. build project, flash leds, format file, etc), but have no command handlers associated in that main plug-in. In each project type plug-in, have command handlers that are enabled when only the correct project type is active.
Assuming you have already worked through a basic tutorial on commands in Eclipse, there is a good advanced one on vogella.com that covers many useful features for being properly dynamic.

Eclipse product: Export multiple versions of a product which has slight variations

This is a relatively open ended question so I wouldn't just mind being pointed in the right direction.
I have a product that uses the Eclipse workbench to allow users to program in a custom language. For this product, I will also have some minor UI and internal changes for a lighter version to be exported. For example, a full version of the product contains some extra views and menus, and behaves slightly differently (like when creating a new file) where as the ligher version does not contain a lot of view and has a couple of different more simplified ones.
I do not want to make a copy of my workspace and then have 2 separate workspaces for a full version and a lighter version as that will be difficult to maintain in the long run especially when there are changes in code relevant to both. I want to be able to export both, full and light versions of a product from a common workspace.
How can I go about this? Or where can I start looking?
The product is a collection of features and uses the Eclipse workbench as its base application.
I would like to clarify that I am asking how I could hide a view for the full or light version, as an example. I know in C#, we have options like #if. I have seen a lot of questions which refer to having 2 different versions of the same code, but nothing about how they could have 2 different versions of the same code.
You want the Eclipse RCP book it really fully explains how to do this. And to do it you need a solid understanding of the concepts of Eclipse plugin, feature, product, fragment and a few other things.
Essentially you can segment your application in to multiple plugins (have a base plugin for example, and then another that provides additional functionality). Then you organize those plugins into features that are the collection of the functionality to be installed. The notion of a "product" in Eclipse has to do with the branding, so you would probably have two products, a lite and a full one. The products could have a branding plugin (where the product is actually declared).
This should get you started.

Eclipse UI Plugins

In a custom Eclipse's product We are asking ourselves:
Should we create one single UI plugin for all the user interface matters or should we broke these matters in several plugins (for example, ui.views - ui.preferences - ui.properties etc ...)
It seems Eclipse's "official" products such as CDT, JDT ... only have one UI plugin and some third party plugins I am using have several ui plugins (Papyrus for example)
I know this is rather a subjective question but I would be interested to learn about the way you manage your UI stuff.
Manu
I'd create separate bundles (or plugins) for each independently usable component. So if I have e.g. a view that can be used without some other things, I'd put it in a bundle of its own. I find that this makes it easier to configure the feature, replace certain parts, provide custom combinations of components, handle dependencies, and such.
If your plugin does one thing (e.g. add a menu item to order pizza) it makes little sense to split it up, you're just introducing complexity. The modularity of your product is the key factor in deciding how to split the functions into plugins. Consider the functionality you're trying to deliver and whether there are any optional components or pieces that may be useful in isolation.
Take m2eclipse as an example, it has multiple UI plugins, but that is because they are functionally separate. The XML editor is certainly a useful UI addition, but users of the core function (dependency management) don't necessarily need it so it makes sense to bundle it separately and make it optional.
Ignoring anything specific to Eclipse, I would say from a product support perspective it makes much more sense to have a single plug-in. This has the following benefits:
Every customer has the same environment, so if someone contacts you with a problem you know what they have.
You have to test a single configuration. If you split your code into 3 plug-ins that's 7 different configurations you have to test.
In future you won't have to worry about which plug-in new functionality should be added to.

How can one use the Web Page Editor in custom RCP application?

I want to use the "Web Tools Editor" that is part of the Web Tools Plattform in my own RCP-Application. I think i have got some understanding on the RCP plattform by now, but I still have no clue how to access the functionality of the pagedesigner (org.eclipse.jst.pagedesigner) after adding it as a dependency to my project. Has anyone some experience in adding components of the web tools plattform into an RCP-Application and can give me a hint or something?
There's a difficulty with these sorts of requests (I am, myself, trying to include this or that feature that I saw in the Eclipse IDE, every so often).
The trick is to try and identify the component you want to bring in, and then try and pull it into your project, without bringing in too many dependencies.
The first step used to be quite hard, but since 3.4 it is a matter of using the Plug-In Spy - hold down Alt-Shift-F1 on whilst your desired component is in focus should give you a tooltip showing you the class, the bundle, etc etc.
The second step is altogether more tricky and is where I usuaully fail to get any results:
if you are lucky then you can just include the bundle in the launch configuration/.product of your app. Once you hit Add Required Bundles, you are not left with 3000 bundles (i.e. your RCP is now Eclipse).
usually, this is not the case, because the Eclipse team haven't refactored the bit of code you're interested in out into an RCP safe bundle. If so, then you're going to have to do that yourself.
Again, if you are lucky then that will mean moving some classes out of the eclipse bundle into your own, including internal classes, and that will be the end of it - i.e. the dependencies of your desired functionality are all within the bundle.
If you're unlucky, then you need to isolate/reimplement the bit of functionality that is required, and change your version of the copied code.
It is hard laborious, and pretty difficult to upgrade. I realise that none of this is what you want to hear.