Page 1 of 1

Start Editor with Workbenchpage

Posted: Mon Dec 05, 2011 2:57 pm
by SSC
Hi,

I would like to know if there is a way to have a standalone Eclipse RCP project and just including the XML Editor and nothing else?
I am just trying to with an

Code: Select all

IWorkbenchpage
.

Code: Select all


IWorkbenchpage page = site.getPage();
IEditorPart editor = page.openEditor([color=#FF0040]?EditorInput?[/color],
"com.oxygenxml.editor.editors.xml.XMLEditor");
Unfortunately I am not able to figure out how to do it right or if it is even possible to start the Oxygen Editor without having the Oxygen Perpective and all those other features which I do not want to have in my Application.
I just want to include the XML Editor and nothing else.

Re: Start Editor with Workbenchpage

Posted: Mon Dec 05, 2011 3:18 pm
by Radu
Hi,

The Oxygen XML Plugin for Eclipse comes with a plugin.xml plugin configuration which defines these additional perspectives:

Code: Select all

  <extension point="org.eclipse.ui.perspectives">
<perspective class="com.oxygenxml.editor.perspective.XMLPerspectiveFactory"
icon="eclipseIcons/Oxygen16.gif"
id="com.oxygenxml.editor.xml.perspective" name="oXygen XML"/>
<perspective class="com.oxygenxml.editor.perspective.DBPerspectiveFactory"
icon="eclipseIcons/DbConnection16.gif"
id="com.oxygenxml.editor.db.perspective" name="oXygen DB"/>
<perspective
class="com.oxygenxml.editor.perspective.XSLTDebuggerPerspectiveFactory"
icon="eclipseIcons/DebuggerXSLTView16.gif"
id="com.oxygenxml.editor.debugger.perspective.xslt" name="oXygen XSLT Debugger"/>
<perspective
class="com.oxygenxml.editor.perspective.XQueryDebuggerPerspectiveFactory"
icon="eclipseIcons/DebuggerXQueryView16.gif"
id="com.oxygenxml.editor.debugger.perspective.xquery" name="oXygen XQuery Debugger"/>
</extension>
If you want to distribute a lighter installation of an Oxygen XML Plugin for Eclipse then you will have to edit our plugin.xml and remove the actions and contributors that you do not want.

Regards,
Radu

Re: Start Editor with Workbenchpage

Posted: Tue Dec 06, 2011 1:47 pm
by SSC
Thanks for your answer.
Now I was able to remove the xml perspective.
But now I am wondering how omit the XML and DITA menues and those additional coolbar items.
In the plugin.xml I cannot find an org.eclipse.ui.menues extension for the menu:org.eclipse.ui.main.menu.
How are those items added then and how can I omit them?

Re: Start Editor with Workbenchpage

Posted: Tue Dec 06, 2011 3:01 pm
by Radu
Hi,

The contributions to the main XML menu and toolbars are made in Java code by the action bar contributor classes set in the plugin.xml:

com.oxygenxml.editor.editors.xml.OxygenXMLEditorActionBarContributor

So this cannot be easily changed.

When the XML is being edited in the Author page there is indeed an additional main menu entry + an internal toolbar for each page. This is also added by Java code based on the actions provided by the Document Type (DITA in your case) in the Oxygen XML Document Type Association Preferences page. So only by editing the corresponding document type you can remove the DITA menu + most of the Author actions which appear in the internal coolbar.

Regards,
Radu

Re: Start Editor with Workbenchpage

Posted: Wed Dec 21, 2011 2:52 pm
by SSC

Code: Select all


IWorkbenchpage page = site.getPage();
IEditorPart editor = page.openEditor(?EditorInput?,
"com.oxygenxml.editor.editors.xml.XMLEditor");
Is it possible to start the XML Editor like it is done in the code mentioned above?

I am not sure which IEditorInput implementation is require for your Editor.
Can you give me a hint how to use the openEditor method of the workbenchpage?

Re: Start Editor with Workbenchpage

Posted: Wed Dec 21, 2011 3:10 pm
by Radu
Hi,

In our implementation when we try to open a resource specifically using our XML Editor, the code is like:

Code: Select all

IWorkbenchPage page = EditorPlugin.getActiveWorkbenchWindow().getActivePage();
IEditorInput editorInput = ...
IEditorPart editor = IDE.openEditor(page, editorInput, "com.oxygenxml.editor.editors.xml.XMLEditor", true);
Any kind of IEditorInput implementation should be OK.
In the plugin.xml our editor is registered on most XML extensions so even without specifying our editor's specific ID our editor should be the one which is invoked.
After open you can check that the editor part that you obtain is an instance of ro.sync.exml.workspace.api.editor.WSEditor.

Regards,
Radu

Re: Start Editor with Workbenchpage

Posted: Thu Dec 22, 2011 12:12 pm
by SSC
Hi,

Unfortunately I get a NullPointerException like I already did before with my code :

Code: Select all


java.lang.NullPointerException
at org.eclipse.ui.editors.text.ForwardingDocumentProvider.addElementStateListener(ForwardingDocumentProvider.java:211)
at com.oxygenxml.editor.editors.xml.nb.<init>(Unknown Source)
at com.oxygenxml.editor.editors.b.c.<init>(Unknown Source)
at com.oxygenxml.editor.editors.xml.AbstractXMLEditor.createEditorPages(Unknown Source)
at com.oxygenxml.editor.editors.hb.createPages(Unknown Source)
at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:348)
at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:670)
at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1254)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1207)
at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1606)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:497)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:483)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112)
at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)
at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)
at org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:778)
at org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:677)
at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:638)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2860)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2768)
at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2760)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2711)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2707)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2691)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2682)
at eu.doccenter.kgu.client.oxygen.integration.OxygenToolPlugin$1.run(OxygenToolPlugin.java:66)
at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164)
at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at com.teamcenter.rac.contmgmt.client.DcApplication.start(DcApplication.java:216)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Any suggestions to solve this problem?

Re: Start Editor with Workbenchpage

Posted: Thu Dec 22, 2011 3:23 pm
by Radu
Hi,

What exact Oxygen version are you using?

I'm sorry but I cannot reproduce this, I tried to create a contextual menu action, add it to the Project for certain ".xml" documents and from that action to open an XML Editor using the code I've already sent you.

Can you perform an async exec on the task which opens the editor like Display.getDefault().asyncExec(runnable)?

From what context are you trying to open an XML editor?

Regards,
Radu

Re: Start Editor with Workbenchpage

Posted: Thu Dec 22, 2011 5:08 pm
by SSC
What exact Oxygen version are you using?
I am using the lastest version of the oxygen xml editor ( 13.1 )
Can you perform an async exec on the task which opens the editor like Display.getDefault().asyncExec(runnable)?
I am already performing an Display.getDefault().syncExec(new Runnable() {... for the opening process of the editor.
From what context are you trying to open an XML editor?
We have our own custom IEditorInput for our former used xml editors.
Our implementation of the IEditorInput interface receives a wrapper class through constructor injection which contains the actual xml file ,the css stylesheet and some specific CMS parameters.
But I am wondering how your oxygen xml editor will receive the file to actually show it in the editor.
In a former forum post you said that your xml editor accepts any kind of IEditorInput, but how is it possible when the IEditorInput interface has not any methods which gives you information about the actual content which is supposed to be shown in the EditorPart.
Also the eclipse standart NullEditorInput class throws exactly the same NullPointerException which I postet before.
So what specific needs does your xml editor have concerning the IEditorInput?

Thanks in advance.

Re: Start Editor with Workbenchpage

Posted: Thu Dec 22, 2011 5:33 pm
by Radu
Hi,

So the Text page in the XML multi page editor extends a org.eclipse.ui.editors.text.TextEditor which needs to be properly initialized (the other pages set listeners to the document provider from the Text page).

From what I've logged this text editor receives this callback with the IEditorInput that you have set:

Code: Select all

org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.setDocumentProvider(IEditorInput)
The Eclipse code is like this:

Code: Select all

	protected void setDocumentProvider(IEditorInput input) {
fImplicitDocumentProvider= DocumentProviderRegistry.getDefault().getDocumentProvider(input);
IDocumentProvider provider= super.getDocumentProvider();
if (provider instanceof ForwardingDocumentProvider) {
ForwardingDocumentProvider forwarder= (ForwardingDocumentProvider) provider;
forwarder.setParentProvider(fImplicitDocumentProvider);
}
}
It seems that in the case of the NullEditorInput (and probably in your case too) this call DocumentProviderRegistry.getDefault().getDocumentProvider(input) returns null and thus the TextEditor has a ForwardingDocumentProvider wrapped over a null document provider, making a lot of listeners and getter methods fail.

Regards,
Radu