Skip to main content



      Home
Home » Modeling » Graphiti » Drilldown feature DiagramInput
Drilldown feature DiagramInput [message #690154] Wed, 29 June 2011 00:40 Go to next message
Eclipse UserFriend
Hello,

I am using the drilldown feature of graphiti to open navigate into my selection. The code snippet i used to open up a new editor was as below:

Diagram diagram = ...
String providerId = ... 

DiagramEditorInput editorInput = new DiagramEditorInput(EcoreUtil.getURI(diagram),getDiagramEditor().getEditingDomain(),providerId);


But with the latest version of graphiti I am unable to do that. The only thing I see that affects my feature that has changed is the "createNormalizedUri()" method in DiagramEditorInput.java. If I comment out the below two lines, it works like before.

URI trimFragment = ret.trimFragment();
ret = GraphitiUiInternal.getEmfService().mapDiagramFileUriToDiagramUri(ret);

Could someone please help me out and tell me what do i need to change to adapt to the new functionality ?

Thanks in advance.

Best Regards,
Murthy
Re: Drilldown feature DiagramInput [message #690228 is a reply to message #690154] Wed, 29 June 2011 03:57 Go to previous messageGo to next message
Eclipse UserFriend
Murthy,

we added these line to avoid the bug that one diagram can be opened in more
than one diagram editor (for one diagram type). To do that we needed to make
sure that the URI stored in the editor input is always the same for the same
diagram.

What I don't yet understand is why this affects your drill down behavior? Is
the new diagram that should be opened the same as the current one? If yes,
the drill down will not open a new editor, but the drill down feature's
intention is to open another diagram, not the same one again. What would be
displayed in the second diagram?

Michael


"Murthybhat" schrieb im Newsbeitrag news:iue9qf$u9v$1@news.eclipse.org...

Hello,

I am using the drilldown feature of graphiti to open navigate into my
selection. The code snippet i used to open up a new editor was as below:


Diagram diagram = ...
String providerId = ...

DiagramEditorInput editorInput = new
DiagramEditorInput(EcoreUtil.getURI(diagram),getDiagramEditor().getEditingDomain(),providerId);


But with the latest version of graphiti I am unable to do that. The only
thing I see that affects my feature that has changed is the
"createNormalizedUri()" method in DiagramEditorInput.java. If I comment out
the below two lines, it works like before.


URI trimFragment = ret.trimFragment();
ret = GraphitiUiInternal.getEmfService().mapDiagramFileUriToDiagramUri(ret);
Could someone please help me out and tell me what do i need to change to
adapt to the new functionality ?

Thanks in advance.

Best Regards,
Murthy
Re: Drilldown feature DiagramInput [message #690265 is a reply to message #690228] Wed, 29 June 2011 05:43 Go to previous messageGo to next message
Eclipse UserFriend
Hello Michael,

I have the following scenario. I have a diagram editor which has some parent component and some child components. A Parent component can either have child components or more parent components. On double clicking of the parent, a new diagram is opened which is similar to the current diagram but the chosenparent as the root now.

My code looks something like this
	@Override
	public void execute(ICustomContext context) {
		if(feature==DRILLDOWN_OPEN)
			super.execute(context);
		else if(feature==DRILLDOWN_CREATE)
			createNewAndOpen(context);
	}

	private void createNewAndOpen(ICustomContext context) {

		final String diagramTypeId = "DiagramType";
		Child child = getChild(context);
		final String diagramName = "Child";

		Diagram diagram = Graphiti.getPeCreateService().createDiagram(diagramTypeId, diagramName, true);
		//Associating diagram with context
		link(diagram, child);
		getDiagram().eResource().getContents().add(diagram);

		String providerId = GraphitiUi.getExtensionManager().getDiagramTypeProviderId(diagram.getDiagramTypeId());
		
		URI uri = EcoreUtil.getURI(child);
		DiagramEditorInput editorInput = new DiagramEditorInput(uri, getDiagramEditor().getEditingDomain(), providerId);

		try {
			IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
			IEditorPart openEditor = activePage.openEditor(editorInput, DiagramEditor.DIAGRAM_EDITOR_ID);			
		} catch (PartInitException e) {
			String error = "Error while opening diagram editor";			
			ErrorDialog.openError(getShell(), "An error occured", null, status);
		}

	}


With those two lines in diagrameditorinput, the "normalized uri" is the same as the parent uri. And hence the same diagram is opened again. any thoughts ?

[Updated on: Wed, 29 June 2011 05:46] by Moderator

Re: Drilldown feature DiagramInput [message #690457 is a reply to message #690265] Wed, 29 June 2011 10:34 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

i fear you violate the policy, that in a diagram file there is to be only
one diagram object
and this should be the root object.
I think you might be able to solve the issue if you store the new diagram in
a separate file.

Best, Tim
Re: Drilldown feature DiagramInput [message #690458 is a reply to message #690457] Wed, 29 June 2011 10:41 Go to previous messageGo to next message
Eclipse UserFriend
Why there should be only one diagram in a diagram file and this should be
the first root element:

- otherwise we could not react properly on a double-click (open diagram) on
a diagram file in the navigator/explorer view...
- otherwise lots of notifications have to be filtered since every (even only
visual) change in one diagram is reported to the other...
- ....
Re: Drilldown feature DiagramInput [message #690715 is a reply to message #690458] Thu, 30 June 2011 00:32 Go to previous messageGo to next message
Eclipse UserFriend
Hello Tim,

Thanks for the information. I now understand the theory behind oneFile=oneDiagram Smile

But in my case, where I have a complicated nested structure it would be a little difficult to create a new file for every parent object. I would then end up with lot of diagram files for a single domain file. Sad I ll try to figure if i can avoid it somehow for my use-case.

Please let me know if there is any other workaround for this.

Regards,
Murthy
Re: Drilldown feature DiagramInput [message #690777 is a reply to message #690715] Thu, 30 June 2011 04:02 Go to previous messageGo to next message
Eclipse UserFriend
Yes it is possible to store multiple diagrams in one file, at least partly.

I have subclassed and customized few classes (DiagramEditor, DiagramEditorInput, DiagramEditorFactory) to get this work. But now I am facing issue with shared editing domain across multiple diagram editors http://goo.gl/JEOwY

So multiple diagrams in one file are not supported, but possible to implement with some effort (with assumption that mentioned editing domain issue will be solved)
Re: Drilldown feature DiagramInput [message #690799 is a reply to message #690777] Thu, 30 June 2011 04:49 Go to previous message
Eclipse UserFriend
Thanks Doboru.

Even i was thinking to implement on the same lines. But handling of the notifications would be an issue in case of the same editing domain for all the open editors for me.


Regards,
Murthy
Previous Topic:Library example
Next Topic:Incorrect behaviour of DiagramEditorBehavior when two instances of editor share same editing domain
Goto Forum:
  


Current Time: Wed Jul 23 15:12:26 EDT 2025

Powered by FUDForum. Page generated in 0.05170 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top