Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 341898

Summary: Support AdvancedPropertySheet by providing mechanism for registering an AdapterFacotry against ContainerShapeEditPart
Product: [Modeling] Graphiti Reporter: Rhett Hudson <rhett.hudson>
Component: CoreAssignee: Project Inbox <graphiti-inbox>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: matthias.gorning, michael.wenz, refsdal.ivar, sgandon
Version: 0.7.0Flags: michael.wenz: juno+
Target Milestone: 0.9.0   
Hardware: All   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=357632
Whiteboard: Juno M6 Theme_round_offs

Description Rhett Hudson CLA 2011-04-05 09:09:04 EDT
Build Identifier: 

The Eclipse framework provides a tabbed property sheet section, called AdvancedPropertySheet, that allows an "old style" property sheet interface to be put on a tab. Graphiti has good support for tabbed property sheets, but the "old style" property sheet requires registration of an AdapterFactory that adapts the workbench selection into an IPropertySource.

In Graphiti's case, the workbench selection is a ContainerShapeEditPart. It is entirely possible to register the AdapterFactory and implement the AdvancedPropertySheet class for a Graphiti workbench selection, the only issue is that ContainerShapeEditPart is an internal class. Doing so results in making a "discouraged" access to a class that the Graphiti plugin has not explicitly exposed.

Some options:

Exposing the internal class is probably not the best course of action. Perhaps Graphiti could expose a public interface that ContainerShapeEditPart could implement. Likely, the only methods required from the ContainerShapeEditPart are getFeatureProvider() and getModel().

Graphiti could provide a service that registers an AdapterFactory for the internal class on the user's behalf.

Graphiti could provide an extension point that registers the AdapterFactor declaratively.


Reproducible: Always
Comment 1 Rhett Hudson CLA 2011-04-05 09:13:14 EDT
Here's a link to the original forum discussion of this feature request.

http://www.eclipse.org/forums/index.php?t=msg&th=205597
Comment 2 Rhett Hudson CLA 2011-05-25 10:17:23 EDT
I have been able to make the warning go away by registering the adapter against org.eclipse.gef.editparts.AbstractGraphicalEditPart instead of ContainerShapeEditPart. AbstractGraphicalEditPart is a GEF superclass of ContainerShapeEditPart that isn't internal. This might have unintended side effects for an application using more than one GEF-based feature.
Comment 3 Michael Wenz CLA 2011-07-18 07:10:17 EDT
Would like to target for Juno
Comment 4 Sébastien Gandon CLA 2011-09-12 04:55:38 EDT
I was also looking at EEF (http://www.eclipse.org/modeling/emft/?project=eef) that is an eclipse project that generates a Tabbed property sheet from an EMF model.
 and I am facing the same problem, that is the selection is not an EObject. 
EEF is trying to resolve the selection this way :
	/**
	 * @param object
	 * @return
	 */
	protected EObject resolveSemanticObject(Object object) {
		if (object instanceof EObject) {
			return (EObject)object;
		} else if (object instanceof IAdaptable) {
			IAdaptable adaptable = (IAdaptable)object;
			if (adaptable.getAdapter(SemanticAdapter.class) != null) {
				SemanticAdapter semanticAdapter = (SemanticAdapter)adaptable
						.getAdapter(SemanticAdapter.class);
				return semanticAdapter.getEObject();
			} else if (adaptable.getAdapter(EObject.class) != null) {
				return (EObject)adaptable.getAdapter(EObject.class);
			}
		}
		return null;
	}

So we definitly need a way to register AdapterFactory to the Graphiti ContainerShapeEditPart.
That would be very helpful.
Comment 5 Sébastien Gandon CLA 2011-09-12 05:12:50 EDT
Just a remark about adapting to IPropertySource,
looking at the graphiti code, it seems that 
org.eclipse.graphiti.ui.internal.parts.PictogramElementDelegate.getAdapter(Class) is delegating to the IToolBehaviorProvider.
And this is a class you can provide in you type provider by overrinding :
org.eclipse.graphiti.dt.AbstractDiagramTypeProvider.getCurrentToolBehaviorProvider().
Does'nt it fits your need Rhett ?
Comment 6 Rhett Hudson CLA 2011-09-12 16:29:19 EDT
It looks like it might. Though it's not clear that that behavior is a documented feature of a public interface. So, my choice would seem to be relying on undocumented behavior of an internal method or registering an adapter factory against an internal class. I think I prefer the later. I'd at least get a compiler error if the class went away. :)
Comment 7 Michael Wenz CLA 2011-09-15 07:15:32 EDT
*** Bug 357632 has been marked as a duplicate of this bug. ***
Comment 8 Michael Wenz CLA 2011-09-15 07:17:21 EDT
Bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=357632 gives more details on how to reuse generated EMF property sheets. The solution provided to solve this bug should also enable to scenerio described there.
Comment 9 Michael Wenz CLA 2012-02-21 06:47:59 EST
This is now solved in a way very similar to what Rhett proposed as first alternative.
Graphiti now provides a public-API base class for its edit parts for Shapes (org.eclipse.graphiti.ui.platform.GraphitiShapeEditPart) and one for the edit parts for connections (org.eclipse.graphiti.ui.platform.GraphitiConnectionEditPart); these classes can now be used to define an adapter factory extension without API-warnings that adapts the selected edit part to an IPropertySource. The interface solution does not help since the Eclipse adapter factory only works with class objects here.
Besides I added a small example in the tutorial implementation (a tabular property section for EReferences showing the name of the selected connection) and a short description of that in the tutorial page on properties.

I hope this also works out for the EEF issue, Sebastien just let me know in case it doesn't.

Checked-in and pushed to Eclipse:
commit c82ab708a20a5a25f3d424f90d1562dbd2189176
Author: mwenz <michael.wenz@sap.com> 2012-02-21 12:37:35
Committer: mwenz <michael.wenz@sap.com> 2012-02-21 12:37:35
Parent: 3f4b57fdc30f3634bfb140aa21b714d026198528 (Bug 371671 - addGraphicalRepresentation returns null in dark mode * added test)
Branches: origin/master, master
Comment 10 Michael Wenz CLA 2012-04-11 10:53:34 EDT
Bookkeeping: Set target release
Comment 11 Michael Wenz CLA 2012-06-29 04:19:59 EDT
Part of Graphiti 0.9.0 (Eclipse Juno)