Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » GMF & EMF synergy
GMF & EMF synergy [message #706562] Sun, 31 July 2011 14:24 Go to next message
janpojer is currently offline janpojerFriend
Messages: 40
Registered: July 2011
Member
Hi everyone,

i was wondering if anyone can give me a tip or an advice on the following issue:

I am trying to create an EMF editor to define certain elements (thats fairly easy) and then to create a GMF editor using the EMF as its source. By that i mean that what each element I define in the EMF, can be dynamically seen in the palette of my GMF and allowed to be drawn.

Anyone has experience with this kind of implementation? I tryied to merge both GMF and EMF in one as adviced in many articles but the problem is that than everytime i add an element to EMF it is automatically added to the GMF diagram, which is not desired.

Thanks for any tips for implementation approach...
Re: GMF & EMF synergy [message #707081 is a reply to message #706562] Mon, 01 August 2011 07:48 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Hello,

I think you'll have to redefine a palette to make it aware of your
current open model and add items to it dynamically. You could use
listeners for that.

What you'll have to do is to tweak the generated code for the Palette to
use your custom Palette instead of the default one. I suggest you to
report these modifications in custom templates [1] to avoid later issues.

[1]
http://wiki.eclipse.org/Graphical_Modeling_Framework/Tutorial/Part_3#Customizing_generation_templates

HTH
--
http://mickaelistria.wordpress.com
http://twitter.com/#!/mickaelistria
http://www.petalslink.com
Re: GMF & EMF synergy [message #707334 is a reply to message #707081] Mon, 01 August 2011 14:18 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

this is part of one of my custom template building a pallete according to a selected element. This is part of Editor.xpt:

«AROUND additions FOR gmfgen::GenEditorView-»
/**
* @generated
*/
private org.eclipse.ui.ISelectionListener selectionListener = new org.eclipse.ui.ISelectionListener() {

 @Override
 public void selectionChanged(org.eclipse.ui.IWorkbenchPart part, org.eclipse.jface.viewers.ISelection selection) {
   //some code here		
   
   if (editPart.resolveSemanticElement() instanceof ElementTypeOfInterest)
     managePalette(editPart.resolveSemanticElement());

 }
};
	
/**
 * @generated
 */
@Override
protected void startListening() {
 super.startListening();
		
 org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener);
}
	
/**
 * @generated
 */
@Override
protected void stopListening() {
  super.stopListening();
		
  org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().removePostSelectionListener(selectionListener);
}

/**
 * @generated
 */
private void managePalette(EObject selectedElement)
{
  //Does custom group exist
  if (customElementsGroup == null)
  {
    org.eclipse.gef.palette.PaletteRoot root = getEditDomain().getPaletteViewer().getPaletteRoot();
			
    customElementsGroup = new org.eclipse.gef.palette.PaletteDrawer("DSL Elements");
    customElementsGroup.setId("dslElementsGroup"); 
			
    root.add(dslElementsGroup);
  }
		
   customElementsGroup.getChildren().clear();
		
   de.uni_mannheim.informatik.swt.models.plm.PLM.diagram.part.PLMDiagramEditor.NodeToolEntry entry = new de.uni_mannheim.informatik.swt.models.plm.PLM.diagram.part.PLMDiagramEditor.NodeToolEntry(e.getName(), "Creates a new " + e.getName(), java.util.Collections.singletonList(XXX.diagram.providers.XXXElementTypes.XXX_0000));
				
    entry.setId(e.getName() + "CreationTool");
    entry.setSmallIcon(XXXDiagramEditorPlugin.findImageDescriptor("/xxx.xxx.xxx/icons/xxx.gif")); //$NON-NLS-1
    entry.setLargeIcon(XXXDiagramEditorPlugin.findImageDescriptor("/xxx.xxx.xxx/icons/xxx.gif"));
				
    dslElementsGroup.add(entry);
}


Hope that helps!

Ralph
Re: GMF & EMF synergy [message #709056 is a reply to message #707334] Wed, 03 August 2011 13:05 Go to previous message
janpojer is currently offline janpojerFriend
Messages: 40
Registered: July 2011
Member
Thanks a lot for the posts. I'll give it a shot and report back.
Previous Topic:Diagram is not present in resource
Next Topic:EMF and GEF
Goto Forum:
  


Current Time: Fri Apr 26 06:57:34 GMT 2024

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

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

Back to the top