Bug 518294 - Improve flexibility of the "bundleShapes" extension point
Summary: Improve flexibility of the "bundleShapes" extension point
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 5.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 5.1.0   Edit
Assignee: Jessy Mallet CLA
QA Contact:
URL:
Whiteboard: diagram svg
Keywords: helpwanted, triaged
Depends on:
Blocks:
 
Reported: 2017-06-15 06:12 EDT by Cedric Brun CLA
Modified: 2017-11-08 03:37 EST (History)
1 user (show)

See Also:


Attachments
The plugin which contains the extension for testing. (4.08 KB, application/x-zip-compressed)
2017-09-21 11:18 EDT, Jessy Mallet CLA
no flags Details
The modeling project using the extension. (2.81 KB, application/x-zip-compressed)
2017-09-21 11:19 EDT, Jessy Mallet CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Cedric Brun CLA 2017-06-15 06:12:15 EDT
When using this extension point one can specify Id's and attributes for the color, bordercolor and bordersize.

These definitions are required in the grammar (though the PDE tooling is not enforcing anything), failing to put those will lead to a crash when opening the diagram, for instance:

```java.lang.StringIndexOutOfBoundsException: String index out of range: 11
	at java.lang.String.substring(String.java:1963)
	at org.eclipse.sirius.diagram.ui.tools.api.figure.BundledImageFigure.getNewStyle(BundledImageFigure.java:399)
	at org.eclipse.sirius.diagram.ui.tools.api.figure.BundledImageFigure.updateDocumentColors(BundledImageFigure.java:289)
	at org.eclipse.sirius.diagram.ui.tools.api.figure.BundledImageFigure.updateColors(BundledImageFigure.java:210)
	at org.eclipse.sirius.diagram.ui.tools.api.figure.BundledImageFigure.refreshFigure(BundledImageFigure.java:415)
	at org.eclipse.sirius.diagram.ui.tools.api.figure.BundledImageFigure.createImageFigure(BundledImageFigure.java:164)
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.BundledImageEditPart.createNodeShape(BundledImageEditPart.java:118)
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.BundledImageEditPart.createNodeFigure(BundledImageEditPart.java:176)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart.createFigure(ShapeNodeEditPart.java:90)
	at org.eclipse.gef.editparts.AbstractGraphicalEditPart.getFigure(AbstractGraphicalEditPart.java:494)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart.addChildVisual(AbstractBorderedShapeEditPart.java:90)
	at org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:211)

`` 

when having a definition with none of these attributes defined.

As a user I would have expected that Sirius would have had used the image "as is" without any replacement, and not fail like that.
Comment 1 Pierre-Charles David CLA 2017-06-15 08:17:51 EDT
Agreed. It seems there are two aspects:
* improve the extension point definition to help PDE help the user;
* make the code more robust in the presence of invalid configuration.

In case of miconfiguration, the code should:
* log an error/warning with enough information about what is wrong and what is expected for the specifier to fix the problem (i.e. not just "An error occured", but "Id 'foo' should denote a gradient stop (or whatever) but none could be found in 'bar.svg'");
* fallback to using the raw SVG (or maybe with only the correctly configured style adjustments) instead of crashing.
Comment 2 Cedric Brun CLA 2017-06-15 08:22:51 EDT
I'm still fighting to get my shapes working as I expect, it seems there is an assumption that a color is a gradient for instance... (I'm not 100%, I don't have errors now but the color is still not changing).

As a user, it feels like pure and simple variable substitution in the SVG would be much simpler and less error prone.
Comment 3 Eclipse Genie CLA 2017-09-19 11:55:27 EDT
New Gerrit change created: https://git.eclipse.org/r/105418
Comment 5 Jessy Mallet CLA 2017-09-21 11:18:52 EDT
Created attachment 270295 [details]
The plugin which contains the extension for testing.
Comment 6 Jessy Mallet CLA 2017-09-21 11:19:21 EDT
Created attachment 270296 [details]
The modeling project using the extension.
Comment 7 Jessy Mallet CLA 2017-09-21 11:24:14 EDT
Steps to reproduce:

* import in your workspace the plugin project from bundleShapeExtension.zip archive,
* launch a runtime,
* import in the runtime workspace the modeling project from  modelingProject.zip
* open the errorLog view,
* open the diagram "new myPackage" -> The diagram should have opened without Exception
* Ensure that the ring to describe the class is blue (as specified in the odesign file and possible thanks to the extension) ->OK
* Ensure that a warning is displayed in the error Log about incomplete extension -> OK
Comment 8 Pierre-Charles David CLA 2017-09-21 11:47:25 EDT
Fixed.
Comment 9 Jessy Mallet CLA 2017-09-25 04:38:35 EDT
Validated on Sirius Stable 5.1.0.201709221508
Comment 10 Pierre-Charles David CLA 2017-11-08 03:37:12 EST
Available in Sirius 5.1.0, see https://wiki.eclipse.org/Sirius/5.1.0.