Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » cannot reopen diagram in the editor after executing SetBoundsCommand or setLayoutConstraint(cannot reopen diagram in the editor after executing SetBoundsCommand or setLayoutConstraint)
cannot reopen diagram in the editor after executing SetBoundsCommand or setLayoutConstraint [message #983688] Tue, 13 November 2012 23:32 Go to next message
Melan Nimesh is currently offline Melan Nimesh
Messages: 6
Registered: April 2011
Location: Colombo
Junior Member
Hi,

I tried to generate diagram nodes and link programatically using EMF command and it worked fine, except node locations

I tired to relocated node using SetBoundsCommand

GraphicalEditPart gEditpart = (GraphicalEditPart)editpart;
Rectangle rect = gEditpart.getFigure().getClientArea().getCopy();
rect.setLocation(location.x, location.y);
SetBoundsCommand sbc = new SetBoundsCommand(editpart.getEditingDomain(), "change location", new EObjectAdapter((View) editpart.getModel()), rect);

editpart.getDiagramEditDomain().getDiagramCommandStack().execute(new ICommandProxy(sbc));


after executing above command, it looked fine as expected

but when reopening diagram in the editor, I am getting this error

IRJS0007E Semantic refresh failed

!ENTRY org.eclipse.gmf.runtime.diagram.ui.resources.editor 4 1 2012-11-14 09:37:52.157
!MESSAGE Unresolved reference '_xVpzkC4QEeKAObqZ4Gv3Bg'. (platform:/resource/myproject/src/myfile.test_diagram, 33, 201)

!ENTRY org.eclipse.gmf.runtime.diagram.ui.resources.editor 4 1 2012-11-14 09:37:52.157
!MESSAGE Unresolved reference '_xV_KwC4QEeKAObqZ4Gv3Bg'. (platform:/resource/myproject/src/myfile.test_diagram, 33, 201)

!ENTRY org.eclipse.gmf.runtime.diagram.ui.resources.editor 4 1 2012-11-14 09:37:52.158
!MESSAGE Unresolved reference '_xV_x0C4QEeKAObqZ4Gv3Bg'. (platform:/resource/myproject/src/myfile.test_diagram, 38, 201)

!ENTRY org.eclipse.gmf.runtime.diagram.ui.resources.editor 4 1 2012-11-14 09:37:52.158
!MESSAGE Unresolved reference '_xWUh8C4QEeKAObqZ4Gv3Bg'. (platform:/resource/myproject/src/myfile.test_diagram, 38, 201)

!ENTRY org.eclipse.gmf.runtime.diagram.ui.resources.editor 4 1 2012-11-14 09:37:52.158
!MESSAGE Unresolved reference '_xWVwEC4QEeKAObqZ4Gv3Bg'. (platform:/resource/myproject/src/myfile.test_diagram, 43, 201)

!ENTRY org.eclipse.gmf.runtime.diagram.ui.resources.editor 4 1 2012-11-14 09:37:52.159
!MESSAGE Unresolved reference '_xWsVYC4QEeKAObqZ4Gv3Bg'. (platform:/resource/myproject/src/myfile.test_diagram, 43, 201)

!ENTRY org.eclipse.gmf.runtime.diagram.ui.resources.editor 4 1 2012-11-14 09:37:52.159
!MESSAGE Unresolved reference '_xXHzMC4QEeKAObqZ4Gv3Bg'. (platform:/resource/myproject/src/myfile.test_diagram, 48, 201)

!ENTRY org.eclipse.gmf.runtime.diagram.ui.resources.editor 4 1 2012-11-14 09:37:52.159
!MESSAGE Unresolved reference '_xVqaoC4QEeKAObqZ4Gv3Bg'. (platform:/resource/myproject/src/myfile.test_diagram, 48, 201)

!ENTRY org.eclipse.gmf.runtime.diagram.ui.resources.editor 4 1 2012-11-14 09:37:52.160
!MESSAGE Unresolved reference '_xWtjgC4QEeKAObqZ4Gv3Bg'. (platform:/resource/myproject/src/myfile.test_diagram, 53, 201)

!ENTRY org.eclipse.gmf.runtime.diagram.ui.resources.editor 4 1 2012-11-14 09:37:52.160
!MESSAGE Unresolved reference '_xXHMIC4QEeKAObqZ4Gv3Bg'. (platform:/resource/myproject/src/myfile.test_diagram, 53, 201)

!ENTRY org.eclipse.gmf.runtime.diagram.ui 4 2 2012-11-14 09:37:57.396
!MESSAGE IRJS0007E Semantic refresh failed.
!STACK 0
java.lang.NullPointerException
	at org.test.myeditor.diagram.edit.policies.TestDiagramCanonicalEditPolicy.refreshConnections(TestDiagramCanonicalEditPolicy.java:201)
	at org.test.myeditor.diagram.edit.policies.TestDiagramCanonicalEditPolicy.refreshSemantic(TestDiagramCanonicalEditPolicy.java:167)
	at org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy.refresh(CanonicalEditPolicy.java:961)
	at org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy.refreshOnActivate(CanonicalEditPolicy.java:638)
	at org.test.myeditor.diagram.edit.policies.TestDiagramCanonicalEditPolicy.refreshOnActivate(TestDiagramCanonicalEditPolicy.java:52)
	at org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy.activate(CanonicalEditPolicy.java:628)
	at org.eclipse.gef.editparts.AbstractEditPart.activateEditPolicies(AbstractEditPart.java:173)
	at org.eclipse.gef.editparts.AbstractEditPart.activate(AbstractEditPart.java:155)
	at org.eclipse.gef.editparts.AbstractGraphicalEditPart.activate(AbstractGraphicalEditPart.java:195)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.access$0(GraphicalEditPart.java:1)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.activate(GraphicalEditPart.java:205)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart.activate(DiagramEditPart.java:349)
	at org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:214)
	at org.eclipse.gef.editparts.SimpleRootEditPart.setContents(SimpleRootEditPart.java:105)
	at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents(AbstractEditPartViewer.java:617)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer.setContents(DiagramGraphicalViewer.java:378)
	at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents(AbstractEditPartViewer.java:626)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initializeGraphicalViewerContents(DiagramEditor.java:872)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initializeGraphicalViewer(DiagramEditor.java:865)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFlyOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOutPalette.java:116)
	at org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.initializeGraphicalViewer(DiagramDocumentEditor.java:174)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.createGraphicalViewer(DiagramEditor.java:807)
	at org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(GraphicalEditor.java:171)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.createPartControl(DiagramEditor.java:1580)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFlyOutPalette.createPartControl(DiagramEditorWithFlyOutPalette.java:328)
	at org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.createPartControl(DiagramDocumentEditor.java:1510)
	at org.eclipse.ui.part.MultiPageEditorPart.addPage(MultiPageEditorPart.java:241)
	at org.test.myeditor.diagram.part.MyMultiPageEditor.createPage0(MyMultiPageEditor.java:154)
	at org.test.myeditor.diagram.part.MyMultiPageEditor.createPages(MyMultiPageEditor.java:311)
	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:2674)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:683)
	at org.wso2.developerstudio.eclipse.esb.project.provider.NavigatorActionProvider$OpenEditorAction.run(NavigatorActionProvider.java:114)
	at org.eclipse.ui.actions.RetargetAction.run(RetargetAction.java:221)
	at org.eclipse.ui.navigator.CommonNavigatorManager$3.open(CommonNavigatorManager.java:185)
	at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:48)
	at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:845)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:843)
	at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1131)
	at org.eclipse.ui.navigator.CommonViewer.handleOpen(CommonViewer.java:462)
	at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1235)
	at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:264)
	at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:258)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:298)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3540)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3161)
	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 org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	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(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1384)



Is there any way to get rid of error?

Thanks,
Melan
Re: cannot reopen diagram in the editor after executing SetBoundsCommand or setLayoutConstraint [message #985183 is a reply to message #983688] Thu, 15 November 2012 02:59 Go to previous messageGo to next message
Andreas Muelder is currently offline Andreas Muelder
Messages: 71
Registered: July 2011
Member
Hi Melan,

what causes the NullPointerException in your CanonicalEditPolicy? (TestDiagramCanonicalEditPolicy.java:201)
Which element is null?

Andreas

Re: cannot reopen diagram in the editor after executing SetBoundsCommand or setLayoutConstraint [message #985227 is a reply to message #985183] Thu, 15 November 2012 03:50 Go to previous messageGo to next message
Melan Nimesh is currently offline Melan Nimesh
Messages: 6
Registered: April 2011
Location: Colombo
Junior Member
Hi,

Thanks for the quick reply, getSource() and getTarget() of DiagramLink getting null, I am not familiar with this code

EObject diagramLinkSrc = nextDiagramLink.getSource().getElement();
			EObject diagramLinkDst = nextDiagramLink.getTarget().getElement();



refreshConnections() of CanonicalEditPolicy as below

/**
	 * @generated
	 */
	private Collection<IAdaptable> refreshConnections() {
		Map<EObject, View> domain2NotationMap = new HashMap<EObject, View>();
		Collection<EsbLinkDescriptor> linkDescriptors = collectAllLinks(
				getDiagram(), domain2NotationMap);
		Collection existingLinks = new LinkedList(getDiagram().getEdges());
		for (Iterator linksIterator = existingLinks.iterator(); linksIterator
				.hasNext();) {
			Edge nextDiagramLink = (Edge) linksIterator.next();
			int diagramLinkVisualID = EsbVisualIDRegistry
					.getVisualID(nextDiagramLink);
			if (diagramLinkVisualID == -1) {
				if (nextDiagramLink.getSource() != null
						&& nextDiagramLink.getTarget() != null) {
					linksIterator.remove();
				}
				continue;
			}
			EObject diagramLinkObject = nextDiagramLink.getElement();
			EObject diagramLinkSrc = nextDiagramLink.getSource().getElement();
			EObject diagramLinkDst = nextDiagramLink.getTarget().getElement();
			for (Iterator<EsbLinkDescriptor> linkDescriptorsIterator = linkDescriptors
					.iterator(); linkDescriptorsIterator.hasNext();) {
				EsbLinkDescriptor nextLinkDescriptor = linkDescriptorsIterator
						.next();
				if (diagramLinkObject == nextLinkDescriptor.getModelElement()
						&& diagramLinkSrc == nextLinkDescriptor.getSource()
						&& diagramLinkDst == nextLinkDescriptor
								.getDestination()
						&& diagramLinkVisualID == nextLinkDescriptor
								.getVisualID()) {
					linksIterator.remove();
					linkDescriptorsIterator.remove();
					break;
				}
			}
		}
		deleteViews(existingLinks.iterator());
		return createConnections(linkDescriptors, domain2NotationMap);
	}



Thanks,
Melan
Re: cannot reopen diagram in the editor after executing SetBoundsCommand or setLayoutConstraint [message #985812 is a reply to message #985227] Fri, 16 November 2012 04:13 Go to previous messageGo to next message
Andreas Muelder is currently offline Andreas Muelder
Messages: 71
Registered: July 2011
Member
Hi,
this is strange. Are you sure that setting the bounds causes the edge to loose the source and the target?
If you can upload the project, I will have a look at it.
Regards,

Andreas
Re: cannot reopen diagram in the editor after executing SetBoundsCommand or setLayoutConstraint [message #985918 is a reply to message #985812] Fri, 16 November 2012 11:51 Go to previous message
Melan Nimesh is currently offline Melan Nimesh
Messages: 6
Registered: April 2011
Location: Colombo
Junior Member
Hi,

Yes, I was wrong. I noticed it just did not happen when setting the bounds. I was able to get rid of it by calling my code async way via ProgressMonitorDialog, I don't understand why this is working!

my code as follows

try {
			Shell activeShell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
			ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(activeShell);
			progressMonitorDialog.setOpenOnRun(true);
			progressMonitorDialog.run(true, false, new IRunnableWithProgress() {

				@Override
				public void run(IProgressMonitor monitor) throws InvocationTargetException,
						InterruptedException {
					try {
						monitor.setTaskName("Generating diagram from source");
						Deserializer.getInstance().updateDesign(xml, graphicalEditor);
						setSourceDirty(false);
					} catch (Exception e) {
						new InvocationTargetException(e);
					}
				}
			
			});
			
		} catch (InvocationTargetException e) {
			log.error("Error while generating diagram from source",e.getTargetException());
		} catch (InterruptedException e) {
			log.warn("The operation was canceled by the user", e);
		} finally{
			firePropertyChange(PROP_DIRTY);
		}


Thanks,
Melan

[Updated on: Fri, 16 November 2012 11:52]

Report message to a moderator

Previous Topic:Edit(Copy,Paste) not working with Eclipse Juno(4.2) and GMF(3.0.1)
Next Topic:Composite Structures and GMF
Goto Forum:
  


Current Time: Sun Aug 31 00:37:42 EDT 2014

Powered by FUDForum. Page generated in 0.02070 seconds