Open eclipse view along with custom editor in PDE - eclipse

I have created a custom eclipse editor and want a view to be opened in the event the editor is active. If the view is already open then nothing should be done. I also want this functionality for the console in that the console should be open in the event my custom editor is active. Is this possible to do in Eclipse plugin development environment?

You can open the view in the init method of your editor using something like:
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.showView("org.eclipse.ui.console.ConsoleView");
This will open the view if it is not open or make it the active view if it is already open.

Related

Opening compare editor results inside a wizard page

In my custom plugin I am trying open compare result inside a wizard page but they always open in an editor or as a new dialog.
I am overriding setVisible(booolean)method, so as soon as wizard page is visible I am opening compare editor using CompareUI.openCompareEditor()call, but this opens up a new editor in the background.
Is it possible to open compare editor results inside a wizard page.
Thanks!!
There is no existing support for this.
You could read the source of the dialog that is displayed by openCompareDialog.openCompareDialog - this is org.eclipse.compare.internal.CompareDialog.
It looks like it might be possible to do the same thing in a wizard page without using internal classes by adapting what that dialog does.

Eclipse: Opening a view in detached window

Say I have a a detached window with a view in it. And I have an action to open the same kind of view, I would like to open it in the detached window, is there anyway to do it?
I have tried getting the IWorkBenchPage of the detached window where the open action is called and calling showView on it, but the new window is still opened in the Eclipse window.
This can be done in Eclipse from version Mars(4.5) and higher Using the mars specific UI API. e.g. MPart as opposed to ViewPart

Package Explorer view in eclipse opens always in a new window

When I open the package explorer perspective in eclipse, it always opens in a new window. I would want this to be attached to the editor. Please refer the image below
My preferences for perspective is as follows
I could not find a way to solve this. Please help. I am using eclipse Luna
From navigation bar select 'Window' >>> 'New window'.
It looks like you have the editor area maximized, so there is no space for other views on the main window.
Double click on the editor tab bar to restore the editor area to normal (not maximized) and the package explorer should display as normal.
Closing all open perspectives and opening package explorer again solved it.

Eclipse: open in browser rather than code pane

Mousing over an Android class I get a popup tool tip.
One of the links opens up the documentation for the class. However it currently opens this up in the code pane and I'd like it to open up in a browser.
How do you change this behaviour?
Put caret on the class name in Java Editor and press Shift+F2.

Open a eclipse Editor programmatically

I am trying to add eclipse editor in 'open with' menu for files with a particular extension.
I do that with launcher in org.eclipse.ui.editors extension point.In the launcher I use "open editor" method which requires to pass editor Id. Is there any way such that we can open a editor programmatically without passing the editor ID? Can we open editor programmatically by passing the instance of the class which implements the editor?..
Take a look on the IDE class's function openEditor():
IFile fileToOpen = ...
IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
IDE.openEditor( page, fileToOpen );
Note that a few checks might be important here (if the file exists or not, can be opened, you can access the active page - it is not null, etc.)