[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.mdt.uml2tools] Re: cannot open diagram programmatically

Hi Aram,

I found the root of the problem.

If diagram file is located in eclipse workspace, it is opened correctly in both Windows and Linux (I use Ubuntu) systems.
However, when I tried to open diagrams that are not in workspace, it didn't work, while *.uml files were opened well.
The reason is, that when file isn't located in Workspace, IDE.getEditorInput() is instanceof FileStoreEditorInput. It is used as a parameter in UMLDiagramEditor#setDocumentProvider(IEditorInput) .
UMLDiagramEditor#setDocumentProvider(IEditorInput) sets null in such case. That's why getDocumentProvider() returns null after and you see NPE.


Solution is to add diagram file to your workspace before opening it. It should help.
I hope I wasn't late with the advice.


Best wishes,
Tatiana.

Hey guys,

I still can't find it. I have to give a demo at thursday and
I'd like to
have it working :). The UML2 tree editor works fine while the diagram
editor always results in an error saying that he can't find the file,
while
the file is there.
thnx.

Aram Hovsepyan wrote:

Hi,

I have the following problem using UML2Tools plugin.

I can open the uml2class_diagram files from my Eclipse, however
this does
not work when I do this programmatically. I get the following
error: "Cannot open input element. Reason: text editor does not have
a
document provider".
All other files open fine.

Here is the code that handles the opening:

IFileStore fileStore = EFS.getLocalFileSystem().getStore(new
Path(path));

IDE.openEditorOnFileStore(PlatformUI.getWorkbench().getActiveWorkbench
Window().getActivePage(),

fileStore);

I've already tried to launch eclipse with the -clean option. Doesn't
help. Thanks in advance for the help.

Here is the complete stack trace of the exception:

java.lang.NullPointerException
at
org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocum
entEditor$1.run(DiagramDocumentEditor.java:120)

at

org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalConte
xt.java:369)

at

org.eclipse.jface.operation.ModalContext.run(ModalContext.java:313)

at

org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.jav
a:758)

at

org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)

at
org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java
:755) at

org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2451)

at

org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocum
entEditor.init(DiagramDocumentEditor.java:129)

at

org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:79
4)

at

org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReferen
ce.java:643)

at

org.eclipse.ui.internal.EditorReference.createPart(EditorReference.jav
a:426)

at

org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartRe
ference.java:592)

at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:299) at

org.eclipse.ui.internal.presentations.PresentablePart.setVisible(Prese
ntablePart.java:179)

at

org.eclipse.ui.internal.presentations.util.PresentablePartFolder.selec
t(PresentablePartFolder.java:268)

at

org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(
LeftToRightTabOrder.java:65)

at

org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.sel
ectPart(TabbedStackPresentation.java:400)

at

org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartSta
ck.java:1256)

at

org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1209)

at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1604) at
org.eclipse.ui.internal.PartStack.add(PartStack.java:499) at
org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103) at
org.eclipse.ui.internal.PartStack.add(PartStack.java:485) at
org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112) at

org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContai
ner.java:63)

at

org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.
java:217)

at

org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.ja
va:207)

at

org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.ja
va:774)

at

org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorM
anager.java:673)

at

org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:63
4)

at

org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchP
age.java:2737)

at

org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.jav
a:2651)

at
org.eclipse.ui.internal.WorkbenchPage.access$1
(WorkbenchPage.java:2643)

at

org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2595)

at

org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)

at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2
590)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2
574)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2
557)
at org.eclipse.ui.ide.IDE.openEditorOnFileStore(IDE.java:1090)
at
org.kuleuven.grecco.views.GreccoConcernLibraryView$3.run(GreccoConcern
LibraryView.java:233)

at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) at

org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(
ActionContributionItem.java:546)

at org.eclipse.jface.action.ActionContributionItem.access$
(ActionContributionItem.java:490)
at
org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionCo
ntributionItem.java:402)

at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1101) at

org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3319)

at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2971)
at

org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)

at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353) at
org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219) at
org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466) at

org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.jav
a:289)

at

org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java
:461)

at

org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)

at

org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplic
ation.java:106)

at

org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle
.java:169)

at

org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplic
ation(EclipseAppLauncher.java:106)

at

org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(Ecl
ipseAppLauncher.java:76)

at

org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.jav
a:363)

at

org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.jav
a:176)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at

sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
ava:39)

at

sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)
at
org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447) at
org.eclipse.equinox.launcher.Main.run(Main.java:1173)