only one editor at a time? RCP - eclipse-rcp

I was wondering if there is a manner to make it impossible to open more than 1 editor at a time? what I have now is a button that each time it is pressed gives a new editor.
I am using eclipse RCP
thanks

You could add an IPartListener on the IPartService of the IWorkbenchWindow that close all other editors when a new editor is opened. You find the current set of editors via IWorkbenchPage.getEditorReferences().

Related

Eclipse Workbench Window with always on top wizard

I have an API which opens up a new workbench window with my own editor as default editor.
Now when I call this API in a wizard , which has always-on-top behavior, my new workbench window opens up but when I even click on this window it gets below the already opened wizard. When I close this wizard, the newly workbench window works fine.
So my question is, can I open a new workbench window on top of a wizard using -
PlatformUI.getWorkbench().openWorkbenchWindow(<my_perspective_id>, null);
Detailed example, say X is my initial workbench window , I open a wizard W from that workbench window X...........
Now in that wizard I call an API to open up my new workbench window , but this workbench window doesn't stay in focus. Any Solutions ?
Thanks in Advance !
No you can't get the window above the wizard. The always on top setting for the wizard applies to the entire application.

How to make Eclipse open code editor not in same pane as Project Explorer (again)?

For the past several days, when I double-click files in the Package Explorer in Eclipse, the text/code editor is opening in the same pane as the Project Explorer.
It did not always behave this way. It used to open the editor in a different pane or new pane.
How can I undo whatever I did?
If I understand correctly, Reset your perspective to default might help resolve this issue.
Window --> Perspective --> Reset Perspective

What are the properties of a "non-participating editor" in eclipse?

The eclipse documentation says that the method
IWorkbenchPage.hideEditor(IEditorReference ref)
will "remove an open editor, turn it into a non-participating editor". But what does non-participating mean? Is the plugin still running in the background? Is it still possible to programmatically access the EditorPart of the hidden editor in another plugin?
If I had a GEF editor and would hide it using hideEditor(), would it still be possible to render an overview of the diagram?
Looking at the Eclipse Kepler implementation of IWorkbenchPage the hideEditor method does nothing except logging an unsupported message if debugging is enabled.

How do you make new editors open in another screen?

I use dual monitor for work and I prefer to have the editor on my main screen while the rest of eclipse in my laptop monitor.
However, when I open a new file, that is. I open a file with Cmd-Shift-R, files are opened in my laptop monitor as opposed to the editor that I dragged to my main screen.
I find this mildly annoying. Any ideas?
Are using the Window -> New Window feature? In that case it depends on which window you're working on at the time you press Ctrl+Shift+R.
However, if you're streching only one Eclipse window along both monitors, then the Open Resource dialog will be opened in your "monitor number 1" (and that depends on your graphic configuration: Laptop+Main or Main+Laptop).
I found easier to avoid the new window menu and just to drag those views out of eclipse. This creates a secondary window but the project explorer is linked to the old window so double click will open the file on the main window.
I recommend to save everything as a new perspective that I usually call "Java 2 Windows". This way I can change perspectives when I do not have an auxiliar screen.
P.S. Just avoid closing the auxiliar window when leaving eclipse.

Listen on Eclipse Editor Events

I'm writing a plugin for Eclipse and I'm wondering how I can listen on editor text changed events for any of the active editors.
Basically I want listener events to fire when any text is modified in any of the open editors.
You want to get to the JFace Document object associated with the editor and add an IDocumentListener, that should get you started.
Sounds really untypical. Also very intrusive and dangerous. Why would you want to listen to any typing in any of the editors? It is strongly recommended not to do it. Shouldn't that be limited to a bunch of editors for a same model (IEditorInput)?
IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
IEditorReference[] editorReferences = page.getEditorReferences();
From editorReferences try and find out a way to add a listener. IEditorReference is a handle, it doesn't mean the editor is activated. When you open eclipse, editors are activated lazily (when they are clicked for opening). So activating all open editors can also cause performance issues.