E4 Focus perspective if view is already opened - java

I'm developing an E4 plugin application which contains 2 perspectives and a couple of views. I've added these views to the Eclipse Window->Show View -> Other.. menu and they open accordingly. If I open a view that is already opened in another perspective I would like the application to focus on that perspective instead of opening a new view in the current perspective.
Is it achievable? I already unchecked "multiple" property in the part descriptor but it still doesn't work.

'Window > Show View' just opens a view in the current perspective using the IWorkbenchPage.showView method.
There is no support for switching to a different perspective.

Related

Java mission control - visualize event

Is it possible to visualize JFR events on chart? Sure I can browse them in log section but I'd like to visiualize them on chart also.
A good example would be "Machine total" attribute from "CPU Load" event.
If it is possible how to achieve it?
Use the Designer View:
Window -> Show View -> Designer (Unsupported)
Open a JFR file
Go to the appropriate tab
Click the red stop button in the designer view
Use context menus in either the editor view or designer view to modify the existing GUI
Use the designer view and New Group or New tab to add new GUI (close and reopen the JFR file to view the new tab structure)
This is both unsupported and undocumented, but is however how the standard JFR GUI is built. I'm trying to find an online video where either I or someone else has demoed this..
(Your example with "Machine total" is already visualized though, both on General/Overview and Threads/Overview)
Good luck!

Eclipse RCP - Open a View in the Editor Area (3.8/e4 hybrid)

I'm working on a 3.8-e4 hybrid (i.e we have the Luna dependencies, but we do not use the Application.e4xmi, yet). So we're basically running the compact layer.
With that being said, it would be nice to find an e4 programmatic way to stack these nasty views onto the editor folder.
1.) Problem
I want to place a generic view folder in the editor area, so that each view which is opened at runtime will be opened there.
(pic stolen from this question)
2.1) Possible fix no.1: Using plugin.xml
Create a perspective extension, and add each possible view to that extension, with relationship stack over relative org.eclipse.ui.editorss. This is a bit inconvenient if you have too many views awating to be opened, and if the project scales quickly. I also noticed that wildcard view IDs do not work here.
If you find yourself the time to add each possible view to the perspective extension, that would work. Although, IF you open a view which is not added here (ie: opens in a different folder), then each subsequent opened view will be opened in the previous folder, and NOT in the editor area (inquire further explanation if you don't get it).
2.2) Possible fix no.2: Using code in the perspective factory
In the IPerspectiveFactory, we do have access to the IPageLayout, which happens to be org.eclipse.ui.internal.e4.compatibility.ModeledPageLayout (e4 stuff).
Now, this ModeledPageLayout implementation is reasonable, but also no documentation and weird public APIs. This one gives the possibility to stack a view over any other relative
modeledPageLayout.stackView("newView0", IPageLayout.ID_EDITOR_AREA);
This would be the programmatic version of 2.1. Also, the same problem appears here. If a view is opened somewhere else, the code above becomes useless.
Interesting enough, the stackView API does not support wildcards (while others such as addView do).
2.3) Possible fix no.3: Workarounds yaaay!
I have a lot of perspectives, and a lot of different folders in each one. Everything is precisely placed.
Since Eclipse offers the APIs to get all the view IDs from everywhere around the system, I want to do the following, per perspective: each view ID which wasn't added to a specific folder will be appended to the editor area (ie editor folder, editor stack).
This would be my last resort, unless someone offers a more convenient and timesaving solution.
Remember, an e4 programmatic alternative is more flexible!
3.) Related questions
Eclipse RCP -- Open View in Editor folder
Eclipse RCP - Stacking a view with the editor area?
Custom Eclipse perspective, with initially invisble view stacked to editor area
Google question, Lars answer
These would be rendered deprecated for the e4 release.
4.) Related Bug on Eclipse's Bugzilla:
This recent bug opened by myself has an attachment with a small SSCCE. The steps to reproduce this are described in this comment, so I'm not going to copy-paste them here.
I suggest you go with Possible fix no.3, since i think there isn't a faster method to do this.

RCP Application coundn't find new added view

I am using Eclipse Juno for RCP RAP developer. I have created a Plug-in Project with a single view and it runs normally. But whenever I tried to add a new view into that workbench, the window dosent update. Also if I change the id of the current view, it also not working. And if I delete the current view, it also showing it. As a whole, the view part is not updating of the application. Anybody knows any answer ?
Your changes doesn't get applied correctly.
Eclipse 4 persists certain user changes in your application. During
development this might lead to situations where changes are not
correctly applied and displayed, e.g. you define a new menu entry and
this entry is not displayed in your application.
You have to add -clearPersistedState as a program argument for your application or set the Clear flag in the Main tab of your Run configuration.
Take a look here for further information and a more detailed description.

How to execute a view from another view of a Eclipse plug-in programatically?

I have a view in a eclipse plug-in. I need to open a view on a action of hyperlink in the current view.
There are a lot of ways to do it. Here are the steps to do it:
Find the context you are in.
page = self.getSite().getPage(); gets the page from where to open the view.
page.showView(<ID of page>);
See the questions:
Open a view programatically
How to open a view programatically?
Stackoverflow: Programmatically showing a View from an Eclipse Plug-in

Eclipse RCP: Why is the view missing when running as a Product?

I'm brushing up my Eclipse RCP skill by trying to enhance my one-year-old side RCP application. This application has one perspective, and this perspective has 3 views, and I'm adding another view into the same perspective. To add this new view, I added it in the MANIFEST.MF file under Extensions tab and created the Java file for it.
When I run it as an Application, it works. I see all 4 views in the application. But, when I run it as a Product, that new view is missing. It almost seems like the new view is not registered in the Product. There's no error in the console log either. I think I must be missing a step here, but I can't seem figure out here... pretty frustrating!
Note: The views are added into the perspective programmatically (in Java code), not through MANIFEST.MF file. I just realized that even when I change the existing view's layout (ex: size, or location), it doesn't get reflected when running as a Product either, but it works when running as an Application... sigh!
Note: I commented out all the code in my perspective class, in another word, all the views are removed from the perspective. When I launch the Product, I'm still seeing 3 views in the application. I'm thinking there's something to do with caching, but I'm just bummed now.
Any helps are greatly appreciated here! Thanks much,
Okay, after aimlessly clicking around, I figured out the solution. The workspace data needs to be cleared to pick up changes from the perspective.
To do so...
Right click the product file
Choose "Run Configurations..."
Under "Main" tab, check "Clear" checkbox and "workspace" radio button.
Run it.
Hope this will save some of you from troubles.
I've been bitten by this a couple of times until I figured out the easiest workaround: it's sufficient to reset the perspective. There are two ways to achieve this:
Right-click on your perspective in the perspective selector bar at the top right and click on Reset.
Switch to your perspective and then go to Window | Reset perspective....
After that, the changes to your perspective should be picked up.

Categories

Resources