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

Bug 357898

Summary: Provide access to actual background color for generated edit parts
Product: [Modeling] GMF-Tooling Reporter: Miles Parker <milesparker>
Component: CoreAssignee: Project Inbox <gmp.gmf-tooling-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: borlander, mistria, ralphgerbig
Version: 2.4   
Target Milestone: 3.0   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Bug Depends on: 368169    
Bug Blocks:    

Description Miles Parker CLA 2011-09-15 21:01:03 EDT
Currently the generated code for edit parts includes:

	/**
	 * @generated
	 */
	protected void setForegroundColor(Color color) {
		if (primaryShape != null) {
			primaryShape.setForegroundColor(color);
		}
	}

	/**
	 * @generated
	 */
	protected void setBackgroundColor(Color color) {
		if (primaryShape != null) {
			primaryShape.setBackgroundColor(color);
		}
	}

But there are no equivalent methods for determining the background color of the enclosed shape. And because there doesn't appear to be a common interface that allows us to find the primary shape for an arbitrary edit part, there is no way to discover this except by assuming that the first child will be that primary shape.
Comment 1 Ralph Gerbig CLA 2011-09-16 03:02:09 EDT
What do you mean by enclosed shape? The draw2d figure? What is your usecase?
Comment 2 Miles Parker CLA 2011-09-16 12:47:46 EDT
(In reply to comment #1)
> What do you mean by enclosed shape? The draw2d figure? What is your usecase?

Yes...for example in the generated EcoreTools EClassEditPart, a "primaryshape" is created which is then the actual shape being drawn. So the figure provided by the getFigure method is essentially useless for extension. But there is no ability to access that primary figure for usage that assumes a generic generated GMF editor. A getter is generated but it is specific to the concrete class:

	/**
	 * @generated
	 */
	public ClassFigure getPrimaryShape() {
		return (ClassFigure) primaryShape;
	}
Comment 3 Mickael Istria CLA 2011-09-19 05:03:19 EDT
I am not sure I fully understand. Can you please detail why the getFigure method does not fit to your use-case?
Comment 4 Miles Parker CLA 2011-09-19 14:28:05 EDT
(In reply to comment #3)
> I am not sure I fully understand. Can you please detail why the getFigure
> method does not fit to your use-case?

Because getFigure does not return the actual figure used to represent the edit part.
Comment 5 Michael Golubev CLA 2012-01-18 19:47:51 EST
We had recently encountered the different use case that may be easily solved by providing something like 
IPrimaryShapeEditPart extends IGraphicalEditPart {IFigure getPrimaryShape();}

We also decided to finally have a tooling-runtime feature / plugin(s) that will provide the common API and glue code for all generated editors (see bugzilla #368169)

I think it is a time to reconsider this bugzilla.