Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Editor hasn't "Connection Creation Assistants" in MultiPageEditor
Editor hasn't "Connection Creation Assistants" in MultiPageEditor [message #1064930] Fri, 21 June 2013 13:12 Go to next message
Binhua Liu is currently offline Binhua Liu
Messages: 7
Registered: June 2013
Junior Member
Hi everyone,

I try to add the GMF editor into MultiPageEditor, my problem is, when mouse over the node in the gmf editor which in MultiPageEditor, the connection handle don't show. I think it caused by CONNECTION_HANDLES EditorPolicy isn't installed. So, how can I create the editor instance with CONNECTION_HANDLE policy? (now, I just 'new' the editor, I think it is not enough, it is maybe the point)

the code is like:

	
public void addPage(IFile file, String pageName)
	{
		FileEditorInput input = new FileEditorInput(file);
		VuidesignerDiagramEditor editor= new VuidesignerDiagramEditor();
		int index;
		try {
			index = addPage(editor,input);
		} catch (PartInitException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return;
		}
		setPageText(index,pageName);
	}



Thank you very much
Re: Editor hasn't "Connection Creation Assistants" in MultiPageEditor [message #1065132 is a reply to message #1064930] Mon, 24 June 2013 09:17 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph Gerbig
Messages: 697
Registered: November 2009
Senior Member
Hi,

can you post a minimal example or the code that you wrote by hand?

Ralph
Re: Editor hasn't "Connection Creation Assistants" in MultiPageEditor [message #1065224 is a reply to message #1064930] Mon, 24 June 2013 16:48 Go to previous messageGo to next message
Michael Golubev is currently offline Michael Golubev
Messages: 373
Registered: July 2009
Senior Member
Hello,

Check this:

package org.eclipse.gmf.runtime.diagram.ui.editpolicies;
public abstract class DiagramAssistantEditPolicy

/**
* Returns true if the diagram assistant should be shown; false otherwise.
* This can be overridden to check any other conditions which must be met
* prior to showing the diagram assistant.
*
* @return true if the diagram assistant should be shown; false otherwise.
*/
protected boolean shouldShowDiagramAssistant() {
return getHost().isActive() && isPreferenceOn() && isHostEditable()
&& isHostResolvable() && isDiagramPartActive();
}

last && is suspicious here: isDiagramPartActive() because:


/**
* Checks if the diagram part is active.
*
* @return True if the diagram part is active; false otherwise.
*/
private boolean isDiagramPartActive() {
IWorkbenchWindow window = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow();

if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
IWorkbenchPart activePart = page.getActivePart();
if (activePart instanceof IDiagramWorkbenchPart) { <--- may be false in your case of multipage editor
return ((IDiagramWorkbenchPart) activePart)
.getDiagramEditPart().getRoot().equals(
((IGraphicalEditPart) getHost()).getRoot());
}
}
}
return false;
}

If I am right, it should be obvious how to fix from here.

Regards,
Michael
Re: Editor hasn't "Connection Creation Assistants" in MultiPageEditor [message #1074558 is a reply to message #1065224] Sat, 27 July 2013 00:28 Go to previous message
Binhua Liu is currently offline Binhua Liu
Messages: 7
Registered: June 2013
Junior Member
Michael Golubev wrote on Mon, 24 June 2013 16:48
Hello,

Check this:

package org.eclipse.gmf.runtime.diagram.ui.editpolicies;
public abstract class DiagramAssistantEditPolicy

/**
* Returns true if the diagram assistant should be shown; false otherwise.
* This can be overridden to check any other conditions which must be met
* prior to showing the diagram assistant.
*
* @return true if the diagram assistant should be shown; false otherwise.
*/
protected boolean shouldShowDiagramAssistant() {
return getHost().isActive() && isPreferenceOn() && isHostEditable()
&& isHostResolvable() && isDiagramPartActive();
}

last && is suspicious here: isDiagramPartActive() because:


/**
* Checks if the diagram part is active.
*
* @return True if the diagram part is active; false otherwise.
*/
private boolean isDiagramPartActive() {
IWorkbenchWindow window = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow();

if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
IWorkbenchPart activePart = page.getActivePart();
if (activePart instanceof IDiagramWorkbenchPart) { <--- may be false in your case of multipage editor
return ((IDiagramWorkbenchPart) activePart)
.getDiagramEditPart().getRoot().equals(
((IGraphicalEditPart) getHost()).getRoot());
}
}
}
return false;
}

If I am right, it should be obvious how to fix from here.

Regards,
Michael


Hi, Michael, thank you very much, I needn't this feature in my application now, but I will take a try of your code. Smile
Previous Topic:Delete command of Model Element
Next Topic:How to draw the edge using the relative points and anchor information available in the .notation
Goto Forum:
  


Current Time: Sat Aug 23 15:50:24 EDT 2014

Powered by FUDForum. Page generated in 0.01744 seconds