Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2013-10-29 05:31:24 -0400
committerptessier2013-10-29 05:31:24 -0400
commited8d539d2549c89008c5f4e35c871ff7b4f79b2c (patch)
treeaccfbabdc0dbef76a084e81dbbccfd7ee02dc03d /plugins
parent8be72fef63089c63158c73894a032b2cfb1183a7 (diff)
downloadorg.eclipse.papyrus-ed8d539d2549c89008c5f4e35c871ff7b4f79b2c.tar.gz
org.eclipse.papyrus-ed8d539d2549c89008c5f4e35c871ff7b4f79b2c.tar.xz
org.eclipse.papyrus-ed8d539d2549c89008c5f4e35c871ff7b4f79b2c.zip
420595: [All diagrams] when a element is displayed as symbol, links must
follow symbol https://bugs.eclipse.org/bugs/show_bug.cgi?id=420595
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF8
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/NodeEditPart.java103
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/FollowSVGSymbolEditPolicy.java139
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/ICustomNodePlate.java34
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/SVGNodePlateFigure.java (renamed from plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/SVGNodePlateFigure.java)83
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/AbstractShapeProvider.java29
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/GetSVGDocumentForViewOperation.java59
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/IShapeProvider.java10
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/ShapeService.java21
-rw-r--r--plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementEditPart.java1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/edit/part/CShapeNamedElementEditPart.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractCommentEditPart.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractConstraintEditPart.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/NamedElementEditPart.java21
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/PackageNodePlateFigure.java30
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/META-INF/MANIFEST.MF8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/ActorShapeProvider.java13
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/StereotypedElementShapeProvider.java35
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/TypedElementShapeProvider.java36
19 files changed, 614 insertions, 22 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
index f1487d81184..d3d69b1c721 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
@@ -45,7 +45,13 @@ Require-Bundle: org.eclipse.emf.edit.ui;bundle-version="2.5.0",
org.eclipse.core.databinding.property;bundle-version="1.4.200",
org.eclipse.gmf.runtime.draw2d.ui.render;bundle-version="1.4.1",
org.eclipse.core.expressions,
- org.eclipse.papyrus.uml.tools;bundle-version="0.10.1"
+ org.eclipse.papyrus.uml.tools;bundle-version="0.10.1",
+ org.apache.batik.dom.svg,
+ org.apache.batik.util,
+ org.apache.batik.svggen,
+ org.apache.batik.dom,
+ org.w3c.dom.svg,
+ org.apache.batik.css
Bundle-Vendor: %providerName
Bundle-Version: 0.10.1.qualifier
Bundle-ManifestVersion: 2
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/NodeEditPart.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/NodeEditPart.java
index f6389cb3bd4..5e3f62a93b7 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/NodeEditPart.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpart/NodeEditPart.java
@@ -14,23 +14,38 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.editpart;
+import org.apache.batik.dom.svg.SVGOMDocument;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.StackLayout;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
+import org.eclipse.gmf.runtime.notation.BooleanValueStyle;
import org.eclipse.gmf.runtime.notation.FillStyle;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.runtime.notation.datatype.GradientData;
import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.BorderDisplayEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.FollowSVGSymbolEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.shape.ShapeService;
import org.eclipse.swt.graphics.Color;
/**
- * this uml edit part can refresh shadow and gradient.
+ * this edit part can refresh shadow and gradient.
*/
public abstract class NodeEditPart extends AbstractBorderedShapeEditPart implements IPapyrusEditPart {
+ private SVGNodePlateFigure svgNodePlate;
+ protected IFigure shape;
+ /**
+ *
+ * Constructor.
+ *
+ * @param view
+ */
public NodeEditPart(View view) {
super(view);
}
@@ -43,6 +58,33 @@ public abstract class NodeEditPart extends AbstractBorderedShapeEditPart impleme
return createNodeFigure();
}
+ protected void refreshSVGPath(){
+ View view = getNotationView();
+ if( svgNodePlate!=null){
+ BooleanValueStyle followStyle = (BooleanValueStyle)view.getNamedStyle(NotationPackage.eINSTANCE.getBooleanValueStyle(), FollowSVGSymbolEditPolicy.FOLLOW_SVG_SYMBOL);
+ if(followStyle != null && followStyle.isBooleanValue()) {
+ if(ShapeService.getInstance().hasShapeToDisplay(getNotationView())){
+ int DocumentNumber=ShapeService.getInstance().getSVGDocumentToDisplay(getNotationView()).size();
+ SVGOMDocument svgdoc=null;
+ if( DocumentNumber>1){
+ svgdoc=ShapeService.getInstance().getSVGDocumentToDisplay(getNotationView()).get(DocumentNumber-1);
+ }
+ else if(DocumentNumber==1 ){
+ svgdoc=ShapeService.getInstance().getSVGDocumentToDisplay(getNotationView()).get(0);
+ }
+
+ svgNodePlate.setSVGDocument(svgdoc);
+ }
+ else{
+ svgNodePlate.setSVGDocument(null);
+ }
+ }
+ else{
+ svgNodePlate.setSVGDocument(null);
+ }
+ }
+ }
+
/**
* <p>
* Returns the primary shape being the View of this edit part.
@@ -178,4 +220,63 @@ public abstract class NodeEditPart extends AbstractBorderedShapeEditPart impleme
super.createDefaultEditPolicies();
installEditPolicy(BorderDisplayEditPolicy.BORDER_DISPLAY_EDITPOLICY, new BorderDisplayEditPolicy());
}
+ /**
+ *
+ * @return the figure that represent the shape, this class is generated by the GMF tooling
+ */
+ protected abstract IFigure createNodePlate();
+ /**
+ *
+ * @return the figure that represent the shape, this class is generated by the GMF tooling
+ */
+ protected abstract IFigure createNodeShape();
+
+ /**
+ * this method installs the content pane in the node shape to add compartment for example
+ * @param nodeShape
+ * @return the figure that is the the node shape
+ */
+ protected abstract IFigure setupContentPane(IFigure nodeShape);
+
+
+ /**
+ * Now the method create node plate is not used,
+ * If you want to overlad it you must overload createSVGNodePlate
+ * @return the figure that allow following border of shape
+ */
+ protected NodeFigure createSVGNodePlate() {
+
+ svgNodePlate= new SVGNodePlateFigure(200, 100);
+ svgNodePlate.setDefaultNodePlate(createNodePlate());
+ return svgNodePlate;
+ }
+
+ /**
+ * Creates figure for this edit part.
+ *
+ * Body of this method does not depend on settings in generation model
+ * so you may safely remove <i>generated</i> tag and modify it.
+ *
+ */
+ protected NodeFigure createMainFigureWithSVG() {
+
+ NodeFigure figure = createSVGNodePlate();
+
+ figure.setLayoutManager(new StackLayout());
+ shape = createNodeShape();
+ figure.add(shape);
+ setupContentPane(shape);
+ return figure;
+ }
+
+ @Override
+ public IFigure getContentPane() {
+ if( shape!=null){
+ IFigure contentPane=setupContentPane(shape);
+ return contentPane;
+ }
+ else {
+ return super.getContentPane();
+ }
+ }
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/FollowSVGSymbolEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/FollowSVGSymbolEditPolicy.java
new file mode 100644
index 00000000000..bb187a958ea
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/FollowSVGSymbolEditPolicy.java
@@ -0,0 +1,139 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.common.editpolicies;
+
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.editpolicies.GraphicalEditPolicy;
+import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.BooleanValueStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomBooleanStyleObservableValue;
+
+/**
+ * this edit policy has in charge to display follow the symbol associated to the node
+ * associated figure has to be a {@link NodeNamedElementFigure}
+ */
+public class FollowSVGSymbolEditPolicy extends GraphicalEditPolicy implements IChangeListener {
+ /**
+ * name of the style to get for follow the Symbol
+ */
+ public static final String FOLLOW_SVG_SYMBOL = "FollowSVGSymbol";
+
+ /** key for this edit policy */
+ public final static String FOLLOW_SVG_SYMBOL_EDITPOLICY = "followSVGSymbolEditPolicy";
+
+ protected IObservableValue styleObservable;
+
+
+
+ /**
+ * Creates a new QualifiedNameDisplayEditPolicy
+ */
+ public FollowSVGSymbolEditPolicy() {
+ super();
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public void activate() {
+ // retrieve the view and the element managed by the edit part
+ View view = (View)getHost().getModel();
+ if(view == null) {
+ return;
+ }
+
+ styleObservable = new CustomBooleanStyleObservableValue(view, EMFHelper.resolveEditingDomain(view), FOLLOW_SVG_SYMBOL);
+ styleObservable.addChangeListener(this);
+
+ refreshFigure();
+ }
+
+
+ /**
+ * refresh the qualified name
+ */
+ protected void refreshFigure() {
+ if(getHost() instanceof GraphicalEditPart) {
+ GraphicalEditPart editPart=(GraphicalEditPart)getHost();
+ BooleanValueStyle followStyle=getFollowSymbolStyle(editPart.getNotationView());
+ if(followStyle!=null && followStyle.isBooleanValue()==true){
+ final IFigure fig=getHostFigure();
+
+
+
+
+
+ System.err.println(fig);
+
+
+ }
+ }
+ }
+
+ /**
+ *
+ * @param currentView
+ * @return the current Style that repersent the boder
+ */
+ protected BooleanValueStyle getFollowSymbolStyle(View currentView){
+ return (BooleanValueStyle)currentView.getNamedStyle(NotationPackage.eINSTANCE.getBooleanValueStyle(),FOLLOW_SVG_SYMBOL);
+
+ }
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public void deactivate() {
+ // retrieve the view and the element managed by the edit part
+ View view = (View)getHost().getModel();
+ if(view == null) {
+ return;
+ }
+ if(styleObservable != null) {
+ styleObservable.removeChangeListener(this);
+ styleObservable.dispose();
+ styleObservable = null;
+ }
+
+ }
+
+
+ /**
+ * Gets the diagram event broker from the editing domain.
+ *
+ * @return the diagram event broker
+ */
+ protected DiagramEventBroker getDiagramEventBroker() {
+ TransactionalEditingDomain theEditingDomain = ((IGraphicalEditPart)getHost()).getEditingDomain();
+ if(theEditingDomain != null) {
+ return DiagramEventBroker.getInstance(theEditingDomain);
+ }
+ return null;
+ }
+
+ public void handleChange(ChangeEvent event) {
+ getHost().refresh();
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/ICustomNodePlate.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/ICustomNodePlate.java
new file mode 100644
index 00000000000..8a0f3306272
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/ICustomNodePlate.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.gmfdiag.common.figure.node;
+
+
+/**
+ * this class is used to raise that the implemented Default Node plate is custom.
+ * So the SVGNodePlate must delegate to it some functions
+ *
+ */
+public interface ICustomNodePlate {
+ /**
+ * set the SVG node plate that contain this custom node plate
+ * @param svgNodePlateFigure not null
+ */
+ public void setSVGNodePlateContainer(SVGNodePlateFigure svgNodePlateFigure);
+ /**
+ * get the SVG node plate that contains this custom node plate
+ * @return the SVG node plate
+ */
+ public SVGNodePlateFigure getSvgNodePlateContainer();
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/SVGNodePlateFigure.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/SVGNodePlateFigure.java
index 107fd4144ce..aac08394216 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/SVGNodePlateFigure.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/SVGNodePlateFigure.java
@@ -10,16 +10,18 @@
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
*****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.figure.node;
+package org.eclipse.papyrus.infra.gmfdiag.common.figure.node;
import java.util.ArrayList;
import org.apache.batik.dom.svg.AbstractSVGPathSegList.SVGPathSegMovetoLinetoItem;
import org.apache.batik.dom.svg.SVGOMPathElement;
+import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.PrecisionPoint;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.ScalableCompartmentFigure;
import org.w3c.dom.Element;
import org.w3c.dom.svg.SVGAnimatedLength;
import org.w3c.dom.svg.SVGDocument;
@@ -37,6 +39,7 @@ public class SVGNodePlateFigure extends DefaultSizeNodeFigure {
protected SVGPathSegList pathSegList=null;
protected SVGDocument svgDocument=null;
+ protected DefaultSizeNodeFigure defaultNodePlate;
/**
@@ -44,12 +47,31 @@ public class SVGNodePlateFigure extends DefaultSizeNodeFigure {
* @param svgDocument the SVG document
*/
public void setSVGDocument(SVGDocument svgDocument) {
- this.svgDocument = svgDocument;
- Element path=svgDocument.getElementById("PapyrusPath");
- if( path!=null){
- SVGOMPathElement svgPath=(SVGOMPathElement)path;
- SVGPathSegList segmentList=svgPath.getPathSegList();
- this.setSegemntList(segmentList);
+ if(svgDocument==null){
+ this.svgDocument = null;
+ this.pathSegList=null;
+ }
+ else{
+ this.svgDocument = svgDocument;
+ Element path=svgDocument.getElementById("PapyrusPath");
+ if( path!=null){
+ SVGOMPathElement svgPath=(SVGOMPathElement)path;
+ SVGPathSegList segmentList=svgPath.getPathSegList();
+ this.setSegemntList(segmentList);
+ }
+ }
+ }
+
+ /**
+ * set the node plate that is wrapped by it.
+ * @param defaultNodePlate
+ */
+ public void setDefaultNodePlate(IFigure defaultNodePlate){
+ if( defaultNodePlate instanceof DefaultSizeNodeFigure){
+ this.defaultNodePlate=(DefaultSizeNodeFigure)defaultNodePlate;
+ }
+ if( defaultNodePlate instanceof ICustomNodePlate){
+ ((ICustomNodePlate)this.defaultNodePlate).setSVGNodePlateContainer(this);
}
}
@@ -72,10 +94,39 @@ public class SVGNodePlateFigure extends DefaultSizeNodeFigure {
this.pathSegList= pathSegList;
}
+ public boolean containShapeCompatment(){
+ if( this.getChildren().size()>0&& this.getChildren().get(0) instanceof IFigure){
+ IFigure primaryShape= (IFigure)this.getChildren().get(0);
+ for(Object subFigure : primaryShape.getChildren()) {
+ if(subFigure instanceof ScalableCompartmentFigure ){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public IFigure getShapeCompatment(){
+ if( this.getChildren().size()>0&& this.getChildren().get(0) instanceof IFigure){
+ IFigure primaryShape= (IFigure)this.getChildren().get(0);
+ for(Object subFigure : primaryShape.getChildren()) {
+ if(subFigure instanceof ScalableCompartmentFigure ){
+ return (IFigure)subFigure;
+ }
+ }
+ }
+ return null;
+ }
+
+
// This returns as the anchoring area only the central line
@Override
public PointList getPolygonPoints() {
if (this.pathSegList==null){
+ if (defaultNodePlate!=null){
+ defaultNodePlate.setBounds(this.getBounds());
+ return defaultNodePlate.getPolygonPoints();
+ }
return super.getPolygonPoints();
}
double svgWidth=0;
@@ -88,10 +139,10 @@ public class SVGNodePlateFigure extends DefaultSizeNodeFigure {
SVGLength svgWidthLength =widthALength.getBaseVal();
SVGLength svgHeightLength =heightALength.getBaseVal();
if( svgWidthLength!=null &&svgHeightLength!=null){
- // if( width.getUnitType()==width.SVG_LENGTHTYPE_PX){
- svgWidth= svgWidthLength.getValueInSpecifiedUnits();
- svgHeight= svgHeightLength.getValueInSpecifiedUnits();
- // }
+ // if( width.getUnitType()==width.SVG_LENGTHTYPE_PX){
+ svgWidth= svgWidthLength.getValueInSpecifiedUnits();
+ svgHeight= svgHeightLength.getValueInSpecifiedUnits();
+ // }
}
}
}
@@ -111,7 +162,7 @@ public class SVGNodePlateFigure extends DefaultSizeNodeFigure {
String letter= linetoItem.getPathSegTypeAsLetter();
float x= (float)linetoItem.getX();
float y=(float) linetoItem.getY();
- // System.out.println("value="+value +" letter="+letter+ " x="+ x+ " y="+y);
+ // System.out.println("value="+value +" letter="+letter+ " x="+ x+ " y="+y);
if( letter.equals("M")){
currentAbsoluteSVGPositionX=x;
currentAbsoluteSVGPositionY=y;
@@ -155,8 +206,14 @@ public class SVGNodePlateFigure extends DefaultSizeNodeFigure {
}
//System.out.println("Size of the SVG figure is= "+maxHeight +" "+maxHeight);
PointList points = new PointList(5);
- Rectangle anchorableRectangle = getHandleBounds();
+ Rectangle anchorableRectangle=null;
+ if(containShapeCompatment()){
+ anchorableRectangle =getShapeCompatment().getBounds();
+ }
+ else{
+ anchorableRectangle = getHandleBounds();
+ }
double ratioX=anchorableRectangle.width/maxWitdh;
double ratioY=anchorableRectangle.height/maxHeight;
//PackageFigure packageFigure = getPackageFigure();
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/AbstractShapeProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/AbstractShapeProvider.java
index 5808a168734..356ad8ff526 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/AbstractShapeProvider.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/AbstractShapeProvider.java
@@ -13,9 +13,13 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.service.shape;
+import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
+import org.apache.batik.dom.svg.SVGOMDocument;
import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.w3c.dom.Document;
/**
* Abstract implementation of the shape provider interface.
@@ -97,5 +101,28 @@ public abstract class AbstractShapeProvider extends AbstractProvider implements
description = element.getAttribute(DESCRIPTION);
bundleId = element.getContributor().getName();
}
-
+
+ /**
+ *
+ * @param location
+ * @return the Document SVG from its location, can return null if this is not a svg
+ */
+ public SVGOMDocument getSVGDocument(String location){
+ if (!location.endsWith(".svg")){
+ return null;
+ }
+ URI svgURI=URI.createURI(location);
+ String parser = org.apache.batik.util.XMLResourceDescriptor.getXMLParserClassName();
+ SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
+
+ try {
+ Document doc = f.createDocument(svgURI.toString());
+ SVGOMDocument svgDocument=(SVGOMDocument)doc;
+ return svgDocument;
+
+ } catch (Exception e) {
+ org.eclipse.papyrus.infra.core.Activator.log.error(e);
+ }
+ return null;
+ }
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/GetSVGDocumentForViewOperation.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/GetSVGDocumentForViewOperation.java
new file mode 100644
index 00000000000..4f765742456
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/GetSVGDocumentForViewOperation.java
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Patrick Tessier (CEA LIST) - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.common.service.shape;
+
+import java.util.List;
+
+import org.apache.batik.dom.svg.SVGOMDocument;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.common.core.service.IProvider;
+
+/**
+ * Operation to find a list of shapes, given a view
+ */
+public class GetSVGDocumentForViewOperation implements IOperation, IShapeProviderOperation {
+
+ /** View from which shape has to be retrieved */
+ private final EObject view;
+
+ /**
+ * Creates a new GetShapeProvidersForViewOperation.
+ *
+ * @param view
+ * the EObject for which shapes has to be found
+ */
+ protected GetSVGDocumentForViewOperation(EObject view) {
+ assert null != view : "GetDocumentForViewOperation constructor received NULL as argument"; //$NON-NLS-1$
+ this.view = view;
+ }
+
+ /**
+ * @{inheritDoc
+ */
+ public List<SVGOMDocument> execute(IProvider provider) {
+ if(!(provider instanceof IShapeProvider)) {
+ return null;
+ }
+ IShapeProvider shapeProvider = (IShapeProvider)provider;
+ return shapeProvider.getSVGOMDocument(getView());
+ }
+
+ /**
+ * Returns the view for which this operation is looking for shapes
+ *
+ * @return the view for which this operation is looking for shapes
+ */
+ protected EObject getView() {
+ return view;
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/IShapeProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/IShapeProvider.java
index 2fa40ec9862..5682aea6537 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/IShapeProvider.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/IShapeProvider.java
@@ -15,6 +15,7 @@ package org.eclipse.papyrus.infra.gmfdiag.common.service.shape;
import java.util.List;
+import org.apache.batik.dom.svg.SVGOMDocument;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.service.IProvider;
@@ -50,6 +51,15 @@ public interface IShapeProvider extends IProvider {
* @return the list of shapes or <code>null</code> if no shapes have to be displayed by this provider
*/
List<RenderedImage> getShapes(EObject view);
+
+ /**
+ * Returns the list of SVG Documents proposed by this provider
+ *
+ * @param view
+ * the view for which shapes are looked for
+ * @return the list of SVG DOCUMENT or <code>null</code> if no shapes have to be displayed by this provider
+ */
+ List<SVGOMDocument> getSVGOMDocument(EObject view);
/**
* Returns <code>true</code> if the provider can display shapes.
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/ShapeService.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/ShapeService.java
index 87ef079545b..cd2f7a6a718 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/ShapeService.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/ShapeService.java
@@ -17,6 +17,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.apache.batik.dom.svg.SVGOMDocument;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.emf.ecore.EObject;
@@ -74,6 +75,26 @@ public class ShapeService extends org.eclipse.gmf.runtime.common.core.service.Se
}
return images;
}
+
+
+ /**
+ * Returns the shape to be displayed
+ *
+ * @param view
+ * the EObject for which the shape is computed
+ * @return the shape to be displayed
+ */
+ public List<SVGOMDocument> getSVGDocumentToDisplay(EObject view) {
+ @SuppressWarnings("unchecked")
+ List<List<SVGOMDocument>> listOfListOfImages = (List<List<SVGOMDocument>>)execute(ExecutionStrategy.REVERSE, new GetSVGDocumentForViewOperation(view));
+ List<SVGOMDocument> images = new ArrayList<SVGOMDocument>();
+ for(List<SVGOMDocument> listOfImages : listOfListOfImages) {
+ if(listOfImages != null && !listOfImages.isEmpty()) {
+ images.addAll(listOfImages);
+ }
+ }
+ return images;
+ }
/**
* Ask all the shape providers to add their required notification listeners to the diagram event broker.
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementEditPart.java
index 6e2c6550ea0..4aae792ba0a 100644
--- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementEditPart.java
+++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementEditPart.java
@@ -93,6 +93,7 @@ public abstract class AbstractElementEditPart extends NamedElementEditPart {
protected abstract IFigure getContentPaneFor(IGraphicalEditPart editPart);
+
protected NodeFigure createNodePlate() {
String prefElementId = getNotationView().getType();
IPreferenceStore store = Activator.getInstance().getPreferenceStore();
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/edit/part/CShapeNamedElementEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/edit/part/CShapeNamedElementEditPart.java
index 41a070b47c0..7d130955f30 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/edit/part/CShapeNamedElementEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/edit/part/CShapeNamedElementEditPart.java
@@ -21,11 +21,11 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper;
import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ShapeNamedElementEditPart;
import org.eclipse.papyrus.uml.diagram.clazz.part.UMLDiagramEditorPlugin;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.SVGNodePlateFigure;
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
import org.eclipse.uml2.uml.Stereotype;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractCommentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractCommentEditPart.java
index d2a8aba4197..fb16d998b14 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractCommentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractCommentEditPart.java
@@ -29,7 +29,7 @@ import org.eclipse.swt.graphics.Color;
/**
* this is a abstract editpart to display a comment
*/
-public class AbstractCommentEditPart extends NodeEditPart {
+public abstract class AbstractCommentEditPart extends NodeEditPart {
public AbstractCommentEditPart(View view) {
super(view);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractConstraintEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractConstraintEditPart.java
index 726b3ed4c6f..17305bcfeb0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractConstraintEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractConstraintEditPart.java
@@ -26,7 +26,7 @@ import org.eclipse.swt.graphics.Font;
* this is an abstract editpart to manage a constraint
*
*/
-public class AbstractConstraintEditPart extends NamedElementEditPart {
+public abstract class AbstractConstraintEditPart extends NamedElementEditPart {
protected static final String CONSTRAINT_VALUE_SPECIFICATION_LISTENER = "Constraint_valueSpecification_Listener";
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/NamedElementEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/NamedElementEditPart.java
index 0e1e1937a78..da27e7e362c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/NamedElementEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/NamedElementEditPart.java
@@ -13,12 +13,19 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.editparts;
+import org.apache.batik.dom.svg.SVGOMDocument;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.StackLayout;
import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gmf.runtime.diagram.ui.figures.BorderedNodeFigure;
+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.BooleanValueStyle;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.FollowSVGSymbolEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.NameDisplayEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.shape.ShapeService;
import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeNamedElementFigure;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
@@ -31,6 +38,8 @@ import org.eclipse.uml2.uml.NamedElement;
*/
public abstract class NamedElementEditPart extends UMLNodeEditPart implements IUMLNamedElementEditPart {
+
+
/**
* {@inheritDoc}
*/
@@ -68,6 +77,7 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
refreshIconNamedLabel();
refreshFontColor();
refreshLabelDisplay();
+ refreshSVGPath();
}
}
@@ -87,6 +97,8 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
}
}
+
+
/**
* A method to specify the labels to be update when the font is refreshed.
* Subclasses should call super.refreshLabelsFont(font)
@@ -134,6 +146,13 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy(NameDisplayEditPolicy.NAME_DISPLAY_EDITPOLICY, new NameDisplayEditPolicy());
+ installEditPolicy(FollowSVGSymbolEditPolicy.FOLLOW_SVG_SYMBOL_EDITPOLICY, new FollowSVGSymbolEditPolicy());
+ }
+
+ protected NodeFigure createNodeFigure() {
+ return new BorderedNodeFigure(createMainFigureWithSVG());
}
-}
+
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/PackageNodePlateFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/PackageNodePlateFigure.java
index 1bcde8b27df..2c2064a5415 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/PackageNodePlateFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/PackageNodePlateFigure.java
@@ -17,6 +17,8 @@ import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.ICustomNodePlate;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure;
/**
* this figure is used to display at the good positionn acnhor on the
@@ -25,8 +27,9 @@ import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
* @author PT202707
*
*/
-public class PackageNodePlateFigure extends DefaultSizeNodeFigure {
+public class PackageNodePlateFigure extends DefaultSizeNodeFigure implements ICustomNodePlate{
+ protected SVGNodePlateFigure svgNodePlateFigure=null;
// @unused
public PackageNodePlateFigure(Dimension defSize) {
super(defSize);
@@ -48,9 +51,14 @@ public class PackageNodePlateFigure extends DefaultSizeNodeFigure {
return (PackageFigure)getChildren().get(0);
}
+ if(svgNodePlateFigure!=null &&svgNodePlateFigure.getChildren().size() > 0 && svgNodePlateFigure.getChildren().get(0) instanceof PackageFigure) {
+ return (PackageFigure)svgNodePlateFigure.getChildren().get(0);
+
+ }
return null;
}
+
// This returns as the anchoring area only the central line
@Override
public PointList getPolygonPoints() {
@@ -76,4 +84,24 @@ public class PackageNodePlateFigure extends DefaultSizeNodeFigure {
return points;
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.ICustomNodePlate#setSVGNodePlateContainer(org.eclipse.papyrus.uml.diagram.common.figure.node.SVGNodePlateFigure)
+ *
+ * @param svgNodePlateFigure
+ */
+ public void setSVGNodePlateContainer(SVGNodePlateFigure svgNodePlateFigure) {
+ this.svgNodePlateFigure=svgNodePlateFigure;
+
+ }
+/**
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.node.ICustomNodePlate#getSvgNodePlateContainer()
+ *
+ * @return
+ */
+ public SVGNodePlateFigure getSvgNodePlateContainer() {
+ return this.svgNodePlateFigure;
+ }
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/META-INF/MANIFEST.MF
index a962ea7c9bd..7f6d6c17d59 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/META-INF/MANIFEST.MF
@@ -16,7 +16,13 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.core.log;bundle-version="0.10.1",
org.eclipse.papyrus.uml.diagram.common;bundle-version="0.10.1",
org.eclipse.papyrus.uml.appearance;bundle-version="0.10.1",
- org.eclipse.papyrus.infra.emf;bundle-version="0.10.1"
+ org.eclipse.papyrus.infra.emf;bundle-version="0.10.1",
+ org.apache.batik.dom.svg,
+ org.apache.batik.util,
+ org.apache.batik.svggen,
+ org.apache.batik.dom,
+ org.w3c.dom.svg,
+ org.apache.batik.css
Export-Package: org.eclipse.papyrus.uml.diagram.symbols,
org.eclipse.papyrus.uml.diagram.symbols.provider
Bundle-Vendor: %Bundle-Vendor
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/ActorShapeProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/ActorShapeProvider.java
index aa462ad6907..0bef48763c5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/ActorShapeProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/ActorShapeProvider.java
@@ -18,6 +18,7 @@ import java.net.URL;
import java.util.Arrays;
import java.util.List;
+import org.apache.batik.dom.svg.SVGOMDocument;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
@@ -146,4 +147,16 @@ public class ActorShapeProvider extends AbstractShapeProvider {
}
}
+ public List<SVGOMDocument> getSVGOMDocument(EObject view) {
+ if(providesShapes(view)) {
+ String path ="platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/symbols/actor.svg"; //$NON-NLS-1$
+ SVGOMDocument document=getSVGDocument(path);
+ if(document==null){
+ return null;
+ }
+ return Arrays.asList(getSVGDocument(path));
+ }
+ return null;
+ }
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/StereotypedElementShapeProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/StereotypedElementShapeProvider.java
index ea602281c0b..938e421d447 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/StereotypedElementShapeProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/StereotypedElementShapeProvider.java
@@ -6,7 +6,10 @@ import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
+import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
+import org.apache.batik.dom.svg.SVGOMDocument;
import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EcorePackage;
@@ -23,6 +26,7 @@ import org.eclipse.papyrus.uml.diagram.symbols.Activator;
import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
+import org.w3c.dom.Document;
/**
* This provider is linked to the {@link ShapeService}. It returns the shapes for a given element corresponding to the stereotypes applied on the
@@ -96,6 +100,35 @@ public class StereotypedElementShapeProvider extends AbstractShapeProvider {
return false;
}
+ public List<SVGOMDocument> getSVGOMDocument(EObject view) {
+ if(!(view instanceof View)) {
+ return null;
+ }
+ EObject element = ((View)view).getElement();
+ if(element instanceof Element) {
+ List<SVGOMDocument> images = new ArrayList<SVGOMDocument>();
+ // it has already been checked that
+ String stereotypesToDisplay = AppliedStereotypeHelper.getStereotypesToDisplay((View)view);
+ StringTokenizer tokenizer = new StringTokenizer(stereotypesToDisplay, ",");
+ while(tokenizer.hasMoreTokens()) {
+ String stereotypeName = tokenizer.nextToken();
+ Stereotype stereotype = ((Element)element).getAppliedStereotype(stereotypeName);
+ org.eclipse.uml2.uml.Image icon = ElementUtil.getStereotypeImage(((Element)element), stereotype, SHAPE_CONSTANT);
+ if(icon != null) {
+ if(icon.getLocation() != "" && icon.getLocation() != null) {
+ SVGOMDocument document=getSVGDocument(icon.getLocation());
+ if(document!=null){
+ images.add(document);
+ }
+ }
+ }
+ }
+ return images;
+ }
+
+ return null;
+ }
+
/**
* {@inheritDoc}
*/
@@ -166,6 +199,8 @@ public class StereotypedElementShapeProvider extends AbstractShapeProvider {
}
}
}
+
+
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/TypedElementShapeProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/TypedElementShapeProvider.java
index b7b1cf67e41..6c9be478df0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/TypedElementShapeProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.symbols/src/org/eclipse/papyrus/uml/diagram/symbols/provider/TypedElementShapeProvider.java
@@ -16,9 +16,13 @@ package org.eclipse.papyrus.uml.diagram.symbols.provider;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.StringTokenizer;
+import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
+import org.apache.batik.dom.svg.SVGOMDocument;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
@@ -29,13 +33,17 @@ import org.eclipse.gmf.runtime.draw2d.ui.render.factory.RenderedImageFactory;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.service.shape.AbstractShapeProvider;
import org.eclipse.papyrus.infra.gmfdiag.common.service.shape.ProviderNotificationManager;
+import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
import org.eclipse.papyrus.uml.diagram.symbols.Activator;
import org.eclipse.papyrus.uml.diagram.symbols.IPapyrusInternalProfileConstants;
import org.eclipse.papyrus.uml.tools.listeners.PapyrusStereotypeListener.StereotypeCustomNotification;
+import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
+import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.TypedElement;
import org.eclipse.uml2.uml.UMLPackage;
+import org.w3c.dom.Document;
/**
* This provider is linked to the {@link ShapeService}. It returns the shapes for a given typed element corresponding to the stereotypes applied on
@@ -70,6 +78,34 @@ public class TypedElementShapeProvider extends AbstractShapeProvider {
return null;
}
+
+ public List<SVGOMDocument> getSVGOMDocument(EObject view) {
+ Type type = getType(view);
+ String path = getSymbolPath(type);
+ if(path != null && path.length() > 0) {
+ URL url;
+ try {
+ url = new URL(path);
+ SVGOMDocument document=getSVGDocument(path);
+ if(document!=null){
+ return Arrays.asList(document);
+ }
+ return Arrays.asList(getSVGDocument(path));
+ } catch (MalformedURLException e) {
+ URI typeResourceURI = type.eResource().getURI();
+ if(typeResourceURI != null) {
+ String workspaceRelativeFolderPath = typeResourceURI.trimSegments(1).toPlatformString(true);
+ String newPath = "platform:/resource/" + workspaceRelativeFolderPath + File.separatorChar + path;
+ SVGOMDocument document=getSVGDocument(newPath);
+ if(document!=null){
+ return Arrays.asList(document);
+ }
+ }
+ }
+ }
+ return null;
+ }
+
/**
* {@inheritDoc}
*/

Back to the top