Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Shape, Connection & Properties View(Connection Properties not shown.)
Shape, Connection & Properties View [message #1272318] Mon, 17 March 2014 16:17 Go to next message
Sudharshan Ravi is currently offline Sudharshan RaviFriend
Messages: 12
Registered: March 2014
Junior Member
Hello,

I have a problem with my implementation of my properties view for my graphical editor. The properties for Shape (EObject) is shown correctly. However, the properties for Connection (EReference) is not shown at all.

My adapter implementation is shown below:
public class GraphitiEditPartToIPropertySourceAdapterFactory implements
IAdapterFactory {

	public GraphitiEditPartToIPropertySourceAdapterFactory() {
		super();
	}

	public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) {
		if (IPropertySource.class.equals(adapterType)) {
			if (adaptableObject instanceof GraphitiConnectionEditPart) {
				GraphitiConnectionEditPart editPart = (GraphitiConnectionEditPart) adaptableObject;
				PictogramElement pictogramElement = editPart.getPictogramElement();
				Object object = editPart.getFeatureProvider().getBusinessObjectForPictogramElement(pictogramElement);
				if (object instanceof EReference) {
					return new EReferencePropertySource((EReference) object);
				} 
			} else if (adaptableObject instanceof GraphitiShapeEditPart && !(adaptableObject instanceof GraphitiConnectionEditPart)) {
				GraphitiShapeEditPart editPart = (GraphitiShapeEditPart) adaptableObject;
				PictogramElement pictogramElement = editPart.getPictogramElement();
				Object object = editPart.getFeatureProvider().getBusinessObjectForPictogramElement(pictogramElement);
				if (object instanceof EObject && !(object instanceof EReference)) {
					return new EClassPropertySource((EObject) object);
				}
			}
		}
		return null;
	}


	@SuppressWarnings("rawtypes")
	public Class[] getAdapterList() {
		return new Class[] { IPropertySource.class };
	}

}


Since I wanted the adapter to handle two types of objects, I chose the adaptableType as shown below:
<extension
         point="org.eclipse.core.runtime.adapters">
      <factory
            adaptableType="org.eclipse.gef.editparts.AbstractGraphicalEditPart"
            class="test.GraphitiEditPartToIPropertySourceAdapterFactory">
         <adapter
               type="org.eclipse.ui.views.properties.IPropertySource">
         </adapter>
      </factory>
   </extension>


As mentioned before, this implementation shows the properties of the shapes correctly but not the connections.

Can someone help me figure where I went wrong? If you require other files from my implementation let me know and I will post it. Thank you. Smile
Re: Shape, Connection & Properties View [message #1272641 is a reply to message #1272318] Tue, 18 March 2014 11:49 Go to previous messageGo to next message
Sudharshan Ravi is currently offline Sudharshan RaviFriend
Messages: 12
Registered: March 2014
Junior Member

[Updated on: Tue, 18 March 2014 12:18]

Report message to a moderator

Re: Shape, Connection & Properties View [message #1272652 is a reply to message #1272318] Tue, 18 March 2014 12:18 Go to previous message
Sudharshan Ravi is currently offline Sudharshan RaviFriend
Messages: 12
Registered: March 2014
Junior Member
For those who have this problem, I have found a solution.

The mistake I made was in adaptableType. I thought you could declare a adaptableType which was a superclass to both shape and connection such as org.eclipse.gef.editparts.AbstractGraphicalEditPart which does not work.

You need to create two adapters each adapting shape and connection separately like this:
shape adaptableType: org.eclipse.graphiti.ui.internal.parts.ContainerShapeEditPart
connection adaptableType: org.eclipse.graphiti.ui.internal.parts.FreeFormConnectionEditPart

   <extension
         point="org.eclipse.core.runtime.adapters">
      <factory
            adaptableType="org.eclipse.graphiti.ui.internal.parts.ContainerShapeEditPart"
            class="se.scania.yset.xmleditor.property.GraphitiEditPartToIPropertySourceAdapterFactory">
         <adapter
               type="org.eclipse.ui.views.properties.IPropertySource">
         </adapter>
      </factory>
      <factory
            adaptableType="org.eclipse.graphiti.ui.internal.parts.FreeFormConnectionEditPart"
            class="se.scania.yset.xmleditor.property.GraphitiEditPartToIPropertySourceAdapterFactory">
         <adapter
               type="org.eclipse.ui.views.properties.IPropertySource">
         </adapter>
      </factory>factory>
   </extension>


These two adapters can still be implemented using the same adapterfactory class.
Previous Topic:Algorithm for laying out children of containers on borders
Next Topic:Create source Anchor while starting Connection
Goto Forum:
  


Current Time: Thu Apr 25 01:22:44 GMT 2024

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

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

Back to the top