is there a possible way to extend a perspective with the extension point org.eclipse.ui.perspectiveExtensions in such a way that its assosioated perspective editor can be added to my MutliPageEditor?
Is there a way to listen for the editor to open and then creating a MutliPageEditor where the opended editor will be added to it?
No, this is not possible.
The perspective extensions don't have any support for merging editors like this.
You can listen for editors (and views) opening but there is no way change the structure of the editor that has opened.
Related
I am in the middle of creating an Eclipse plugin that will open an editor. Everything is mapped out well - my plugin.xml is set up correctly to open the editor for anything with the .xyz extension. The only thing holding me back is the IEditorInput.
I have a subclass of IEditorInput that I created for use with my editor. When I open the editor programmatically, I can create that EditorInput and open the editor correctly. However, when I open the editor using Project Explorer (Right click > Open With > My Editor), it is opened with a FileEditorInput.
How can I change the default behavior of Project Explorer to create the correct IEditorInput? Is there something in plugin.xml that I'm missing?
Thanks!
The editor doesn't get to choose the kind of editor input object it's given. It can use a IDocumentProvider to support different kinds of IEditorInput, but you should never artificially limit your editor to working with one kind of input, even if you do manage to change how the Project Explorer works.
I am developing RCP plug-in with GEF framework.
I've created basic graphical editor (GraphicalEditor and IEditorInput)
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.openEditor(new TEditorInput("T"), TGraphicalEditor.ID,false);
When I run the application I get editor with a header that contains the tab with the name of the editor and control buttons to maximize and minimize the editor.
What I need is to display just the editor, without the header.
Can it be done?
To my knowledge, it is not possible to just hide an editor's tab.
However, you can try two workarounds:
Have your GEF editor be displayed in an Eclipse view instead of an editor and open such a view as a standalone view. An example of how to open a GEF diagram in a view can be found in GEF's Directed Graph Example. An example of how to open a view as standalone can be found in one the Eclipse RCP official tutorials.
Extend the presentation factories extension point to control how workbench parts are displayed (which includes control over the part stack tab).
I suggest you try the first approach, as to me it seems easier to implement.
The idea with editors is that you can instantiate them multiply for different editor inputs. I am not aware of any way to restrict the number of open editors to just one (well, it appears you can in Eclipse 4.2 if that helps you)
For views, what you want can be done by setting the perspective to fixed and set showTitle of the org.eclipse.ui.perspectiveExtensions extension to false on the view. Maybe you can use a view instead of an editor and control the editor input yourself?
(For example, using an editor, the default Open action would instantiate a new editor, while you probably want to replace the contents in your only editor, right?)
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.
Eclipse PDE documentation claims:
You can think of the input object as the document or file that is
being edited. Changes made in an editor are not committed until the
user saves them.
Only one editor can be open for any particular editor input in a
workbench page. For example, if the user is editing readme.txt in the
workbench, opening it again in the same perspective will activate the
same editor. (You can open another editor on the same file from a
different workbench window or perspective).
Obviously it is possible to open a file using different editors - for example .java file using default java editor, and then text editor (by 'open with'). Is this part of the documentation wrong? Or is IEditorInput different for these two editors? I'm just wondering.
It was like that originally, and I think their point was double-clicking on an already open file will just bring it to the front, not open a new editor with the same information. Tht's still true, but that's not the whole truth :-)
I believe that section needs to be expanded, as I'm pretty sure the capability you refer to has been there for years as well. There's a "New Editor" entry in the editor tab context menu that allows you to open the same file in the same type of editor too.
I have two Perspectives and two editor part each.
When preperspective changed to postperspective , the editor opend is closed . then changed again to preperspective , no editor can be recovered.
How can I rememver the Editor Opend , even when changing perspective occured. and can I recover it again?
This behavior actually contradicts to the Eclipse UI metaphor where editors are shared between perspectives.
So you have to implement your own persistent storage for perpective:editors map. Also look at http://help.eclipse.org/help33/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditorInput.html#getPersistable()