Skip to main content


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 17:12 Go to next message
Binhua Liu is currently offline Binhua LiuFriend
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 13:17 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
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 20:48 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
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 04:28 Go to previous message
Binhua Liu is currently offline Binhua LiuFriend
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: Fri Mar 29 05:50:11 GMT 2024

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

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

Back to the top