diff options
| author | Steve Monnier | 2019-01-16 09:57:23 +0000 |
|---|---|---|
| committer | Steve Monnier | 2019-01-28 15:02:45 +0000 |
| commit | 83abac388acbb8e295bb85d47c53f59f9d4f59cd (patch) | |
| tree | 75a3d086f2add00069161ac4efb5acc1a5ef1663 | |
| parent | f9d9a213a6b20cf8a8b25adc4b004b8c7c5c3a25 (diff) | |
| download | org.eclipse.sirius-83abac388acbb8e295bb85d47c53f59f9d4f59cd.tar.gz org.eclipse.sirius-83abac388acbb8e295bb85d47c53f59f9d4f59cd.tar.xz org.eclipse.sirius-83abac388acbb8e295bb85d47c53f59f9d4f59cd.zip | |
[543900] Add new extension point to provide SVG shapes as bundled images
The extension point org.eclipse.sirius.diagram.customBundledImageShape
is an improvement on the extension point
org.eclipse.sirius.diagram.bundledImageShape (still working but
deprecated). This new extension point offers more flexibility for
specifying the SVG location of the color, border color and border size
attributes.
Bug: 543900
Change-Id: Ia00d6136331a0a7815bfa518d9b9a5d2176b9392
Signed-off-by: Steve Monnier <steve.monnier@obeo.fr>
12 files changed, 770 insertions, 112 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/BundledImageFigure.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/BundledImageFigure.java index 7ac8b39bf9..72c74c4992 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/BundledImageFigure.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/BundledImageFigure.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2018 THALES GLOBAL SERVICES and others. + * Copyright (c) 2007, 2019 THALES GLOBAL SERVICES and others. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -119,6 +119,11 @@ public class BundledImageFigure extends SVGFigure { private static final String COLOR_IDENTIFIER = "colorIdentifier"; //$NON-NLS-1$ /** + * The id of the color identifier in a bundle image shape extension + */ + private static final String SUB_ATTRIBUTE_IDENTIFIER = "subAttributeIdentifier"; //$NON-NLS-1$ + + /** * The actual shapeName use to draw the SVG figure */ private String shapeName; @@ -283,48 +288,104 @@ public class BundledImageFigure extends SVGFigure { setURI(getURI(), false); Document document = this.getDocument(); if (document != null && needsUpdate) { - /* Update the primary color (if exists). */ - Element gradientStep1 = findElementInDocument(bundledImage, document, BundledImageFigure.COLOR_IDENTIFIER, BundledImageFigure.SVG_STOP_LIGHTER_ID); - if (gradientStep1 != null) { - String gradientStep1Style = getAttributeValue(gradientStep1, bundledImage, BundledImageFigure.COLOR_ATTRIBUTE, BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME); - if (canAttributeBeUpdated(gradientStep1Style, BundledImageFigure.SVG_STOP_COLOR, BundledImageFigure.COLOR_ATTRIBUTE)) { - gradientStep1.setAttribute(BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME, - BundledImageFigure.getNewStyle(gradientStep1Style, BundledImageFigure.SVG_STOP_COLOR, getLighterGradientColor())); - updated = true; - } + if (isCustomBundledImageExtensionPoint(bundledImage)) { + updated = updateDocumentColorsNewExtensionPoint(needsUpdate, bundledImage, document); + } else { + updated = updateDocumentColorsOldExtensionPoint(needsUpdate, bundledImage, document); } + } + } + return updated; + } - /* Update the secondary gradient color (if exists). */ - Element gradientStep2 = document.getElementById(BundledImageFigure.SVG_STOP_MAIN_ID); - if (gradientStep2 != null) { - String gradientStep2Style = gradientStep2.getAttribute(BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME); - if (canAttributeBeUpdated(gradientStep2Style, BundledImageFigure.SVG_STOP_COLOR, BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME)) { - gradientStep2.setAttribute(BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME, - BundledImageFigure.getNewStyle(gradientStep2Style, BundledImageFigure.SVG_STOP_COLOR, getMainGradientColor())); - updated = true; - } - } + /** + * Specific color processing concerning Bundle Image provided with the extension point + * org.eclipse.sirius.diagram.customBundledImageShape. Indeed, this extension point allows to specify the property + * holding a color but if this property is multi-valued, it also provides the specific sub-attribute referencing the + * color. This is why compared to the updateDocumentColorsOldExtensionPoint there is an additional step using the + * getSubAttributeId method. + */ + private boolean updateDocumentColorsNewExtensionPoint(boolean needsUpdate, BundledImage bundledImage, Document document) { + boolean updated = false; + /* Update the primary color (if exists). */ + Element gradientStep1 = findElementInDocument(bundledImage, document, BundledImageFigure.COLOR_IDENTIFIER, BundledImageFigure.SVG_STOP_LIGHTER_ID); + if (gradientStep1 != null) { + String customProperty = getCustomProperty(bundledImage, BundledImageFigure.COLOR_ATTRIBUTE, BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME); + String gradientStep1Style = getAttributeValue(gradientStep1, bundledImage, BundledImageFigure.COLOR_ATTRIBUTE, BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME); + String subAttributeId = getSubAttributeId(gradientStep1, bundledImage, BundledImageFigure.COLOR_ATTRIBUTE); + if (canAttributeBeUpdated(gradientStep1Style, subAttributeId, BundledImageFigure.COLOR_ATTRIBUTE)) { + gradientStep1.setAttribute(customProperty, BundledImageFigure.getNewStyle(gradientStep1Style, subAttributeId, getLighterGradientColor())); + updated = true; + } + } - /* Update the shadow border (if exists). */ - Element shadow = document.getElementById(BundledImageFigure.SVG_SHADOW_ELEMENT_ID); - if (shadow != null) { - String shadowStyle = shadow.getAttribute(BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME); - if (canAttributeBeUpdated(shadowStyle, BundledImageFigure.SVG_FILL, BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME)) { - shadow.setAttribute(BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME, BundledImageFigure.getNewStyle(shadowStyle, BundledImageFigure.SVG_FILL, getLighterBorderColor())); - updated = true; - } - } + updated = updated || updateDocumentSecondaryColorAndShadowBorder(document); - /* Update the border color (if exists). */ - Element elementWithGradient = findElementInDocument(bundledImage, document, BundledImageFigure.BORDER_COLOR_IDENTIFIER, - BundledImageFigure.SVG_GRADIENT_ELEMENT_ID); - if (elementWithGradient != null) { - String elementWithGradientStyle = getAttributeValue(elementWithGradient, bundledImage, BundledImageFigure.BORDER_COLOR_ATTRIBUTE, BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME); - if (canAttributeBeUpdated(elementWithGradientStyle, BundledImageFigure.SVG_STROKE, BundledImageFigure.BORDER_COLOR_ATTRIBUTE)) { - elementWithGradient.setAttribute(BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME, getNewStyle(elementWithGradientStyle, BundledImageFigure.SVG_STROKE, getMainBorderColor())); - updated = true; - } - } + /* Update the border color (if exists). */ + Element elementWithGradient = findElementInDocument(bundledImage, document, BundledImageFigure.BORDER_COLOR_IDENTIFIER, BundledImageFigure.SVG_GRADIENT_ELEMENT_ID); + if (elementWithGradient != null) { + String customProperty = getCustomProperty(bundledImage, BundledImageFigure.BORDER_COLOR_ATTRIBUTE, BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME); + String elementWithGradientStyle = getAttributeValue(elementWithGradient, bundledImage, BundledImageFigure.BORDER_COLOR_ATTRIBUTE, BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME); + String subAttributeId = getSubAttributeId(elementWithGradient, bundledImage, BundledImageFigure.BORDER_COLOR_ATTRIBUTE); + if (canAttributeBeUpdated(elementWithGradientStyle, subAttributeId, BundledImageFigure.BORDER_COLOR_ATTRIBUTE)) { + elementWithGradient.setAttribute(customProperty, getNewStyle(elementWithGradientStyle, subAttributeId, getMainBorderColor())); + updated = true; + } + } + return updated; + } + + /** + * This method processes the color of standard bundle image and bundle image provided by the deprecated extension + * point: org.eclipse.sirius.diagram.bundledImageShape. This method should be renamed the day we remove this + * deprecated extension point. + */ + private boolean updateDocumentColorsOldExtensionPoint(boolean needsUpdate, BundledImage bundledImage, Document document) { + boolean updated = false; + /* Update the primary color (if exists). */ + Element gradientStep1 = findElementInDocument(bundledImage, document, BundledImageFigure.COLOR_IDENTIFIER, BundledImageFigure.SVG_STOP_LIGHTER_ID); + if (gradientStep1 != null) { + String gradientStep1Style = getAttributeValue(gradientStep1, bundledImage, BundledImageFigure.COLOR_ATTRIBUTE, BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME); + if (canAttributeBeUpdated(gradientStep1Style, BundledImageFigure.SVG_STOP_COLOR, BundledImageFigure.COLOR_ATTRIBUTE)) { + gradientStep1.setAttribute(BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME, + BundledImageFigure.getNewStyle(gradientStep1Style, BundledImageFigure.SVG_STOP_COLOR, getLighterGradientColor())); + updated = true; + } + } + + updated = updated || updateDocumentSecondaryColorAndShadowBorder(document); + + /* Update the border color (if exists). */ + Element elementWithGradient = findElementInDocument(bundledImage, document, BundledImageFigure.BORDER_COLOR_IDENTIFIER, BundledImageFigure.SVG_GRADIENT_ELEMENT_ID); + if (elementWithGradient != null) { + String elementWithGradientStyle = getAttributeValue(elementWithGradient, bundledImage, BundledImageFigure.BORDER_COLOR_ATTRIBUTE, BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME); + if (canAttributeBeUpdated(elementWithGradientStyle, BundledImageFigure.SVG_STROKE, BundledImageFigure.BORDER_COLOR_ATTRIBUTE)) { + elementWithGradient.setAttribute(BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME, getNewStyle(elementWithGradientStyle, BundledImageFigure.SVG_STROKE, getMainBorderColor())); + updated = true; + } + } + return updated; + } + + private boolean updateDocumentSecondaryColorAndShadowBorder(Document document) { + boolean updated = false; + /* Update the secondary gradient color (if exists). */ + Element gradientStep2 = document.getElementById(BundledImageFigure.SVG_STOP_MAIN_ID); + if (gradientStep2 != null) { + String gradientStep2Style = gradientStep2.getAttribute(BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME); + if (canAttributeBeUpdated(gradientStep2Style, BundledImageFigure.SVG_STOP_COLOR, BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME)) { + gradientStep2.setAttribute(BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME, BundledImageFigure.getNewStyle(gradientStep2Style, BundledImageFigure.SVG_STOP_COLOR, getMainGradientColor())); + updated = true; + } + } + + /* Update the shadow border (if exists). */ + Element shadow = document.getElementById(BundledImageFigure.SVG_SHADOW_ELEMENT_ID); + if (shadow != null) { + String shadowStyle = shadow.getAttribute(BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME); + if (canAttributeBeUpdated(shadowStyle, BundledImageFigure.SVG_FILL, BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME)) { + shadow.setAttribute(BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME, BundledImageFigure.getNewStyle(shadowStyle, BundledImageFigure.SVG_FILL, getLighterBorderColor())); + updated = true; } } return updated; @@ -332,9 +393,21 @@ public class BundledImageFigure extends SVGFigure { private boolean updateDocumentBorderSize(boolean needsUpdate, BundledImage bundledImage) { boolean updated = false; - if (needsUpdate) { + if (needsUpdate && this.getDocument() != null) { Document document = this.getDocument(); - if (document != null && needsUpdate) { + if (isCustomBundledImageExtensionPoint(bundledImage)) { + /* Update the border size (if exists). */ + Element elementWithGradient = findElementInDocument(bundledImage, document, BundledImageFigure.BORDER_SIZE_IDENTIFIER, BundledImageFigure.SVG_BORDER_ID); + if (elementWithGradient != null) { + String customProperty = getCustomProperty(bundledImage, BundledImageFigure.BORDER_SIZE_ATTRIBUTE, BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME); + String elementWithGradientStyle = getAttributeValue(elementWithGradient, bundledImage, BundledImageFigure.BORDER_SIZE_ATTRIBUTE, BundledImageFigure.SVG_STYLE_ATTRIBUTE_NAME); + String subAttributeId = getSubAttributeId(elementWithGradient, bundledImage, BundledImageFigure.BORDER_SIZE_ATTRIBUTE); + if (canAttributeBeUpdated(elementWithGradientStyle, subAttributeId, BundledImageFigure.BORDER_SIZE_ATTRIBUTE)) { + elementWithGradient.setAttribute(customProperty, getNewStyle(elementWithGradientStyle, subAttributeId, Integer.toString(getMainBorderSize()))); + updated = true; + } + } + } else { /* Update the border size (if exists). */ Element elementWithGradient = findElementInDocument(bundledImage, document, BundledImageFigure.BORDER_SIZE_IDENTIFIER, BundledImageFigure.SVG_BORDER_ID); if (elementWithGradient != null) { @@ -350,6 +423,23 @@ public class BundledImageFigure extends SVGFigure { return updated; } + private String getCustomProperty(BundledImage bundledImage, String propertyId, String defaultId) { + String result = getBundledImageExtensionQuery().findParameterInExtension(getBundledImageExtensionQuery().getExtensionDefiningProvidedShapeID(bundledImage.getProvidedShapeID()), propertyId); + if (result == null) { + result = defaultId; + } + return result; + } + + private boolean isCustomBundledImageExtensionPoint(BundledImage bundledImage) { + if (bundledImage.getProvidedShapeID() == null) { + return false; + } + String extensionPointUniqueIdentifier = getBundledImageExtensionQuery().getExtensionDefiningProvidedShapeID(bundledImage.getProvidedShapeID()).getDeclaringExtension() + .getExtensionPointUniqueIdentifier(); + return BundledImageExtensionQuery.CUSTOM_BUNDLED_IMAGE_SHAPE_EXTENSION_POINT.equals(extensionPointUniqueIdentifier); + } + private Element findElementInDocument(BundledImage bundledImage, Document document, String elementId, String defaultId) { Element element = null; String findParameterInExtension = getBundledImageExtensionQuery().findParameterInExtension( @@ -370,6 +460,17 @@ public class BundledImageFigure extends SVGFigure { return documentElement.getAttribute(defaultId); } + private String getSubAttributeId(Element documentElement, BundledImage bundledImage, String parentAttributeId) { + if (BundledImageShape.PROVIDED_SHAPE_LITERAL.equals(bundledImage.getShape())) { + IConfigurationElement extensionDefiningProvidedShapeID = getBundledImageExtensionQuery().getExtensionDefiningProvidedShapeID(bundledImage.getProvidedShapeID()); + if (isCustomBundledImageExtensionPoint(bundledImage) && extensionDefiningProvidedShapeID != null && extensionDefiningProvidedShapeID.getChildren(parentAttributeId).length > 0) { + IConfigurationElement[] configurationElements = extensionDefiningProvidedShapeID.getChildren(parentAttributeId); + return getBundledImageExtensionQuery().findParameterInExtension(configurationElements[0], BundledImageFigure.SUB_ATTRIBUTE_IDENTIFIER); + } + } + return null; + } + private BundledImageExtensionQuery getBundledImageExtensionQuery() { return BundledImageExtensionQuery.getInstance(); } @@ -396,16 +497,28 @@ public class BundledImageFigure extends SVGFigure { return String.format("%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue()); //$NON-NLS-1$ } - private static String getNewStyle(String actualStyle, String colorAttribute, String newColor) { - int indexOfColorAttribute = actualStyle.indexOf(colorAttribute); + private static String getNewStyle(String actualStyle, String subAttributeId, String newValue) { + if (subAttributeId == null) { + // if subAttributeId is null, then this is single-valued property and we do not need to insert newValue + // among a list of attributes + String result; + if (actualStyle.startsWith("#")) { //$NON-NLS-1$ + // Colors are prefixed by a "#" + result = "#" + newValue; //$NON-NLS-1$ + } else { + result = newValue; + } + return result; + } + int indexOfColorAttribute = actualStyle.indexOf(subAttributeId); String newStyle; - if (BundledImageFigure.SVG_STROKE_WIDTH.equals(colorAttribute)) { - newStyle = actualStyle.substring(0, indexOfColorAttribute + colorAttribute.length() + 1); + if (BundledImageFigure.SVG_STROKE_WIDTH.equals(subAttributeId)) { + newStyle = actualStyle.substring(0, indexOfColorAttribute + subAttributeId.length() + 1); } else { // Colors have an extra '#' as prefix - newStyle = actualStyle.substring(0, indexOfColorAttribute + colorAttribute.length() + 2); + newStyle = actualStyle.substring(0, indexOfColorAttribute + subAttributeId.length() + 2); } - newStyle = newStyle.concat(newColor); + newStyle = newStyle.concat(newValue); newStyle = newStyle.concat(actualStyle.substring(actualStyle.indexOf(";", indexOfColorAttribute), actualStyle.length())); //$NON-NLS-1$ return newStyle; } @@ -509,11 +622,14 @@ public class BundledImageFigure extends SVGFigure { } private boolean canAttributeBeUpdated(String attributeValue, String svgProperty, String attributeToModify) { - int indexOfProprAttribute = attributeValue.indexOf(svgProperty); - boolean canBeUpdate = indexOfProprAttribute >= 0; - if (!canBeUpdate) { - DiagramPlugin.getDefault().logWarning(MessageFormat.format(Messages.BundledImageShape_attributeAbsent, shapeID, attributeToModify)); + if (svgProperty != null) { + int indexOfProprAttribute = attributeValue.indexOf(svgProperty); + boolean canBeUpdate = indexOfProprAttribute >= 0; + if (!canBeUpdate) { + DiagramPlugin.getDefault().logWarning(MessageFormat.format(Messages.BundledImageShape_attributeAbsent, shapeID, attributeToModify)); + } + return canBeUpdate; } - return canBeUpdate; + return true; } } diff --git a/plugins/org.eclipse.sirius.diagram/plugin.properties b/plugins/org.eclipse.sirius.diagram/plugin.properties index 7a5ff65c11..ec453d3a1e 100644 --- a/plugins/org.eclipse.sirius.diagram/plugin.properties +++ b/plugins/org.eclipse.sirius.diagram/plugin.properties @@ -167,6 +167,7 @@ constraint.validVariable.name = Valid Variables extension-point.canonicalSynchronizerFactoryOverride.name = org.eclipse.sirius.diagram.canonicalSynchronizerFactoryOverride extension-point.diagramTypeProvider.name = org.eclipse.sirius.diagram.diagramTypeProvider extension-point.bundledImageShape.name = org.eclipse.sirius.diagram.bundledImageShape +extension-point.customBundledImageShape.name = org.eclipse.sirius.diagram.customBundledImageShape AbstractDDiagramConstraint_validationErrorMessage = Validation issues AbstractDiagramCommandBuilder_diagramVariableTaskLabel = Add diagram variable diff --git a/plugins/org.eclipse.sirius.diagram/plugin.xml b/plugins/org.eclipse.sirius.diagram/plugin.xml index 21b1b2430c..ad0dbc2440 100644 --- a/plugins/org.eclipse.sirius.diagram/plugin.xml +++ b/plugins/org.eclipse.sirius.diagram/plugin.xml @@ -17,6 +17,7 @@ <extension-point id="diagramTypeProvider" name="%extension-point.diagramTypeProvider.name" schema="schema/diagramTypeProvider.exsd"/> <extension-point id="canonicalSynchronizerFactoryOverride" name="%extension-point.canonicalSynchronizerFactoryOverride.name" schema="schema/canonicalSynchronizerFactoryOverride.exsd"/> <extension-point id="bundledImageShape" name="%extension-point.bundledImageShape.name" schema="schema/bundledImageShape.exsd"/> + <extension-point id="customBundledImageShape" name="%extension-point.customBundledImageShape.name" schema="schema/customBundledImageShape.exsd"/> <extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypes"> <?gmfgen generated="false"?> diff --git a/plugins/org.eclipse.sirius.diagram/schema/bundledImageShape.exsd b/plugins/org.eclipse.sirius.diagram/schema/bundledImageShape.exsd index c660d1380b..40d7b2771a 100644 --- a/plugins/org.eclipse.sirius.diagram/schema/bundledImageShape.exsd +++ b/plugins/org.eclipse.sirius.diagram/schema/bundledImageShape.exsd @@ -6,7 +6,9 @@ <meta.schema plugin="org.eclipse.sirius.diagram" id="bundledImageShape" name="org.eclipse.sirius.diagram.bundledImageShape"/> </appInfo> <documentation> - This extension register new shapes for Bundle Image styles that can be used in Viewpoint Specification Models. + WARNING: This extension point is deprecated. You should use org.eclipse.sirius.diagram.custombundledImageShape instead. + +This extension registers new shapes for Bundle Image styles that can be used in Viewpoint Specification Models. </documentation> </annotation> diff --git a/plugins/org.eclipse.sirius.diagram/schema/customBundledImageShape.exsd b/plugins/org.eclipse.sirius.diagram/schema/customBundledImageShape.exsd new file mode 100644 index 0000000000..78aee31b8c --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram/schema/customBundledImageShape.exsd @@ -0,0 +1,249 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.sirius.diagram" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="org.eclipse.sirius.diagram" id="customBundledImageShape" name="org.eclipse.sirius.diagram.customBundledImageShape"/> + </appInfo> + <documentation> + This extension registers new shapes for Bundle Image styles that can be used in Viewpoint Specification Models. + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence> + <element ref="image"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + a fully qualified identifier of the target extension point + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string" use="required"> + <annotation> + <documentation> + The identifier of the extension instance + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + an optional name of the extension instance + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="image"> + <complexType> + <sequence minOccurs="0" maxOccurs="1"> + <element ref="colorIdentifier"/> + <element ref="colorAttribute"/> + <element ref="borderColorIdentifier"/> + <element ref="borderColorAttribute"/> + <element ref="borderSizeIdentifier"/> + <element ref="borderSizeAttribute"/> + </sequence> + <attribute name="label" type="string" use="required"> + <annotation> + <documentation> + The label of the shape to be displayed in a bundle image style. + </documentation> + </annotation> + </attribute> + <attribute name="imagePath" type="string" use="required"> + <annotation> + <documentation> + Path of the image in this plug-in + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="colorIdentifier"> + <complexType> + <attribute name="colorIdentifier" type="string" use="required"> + <annotation> + <documentation> + Identifier of the shape color tag in the SVG file + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="colorAttribute"> + <complexType> + <sequence minOccurs="0" maxOccurs="1"> + <element ref="subAttributeIdentifier"/> + </sequence> + <attribute name="colorAttribute" type="string" use="required"> + <annotation> + <documentation> + Key of the color attribute of the shape color tag in the SVG file + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="borderColorIdentifier"> + <complexType> + <attribute name="borderColorIdentifier" type="string" use="required"> + <annotation> + <documentation> + Identifier of the shape border color tag in the SVG file + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="borderColorAttribute"> + <complexType> + <sequence minOccurs="0" maxOccurs="1"> + <element ref="subAttributeIdentifier"/> + </sequence> + <attribute name="borderColorAttribute" type="string" use="required"> + <annotation> + <documentation> + Key of the color attribute of the shape border color tag in the SVG file + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="borderSizeIdentifier"> + <complexType> + <attribute name="borderSizeIdentifier" type="string" use="required"> + <annotation> + <documentation> + Identifier of the shape border size tag in the SVG file + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="borderSizeAttribute"> + <complexType> + <sequence minOccurs="0" maxOccurs="1"> + <element ref="subAttributeIdentifier"/> + </sequence> + <attribute name="borderSizeAttribute" type="string" use="required"> + <annotation> + <documentation> + Key of the color attribute of the shape border size tag in the SVG file + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <element name="subAttributeIdentifier"> + <complexType> + <attribute name="subAttributeIdentifier" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + 6.2 + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + The following is an example of a SVG provided to the list of bundled image shapes with this extension point: +<p> +<pre> + + <extension + id="custom.circle.svg" + name="Circle" + point="org.eclipse.sirius.diagram.customBundledImageShape"> + <image + imagePath="/542678.design/images/circle.svg" + label="custom.circle"> + <colorIdentifier + colorIdentifier="circle4"> + </colorIdentifier> + <colorAttribute + colorAttribute="style"> + <subAttributeIdentifier + subAttributeIdentifier="fill"> + </subAttributeIdentifier> + </colorAttribute> + <borderColorIdentifier + borderColorIdentifier="circle4"> + </borderColorIdentifier> + <borderColorAttribute + borderColorAttribute="style"> + <subAttributeIdentifier + subAttributeIdentifier="stroke"> + </subAttributeIdentifier> + </borderColorAttribute> + <borderSizeIdentifier + borderSizeIdentifier="circle4"> + </borderSizeIdentifier> + <borderSizeAttribute + borderSizeAttribute="style"> + <subAttributeIdentifier + subAttributeIdentifier="stroke-width"> + </subAttributeIdentifier> + </borderSizeAttribute> + </image> + </extension> +</pre> +</p> +</pre> +</p> + </documentation> + </annotation> + + + + <annotation> + <appInfo> + <meta.section type="copyright"/> + </appInfo> + <documentation> + Copyright (c) 2019 Obeo<br> + + This program and the accompanying materials +are made available under the terms of the Eclipse Public License 2.0 +which accompanies this distribution, and is available at +<a href="https://www.eclipse.org/legal/epl-2.0">https://www.eclipse.org/legal/epl-v20.html</a>/ + +SPDX-License-Identifier: EPL-2.0 + </documentation> + </annotation> + +</schema> diff --git a/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/internal/queries/BundledImageExtensionQuery.java b/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/internal/queries/BundledImageExtensionQuery.java index f44bbe7a64..2bbae82e54 100644 --- a/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/internal/queries/BundledImageExtensionQuery.java +++ b/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/internal/queries/BundledImageExtensionQuery.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2018 Obeo. + * Copyright (c) 2015, 2019 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -29,13 +29,21 @@ import org.eclipse.core.runtime.Platform; @SuppressWarnings({ "restriction" }) public final class BundledImageExtensionQuery { /** + * Identifier of the newer extension point. + */ + public static final String CUSTOM_BUNDLED_IMAGE_SHAPE_EXTENSION_POINT = "org.eclipse.sirius.diagram.customBundledImageShape"; //$NON-NLS-1$ + + /** * The global instance. */ private static final BundledImageExtensionQuery INSTANCE = new BundledImageExtensionQuery(); /** * Identifier of the extension point. + * + * @deprecated */ + @Deprecated private static final String BUNDLED_IMAGE_SHAPE_EXTENSION_POINT = "org.eclipse.sirius.diagram.bundledImageShape"; //$NON-NLS-1$ private static final String LABEL_ATTRIBUTE = "label"; //$NON-NLS-1$ @@ -69,7 +77,19 @@ public final class BundledImageExtensionQuery { */ public IConfigurationElement[] getExtensions() { if (extensions == null) { - this.extensions = Platform.getExtensionRegistry().getConfigurationElementsFor(BUNDLED_IMAGE_SHAPE_EXTENSION_POINT); + IConfigurationElement[] newExtensionPoints = Platform.getExtensionRegistry().getConfigurationElementsFor(CUSTOM_BUNDLED_IMAGE_SHAPE_EXTENSION_POINT); + IConfigurationElement[] oldExtensionPoints = Platform.getExtensionRegistry().getConfigurationElementsFor(BUNDLED_IMAGE_SHAPE_EXTENSION_POINT); + IConfigurationElement[] allExtensionPoints = new IConfigurationElement[newExtensionPoints.length + oldExtensionPoints.length]; + int extensionsCount = 0; + for (int i = 0; i < newExtensionPoints.length; i++) { + allExtensionPoints[extensionsCount] = newExtensionPoints[i]; + extensionsCount++; + } + for (int i = 0; i < oldExtensionPoints.length; i++) { + allExtensionPoints[extensionsCount] = oldExtensionPoints[i]; + extensionsCount++; + } + this.extensions = allExtensionPoints; } return extensions; } diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html index 76582ffc93..2abaaf0807 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html @@ -138,6 +138,8 @@ <code>org.eclipse.sirius.diagram</code> </h4> <ul> + <li><span class="label label-info">Added</span> The extension point org.eclipse.sirius.diagram.customBundledImageShape has been created in order to provide custom shape to the bundled image style. This extension point offers more flexibility on the specification of the svg tags and attributes holding the color, border color and border size information than the extension point org.eclipse.sirius.diagram.bundledImageShape.</li> + <li><span class="label label-info">Modified</span> The extension point org.eclipse.sirius.diagram.bundledImageShape has been marked as deprecated. Shapes provided by this extension point still work.</li> <li><span class="label label-success">Added</span> The getter and setter methods have been added for the new attribute <code>org.eclipse.sirius.diagram.ui.tools.api.decoration.DecorationDescriptor.isPrintable</code>. This attribute is used to know if the decoration should be hidden when printing or exporting the diagram. The behavior is applied only if there is no printable decoration in its diagram element location (South, West, South-West etc). </li> diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile index cf383f62a8..57a65f9d3b 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile @@ -27,6 +27,8 @@ h4. Changes in @org.eclipse.sirius.diagram.ui@ h4. Changes in @org.eclipse.sirius.diagram@ +* <span class="label label-info">Added</span> The extension point org.eclipse.sirius.diagram.customBundledImageShape has been created in order to provide custom shape to the bundled image style. This extension point offers more flexibility on the specification of the svg tags and attributes holding the color, border color and border size information than the extension point org.eclipse.sirius.diagram.bundledImageShape. +* <span class="label label-info">Modified</span> The extension point org.eclipse.sirius.diagram.bundledImageShape has been marked as deprecated. Shapes provided by this extension point still work. * <span class="label label-success">Added</span> The getter and setter methods have been added for the new attribute @org.eclipse.sirius.diagram.ui.tools.api.decoration.DecorationDescriptor.isPrintable@. This attribute is used to know if the decoration should be hidden when printing or exporting the diagram. The behavior is applied only if there is no printable decoration in its diagram element location (South, West, South-West etc). h4. Changes in @org.eclipse.sirius.common@ diff --git a/plugins/org.eclipse.sirius.doc/doc/developer/deprecated_extensions-provide_custom_bundled_image_shape.html b/plugins/org.eclipse.sirius.doc/doc/developer/deprecated_extensions-provide_custom_bundled_image_shape.html new file mode 100644 index 0000000000..07729ffc40 --- /dev/null +++ b/plugins/org.eclipse.sirius.doc/doc/developer/deprecated_extensions-provide_custom_bundled_image_shape.html @@ -0,0 +1,93 @@ +<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <title>deprecated_extensions-provide_custom_bundled_image_shape</title> + <link type="text/css" rel="stylesheet" href="../resources/bootstrap.css"/> + <link type="text/css" rel="stylesheet" href="../resources/custom.css"/> + </head> + <body> + <h1 id="SiriusProvidecustombundledimageshape">Sirius – Provide custom bundled image shape</h1> + <h2 id="DisclaimerDeprecated">Disclaimer – Deprecated</h2> + <p>This extension point is deprecated (but still working) and should not be used. Instead you should use the + <a href="extensions-provide_custom_bundled_image_shape.html">new extension point</a>. + </p> + <h2 id="Goals">Goals</h2> + <ul> + <li>Sirius provides a basic image style for node mappings. This style offers a selection of five different shapes. This extension point is used to allow specifiers to provide their own shapes defined in a SVG file.</li> + </ul> + <h2 id="Defineabundledimageshapeextension">Define a bundled image shape extension</h2> + <ul> + <li>This extension point is identified as + <code>org.eclipse.sirius.diagram.bundledImageShape</code>. In this extension, there are three required fields: + <ul> + <li>The Id of the extension is for once required as it will be used to identify the provided shape in the models (VSM and graphical models).</li> + <li>The image path, that needs to start with the plug-in name as it is possible to define a bundled image shape extension using an image in a different plug-in.</li> + <li>The image label displayed in VSMs (suffixed with the plug-in name where the bundled image shape extension is declared).</li> + </ul> + </li> + </ul> + <ul> + <li>There are 6 optional parameters in this extension point. These parameters are used to provide the identifier or attribute name concerning the color, border color and border size used in the given SVG file, if these parameters are not the default ones (used in the 5 default shapes). Here is a list of these parameters and the default value. + <ul> + <li>colorIdentifier, the identifier of the tag defining the inner color of the figure. The default identifier is “stop1”.</li> + <li>colorAttribute, the attribute of the tag defining the inner color of the figure. The default identifier is “style”.</li> + <li>borderColorIdentifier, the identifier of the tag defining the border color of the figure. The default identifier is “elementWithGradient”.</li> + <li>borderColorAttribute, the attribute of the tag defining the border color of the figure. The default identifier is “style”.</li> + <li>borderSizeIdentifier, the identifier of the tag defining the border size of the figure. The default identifier is “externalBorder”.</li> + <li>borderSizeAttribute, the attribute of the tag defining the border size of the figure. The default identifier is “style”.</li> + </ul> + </li> + </ul> + <p>Note that it is possible to provide a non SVG file (like a JPEG) but the colors and border size will not be synchronized with the selected information in the VSM.</p> + <h2 id="Example">Example</h2> + <p>The following example defines a new bundled image shape using an image file donut.svg.</p> + <pre> <extension + id="org.eclipse.sirius.tests.swtbot.donut" + point="org.eclipse.sirius.diagram.bundledImageShape"> + <image + imagePath="/org.eclipse.sirius.tests.swtbot/images/donut.svg" + label="Donut"> + <colorIdentifier + colorIdentifier="stop8224-2"> + </colorIdentifier> + <colorAttribute + colorAttribute="style"> + </colorAttribute> + <borderColorIdentifier + borderColorIdentifier="path10796-2-6-2-7"> + </borderColorIdentifier> + <borderColorAttribute + borderColorAttribute="style"> + </borderColorAttribute> + <borderSizeIdentifier + borderSizeIdentifier="path10796-2-6-2-7"> + </borderSizeIdentifier> + <borderSizeAttribute + borderSizeAttribute="style"> + </borderSizeAttribute> + </image> + </extension> + +</pre> + <p>In this sample, the identifier concerning the tags for the inner color (colorIdentifier), the border color (borderColorIdentifier) and the border size (borderSizeIdentifier) are not the default one. However, the attributes are all the default values. Therefore, we can simplify the extension as follows.</p> + <pre> <extension + id="org.eclipse.sirius.tests.swtbot.donut" + point="org.eclipse.sirius.diagram.bundledImageShape"> + <image + imagePath="/org.eclipse.sirius.tests.swtbot/images/donut.svg" + label="Donut"> + <colorIdentifier + colorIdentifier="stop8224-2"> + </colorIdentifier> + <borderColorIdentifier + borderColorIdentifier="path10796-2-6-2-7"> + </borderColorIdentifier> + <borderSizeIdentifier + borderSizeIdentifier="path10796-2-6-2-7"> + </borderSizeIdentifier> + </image> + </extension> +</pre> + </body> +</html>
\ No newline at end of file diff --git a/plugins/org.eclipse.sirius.doc/doc/developer/deprecated_extensions-provide_custom_bundled_image_shape.textile b/plugins/org.eclipse.sirius.doc/doc/developer/deprecated_extensions-provide_custom_bundled_image_shape.textile new file mode 100644 index 0000000000..26125be146 --- /dev/null +++ b/plugins/org.eclipse.sirius.doc/doc/developer/deprecated_extensions-provide_custom_bundled_image_shape.textile @@ -0,0 +1,79 @@ +h1. Sirius - Provide custom bundled image shape + +h2. Disclaimer - Deprecated + +This extension point is deprecated (but still working) and should not be used. Instead you should use the "new extension point":extensions-provide_custom_bundled_image_shape.html. + +h2. Goals + +* Sirius provides a basic image style for node mappings. This style offers a selection of five different shapes. This extension point is used to allow specifiers to provide their own shapes defined in a SVG file. + +h2. Define a bundled image shape extension + +* This extension point is identified as @org.eclipse.sirius.diagram.bundledImageShape@. In this extension, there are three required fields: +** The Id of the extension is for once required as it will be used to identify the provided shape in the models (VSM and graphical models). +** The image path, that needs to start with the plug-in name as it is possible to define a bundled image shape extension using an image in a different plug-in. +** The image label displayed in VSMs (suffixed with the plug-in name where the bundled image shape extension is declared). + +* There are 6 optional parameters in this extension point. These parameters are used to provide the identifier or attribute name concerning the color, border color and border size used in the given SVG file, if these parameters are not the default ones (used in the 5 default shapes). Here is a list of these parameters and the default value. +** colorIdentifier, the identifier of the tag defining the inner color of the figure. The default identifier is "stop1". +** colorAttribute, the attribute of the tag defining the inner color of the figure. The default identifier is "style". +** borderColorIdentifier, the identifier of the tag defining the border color of the figure. The default identifier is "elementWithGradient". +** borderColorAttribute, the attribute of the tag defining the border color of the figure. The default identifier is "style". +** borderSizeIdentifier, the identifier of the tag defining the border size of the figure. The default identifier is "externalBorder". +** borderSizeAttribute, the attribute of the tag defining the border size of the figure. The default identifier is "style". + +Note that it is possible to provide a non SVG file (like a JPEG) but the colors and border size will not be synchronized with the selected information in the VSM. + +h2. Example + +The following example defines a new bundled image shape using an image file donut.svg. + +pre.. + <extension + id="org.eclipse.sirius.tests.swtbot.donut" + point="org.eclipse.sirius.diagram.bundledImageShape"> + <image + imagePath="/org.eclipse.sirius.tests.swtbot/images/donut.svg" + label="Donut"> + <colorIdentifier + colorIdentifier="stop8224-2"> + </colorIdentifier> + <colorAttribute + colorAttribute="style"> + </colorAttribute> + <borderColorIdentifier + borderColorIdentifier="path10796-2-6-2-7"> + </borderColorIdentifier> + <borderColorAttribute + borderColorAttribute="style"> + </borderColorAttribute> + <borderSizeIdentifier + borderSizeIdentifier="path10796-2-6-2-7"> + </borderSizeIdentifier> + <borderSizeAttribute + borderSizeAttribute="style"> + </borderSizeAttribute> + </image> + </extension> + +p. In this sample, the identifier concerning the tags for the inner color (colorIdentifier), the border color (borderColorIdentifier) and the border size (borderSizeIdentifier) are not the default one. However, the attributes are all the default values. Therefore, we can simplify the extension as follows. + +pre.. + <extension + id="org.eclipse.sirius.tests.swtbot.donut" + point="org.eclipse.sirius.diagram.bundledImageShape"> + <image + imagePath="/org.eclipse.sirius.tests.swtbot/images/donut.svg" + label="Donut"> + <colorIdentifier + colorIdentifier="stop8224-2"> + </colorIdentifier> + <borderColorIdentifier + borderColorIdentifier="path10796-2-6-2-7"> + </borderColorIdentifier> + <borderSizeIdentifier + borderSizeIdentifier="path10796-2-6-2-7"> + </borderSizeIdentifier> + </image> + </extension> diff --git a/plugins/org.eclipse.sirius.doc/doc/developer/extensions-provide_custom_bundled_image_shape.html b/plugins/org.eclipse.sirius.doc/doc/developer/extensions-provide_custom_bundled_image_shape.html index 98bdbb1d67..ce4569d0a4 100644 --- a/plugins/org.eclipse.sirius.doc/doc/developer/extensions-provide_custom_bundled_image_shape.html +++ b/plugins/org.eclipse.sirius.doc/doc/developer/extensions-provide_custom_bundled_image_shape.html @@ -10,12 +10,15 @@ <h1 id="SiriusProvidecustombundledimageshape">Sirius – Provide custom bundled image shape</h1> <h2 id="Goals">Goals</h2> <ul> - <li>Sirius provides a basic image style for node mappings. This style offer a selection of five different shapes. This extension point is used to allow specifiers to provide their own shapes defined in a SVG file.</li> + <li>Sirius provides a basic image style for node mappings. This style offers a selection of five different shapes. This extension point is used to allow specifiers to provide their own shapes defined in a SVG file.</li> + <li>This extension point is an improvement on the + <a href="deprecated_extensions-provide_custom_bundled_image_shape.html">org.eclipse.sirius.diagram.bundledImageShape</a> extension point that has limitation and is now deprecated. Both extension points work but only this one will remain in future versions of Sirius. + </li> </ul> <h2 id="Defineabundledimageshapeextension">Define a bundled image shape extension</h2> <ul> <li>This extension point is identified as - <code>org.eclipse.sirius.diagram.bundledImageShape</code>. In this extension, there are three required fields: + <code>org.eclipse.sirius.diagram.customBundledImageShape</code>. In this extension, there are three required fields: <ul> <li>The Id of the extension is for once required as it will be used to identify the provided shape in the models (VSM and graphical models).</li> <li>The image path, that needs to start with the plug-in name as it is possible to define a bundled image shape extension using an image in a different plug-in.</li> @@ -24,66 +27,110 @@ </li> </ul> <ul> - <li>There are 6 optional parameters in this extension point. These parameters are used to provide the identifier or attribute name concerning the color, border color and border size used in the given SVG file, if these parameters are not the default ones (used in the 5 default shapes). Here is a list of these parameters and the default value. + <li>There are 6 optional parameters in this extension point. These parameters are used to provide the identifier or attribute name concerning the color, border color and border size used in the given SVG file. Here is a list of these parameters: <ul> - <li>colorIdentifier, the identifier of the tag defining the inner color of the figure. The default identifier is “stop1”.</li> - <li>colorAttribute, the attribute of the tag defining the inner color of the figure. The default identifier is “style”.</li> - <li>borderColorIdentifier, the identifier of the tag defining the border color of the figure. The default identifier is “elementWithGradient”.</li> - <li>borderColorAttribute, the attribute of the tag defining the border color of the figure. The default identifier is “style”.</li> - <li>borderSizeIdentifier, the identifier of the tag defining the border size of the figure. The default identifier is “externalBorder”.</li> - <li>borderSizeAttribute, the attribute of the tag defining the border color of the figure. The default identifier is “style”.</li> + <li>colorIdentifier, the identifier of the tag defining the inner color of the figure.</li> + <li>colorAttribute, the attribute of the tag defining the inner color of the figure.</li> + <li>borderColorIdentifier, the identifier of the tag defining the border color of the figure.</li> + <li>borderColorAttribute, the attribute of the tag defining the border color of the figure.</li> + <li>borderSizeIdentifier, the identifier of the tag defining the border size of the figure.</li> + <li>borderSizeAttribute, the attribute of the tag defining the border size of the figure.</li> </ul> </li> + <li>As a color or the border size can be defined in a multi-valued property (see example below), on colorAttribute, borderColorAttribute and borderSizeAttribute it is possible to add a subAttributeIdentifier in order to identify this property among the list.</li> </ul> - <p>Note that it is possible to provide a non SVG file but the colors and border size will not be synchronized with the selected information in the VSM.</p> - <h2 id="Example">Example</h2> - <p>The following example defines a new bundled image shape using an image file donut.svg.</p> + <p>Note that it is possible to provide a non SVG file (like a JPEG) but the colors and border size will not be synchronized with the selected information in the VSM.</p> + <h2 id="Examples">Examples</h2> + <p>As examples, we will use the sample provided in + <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=542678">this feature corresponding bugzilla</a> + </p> + <p>circle.svg defines a ring figure thanks to the following ellipse tag:</p> + <pre><ellipse + cx="242.58475" + cy="254.23729" + id="circle4" + style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:44.9;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + rx="217.21455" + ry="214.03659" /> + +</pre> + <p>For this file, the extension point is specified as follows:</p> <pre> <extension - id="org.eclipse.sirius.tests.swtbot.donut" - point="org.eclipse.sirius.diagram.bundledImageShape"> + id="custom.circle.svg" + name="Circle" + point="org.eclipse.sirius.diagram.customBundledImageShape"> <image - imagePath="/org.eclipse.sirius.tests.swtbot/images/donut.svg" - label="Donut"> + imagePath="/542678.design/images/circle.svg" + label="custom.circle"> <colorIdentifier - colorIdentifier="stop8224-2"> + colorIdentifier="circle4"> </colorIdentifier> <colorAttribute colorAttribute="style"> + <subAttributeIdentifier + subAttributeIdentifier="fill"> + </subAttributeIdentifier> </colorAttribute> <borderColorIdentifier - borderColorIdentifier="path10796-2-6-2-7"> + borderColorIdentifier="circle4"> </borderColorIdentifier> <borderColorAttribute borderColorAttribute="style"> + <subAttributeIdentifier + subAttributeIdentifier="stroke"> + </subAttributeIdentifier> </borderColorAttribute> <borderSizeIdentifier - borderSizeIdentifier="path10796-2-6-2-7"> + borderSizeIdentifier="circle4"> </borderSizeIdentifier> <borderSizeAttribute borderSizeAttribute="style"> + <subAttributeIdentifier + subAttributeIdentifier="stroke-width"> + </subAttributeIdentifier> </borderSizeAttribute> </image> </extension> - + </pre> - <p>In this sample, the identifier concerning the tags for the inner color (colorIdentifier), the border color (borderColorIdentifier) and the border size (borderSizeIdentifier) are not the default one. However, the attributes are all the default values. Therefore, we can simplify the extension as follows.</p> - <pre> <extension - id="org.eclipse.sirius.tests.swtbot.donut" - point="org.eclipse.sirius.diagram.bundledImageShape"> + <p>The three properties are defined in a single tag. In the extension point each, colorIdentifier, borderColorIdentifier and borderSizeIdentifier have the same identifier: “circle4”. + <br/>Then, the color, border color and border size are all defined in the multi-valued property “style” of the ellipse tag. Likewise, in the extension point, colorAttribute, borderColorAttribute and borderSizeAttribute have the same value: “style”. + <br/>Finally, in this “style” property, the color is identified by the attribute “fill”, the border color is identified by the attribute “stroke” and the border color is identified by the attribute “stroke-width”. This is why there is a subAttributeIdentifier with these values under colorAttribute, borderColorAttribute and borderSizeAttribute. + </p> + <p>Now let’s take the sample circle2.svg. The result is also a ring but in the svg it uses the tag circle as follows:</p> + <pre> <circle id="circle" cx="250" cy="250" r="210" fill="#fff" stroke="#000" stroke-width="8"/> + +</pre> + <p>Here there is no multi-valued properties, but the 3 properties we are looking for are separated. For this image, the extension point will be specified as follows:</p> + <pre><extension + id="custom.circle2.svg" + name="Circle2" + point="org.eclipse.sirius.diagram.customBundledImageShape"> <image - imagePath="/org.eclipse.sirius.tests.swtbot/images/donut.svg" - label="Donut"> + imagePath="/542678.design/images/circle2.svg" + label="custom.circle2"> <colorIdentifier - colorIdentifier="stop8224-2"> + colorIdentifier="circle"> </colorIdentifier> + <colorAttribute + colorAttribute="fill"> + </colorAttribute> <borderColorIdentifier - borderColorIdentifier="path10796-2-6-2-7"> + borderColorIdentifier="circle"> </borderColorIdentifier> + <borderColorAttribute + borderColorAttribute="stroke"> + </borderColorAttribute> <borderSizeIdentifier - borderSizeIdentifier="path10796-2-6-2-7"> + borderSizeIdentifier="circle"> </borderSizeIdentifier> + <borderSizeAttribute + borderSizeAttribute="stroke-width"> + </borderSizeAttribute> </image> </extension> + </pre> + <p>This time, there is no subAttributeIdentifier, however colorAttribute, borderColorAttribute and borderSizeAttribute have different values.</p> </body> </html>
\ No newline at end of file diff --git a/plugins/org.eclipse.sirius.doc/doc/developer/extensions-provide_custom_bundled_image_shape.textile b/plugins/org.eclipse.sirius.doc/doc/developer/extensions-provide_custom_bundled_image_shape.textile index 918c12ef11..47bb5f9017 100644 --- a/plugins/org.eclipse.sirius.doc/doc/developer/extensions-provide_custom_bundled_image_shape.textile +++ b/plugins/org.eclipse.sirius.doc/doc/developer/extensions-provide_custom_bundled_image_shape.textile @@ -2,74 +2,120 @@ h1. Sirius - Provide custom bundled image shape h2. Goals -* Sirius provides a basic image style for node mappings. This style offer a selection of five different shapes. This extension point is used to allow specifiers to provide their own shapes defined in a SVG file. +* Sirius provides a basic image style for node mappings. This style offers a selection of five different shapes. This extension point is used to allow specifiers to provide their own shapes defined in a SVG file. +* This extension point is an improvement on the "org.eclipse.sirius.diagram.bundledImageShape":deprecated_extensions-provide_custom_bundled_image_shape.html extension point that has limitation and is now deprecated. Both extension points work but only this one will remain in future versions of Sirius. h2. Define a bundled image shape extension -* This extension point is identified as @org.eclipse.sirius.diagram.bundledImageShape@. In this extension, there are three required fields: +* This extension point is identified as @org.eclipse.sirius.diagram.customBundledImageShape@. In this extension, there are three required fields: ** The Id of the extension is for once required as it will be used to identify the provided shape in the models (VSM and graphical models). ** The image path, that needs to start with the plug-in name as it is possible to define a bundled image shape extension using an image in a different plug-in. ** The image label displayed in VSMs (suffixed with the plug-in name where the bundled image shape extension is declared). -* There are 6 optional parameters in this extension point. These parameters are used to provide the identifier or attribute name concerning the color, border color and border size used in the given SVG file, if these parameters are not the default ones (used in the 5 default shapes). Here is a list of these parameters and the default value. -** colorIdentifier, the identifier of the tag defining the inner color of the figure. The default identifier is "stop1". -** colorAttribute, the attribute of the tag defining the inner color of the figure. The default identifier is "style". -** borderColorIdentifier, the identifier of the tag defining the border color of the figure. The default identifier is "elementWithGradient". -** borderColorAttribute, the attribute of the tag defining the border color of the figure. The default identifier is "style". -** borderSizeIdentifier, the identifier of the tag defining the border size of the figure. The default identifier is "externalBorder". -** borderSizeAttribute, the attribute of the tag defining the border color of the figure. The default identifier is "style". +* There are 6 optional parameters in this extension point. These parameters are used to provide the identifier or attribute name concerning the color, border color and border size used in the given SVG file. Here is a list of these parameters: +** colorIdentifier, the identifier of the tag defining the inner color of the figure. +** colorAttribute, the attribute of the tag defining the inner color of the figure. +** borderColorIdentifier, the identifier of the tag defining the border color of the figure. +** borderColorAttribute, the attribute of the tag defining the border color of the figure. +** borderSizeIdentifier, the identifier of the tag defining the border size of the figure. +** borderSizeAttribute, the attribute of the tag defining the border size of the figure. +* As a color or the border size can be defined in a multi-valued property (see example below), on colorAttribute, borderColorAttribute and borderSizeAttribute it is possible to add a subAttributeIdentifier in order to identify this property among the list. -Note that it is possible to provide a non SVG file but the colors and border size will not be synchronized with the selected information in the VSM. +Note that it is possible to provide a non SVG file (like a JPEG) but the colors and border size will not be synchronized with the selected information in the VSM. -h2. Example +h2. Examples -The following example defines a new bundled image shape using an image file donut.svg. +As examples, we will use the sample provided in "this feature corresponding bugzilla":https://bugs.eclipse.org/bugs/show_bug.cgi?id=542678 + +circle.svg defines a ring figure thanks to the following ellipse tag: + +pre.. +<ellipse + cx="242.58475" + cy="254.23729" + id="circle4" + style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:44.9;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + rx="217.21455" + ry="214.03659" /> + +p. For this file, the extension point is specified as follows: pre.. <extension - id="org.eclipse.sirius.tests.swtbot.donut" - point="org.eclipse.sirius.diagram.bundledImageShape"> + id="custom.circle.svg" + name="Circle" + point="org.eclipse.sirius.diagram.customBundledImageShape"> <image - imagePath="/org.eclipse.sirius.tests.swtbot/images/donut.svg" - label="Donut"> + imagePath="/542678.design/images/circle.svg" + label="custom.circle"> <colorIdentifier - colorIdentifier="stop8224-2"> + colorIdentifier="circle4"> </colorIdentifier> <colorAttribute colorAttribute="style"> + <subAttributeIdentifier + subAttributeIdentifier="fill"> + </subAttributeIdentifier> </colorAttribute> <borderColorIdentifier - borderColorIdentifier="path10796-2-6-2-7"> + borderColorIdentifier="circle4"> </borderColorIdentifier> <borderColorAttribute borderColorAttribute="style"> + <subAttributeIdentifier + subAttributeIdentifier="stroke"> + </subAttributeIdentifier> </borderColorAttribute> <borderSizeIdentifier - borderSizeIdentifier="path10796-2-6-2-7"> + borderSizeIdentifier="circle4"> </borderSizeIdentifier> <borderSizeAttribute borderSizeAttribute="style"> + <subAttributeIdentifier + subAttributeIdentifier="stroke-width"> + </subAttributeIdentifier> </borderSizeAttribute> </image> </extension> + +p. The three properties are defined in a single tag. In the extension point each, colorIdentifier, borderColorIdentifier and borderSizeIdentifier have the same identifier: "circle4". +Then, the color, border color and border size are all defined in the multi-valued property "style" of the ellipse tag. Likewise, in the extension point, colorAttribute, borderColorAttribute and borderSizeAttribute have the same value: "style". +Finally, in this "style" property, the color is identified by the attribute "fill", the border color is identified by the attribute "stroke" and the border color is identified by the attribute "stroke-width". This is why there is a subAttributeIdentifier with these values under colorAttribute, borderColorAttribute and borderSizeAttribute. -p. In this sample, the identifier concerning the tags for the inner color (colorIdentifier), the border color (borderColorIdentifier) and the border size (borderSizeIdentifier) are not the default one. However, the attributes are all the default values. Therefore, we can simplify the extension as follows. +Now let's take the sample circle2.svg. The result is also a ring but in the svg it uses the tag circle as follows: pre.. - <extension - id="org.eclipse.sirius.tests.swtbot.donut" - point="org.eclipse.sirius.diagram.bundledImageShape"> + <circle id="circle" cx="250" cy="250" r="210" fill="#fff" stroke="#000" stroke-width="8"/> + +p. Here there is no multi-valued properties, but the 3 properties we are looking for are separated. For this image, the extension point will be specified as follows: + +pre.. +<extension + id="custom.circle2.svg" + name="Circle2" + point="org.eclipse.sirius.diagram.customBundledImageShape"> <image - imagePath="/org.eclipse.sirius.tests.swtbot/images/donut.svg" - label="Donut"> + imagePath="/542678.design/images/circle2.svg" + label="custom.circle2"> <colorIdentifier - colorIdentifier="stop8224-2"> + colorIdentifier="circle"> </colorIdentifier> + <colorAttribute + colorAttribute="fill"> + </colorAttribute> <borderColorIdentifier - borderColorIdentifier="path10796-2-6-2-7"> + borderColorIdentifier="circle"> </borderColorIdentifier> + <borderColorAttribute + borderColorAttribute="stroke"> + </borderColorAttribute> <borderSizeIdentifier - borderSizeIdentifier="path10796-2-6-2-7"> + borderSizeIdentifier="circle"> </borderSizeIdentifier> + <borderSizeAttribute + borderSizeAttribute="stroke-width"> + </borderSizeAttribute> </image> </extension> + +p. This time, there is no subAttributeIdentifier, however colorAttribute, borderColorAttribute and borderSizeAttribute have different values.
\ No newline at end of file |
