Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml')
-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.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AbstractPackageableElementCompartmentEditPart.java18
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml47
-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.java53
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/BorderDisplayEditPolicy.java178
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java13
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ConstraintFigure.java52
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/CornerBentFigure.java9
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/IPapyrusNodeNamedElementFigure.java24
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java94
-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.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/QualifiedNameWrappingLabelFigure.java26
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/SVGNodePlateFigure.java175
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/CreateOrShowExistingElementHelper.java22
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/UMLModelTester.java120
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationBehaviorEditPart.java148
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BorderItemLabelEditPart.java612
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomBehaviorExecutionSpecificationEditPart.java342
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomViewProvider.java319
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/DisplayBehaviorContributionItem.java112
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/BehaviorDisplayHelper.java183
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/prop/Environment.xmi1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/prop/seq.ctx35
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/prop/ui/DisplayBehaviorSection.xwt11
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml4
-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
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/custom-src/org/eclipse/papyrus/uml/diagram/usecase/draw2d/StickMan.java66
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/META-INF/MANIFEST.MF6
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/uml/nattable/xtext/integration/Activator.java (renamed from plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/Activator.java)2
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/uml/nattable/xtext/integration/celleditor/AbstractNatTableXTextCellEditor.java (renamed from plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/celleditor/AbstractNatTableXTextCellEditor.java)7
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/uml/nattable/xtext/integration/util/XTextEditorResultWrapper.java (renamed from plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/util/XTextEditorResultWrapper.java)4
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ConnectorReorientCommand.java6
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ConnectorReorientSemanticCommand.java3
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/ClassifierUtils.java63
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/NamedElementHelper.java24
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ProfileApplicationEditor.java703
-rw-r--r--plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/META-INF/MANIFEST.MF4
-rw-r--r--plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/ui/Activator.java67
45 files changed, 2763 insertions, 923 deletions
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.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AbstractPackageableElementCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AbstractPackageableElementCompartmentEditPart.java
index e1376131860..55c60cf63ca 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AbstractPackageableElementCompartmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AbstractPackageableElementCompartmentEditPart.java
@@ -38,17 +38,21 @@ public abstract class AbstractPackageableElementCompartmentEditPart extends Shap
* @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart#getDragTracker(org.eclipse.gef.Request)
*
*/
+ @Override
public DragTracker getDragTracker(Request req) {
- if(!supportsDragSelection())
+ if(!supportsDragSelection()) {
return super.getDragTracker(req);
- if(req instanceof SelectionRequest && ((SelectionRequest)req).getLastButtonPressed() == 3)
+ }
+ if(req instanceof SelectionRequest && ((SelectionRequest)req).getLastButtonPressed() == 3) {
return new DeselectAllTracker(this) {
+ @Override
protected boolean handleButtonDown(int button) {
getCurrentViewer().select(AbstractPackageableElementCompartmentEditPart.this);
return true;
}
};
+ }
return new RubberbandDragTracker() {
/*
@@ -56,6 +60,7 @@ public abstract class AbstractPackageableElementCompartmentEditPart extends Shap
* on the compartment.
* hence it allows the navigation by double click
*/
+ @Override
protected boolean handleDoubleClick(int button) {
SelectionRequest request = new SelectionRequest();
request.setLocation(getLocation());
@@ -64,10 +69,17 @@ public abstract class AbstractPackageableElementCompartmentEditPart extends Shap
return true;
}
+ @Override
protected void handleFinished() {
- if(getViewer().getSelectedEditParts().isEmpty())
+ if(getViewer().getSelectedEditParts().isEmpty()) {
getViewer().select(AbstractPackageableElementCompartmentEditPart.this);
+ }
}
};
}
+
+ @Override
+ public boolean isSelectable() {
+ return false;
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF
index 40249ea5899..09dfaa19cb1 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF
@@ -92,7 +92,8 @@ Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="0.10.1",
org.w3c.dom.svg,
org.apache.batik.css,
org.apache.batik.util,
- org.apache.batik.dom
+ org.apache.batik.dom,
+ org.eclipse.core.databinding;bundle-version="1.4.1"
Bundle-Vendor: %providerName
Ant-Version: Apache Ant 1.7.0
Bundle-Version: 0.10.1.qualifier
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml
index 8e0a4c7141f..ada1123b5b3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml
@@ -249,6 +249,13 @@
properties="isUMLModel, isUMLProfile"
type="org.eclipse.jface.viewers.ISelection">
</propertyTester>
+ <propertyTester
+ class="org.eclipse.papyrus.uml.diagram.common.util.UMLModelTester"
+ id="org.eclipse.papyrus.UMLModelTester"
+ namespace="org.eclipse.papyrus.UMLModelTester"
+ properties="isUMLModel, isUMLProfile"
+ type="org.eclipse.ui.IWorkbenchPart">
+ </propertyTester>
</extension>
<!-- Reusable test definitions verifying:
@@ -259,33 +266,25 @@
point="org.eclipse.core.expressions.definitions">
<definition id="org.eclipse.papyrus.uml.diagram.common.IsPapyrusActiveWithUMLModel">
- <and>
-
- <with variable="activeEditorId">
- <equals value="org.eclipse.papyrus.infra.core.papyrusEditor"/>
- </with>
-
- <with variable="selection">
- <test property="org.eclipse.papyrus.UMLSelectionTester.isUMLModel" value="true"
- forcePluginActivation="true"/>
- </with>
-
- </and>
+ <with
+ variable="activePart">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.UMLModelTester.isUMLModel"
+ value="true">
+ </test>
+ </with>
</definition>
<definition id="org.eclipse.papyrus.uml.diagram.common.IsPapyrusActiveWithUMLProfile">
- <and>
-
- <with variable="activeEditorId">
- <equals value="org.eclipse.papyrus.infra.core.papyrusEditor"/>
- </with>
-
- <with variable="selection">
- <test property="org.eclipse.papyrus.UMLSelectionTester.isUMLProfile" value="true"
- forcePluginActivation="true"/>
- </with>
-
- </and>
+ <with
+ variable="activePart">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.UMLModelTester.isUMLProfile"
+ value="true">
+ </test>
+ </with>
</definition>
</extension>
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 017ce3129dc..b996fd81b34 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,10 +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.NameLabelIconHelper;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderDisplayEditPolicy;
+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;
@@ -29,6 +38,8 @@ import org.eclipse.uml2.uml.NamedElement;
*/
public abstract class NamedElementEditPart extends UMLNodeEditPart implements IUMLNamedElementEditPart {
+
+
/**
* {@inheritDoc}
*/
@@ -56,7 +67,7 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
}
private void refreshIconNamedLabel() {
- getNodeNamedElementFigure().setNameLabelIcon(NameLabelIconHelper.showLabelIcon((View)getModel()));
+ getNodeNamedElementFigure().setNameLabelIcon(AppearanceHelper.showElementIcon((View)getModel()));
}
@Override
@@ -65,10 +76,33 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
if(getNodeNamedElementFigure() != null && resolveSemanticElement() != null) {
refreshIconNamedLabel();
refreshFontColor();
+ refreshLabelDisplay();
+ refreshSVGPath();
}
+ }
+
+ @Override
+ public void activate() {
+ super.activate();
+ }
+
+ protected void refreshLabelDisplay() {
+ View view = getNotationView();
+ BooleanValueStyle displayNameStyle = (BooleanValueStyle)view.getNamedStyle(NotationPackage.eINSTANCE.getBooleanValueStyle(), NameDisplayEditPolicy.DISPLAY_NAME);
+ if(displayNameStyle != null && !displayNameStyle.isBooleanValue()) {
+ getNodeNamedElementFigure().removeNameLabel();
+ getNodeNamedElementFigure().removeStereotypeLabel();
+ getNodeNamedElementFigure().removeTaggedLabel();
+ } else {
+ getNodeNamedElementFigure().restoreNameLabel();
+ getNodeNamedElementFigure().restoreStereotypeLabel();
+ getNodeNamedElementFigure().restoreTaggedLabel();
+ }
}
+
+
/**
* A method to specify the labels to be update when the font is refreshed.
* Subclasses should call super.refreshLabelsFont(font)
@@ -111,11 +145,18 @@ public abstract class NamedElementEditPart extends UMLNodeEditPart implements IU
getNodeNamedElementFigure().getTaggedLabel().setForegroundColor(color);
}
}
+
@Override
protected void createDefaultEditPolicies() {
- // TODO Auto-generated method stub
super.createDefaultEditPolicies();
- installEditPolicy(BorderDisplayEditPolicy.BORDER_DISPLAY_EDITPOLICY, new BorderDisplayEditPolicy());
+ 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/editpolicies/BorderDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/BorderDisplayEditPolicy.java
deleted file mode 100644
index bf69f75dc6f..00000000000
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/BorderDisplayEditPolicy.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*****************************************************************************
- * 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.uml.diagram.common.editpolicies;
-
-import java.util.List;
-
-import org.eclipse.draw2d.LineBorder;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-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.core.listener.NotificationListener;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ResizableCompartmentEditPart;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.OneLineBorder;
-import org.eclipse.gmf.runtime.notation.BooleanValueStyle;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.core.listenerservice.IPapyrusListener;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.NodeNamedElementFigure;
-import org.eclipse.uml2.uml.NamedElement;
-
-/**
- * this edit policy has in charge to display tthe border of node NodeNamedElement
- * associated figure has to be a {@link NodeNamedElementFigure}
- */
-public class BorderDisplayEditPolicy extends GraphicalEditPolicy implements NotificationListener, IPapyrusListener {
-
- public static final String DISPLAY_BORDER = "BorderDisplay";
-
- /** key for this edit policy */
- public final static String BORDER_DISPLAY_EDITPOLICY = "BORDER_DISPLAY_EDITPOLICY";
-
- /** host semantic element */
- protected NamedElement hostSemanticNamedElement;
-
- /**
- * The parent listeners list
- */
- protected List<Object> parentListeners;
-
- /**
- * Creates a new QualifiedNameDisplayEditPolicy
- */
- public BorderDisplayEditPolicy() {
- 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;
- }
-
- // adds a listener on the view and the element controlled by the
- // editpart
- getDiagramEventBroker().addNotificationListener(view, this);
-
- if(hostSemanticNamedElement == null) {
- return;
- }
- getDiagramEventBroker().addNotificationListener(hostSemanticNamedElement, this);
-
- refreshBorder();
- }
-
- /**
- * refresh the qualified name
- */
- protected void refreshBorder() {
- if(getHost() instanceof NamedElementEditPart) {
- NamedElementEditPart namedElementEditPart=(NamedElementEditPart)getHost();
- BooleanValueStyle boderStyle=getBorderStyle(namedElementEditPart.getNotationView());
- if(boderStyle!=null && boderStyle.isBooleanValue()==false){
- namedElementEditPart.getPrimaryShape().setBorder(null);
- for(Object currentEditPart : namedElementEditPart.getChildren()) {
- if(currentEditPart instanceof ResizableCompartmentEditPart){
- ((ResizableCompartmentEditPart)currentEditPart).getFigure().setBorder(null);
- }
-
- }
-
- }
- else{
- namedElementEditPart.getPrimaryShape().setBorder(new LineBorder());
- for(Object currentEditPart : namedElementEditPart.getChildren()) {
- if(currentEditPart instanceof ResizableCompartmentEditPart){
- ((ResizableCompartmentEditPart)currentEditPart).getFigure().setBorder(new OneLineBorder());
- }
-
- }
- }
- }
- }
-
-/**
- *
- * @param currentView
- * @return the current Style that repersent the boder
- */
- protected BooleanValueStyle getBorderStyle(View currentView){
- List<?> viewStyle=currentView.getStyles();
- for(Object currentStyle : viewStyle) {
- if( currentStyle instanceof BooleanValueStyle){
- if(((BooleanValueStyle)currentStyle).getName().equals(DISPLAY_BORDER)){
- return (BooleanValueStyle)currentStyle;
- }
- }
- }
-
- return null;
-
- }
- /**
- *
- * {@inheritDoc}
- */
- public void deactivate() {
- // retrieve the view and the element managed by the edit part
- View view = (View)getHost().getModel();
- if(view == null) {
- return;
- }
- // remove notification on element and view
- getDiagramEventBroker().removeNotificationListener(view, this);
-
- }
-
-
- /**
- * 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;
- }
-
- /**
- *
- * {@inheritDoc}
- */
- public void notifyChanged(Notification notification) {
- refreshBorder();
- }
-
-
- /**
- * Remove all parents listeners
- */
- public void removeParentListeners() {
- for(Object listener : parentListeners) {
- getDiagramEventBroker().removeNotificationListener((EObject)listener, this);
- }
- }
-}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java
index 8df78015a9a..ed6ff56da83 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/AutomaticCompartmentLayoutManager.java
@@ -67,10 +67,11 @@ public class AutomaticCompartmentLayoutManager extends AbstractLayout {
int minimumHeight = 0;
if(container instanceof CompartmentFigure) {
// display name
- if(((CompartmentFigure)container).getNameLabel() != null) {
+ if(((CompartmentFigure)container).getNameLabel() != null&& container.getChildren().contains(((CompartmentFigure)container).getNameLabel())) {
if(((CompartmentFigure)container).getNameLabel().getPreferredSize().width > minimumWith) {
minimumWith = ((CompartmentFigure)container).getNameLabel().getPreferredSize().width;
}
+
}
}
if(compartmentList.size() != 0) {
@@ -216,8 +217,16 @@ public class AutomaticCompartmentLayoutManager extends AbstractLayout {
for(int i = 0; i < compartmentList.size(); i++) {
compartmentsHeight += compartmentList.get(i).getBounds().height;
+
}
int remainingspace = container.getBounds().height - notCompartmentsHeight;
+ //because of the place of the label we have to remove 3
+ remainingspace=remainingspace-3;
+ //because we move compartment of 1 pixel the space is decrease of 1
+ for(int i = 0; i < compartmentList.size(); i++) {
+ remainingspace=remainingspace-1;
+ }
+
// ratio between the height of all compartments and the size of the
// compartments container.
@@ -225,7 +234,7 @@ public class AutomaticCompartmentLayoutManager extends AbstractLayout {
for(int i = 0; i < compartmentList.size(); i++) {
Rectangle bound = new Rectangle((compartmentList.get(i)).getBounds());
- int value = (int)(bound.height / ratio);
+ int value = (int)((double)bound.height / ratio);
bound.height = value;
bound.x = container.getBounds().x;
if(i > 0) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ConstraintFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ConstraintFigure.java
index 09c2efa5f70..85add30cb94 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ConstraintFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/ConstraintFigure.java
@@ -30,7 +30,9 @@ import org.eclipse.swt.graphics.Image;
public class ConstraintFigure extends CornerBentFigure implements IPapyrusNodeNamedElementFigure, ILabelFigure, IMultilineEditableFigure {
private static final String CHEVRON = String.valueOf("\u00AB") + String.valueOf("\u00BB");
+
protected static final String LEFT_BRACE = "{";
+
private Label taggedLabel;
protected static final String RIGHT_BRACE = "}";
@@ -125,12 +127,13 @@ public class ConstraintFigure extends CornerBentFigure implements IPapyrusNodeNa
return null;
}
- public ConstraintFigure( ) {
+ public ConstraintFigure() {
this(null);
}
- public ConstraintFigure( String tagLabel) {
+
+ public ConstraintFigure(String tagLabel) {
super();
-
+
nameLabel = new WrappingLabel();
nameLabel.setOpaque(false);
@@ -175,6 +178,7 @@ public class ConstraintFigure extends CornerBentFigure implements IPapyrusNodeNa
this.add(taggedLabel, null, 0);
}
}
+
/**
*
* @see org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeNamedElementFigure#setDepth(int)
@@ -283,8 +287,7 @@ public class ConstraintFigure extends CornerBentFigure implements IPapyrusNodeNa
* @param icon
*/
public void setIcon(Image icon) {
- // TODO Auto-generated method stub
-
+ //Nothing
}
/**
@@ -294,7 +297,6 @@ public class ConstraintFigure extends CornerBentFigure implements IPapyrusNodeNa
* @return
*/
public Image getIcon() {
- // TODO Auto-generated method stub
return null;
}
@@ -304,8 +306,8 @@ public class ConstraintFigure extends CornerBentFigure implements IPapyrusNodeNa
*
*
*/
+ @Override
public Dimension getMinimumSize(int wHint, int hHint) {
- // TODO Auto-generated method stub
return new Dimension(20, 20);
}
@@ -318,4 +320,40 @@ public class ConstraintFigure extends CornerBentFigure implements IPapyrusNodeNa
return page.getLocation();
}
+ /**
+ * Create a label that contains the name of the element.
+ */
+ public void restoreNameLabel() {
+ // nameLabel.setOpaque(false);
+ // nameLabel.setAlignment(PositionConstants.MIDDLE);
+ // getNameLabelContainer().add(nameLabel, getNameLabelConstraint(), getNameLabelPosition());
+ }
+
+ public void removeNameLabel() {
+ // if(getNameLabelContainer().getChildren().contains(nameLabel)) {
+ // getNameLabelContainer().remove(nameLabel);
+ // }
+ }
+
+ public void removeStereotypeLabel() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void restoreStereotypeLabel() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void restoreTaggedLabel() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void removeTaggedLabel() {
+ // TODO Auto-generated method stub
+
+ }
+
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/CornerBentFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/CornerBentFigure.java
index 8482eb3de1f..f08fa696d1f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/CornerBentFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/CornerBentFigure.java
@@ -16,6 +16,7 @@ package org.eclipse.papyrus.uml.diagram.common.figure.node;
import java.util.StringTokenizer;
import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.RectangleFigure;
@@ -333,4 +334,12 @@ public class CornerBentFigure extends NoteFigure implements IPapyrusNodeUMLEleme
revalidate();
repaint();
}
+
+ @Override
+ protected void paintBorder(Graphics g) {
+ if(getBorder() == null) {
+ return;
+ }
+ super.paintBorder(g);
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/IPapyrusNodeNamedElementFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/IPapyrusNodeNamedElementFigure.java
index bfbdd12385b..cb3f9d036b4 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/IPapyrusNodeNamedElementFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/IPapyrusNodeNamedElementFigure.java
@@ -63,4 +63,28 @@ public interface IPapyrusNodeNamedElementFigure extends IPapyrusNodeUMLElementFi
public void setNameLabelIcon(boolean displayNameLabelIcon);
+ /**
+ * restore a label that represent the name of the element.
+ */
+ public void restoreNameLabel();
+
+ /** remove the label that represent the name**/
+ public void removeNameLabel();
+ /** remove the label that represent the stereotype**/
+ public void removeStereotypeLabel();
+ /**
+ * restore a label that represent the appliedStereotype of the element.
+ */
+ public void restoreStereotypeLabel();
+
+ /**
+ * restore a label that represent the tagged of the element.
+ */
+ public void restoreTaggedLabel();
+
+
+ /** remove the label that represent the tagged**/
+ public void removeTaggedLabel();
+
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java
index 451992b8944..f9c16e55e98 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java
@@ -28,10 +28,7 @@ import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PrecisionRectangle;
import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
-import org.eclipse.gmf.runtime.notation.BooleanValueStyle;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.ScalableCompartmentFigure;
import org.eclipse.papyrus.uml.appearance.helper.UMLVisualInformationPapyrusConstant;
import org.eclipse.papyrus.uml.diagram.common.figure.layout.PropertiesCompartmentLayoutManager;
import org.eclipse.swt.graphics.Color;
@@ -43,7 +40,8 @@ import org.eclipse.swt.graphics.Image;
*/
public class NodeNamedElementFigure extends PapyrusNodeFigure implements IPapyrusNodeNamedElementFigure, IPapyrusNodeUMLElementFigure {
- protected boolean noBorder=false;
+ protected boolean noBorder = false;
+
private static final String CHEVRON = String.valueOf("\u00AB") + String.valueOf("\u00BB");
private Label taggedLabel;
@@ -93,44 +91,45 @@ public class NodeNamedElementFigure extends PapyrusNodeFigure implements IPapyru
@Override
public void setBorder(Border border) {
- // TODO Auto-generated method stub
- if(border==null){
- noBorder=true;
- }
- else{noBorder=false;
+ if(border == null) {
+ noBorder = true;
+ } else {
+ noBorder = false;
}
super.setBorder(border);
}
+ @Override
protected Border getDefaultBorder(Color borderColor) {
- if( noBorder){
- return null;}
- else{return super.getDefaultBorder(borderColor);}
+ if(noBorder) {
+ return null;
+ } else {
+ return super.getDefaultBorder(borderColor);
+ }
}
@Override
public void remove(IFigure figure) {
- if(figure instanceof AppliedStereotypeCompartmentFigure){
+ if(figure instanceof AppliedStereotypeCompartmentFigure) {
if(stereotypePropertiesContent == null) {
this.createStereotypePropertiesContent();
}
stereotypePropertiesContent.remove(figure);
- }
- else{
+ } else {
super.remove(figure);
}
}
+
@Override
public void add(IFigure figure, Object constraint, int index) {
- if(figure instanceof AppliedStereotypeCompartmentFigure){
+ if(figure instanceof AppliedStereotypeCompartmentFigure) {
if(stereotypePropertiesContent == null) {
this.createStereotypePropertiesContent();
}
stereotypePropertiesContent.add(figure);
- }
- else{
+ } else {
super.add(figure, constraint, index);
}
@@ -169,14 +168,61 @@ public class NodeNamedElementFigure extends PapyrusNodeFigure implements IPapyru
getNameLabelContainer().add(nameLabel, getNameLabelConstraint(), -1);
}
+ public void restoreNameLabel() {
+ nameLabel.setOpaque(false);
+ nameLabel.setAlignment(PositionConstants.MIDDLE);
+ getNameLabelContainer().add(nameLabel, getNameLabelConstraint(), getNameLabelPosition());
+ }
+
+
/**
* Create a label that contains the name of the element.
*/
public void removeNameLabel() {
- if(getNameLabelContainer().getChildren().contains(nameLabel)){
- getNameLabelContainer().remove(nameLabel);}
+ if(getNameLabelContainer().getChildren().contains(nameLabel)) {
+ getNameLabelContainer().remove(nameLabel);
+ }
+ }
+
+
+ public void restoreStereotypeLabel() {
+ if(stereotypesLabel!=null){
+ stereotypesLabel.setOpaque(false);
+ getStereotypeLabelContainer().add(stereotypesLabel, getStereotypeLabelConstraint(), getStereotypePropertiesLabelPosition());
+ }
}
+
+ /**
+ * Create a label that contains the stereotype of the element.
+ */
+ public void removeStereotypeLabel() {
+ if(stereotypesLabel!=null){
+ if(getStereotypeLabelContainer().getChildren().contains(stereotypesLabel)) {
+ getStereotypeLabelContainer().remove(stereotypesLabel);
+ }
+ }
+ }
+
+
+ public void restoreTaggedLabel() {
+ if(taggedLabel!=null){
+ taggedLabel.setOpaque(false);
+ getTagLabelContainer().add(taggedLabel, getTagLabelConstraint(), 0);
+ }
+ }
+
+
+ /**
+ * Create a label that contains the stereotype of the element.
+ */
+ public void removeTaggedLabel() {
+ if(taggedLabel!=null){
+ if(getTagLabelContainer().getChildren().contains(taggedLabel)) {
+ getTagLabelContainer().remove(taggedLabel);
+ }
+ }
+ }
/**
* Get the constraint for adding the name label. Children should override
* and implement this method in case the label must be drawn with a specific
@@ -531,10 +577,10 @@ public class NodeNamedElementFigure extends PapyrusNodeFigure implements IPapyru
}
public Dimension getMinimumDimension() {
- int width =0;
- int height =0;
+ int width = 0;
+ int height = 0;
int temporysize = 0;
- if( getNameLabelContainer().getChildren().contains(getNameLabel())){
+ if(getNameLabelContainer().getChildren().contains(getNameLabel())) {
width = getNameLabel().getTextBounds().width + 10;
height = getNameLabel().getTextBounds().height + 10;
}
@@ -654,6 +700,8 @@ public class NodeNamedElementFigure extends PapyrusNodeFigure implements IPapyru
}
+
+
/**
* Returns the position of the stereotype properties location. this is just
* after stereotype position
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.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/QualifiedNameWrappingLabelFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/QualifiedNameWrappingLabelFigure.java
index 90b0fa9bedc..8ec6970504a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/QualifiedNameWrappingLabelFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/QualifiedNameWrappingLabelFigure.java
@@ -102,5 +102,31 @@ public class QualifiedNameWrappingLabelFigure extends PapyrusWrappingLabel imple
public void setStereotypeDisplay(String stereotypes, Image image) {}
public void setNameLabelIcon(boolean displayNameLabelIcon) {}
public WrappingLabel getNameLabel() {return null;}
+
+
+ public void restoreNameLabel() {
+ // TODO Auto-generated method stub
+
+ }
+ public void removeNameLabel() {
+ // TODO Auto-generated method stub
+
+ }
+ public void removeStereotypeLabel() {
+ // TODO Auto-generated method stub
+
+ }
+ public void restoreStereotypeLabel() {
+ // TODO Auto-generated method stub
+
+ }
+ public void restoreTaggedLabel() {
+ // TODO Auto-generated method stub
+
+ }
+ public void removeTaggedLabel() {
+ // TODO Auto-generated method stub
+
+ }
}
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/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/SVGNodePlateFigure.java
deleted file mode 100644
index 107fd4144ce..00000000000
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/SVGNodePlateFigure.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*****************************************************************************
- * 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.uml.diagram.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.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.w3c.dom.Element;
-import org.w3c.dom.svg.SVGAnimatedLength;
-import org.w3c.dom.svg.SVGDocument;
-import org.w3c.dom.svg.SVGLength;
-import org.w3c.dom.svg.SVGPathSeg;
-import org.w3c.dom.svg.SVGPathSegList;
-import org.w3c.dom.svg.SVGSVGElement;
-
-/**
- * this figure is used to make links following SVG shape
- *
- *
- */
-public class SVGNodePlateFigure extends DefaultSizeNodeFigure {
-
- protected SVGPathSegList pathSegList=null;
- protected SVGDocument svgDocument=null;
-
-
- /**
- * associate the SVG document that represent the SVG
- * @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);
- }
- }
-
- /**
- *
- * Constructor.
- *
- * @param width
- * @param height
- */
- public SVGNodePlateFigure(int width, int height) {
- super(width, height);
- }
- /**
- * set the papyrus path to follow the shape
- * @param pathSegList
- */
-
- public void setSegemntList(SVGPathSegList pathSegList ){
- this.pathSegList= pathSegList;
- }
-
- // This returns as the anchoring area only the central line
- @Override
- public PointList getPolygonPoints() {
- if (this.pathSegList==null){
- return super.getPolygonPoints();
- }
- double svgWidth=0;
- double svgHeight=0;
- SVGSVGElement svgElement=svgDocument.getRootElement();
- if(svgElement!=null ){
- SVGAnimatedLength widthALength=svgElement.getWidth();
- SVGAnimatedLength heightALength=svgElement.getHeight();
- if( widthALength!=null &&heightALength!=null){
- 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();
- // }
- }
- }
- }
-
- //transform coordinate to absolute in the context of the SVG
- //getBounds
- ArrayList<PrecisionPoint> pointList=new ArrayList<PrecisionPoint>();
-
- //current absolute coordinates
- float currentAbsoluteSVGPositionX=0;
- float currentAbsoluteSVGPositionY=0;
- for (int i=0; i<pathSegList.getNumberOfItems();i++){
- SVGPathSeg seg=pathSegList.getItem(i);
- if( seg instanceof SVGPathSegMovetoLinetoItem){
- SVGPathSegMovetoLinetoItem linetoItem=(SVGPathSegMovetoLinetoItem) seg;
- //short value =linetoItem.getPathSegType();
- 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);
- if( letter.equals("M")){
- currentAbsoluteSVGPositionX=x;
- currentAbsoluteSVGPositionY=y;
- pointList.add(new PrecisionPoint(currentAbsoluteSVGPositionX,currentAbsoluteSVGPositionY));
- }
- else if( letter.equals("m")){
- currentAbsoluteSVGPositionX=currentAbsoluteSVGPositionX+x;
- currentAbsoluteSVGPositionY=currentAbsoluteSVGPositionY+y;
- pointList.add(new PrecisionPoint(currentAbsoluteSVGPositionX,currentAbsoluteSVGPositionY));
- }
- else if( letter.equals("L")){
- currentAbsoluteSVGPositionX=x;
- currentAbsoluteSVGPositionY=y;
- pointList.add(new PrecisionPoint(currentAbsoluteSVGPositionX,currentAbsoluteSVGPositionY));
- }
- else if( letter.equals("l")){
- currentAbsoluteSVGPositionX=currentAbsoluteSVGPositionX+x;
- currentAbsoluteSVGPositionY=currentAbsoluteSVGPositionY+y;
- pointList.add(new PrecisionPoint(currentAbsoluteSVGPositionX,currentAbsoluteSVGPositionY));
- }
- }else
- {
- System.err.println("this is not i linear segment "+i);
- }
- }
-
-
- //get the original size of SVG
- double maxWitdh=0;
- double maxHeight=0;
- if(svgWidth!=0 && svgHeight!=0){
- maxWitdh= (double)svgWidth;
- maxHeight= (double)svgHeight;
- }
- else{
- for (int i=0; i<pointList.size();i++){
- PrecisionPoint point=pointList.get(i);
- if(point.preciseX()>maxWitdh){maxWitdh=point.preciseX();}
- if(point.preciseY()>maxHeight){maxHeight=point.preciseY();}
- }
- }
- //System.out.println("Size of the SVG figure is= "+maxHeight +" "+maxHeight);
- PointList points = new PointList(5);
- Rectangle anchorableRectangle = getHandleBounds();
-
- double ratioX=anchorableRectangle.width/maxWitdh;
- double ratioY=anchorableRectangle.height/maxHeight;
- //PackageFigure packageFigure = getPackageFigure();
- //System.out.println("Begin-------------" );
-
- for (int i=0; i<pointList.size();i++){
- PrecisionPoint point=pointList.get(i);
- double x= point.preciseX()*ratioX;
- double y=point.preciseY()*ratioY;
- points.addPoint(anchorableRectangle.x +(int)x, anchorableRectangle.y+(int)y);
- //System.out.println("add point x="+x +" y=" +y +" ratioX= "+ratioX+" ratioY="+ratioY );
- }
- //System.out.println("End-------------" );
- return points;
- }
-}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/CreateOrShowExistingElementHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/CreateOrShowExistingElementHelper.java
index 8dc3740b269..8c5c36871af 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/CreateOrShowExistingElementHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/CreateOrShowExistingElementHelper.java
@@ -53,7 +53,7 @@ public class CreateOrShowExistingElementHelper {
/**
* the link helper to use. Will be used in the future
*/
- private ILinkMappingHelper linkMappingHelper;
+ protected final ILinkMappingHelper linkMappingHelper;
/**
* preferences used to know if the dialog must be displayed or not
@@ -103,7 +103,7 @@ public class CreateOrShowExistingElementHelper {
if(showDialogAccordingPreferences() && defaultCommand.canExecute()) {
final EObject container = req.getContainer();
if(container instanceof Element) {
- final List<EdgeEndsMapper> existingElements = getExistingLinksBetweenSourceAndTarget((Element)req.getContainer(), req.getSource(), req.getTarget(), linkElementType);
+ final List<EdgeEndsMapper> existingElements = getExistingLinksBetweenSourceAndTarget(req, linkElementType);
if(existingElements.size() > 0) {
final String className = getIElementTypeNameToDisplay(linkElementType);
final String dialogTitle = NLS.bind(Messages.CreateOrShowExistingElementHelper_CreateOrRestoreX, className);
@@ -158,25 +158,19 @@ public class CreateOrShowExistingElementHelper {
/**
*
- * @param container
- * the container
- * @param source
- * @param target
+ * @param request
+ * the request to create the element
* @param wantedEClass
* @return
- * a list of {@link EdgeEndsMapper} referencing the exising links between the source and the target
+ * a list of {@link EdgeEndsMapper} referencing the existing links between the source and the target
*/
- protected List<EdgeEndsMapper> getExistingLinksBetweenSourceAndTarget(final Element container, final EObject source, final EObject target, final IElementType wantedElementType) {
+ protected List<EdgeEndsMapper> getExistingLinksBetweenSourceAndTarget(final CreateRelationshipRequest request, final IElementType wantedElementType) {
final List<EdgeEndsMapper> existingElement = new ArrayList<EdgeEndsMapper>();
- for(final Element current : container.getOwnedElements()) {
+ for(final Element current : ((Element)request.getContainer()).getOwnedElements()) {
if(hasWantedType(current, wantedElementType)) {
- if(target != null) {
- int i = 0;
- i++;
- }
final Collection<?> sources = this.linkMappingHelper.getSource(current);
final Collection<?> targets = this.linkMappingHelper.getTarget(current);
- if(sources.contains(source) && targets.contains(target)) {
+ if(sources.contains(request.getSource()) && targets.contains(request.getTarget())) {
final EClass wantedEClass = wantedElementType.getEClass();
if((wantedEClass == UMLPackage.eINSTANCE.getConnector()) || (wantedEClass == UMLPackage.eINSTANCE.getAssociation())) {
existingElement.add(new EdgeEndsMapper(current, sources, null, null));
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/UMLModelTester.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/UMLModelTester.java
new file mode 100644
index 00000000000..c539f1c4d93
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/UMLModelTester.java
@@ -0,0 +1,120 @@
+/*****************************************************************************
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.common.util;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.resource.NotFoundException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.uml.tools.model.UmlModel;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+
+/**
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class UMLModelTester extends PropertyTester {
+
+ /** Tester ID for UML Model nature */
+ public final static String IS_UML_MODEL = "isUMLModel";
+
+ /** Tester ID for UML Profile nature */
+ public final static String IS_UML_PROFILE = "isUMLProfile";
+
+ /** Test the receiver against the selected property */
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ Object currentValue = null;
+ if(IS_UML_MODEL.equals(property)) {
+ currentValue = testUMLModelNature(receiver);
+ return (currentValue == expectedValue);
+ } else if(IS_UML_PROFILE.equals(property)) {
+ currentValue = testUMLProfileNature(receiver);
+ return (currentValue == expectedValue);
+ }
+
+ return false;
+ }
+
+ /** True if root object is a UML Model */
+ protected boolean testUMLModelNature(Object receiver) {
+ EObject root = getRoot(receiver);
+
+ /*
+ * For controlled resources, it is very important to consider root of UML model can be a Package. Of course, we
+ * can still exclude Profile, which should be dedicated to profile diagrams.
+ */
+ return root instanceof Package && !(root instanceof Profile);
+ }
+
+ /** True if root object is a UML Profile */
+ protected boolean testUMLProfileNature(Object receiver) {
+ return (getRoot(receiver) instanceof Profile);
+ }
+
+ private EObject getRoot(Object receiver) {
+ ModelSet modelSet = getModelSet(receiver);
+ return getRoot(modelSet);
+ }
+
+ private ModelSet getModelSet(Object receiver) {
+ if(receiver instanceof IWorkbenchPart) {
+ try {
+
+ /* First, retrieve the ModelSet from the Active Part (e.g. ActiveEditor, ModelExplorer, ...) */
+ IWorkbenchPart currentPart = (IWorkbenchPart)receiver;
+ ServicesRegistry servicesRegistry = (ServicesRegistry)currentPart.getAdapter(ServicesRegistry.class);
+
+ if(servicesRegistry != null) {
+ return ServiceUtils.getInstance().getModelSet(servicesRegistry);
+ }
+
+ /* If not found, retrieve the ModelSet from the Active Editor */
+
+ IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ servicesRegistry = (ServicesRegistry)activeEditor.getAdapter(ServicesRegistry.class);
+
+ if(servicesRegistry != null) {
+ return ServiceUtils.getInstance().getModelSet(servicesRegistry);
+ }
+
+ } catch (Exception ex) {
+ return null; //NPE (getActiveEditor) or ServiceException (Service registry cannot be found). In both cases, we just don't handle the event. Fail silently.
+ }
+ }
+
+ return null;
+ }
+
+ /** Returns the root EObject of currently opened model */
+ private EObject getRoot(ModelSet modelSet) {
+ UmlModel openedModel = (UmlModel)modelSet.getModel(UmlModel.MODEL_ID);
+ if(openedModel != null) {
+ EObject root;
+ try {
+ root = openedModel.lookupRoot();
+ } catch (NotFoundException e) {
+ return null;
+ }
+ return root;
+ }
+
+ return null;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationBehaviorEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationBehaviorEditPart.java
new file mode 100644
index 00000000000..e719a6342f8
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationBehaviorEditPart.java
@@ -0,0 +1,148 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA
+ *
+ *
+ * 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:
+ * Soyatec - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.GroupRequest;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.VisibilityComponentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGEFCommandWrapper;
+import org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser;
+import org.eclipse.papyrus.uml.diagram.sequence.util.BehaviorDisplayHelper;
+import org.eclipse.uml2.uml.BehaviorExecutionSpecification;
+import org.eclipse.uml2.uml.OpaqueBehavior;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Add new Label EditPart for display behavior of an
+ * BehaviorExecutionSpecification.
+ *
+ * @author Jin Liu (jin.liu@soyatec.com)
+ */
+public class BehaviorExecutionSpecificationBehaviorEditPart extends
+ BorderItemLabelEditPart {
+
+ public static final String BEHAVIOR_TYPE = "BehaviorExecutionSpecification_Behavior";
+ static {
+ registerSnapBackPosition(BEHAVIOR_TYPE, new Point(16, 16));
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param view
+ */
+ public BehaviorExecutionSpecificationBehaviorEditPart(View view) {
+ super(view);
+ }
+
+ @Override
+ protected EObject getParserElement() {
+ EObject parserElement = super.getParserElement();
+ if (parserElement instanceof BehaviorExecutionSpecification) {
+ return ((BehaviorExecutionSpecification) parserElement)
+ .getBehavior();
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BorderItemLabelEditPart#createFigurePrim()
+ *
+ * @return
+ */
+
+ @Override
+ protected IFigure createFigurePrim() {
+ WrappingLabel label = new WrappingLabel();
+ label.setTextWrap(true);
+ return label;
+ }
+
+ @Override
+ protected boolean isEditable() {
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BorderItemLabelEditPart#createParser()
+ *
+ * @return
+ */
+ @Override
+ protected IParser createParser() {
+ return new MessageFormatParser(
+ new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }) {
+
+ @Override
+ public String getPrintString(IAdaptable adapter, int flags) {
+ String printString = super.getPrintString(adapter, flags);
+ EObject obj = (EObject) adapter.getAdapter(EObject.class);
+ if (obj instanceof OpaqueBehavior) {
+ OpaqueBehavior opaque = (OpaqueBehavior) obj;
+ if (opaque.isSetLanguages()) {
+ StringBuffer buf = new StringBuffer(printString);
+ buf.append("{");
+ EList<String> languages = opaque.getLanguages();
+ EList<String> bodies = opaque.getBodies();
+ for (int i = 0; i < languages.size(); i++) {
+ if (i != 0) {
+ buf.append(", ");
+ }
+ buf.append("{");
+ buf.append(languages.get(i));
+ buf.append("}");
+ if (i < bodies.size()) {
+ String body = bodies.get(i);
+ if (body != null) {
+ buf.append(body);
+ }
+ }
+ }
+ buf.append("}");
+ return new String(buf);
+ }
+ }
+ return printString;
+ }
+ };
+ }
+
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ removeEditPolicy(EditPolicy.COMPONENT_ROLE);
+ installEditPolicy(EditPolicy.COMPONENT_ROLE,
+ new VisibilityComponentEditPolicy() {
+ @Override
+ protected Command createDeleteViewCommand(
+ GroupRequest deleteRequest) {
+ org.eclipse.emf.common.command.Command cmd = BehaviorDisplayHelper
+ .getChangeDisplayBehaviorCommand(
+ getEditingDomain(), getPrimaryView(),
+ false);
+ return new EMFtoGEFCommandWrapper(cmd);
+ }
+ });
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BorderItemLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BorderItemLabelEditPart.java
new file mode 100644
index 00000000000..b81d47bceb0
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BorderItemLabelEditPart.java
@@ -0,0 +1,612 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA
+ *
+ *
+ * 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:
+ * Soyatec - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionLocator;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.handles.MoveHandle;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
+import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
+import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog;
+import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
+import org.eclipse.papyrus.uml.diagram.sequence.Activator;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLTextSelectionEditPolicy;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Feature;
+
+
+/**
+ * Abstract LabelEditPart which should be located around of BorderedNodeFigure.
+ *
+ * @author Jin Liu (jin.liu@soyatec.com)
+ */
+public abstract class BorderItemLabelEditPart extends LabelEditPart implements ITextAwareEditPart, IBorderItemEditPart {
+
+ private DirectEditManager manager;
+
+ private IParser parser;
+
+ private List<?> parserElements;
+
+ private String defaultText;
+
+ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
+
+ protected IDirectEditorConfiguration configuration;
+
+ /**
+ * Constructor.
+ *
+ * @param view
+ */
+ public BorderItemLabelEditPart(View view) {
+ super(view);
+ }
+
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new BorderItemSelectionEditPolicy() {
+
+ protected List createSelectionHandles() {
+ MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost());
+ mh.setBorder(null);
+ return Collections.singletonList(mh);
+ }
+ });
+ }
+
+ public IBorderItemLocator getBorderItemLocator() {
+ IFigure parentFigure = getFigure().getParent();
+ if(parentFigure != null && parentFigure.getLayoutManager() != null) {
+ Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure());
+ return (IBorderItemLocator)constraint;
+ }
+ return null;
+ }
+
+ public void refreshBounds() {
+ Point location = getLocation();
+ if(location == null) {
+ location = new Point();
+ }
+ Dimension size = getSize();
+ if(size == null) {
+ size = new Dimension();
+ }
+ IBorderItemLocator borderItemLocator = getBorderItemLocator();
+ if(borderItemLocator != null) {
+ borderItemLocator.setConstraint(new Rectangle(location, size));
+ }
+ }
+
+ protected Point getLocation() {
+ Point point = new Point();
+ point.x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ point.y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ return point;
+ }
+
+ protected Dimension getSize() {
+ Dimension size = new Dimension();
+ size.width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ size.height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ return size;
+ }
+
+ public int getKeyPoint() {
+ return ConnectionLocator.MIDDLE;
+ }
+
+ protected String getLabelTextHelper(IFigure figure) {
+ if(figure instanceof WrappingLabel) {
+ return ((WrappingLabel)figure).getText();
+ } else if(figure instanceof ILabelFigure) {
+ return ((ILabelFigure)figure).getText();
+ } else {
+ return ((Label)figure).getText();
+ }
+ }
+
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if(figure instanceof WrappingLabel) {
+ ((WrappingLabel)figure).setText(text);
+ } else if(figure instanceof ILabelFigure) {
+ ((ILabelFigure)figure).setText(text);
+ } else {
+ ((Label)figure).setText(text);
+ }
+ }
+
+ protected Image getLabelIconHelper(IFigure figure) {
+ if(figure instanceof WrappingLabel) {
+ return ((WrappingLabel)figure).getIcon();
+ } else if(figure instanceof ILabelFigure) {
+ return ((ILabelFigure)figure).getIcon();
+ } else {
+ return ((Label)figure).getIcon();
+ }
+ }
+
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if(figure instanceof WrappingLabel) {
+ ((WrappingLabel)figure).setIcon(icon);
+ } else if(figure instanceof ILabelFigure) {
+ ((ILabelFigure)figure).setIcon(icon);
+ } else {
+ ((Label)figure).setIcon(icon);
+ }
+ }
+
+ public void setLabel(WrappingLabel figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ protected List getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ protected Image getLabelIcon() {
+ return null;
+ }
+
+ protected String getLabelText() {
+ String text = null;
+ EObject parserElement = getParserElement();
+ if(parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
+ }
+ if(text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+
+ public void setLabelText(String text) {
+ setLabelTextHelper(getFigure(), text);
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ public String getEditText() {
+ if(getParserElement() == null || getParser() == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
+ }
+
+ protected boolean isEditable() {
+ return getParser() != null;
+ }
+
+ public ICellEditorValidator getEditTextValidator() {
+ return new ICellEditorValidator() {
+
+ public String isValid(final Object value) {
+ if(value instanceof String) {
+ final EObject element = getParserElement();
+ final IParser parser = getParser();
+ try {
+ IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl() {
+
+ public void run() {
+ setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value));
+ }
+ });
+ return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+ // shouldn't get here
+ return null;
+ }
+ };
+ }
+
+ public IContentAssistProcessor getCompletionProcessor() {
+ if(getParserElement() == null || getParser() == null) {
+ return null;
+ }
+ return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
+ }
+
+ public ParserOptions getParserOptions() {
+ return ParserOptions.NONE;
+ }
+
+ public final IParser getParser() {
+ if(parser == null) {
+ parser = createParser();
+ }
+ return parser;
+ }
+
+ protected abstract IParser createParser();
+
+ protected DirectEditManager getManager() {
+ if(manager == null) {
+ setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ protected void performDirectEdit() {
+ getManager().show();
+ }
+
+ protected void performDirectEdit(Point eventLocation) {
+ if(getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ private void performDirectEdit(char initialCharacter) {
+ if(getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager)getManager()).show(initialCharacter);
+ } else {
+ performDirectEdit();
+ }
+ }
+
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
+ directEditionMode = getDirectEditionType();
+ }
+ switch(directEditionMode) {
+ case IDirectEdition.NO_DIRECT_EDITION:
+ // no direct edition mode => does nothing
+ return;
+ case IDirectEdition.EXTENDED_DIRECT_EDITOR:
+ updateExtendedEditorConfiguration();
+ if(configuration == null || configuration.getLanguage() == null) {
+ performDefaultDirectEditorEdit(theRequest);
+ } else {
+ configuration.preEditAction(resolveSemanticElement());
+ Dialog dialog = null;
+ if(configuration instanceof IPopupEditorConfiguration) {
+ IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this);
+ helper.showEditor();
+ return;
+ } else if(configuration instanceof IAdvancedEditorConfiguration) {
+ dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()));
+ } else if(configuration instanceof IDirectEditorConfiguration) {
+ dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), ((IDirectEditorConfiguration)configuration).getTextToEdit(resolveSemanticElement()), (IDirectEditorConfiguration)configuration);
+ } else {
+ return;
+ }
+ final Dialog finalDialog = dialog;
+ if(Window.OK == dialog.open()) {
+ TransactionalEditingDomain domain = getEditingDomain();
+ RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
+
+ @Override
+ protected void doExecute() {
+ configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue());
+ }
+ };
+ domain.getCommandStack().execute(command);
+ }
+ }
+ break;
+ case IDirectEdition.DEFAULT_DIRECT_EDITOR:
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if(isActive() && isEditable()) {
+ if(theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character)theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest)theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ protected void refreshLabel() {
+ EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
+ if(maskLabelPolicy == null) {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ }
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) {
+ ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback();
+ }
+ refreshBounds();
+ }
+
+ protected void refreshUnderline() {
+ FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if(style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline());
+ }
+ if(resolveSemanticElement() instanceof Feature) {
+ if(((Feature)resolveSemanticElement()).isStatic()) {
+ ((WrappingLabel)getFigure()).setTextUnderline(true);
+ } else {
+ ((WrappingLabel)getFigure()).setTextUnderline(false);
+ }
+ }
+ }
+
+ protected void refreshStrikeThrough() {
+ FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if(style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ protected void refreshFont() {
+ FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if(style != null) {
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
+ setFont(fontData);
+ }
+ }
+
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ protected void addSemanticListeners() {
+ if(getParser() instanceof ISemanticParser) {
+ EObject element = resolveSemanticElement();
+ parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element);
+ for(int i = 0; i < parserElements.size(); i++) {
+ addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$
+ }
+ } else {
+ super.addSemanticListeners();
+ }
+ }
+
+ protected void removeSemanticListeners() {
+ if(parserElements != null) {
+ for(int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ protected AccessibleEditPart getAccessibleEditPart() {
+ if(accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ public void getName(AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
+ }
+ return accessibleEP;
+ }
+
+ private View getFontStyleOwnerView() {
+ return (View)getModel();
+ }
+
+ public int getDirectEditionType() {
+ if(checkExtendedEditor()) {
+ initExtendedEditorConfiguration();
+ return IDirectEdition.EXTENDED_DIRECT_EDITOR;
+ }
+ if(checkDefaultEdition()) {
+ return IDirectEdition.DEFAULT_DIRECT_EDITOR;
+ }
+ // not a named element. no specific editor => do nothing
+ return IDirectEdition.NO_DIRECT_EDITION;
+ }
+
+ protected boolean checkExtendedEditor() {
+ if(resolveSemanticElement() != null) {
+ return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ return false;
+ }
+
+ protected boolean checkDefaultEdition() {
+ return (getParser() != null);
+ }
+
+ protected void initExtendedEditorConfiguration() {
+ if(configuration == null) {
+ final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if(languagePreferred != null && !languagePreferred.equals("")) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName());
+ }
+ }
+ }
+
+ protected void updateExtendedEditorConfiguration() {
+ String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
+ if(languagePreferred != null && !languagePreferred.equals("") && languagePreferred != configuration.getLanguage()) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
+ } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
+ configuration = null;
+ }
+ }
+
+ protected void performDefaultDirectEditorEdit(final Request theRequest) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if(isActive() && isEditable()) {
+ if(theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character)theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest)theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ protected void handleNotificationEvent(Notification event) {
+ Object feature = event.getFeature();
+ if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
+ Integer c = (Integer)event.getNewValue();
+ setFontColor(DiagramColorRegistry.getInstance().getColor(c));
+ } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
+ refreshUnderline();
+ } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
+ refreshStrikeThrough();
+ } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
+ refreshFont();
+ } else {
+ if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
+ refreshLabel();
+ }
+ if(getParser() instanceof ISemanticParser) {
+ ISemanticParser modelParser = (ISemanticParser)getParser();
+ if(modelParser.areSemanticElementsAffected(null, event)) {
+ removeSemanticListeners();
+ if(resolveSemanticElement() != null) {
+ addSemanticListeners();
+ }
+ refreshLabel();
+ }
+ }
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ protected IFigure createFigure() {
+ final IFigure label = createFigurePrim();
+ defaultText = getLabelTextHelper(label);
+ return label;
+ }
+
+ protected IFigure createFigurePrim() {
+ return new WrappingLabel();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomBehaviorExecutionSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomBehaviorExecutionSpecificationEditPart.java
index 6845c29c349..f0e0f71e7fa 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomBehaviorExecutionSpecificationEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomBehaviorExecutionSpecificationEditPart.java
@@ -13,26 +13,88 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.DelegatingLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PrecisionPoint;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartListener;
import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
+import org.eclipse.gef.handles.MoveHandle;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.figures.BorderedNodeFigure;
+import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
+import org.eclipse.gmf.runtime.notation.DecorationNode;
+import org.eclipse.gmf.runtime.notation.LayoutConstraint;
+import org.eclipse.gmf.runtime.notation.Location;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.helper.NotificationHelper;
+import org.eclipse.papyrus.uml.diagram.common.providers.UIAdapterImpl;
import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ExecutionSpecificationEndEditPart.DummyCommand;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExecutionGraphicalNodeEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.semantic.CustomBehaviorExecutionSpecificationItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.sequence.util.BehaviorDisplayHelper;
+import org.eclipse.papyrus.uml.diagram.sequence.util.CommandHelper;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.BehaviorExecutionSpecification;
+import org.eclipse.uml2.uml.UMLPackage;
/**
+ * Fixed bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=417376. Display the behavior of an BehaviorExecutionSpecification as a Label.
+ *
+ * IMPORTANT, the new behavior label was added to the BorderedNodeFigure of Interaction, it seems there are some problems about moving when it was
+ * added
+ * on the BorderedNodeFigure of current BehaviorExecutionSpecification EditPart.
+ *
* @author Jin Liu (jin.liu@soyatec.com)
*/
public class CustomBehaviorExecutionSpecificationEditPart extends BehaviorExecutionSpecificationEditPart {
+ private NotificationHelper helper = new NotificationHelper(new UIAdapterImpl() {
+
+ @Override
+ protected void safeNotifyChanged(Notification msg) {
+ handleNotificationEvent(msg);
+ }
+ });
+
+ /**
+ * Registered a removing listener in parent editpart, this can help us to remove the behavior label(tips: behavior label was added to interaction
+ * figure.).
+ */
+ private EditPartListener selfRemovingListener;
+
/**
* Constructor.
*
@@ -54,6 +116,60 @@ public class CustomBehaviorExecutionSpecificationEditPart extends BehaviorExecut
installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ExecutionGraphicalNodeEditPolicy());
}
+ @Override
+ protected LayoutEditPolicy createLayoutEditPolicy() {
+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() {
+
+ protected EditPolicy createChildEditPolicy(EditPart child) {
+ if(child instanceof BehaviorExecutionSpecificationBehaviorEditPart) {
+ return new BorderItemSelectionEditPolicy() {
+
+ protected List createSelectionHandles() {
+ MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost());
+ mh.setBorder(null);
+ return Collections.singletonList(mh);
+ }
+
+ protected Command getMoveCommand(ChangeBoundsRequest request) {
+ IBorderItemEditPart borderItemEP = (IBorderItemEditPart)getHost();
+ IBorderItemLocator borderItemLocator = borderItemEP.getBorderItemLocator();
+
+ if(borderItemLocator != null) {
+ LayoutConstraint layout = ((Node)getHost().getModel()).getLayoutConstraint();
+ Point location = new Point();
+ if(layout instanceof Location) {
+ location.x = ((Location)layout).getX();
+ location.y = ((Location)layout).getY();
+ }
+ location.translate(request.getMoveDelta());
+
+ ICommand moveCommand = new SetBoundsCommand(borderItemEP.getEditingDomain(), DiagramUIMessages.Commands_MoveElement, new EObjectAdapter((View)getHost().getModel()), location);
+ return new ICommandProxy(moveCommand);
+ }
+ return null;
+ }
+
+
+ };
+ }
+ EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if(result == null) {
+ result = new NonResizableEditPolicy();
+ }
+ return result;
+ }
+
+ protected Command getMoveChildrenCommand(Request request) {
+ return null;
+ }
+
+ protected Command getCreateCommand(CreateRequest request) {
+ return null;
+ }
+ };
+ return lep;
+ }
+
/**
* Overrides to disable the defaultAnchorArea. The edge is no more stuck with the middle of the
* figure.
@@ -108,6 +224,50 @@ public class CustomBehaviorExecutionSpecificationEditPart extends BehaviorExecut
}
/**
+ * We did NOT use a BorderedNodeFigure in current EditPart. There are some problems about moving external labels.
+ *
+ * We just find and use the root(Interaction) BorderedNodeFigure.
+ */
+ private BorderedNodeFigure getBorderedFigure() {
+ EditPart parent = getParent();
+ while(parent != null && !(parent instanceof CustomInteractionEditPart)) {
+ parent = parent.getParent();
+ }
+ if(parent != null) {
+ return ((CustomInteractionEditPart)parent).getBorderedFigure();
+ }
+ return null;
+ }
+
+ @Override
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if(childEditPart instanceof BehaviorExecutionSpecificationBehaviorEditPart) {
+ IFigure childFigure = ((BehaviorExecutionSpecificationBehaviorEditPart)childEditPart).getFigure();
+ BorderedNodeFigure borderedFigure = getBorderedFigure();
+ final IFigure figure = getFigure();
+ BehaviorLabelLocator locator = new BehaviorLabelLocator(figure);
+ if(borderedFigure != null) {
+ borderedFigure.getBorderItemContainer().add(childFigure, locator);
+ }
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ @Override
+ protected void removeChildVisual(EditPart childEditPart) {
+ if(childEditPart instanceof BehaviorExecutionSpecificationBehaviorEditPart) {
+ IFigure childFigure = ((BehaviorExecutionSpecificationBehaviorEditPart)childEditPart).getFigure();
+ BorderedNodeFigure borderedFigure = getBorderedFigure();
+ if(borderedFigure != null) {
+ borderedFigure.getBorderItemContainer().remove(childFigure);
+ }
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
* @see org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BehaviorExecutionSpecificationEditPart#setLineWidth(int)
*
* @param width
@@ -116,4 +276,186 @@ public class CustomBehaviorExecutionSpecificationEditPart extends BehaviorExecut
protected void setLineWidth(int width) {
// super.setLineWidth(width);
}
+
+ @Override
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshBehavior();
+ }
+
+ @Override
+ protected void refreshBounds() {
+ super.refreshBounds();
+ refreshBehavior();
+ }
+
+ protected void refreshBehavior() {
+ if(!BehaviorDisplayHelper.shouldDisplayBehavior(getNotationView())) {
+ return;
+ }
+ List children = getChildren();
+ for(Object child : children) {
+ if(child instanceof BehaviorExecutionSpecificationBehaviorEditPart) {
+ ((BehaviorExecutionSpecificationBehaviorEditPart)child).refresh();
+ }
+ }
+ }
+
+ @Override
+ public void activate() {
+ super.activate();
+ EObject elt = resolveSemanticElement();
+ if(elt instanceof BehaviorExecutionSpecification) {
+ Behavior behavior = ((BehaviorExecutionSpecification)elt).getBehavior();
+ if(behavior != null) {
+ helper.listenObject(behavior);
+ }
+ }
+ if(getParent() != null) {
+ getParent().addEditPartListener(selfRemovingListener = new EditPartListener.Stub() {
+
+ @Override
+ public void removingChild(EditPart child, int index) {
+ if(child == CustomBehaviorExecutionSpecificationEditPart.this) {
+ List children = new ArrayList(getChildren());
+ for(Object object : children) {
+ if(object instanceof BehaviorExecutionSpecificationBehaviorEditPart) {
+ removeChild((EditPart)object);
+ break;
+ }
+ }
+ }
+ }
+ });
+ }
+ }
+
+ @Override
+ public void deactivate() {
+ helper.unlistenAll();
+ if(getParent() != null) {
+ getParent().removeEditPartListener(selfRemovingListener);
+ }
+ super.deactivate();
+ }
+
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ super.handleNotificationEvent(event);
+ Object feature = event.getFeature();
+ Object notifier = event.getNotifier();
+ if(UMLPackage.eINSTANCE.getBehaviorExecutionSpecification_Behavior() == feature) {
+ helper.unlistenObject((Notifier)event.getOldValue());
+ helper.listenObject((Notifier)event.getNewValue());
+ refreshBehavior();
+ } else if(notifier != null) {
+ EObject elt = resolveSemanticElement();
+ if(elt instanceof BehaviorExecutionSpecification && notifier == ((BehaviorExecutionSpecification)elt).getBehavior()) {
+ refreshBehavior();
+ }
+ }
+ if(BehaviorDisplayHelper.isDisplayBehaviorChanged(event)) {
+ refreshChildren();
+ }
+ }
+
+ @Override
+ protected List getModelChildren() {
+ List modelChildren = new ArrayList(super.getModelChildren());
+ boolean displayBehavior = BehaviorDisplayHelper.shouldDisplayBehavior(getNotationView());
+ //Lazy check and create behavior label model.
+ boolean hasBehaviorLabel = false;
+ final View view = getNotationView();
+ for(Object object : view.getChildren()) {
+ if(object instanceof View && BehaviorExecutionSpecificationBehaviorEditPart.BEHAVIOR_TYPE.equals(((View)object).getType())) {
+ hasBehaviorLabel = true;
+ if(!displayBehavior) {
+ modelChildren.remove(object);
+ }
+ break;
+ }
+ }
+ if(!hasBehaviorLabel && displayBehavior) {
+ final DecorationNode behaviorLabel = NotationFactory.eINSTANCE.createDecorationNode();
+ Location location = NotationFactory.eINSTANCE.createLocation();
+ location.setX(16);
+ location.setY(16);
+ behaviorLabel.setLayoutConstraint(location);
+ behaviorLabel.setType(BehaviorExecutionSpecificationBehaviorEditPart.BEHAVIOR_TYPE);
+ CommandHelper.executeCommandWithoutHistory(getEditingDomain(), new DummyCommand() {
+
+ @Override
+ public void execute() {
+ ViewUtil.insertChildView(view, behaviorLabel, ViewUtil.APPEND, true);
+ }
+ }, true);
+ modelChildren.add(behaviorLabel);
+ }
+ return modelChildren;
+ }
+
+ private static class BehaviorLabelLocator implements IBorderItemLocator {
+
+ private IFigure referenceFigure;
+
+ private Rectangle constraint = new Rectangle();
+
+
+ /**
+ * Constructor.
+ *
+ */
+ public BehaviorLabelLocator(IFigure referenceFigure) {
+ this.referenceFigure = referenceFigure;
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#setConstraint(org.eclipse.draw2d.geometry.Rectangle)
+ *
+ * @param constraint
+ */
+
+ public void setConstraint(Rectangle constraint) {
+ this.constraint = constraint;
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#getValidLocation(org.eclipse.draw2d.geometry.Rectangle,
+ * org.eclipse.draw2d.IFigure)
+ *
+ * @param proposedLocation
+ * @param borderItem
+ * @return
+ */
+
+ public Rectangle getValidLocation(Rectangle proposedLocation, IFigure borderItem) {
+ return new Rectangle(proposedLocation);
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#getCurrentSideOfParent()
+ *
+ * @return
+ */
+
+ public int getCurrentSideOfParent() {
+ return 0;
+ }
+
+ /**
+ * @see org.eclipse.draw2d.Locator#relocate(org.eclipse.draw2d.IFigure)
+ *
+ * @param target
+ */
+
+ public void relocate(IFigure target) {
+ Rectangle ref = referenceFigure.getBounds().getCopy();
+ referenceFigure.translateToAbsolute(ref);
+ Rectangle bounds = constraint.getTranslated(ref.getLocation());
+ bounds.setSize(target.getPreferredSize());
+ target.translateToRelative(bounds);
+ target.setBounds(bounds);
+ }
+
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java
index 546c24f04c3..2bb1b3a380f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java
@@ -41,6 +41,8 @@ public class CustomEditPartProvider extends UMLEditPartProvider {
return new GateNameEditPart(view);
} else if(InteractionOperandGuardEditPart.GUARD_TYPE.equals(view.getType())) {
return new InteractionOperandGuardEditPart(view);
+ } else if(BehaviorExecutionSpecificationBehaviorEditPart.BEHAVIOR_TYPE.equals(view.getType())) {
+ return new BehaviorExecutionSpecificationBehaviorEditPart(view);
}
if(view instanceof Connector) {
if(((Connector)view).getType().equals(SequenceUtil.OBSERVATION_LINK_TYPE))
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomViewProvider.java
index d19b87b3f6f..88437eb3196 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomViewProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomViewProvider.java
@@ -33,6 +33,7 @@ import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BehaviorExecutionSpecificationBehaviorEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentCombinedFragmentCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CommentAnnotatedElementEditPart;
@@ -62,65 +63,94 @@ import org.eclipse.uml2.uml.InteractionOperand;
public class CustomViewProvider extends UMLViewProvider {
protected boolean provides(CreateNodeViewOperation op) {
- if(op.getContainerView() == null) {
+ if (op.getContainerView() == null) {
return false;
}
int visualID = UMLVisualIDRegistry.getVisualID(op.getSemanticHint());
- if(visualID == DurationConstraintEditPart.VISUAL_ID) { // avoid to modify UMLVisualIDRegistry.getNodeVisualID(View, EObject)
- if(InteractionInteractionCompartmentEditPart.VISUAL_ID == UMLVisualIDRegistry.getVisualID(op.getContainerView()))
+ if (visualID == DurationConstraintEditPart.VISUAL_ID) { // avoid to
+ // modify
+ // UMLVisualIDRegistry.getNodeVisualID(View,
+ // EObject)
+ if (InteractionInteractionCompartmentEditPart.VISUAL_ID == UMLVisualIDRegistry
+ .getVisualID(op.getContainerView()))
return true;
}
return super.provides(op);
}
protected boolean provides(CreateViewForKindOperation op) {
- if(op.getContainerView() == null) {
+ if (op.getContainerView() == null) {
return false;
}
int visualID = UMLVisualIDRegistry.getVisualID(op.getSemanticHint());
- if(visualID == DurationConstraintEditPart.VISUAL_ID) { // avoid to modify UMLVisualIDRegistry.getNodeVisualID(View, EObject)
- if(InteractionInteractionCompartmentEditPart.VISUAL_ID == UMLVisualIDRegistry.getVisualID(op.getContainerView()))
+ if (visualID == DurationConstraintEditPart.VISUAL_ID) { // avoid to
+ // modify
+ // UMLVisualIDRegistry.getNodeVisualID(View,
+ // EObject)
+ if (InteractionInteractionCompartmentEditPart.VISUAL_ID == UMLVisualIDRegistry
+ .getVisualID(op.getContainerView()))
return true;
}
return super.provides(op);
}
@Override
- public Edge createEdge(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) {
- Edge edge = super.createEdge(semanticAdapter, containerView, semanticHint, index, persisted, preferencesHint);
- if(edge != null) {
+ public Edge createEdge(IAdaptable semanticAdapter, View containerView,
+ String semanticHint, int index, boolean persisted,
+ PreferencesHint preferencesHint) {
+ Edge edge = super.createEdge(semanticAdapter, containerView,
+ semanticHint, index, persisted, preferencesHint);
+ if (edge != null) {
edge.getStyles().add(NotationFactory.eINSTANCE.createLineStyle());
- final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initForegroundFromPrefs(edge, prefStore, "Message");
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint
+ .getPreferenceStore();
+ PreferenceInitializerForElementHelper.initForegroundFromPrefs(edge,
+ prefStore, "Message");
}
return edge;
}
- public Node createTimeObservation_3020(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ public Node createTimeObservation_3020(EObject domainElement,
+ View containerView, int index, boolean persisted,
+ PreferencesHint preferencesHint) {
Shape node = NotationFactory.eINSTANCE.createShape();
node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(TimeObservationEditPart.VISUAL_ID));
+ node.setType(UMLVisualIDRegistry
+ .getType(TimeObservationEditPart.VISUAL_ID));
ViewUtil.insertChildView(containerView, node, index, persisted);
node.setElement(domainElement);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initForegroundFromPrefs(node, prefStore, "TimeObservation");
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "TimeObservation");
- PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node, prefStore, "TimeObservation");
- Node label5010 = createLabel(node, UMLVisualIDRegistry.getType(TimeObservationLabelEditPart.VISUAL_ID), true);
- label5010.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location5010 = (Location)label5010.getLayoutConstraint();
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint
+ .getPreferenceStore();
+ PreferenceInitializerForElementHelper.initForegroundFromPrefs(node,
+ prefStore, "TimeObservation");
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node,
+ prefStore, "TimeObservation");
+ PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node,
+ prefStore, "TimeObservation");
+ Node label5010 = createLabel(node,
+ UMLVisualIDRegistry
+ .getType(TimeObservationLabelEditPart.VISUAL_ID), true);
+ label5010.setLayoutConstraint(NotationFactory.eINSTANCE
+ .createLocation());
+ Location location5010 = (Location) label5010.getLayoutConstraint();
location5010.setX(0);
location5010.setY(0);
- Node label5014 = createLabel(node, UMLVisualIDRegistry.getType(TimeObservationAppliedStereotypeEditPart.VISUAL_ID), true);
- label5014.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location5014 = (Location)label5014.getLayoutConstraint();
+ Node label5014 = createLabel(
+ node,
+ UMLVisualIDRegistry
+ .getType(TimeObservationAppliedStereotypeEditPart.VISUAL_ID),
+ true);
+ label5014.setLayoutConstraint(NotationFactory.eINSTANCE
+ .createLocation());
+ Location location5014 = (Location) label5014.getLayoutConstraint();
location5014.setX(0);
location5014.setY(0);
return node;
}
- protected Node createLabel(View owner, String hint, boolean isTimeObservationLable) {
+ protected Node createLabel(View owner, String hint,
+ boolean isTimeObservationLable) {
Shape node = NotationFactory.eINSTANCE.createShape();
node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
node.setType(hint);
@@ -128,153 +158,250 @@ public class CustomViewProvider extends UMLViewProvider {
return node;
}
- public Node createDurationConstraint_3021(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ public Node createDurationConstraint_3021(EObject domainElement,
+ View containerView, int index, boolean persisted,
+ PreferencesHint preferencesHint) {
Shape node = NotationFactory.eINSTANCE.createShape();
node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(DurationConstraintEditPart.VISUAL_ID));
+ node.setType(UMLVisualIDRegistry
+ .getType(DurationConstraintEditPart.VISUAL_ID));
ViewUtil.insertChildView(containerView, node, index, persisted);
node.setElement(domainElement);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initForegroundFromPrefs(node, prefStore, "DurationConstraint");
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "DurationConstraint");
- PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node, prefStore, "DurationConstraint");
- Node label5011 = createLabel(node, UMLVisualIDRegistry.getType(DurationConstraintLabelEditPart.VISUAL_ID));
- label5011.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location5011 = (Location)label5011.getLayoutConstraint();
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint
+ .getPreferenceStore();
+ PreferenceInitializerForElementHelper.initForegroundFromPrefs(node,
+ prefStore, "DurationConstraint");
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node,
+ prefStore, "DurationConstraint");
+ PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node,
+ prefStore, "DurationConstraint");
+ Node label5011 = createLabel(node,
+ UMLVisualIDRegistry
+ .getType(DurationConstraintLabelEditPart.VISUAL_ID));
+ label5011.setLayoutConstraint(NotationFactory.eINSTANCE
+ .createLocation());
+ Location location5011 = (Location) label5011.getLayoutConstraint();
location5011.setX(25);
location5011.setY(0);
- Node label5015 = createLabel(node, UMLVisualIDRegistry.getType(DurationConstraintAppliedStereotypeEditPart.VISUAL_ID));
- label5015.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location5015 = (Location)label5015.getLayoutConstraint();
+ Node label5015 = createLabel(
+ node,
+ UMLVisualIDRegistry
+ .getType(DurationConstraintAppliedStereotypeEditPart.VISUAL_ID));
+ label5015.setLayoutConstraint(NotationFactory.eINSTANCE
+ .createLocation());
+ Location location5015 = (Location) label5015.getLayoutConstraint();
location5015.setX(0);
location5015.setY(-22);
return node;
}
- public Node createCombinedFragment_3004(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ public Node createCombinedFragment_3004(EObject domainElement,
+ View containerView, int index, boolean persisted,
+ PreferencesHint preferencesHint) {
Shape node = NotationFactory.eINSTANCE.createShape();
node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(CombinedFragmentEditPart.VISUAL_ID));
+ node.setType(UMLVisualIDRegistry
+ .getType(CombinedFragmentEditPart.VISUAL_ID));
ViewUtil.insertChildView(containerView, node, index, persisted);
node.setElement(domainElement);
// initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initForegroundFromPrefs(node, prefStore, "CombinedFragment");
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "CombinedFragment");
- PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node, prefStore, "CombinedFragment");
- Node compartment = createCompartment(node, UMLVisualIDRegistry.getType(CombinedFragmentCombinedFragmentCompartmentEditPart.VISUAL_ID), false, false, true, true);
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint
+ .getPreferenceStore();
+ PreferenceInitializerForElementHelper.initForegroundFromPrefs(node,
+ prefStore, "CombinedFragment");
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node,
+ prefStore, "CombinedFragment");
+ PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node,
+ prefStore, "CombinedFragment");
+ Node compartment = createCompartment(
+ node,
+ UMLVisualIDRegistry
+ .getType(CombinedFragmentCombinedFragmentCompartmentEditPart.VISUAL_ID),
+ false, false, true, true);
// Add by default InteractionOperand
- for(InteractionOperand interactionOperand : ((CombinedFragment)domainElement).getOperands()) {
- createInteractionOperand_3005(interactionOperand, compartment, -1, true, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
+ for (InteractionOperand interactionOperand : ((CombinedFragment) domainElement)
+ .getOperands()) {
+ createInteractionOperand_3005(interactionOperand, compartment, -1,
+ true, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
}
- //initialization for the compartment visibility
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "CombinedFragment");
+ // initialization for the compartment visibility
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(
+ node, prefStore, "CombinedFragment");
return node;
}
- public Node createDurationConstraint_3023(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ public Node createDurationConstraint_3023(EObject domainElement,
+ View containerView, int index, boolean persisted,
+ PreferencesHint preferencesHint) {
Node node = NotationFactory.eINSTANCE.createShape();
- node.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle());
+ node.getStyles()
+ .add(NotationFactory.eINSTANCE.createDescriptionStyle());
node.getStyles().add(NotationFactory.eINSTANCE.createFillStyle());
node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(DurationConstraintInMessageEditPart.VISUAL_ID));
+ node.setType(UMLVisualIDRegistry
+ .getType(DurationConstraintInMessageEditPart.VISUAL_ID));
ViewUtil.insertChildView(containerView, node, index, persisted);
node.setElement(domainElement);
// custom layout for location
- Location location3023 = (Location)node.getLayoutConstraint();
+ Location location3023 = (Location) node.getLayoutConstraint();
location3023.setX(0);
location3023.setY(20);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node, prefStore, "DurationConstraint");
- Node label5018 = createLabel(node, UMLVisualIDRegistry.getType(DurationConstraintInMessageLabelEditPart.VISUAL_ID));
- Node label5019 = createLabel(node, UMLVisualIDRegistry.getType(DurationConstraintInMessageAppliedStereotypeEditPart.VISUAL_ID));
- label5019.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location5019 = (Location)label5019.getLayoutConstraint();
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint
+ .getPreferenceStore();
+ PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node,
+ prefStore, "DurationConstraint");
+ Node label5018 = createLabel(
+ node,
+ UMLVisualIDRegistry
+ .getType(DurationConstraintInMessageLabelEditPart.VISUAL_ID));
+ Node label5019 = createLabel(
+ node,
+ UMLVisualIDRegistry
+ .getType(DurationConstraintInMessageAppliedStereotypeEditPart.VISUAL_ID));
+ label5019.setLayoutConstraint(NotationFactory.eINSTANCE
+ .createLocation());
+ Location location5019 = (Location) label5019.getLayoutConstraint();
location5019.setX(0);
location5019.setY(-22);
return node;
}
- public Node createDurationObservation_3024(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ public Node createDurationObservation_3024(EObject domainElement,
+ View containerView, int index, boolean persisted,
+ PreferencesHint preferencesHint) {
Node node = NotationFactory.eINSTANCE.createShape();
- node.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle());
+ node.getStyles()
+ .add(NotationFactory.eINSTANCE.createDescriptionStyle());
node.getStyles().add(NotationFactory.eINSTANCE.createFillStyle());
node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(DurationObservationEditPart.VISUAL_ID));
+ node.setType(UMLVisualIDRegistry
+ .getType(DurationObservationEditPart.VISUAL_ID));
ViewUtil.insertChildView(containerView, node, index, persisted);
node.setElement(domainElement);
// custom layout for location
- Location location3024 = (Location)node.getLayoutConstraint();
+ Location location3024 = (Location) node.getLayoutConstraint();
location3024.setX(0);
location3024.setY(0);
- // initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node, prefStore, "DurationObservation");
- Node label5016 = createLabel(node, UMLVisualIDRegistry.getType(DurationObservationLabelEditPart.VISUAL_ID));
- Node label5017 = createLabel(node, UMLVisualIDRegistry.getType(DurationObservationAppliedStereotypeEditPart.VISUAL_ID));
- label5017.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- Location location5017 = (Location)label5017.getLayoutConstraint();
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint
+ .getPreferenceStore();
+ PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node,
+ prefStore, "DurationObservation");
+ Node label5016 = createLabel(node,
+ UMLVisualIDRegistry
+ .getType(DurationObservationLabelEditPart.VISUAL_ID));
+ Node label5017 = createLabel(
+ node,
+ UMLVisualIDRegistry
+ .getType(DurationObservationAppliedStereotypeEditPart.VISUAL_ID));
+ label5017.setLayoutConstraint(NotationFactory.eINSTANCE
+ .createLocation());
+ Location location5017 = (Location) label5017.getLayoutConstraint();
location5017.setX(0);
location5017.setY(0);
return node;
}
- public Node createConsiderIgnoreFragment_3007(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ public Node createConsiderIgnoreFragment_3007(EObject domainElement,
+ View containerView, int index, boolean persisted,
+ PreferencesHint preferencesHint) {
Shape node = NotationFactory.eINSTANCE.createShape();
node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- node.setType(UMLVisualIDRegistry.getType(ConsiderIgnoreFragmentEditPart.VISUAL_ID));
+ node.setType(UMLVisualIDRegistry
+ .getType(ConsiderIgnoreFragmentEditPart.VISUAL_ID));
ViewUtil.insertChildView(containerView, node, index, persisted);
node.setElement(domainElement);
// initializeFromPreferences
- final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initForegroundFromPrefs(node, prefStore, "ConsiderIgnoreFragment");
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "ConsiderIgnoreFragment");
- PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node, prefStore, "ConsiderIgnoreFragment");
- Node compartment = createCompartment(node, UMLVisualIDRegistry.getType(CombinedFragmentCombinedFragmentCompartmentEditPart.VISUAL_ID), false, false, true, true);
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint
+ .getPreferenceStore();
+ PreferenceInitializerForElementHelper.initForegroundFromPrefs(node,
+ prefStore, "ConsiderIgnoreFragment");
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node,
+ prefStore, "ConsiderIgnoreFragment");
+ PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node,
+ prefStore, "ConsiderIgnoreFragment");
+ Node compartment = createCompartment(
+ node,
+ UMLVisualIDRegistry
+ .getType(CombinedFragmentCombinedFragmentCompartmentEditPart.VISUAL_ID),
+ false, false, true, true);
// Add by default InteractionOperand
- for(InteractionOperand interactionOperand : ((CombinedFragment)domainElement).getOperands()) {
- createInteractionOperand_3005(interactionOperand, compartment, -1, true, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
+ for (InteractionOperand interactionOperand : ((CombinedFragment) domainElement)
+ .getOperands()) {
+ createInteractionOperand_3005(interactionOperand, compartment, -1,
+ true, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
}
- //initialization for the compartment visibility
- PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "ConsiderIgnoreFragment");
+ // initialization for the compartment visibility
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(
+ node, prefStore, "ConsiderIgnoreFragment");
return node;
}
- public Edge createCommentAnnotatedElement_4010(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Edge edge = NotationFactory.eINSTANCE.createEdge(); // override Connector
+ public Edge createCommentAnnotatedElement_4010(View containerView,
+ int index, boolean persisted, PreferencesHint preferencesHint) {
+ Edge edge = NotationFactory.eINSTANCE.createEdge(); // override
+ // Connector
edge.getStyles().add(NotationFactory.eINSTANCE.createRoutingStyle());
edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
- ArrayList<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE
+ .createRelativeBendpoints();
+ ArrayList<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(
+ 2);
points.add(new RelativeBendpoint());
points.add(new RelativeBendpoint());
bendpoints.setPoints(points);
edge.setBendpoints(bendpoints);
ViewUtil.insertChildView(containerView, edge, index, persisted);
- edge.setType(UMLVisualIDRegistry.getType(CommentAnnotatedElementEditPart.VISUAL_ID));
+ edge.setType(UMLVisualIDRegistry
+ .getType(CommentAnnotatedElementEditPart.VISUAL_ID));
edge.setElement(null);
// initializePreferences
- final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore();
- PreferenceInitializerForElementHelper.initForegroundFromPrefs(edge, prefStore, "Undefined");
- PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Undefined");
- PreferenceInitializerForElementHelper.initRountingFromPrefs(edge, prefStore, "Undefined");
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint
+ .getPreferenceStore();
+ PreferenceInitializerForElementHelper.initForegroundFromPrefs(edge,
+ prefStore, "Undefined");
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge,
+ prefStore, "Undefined");
+ PreferenceInitializerForElementHelper.initRountingFromPrefs(edge,
+ prefStore, "Undefined");
return edge;
}
- //Add Guard label support.
+ // Add Guard label support.
@Override
- public Node createInteractionOperand_3005(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
- Node node = super.createInteractionOperand_3005(domainElement, containerView, index, persisted, preferencesHint);
- DecorationNode guardNode = NotationFactory.eINSTANCE.createDecorationNode();
+ public Node createInteractionOperand_3005(EObject domainElement,
+ View containerView, int index, boolean persisted,
+ PreferencesHint preferencesHint) {
+ Node node = super.createInteractionOperand_3005(domainElement,
+ containerView, index, persisted, preferencesHint);
+ DecorationNode guardNode = NotationFactory.eINSTANCE
+ .createDecorationNode();
Bounds b = NotationFactory.eINSTANCE.createBounds();
b.setX(5);
b.setY(5);
guardNode.setLayoutConstraint(b);
guardNode.setType(InteractionOperandGuardEditPart.GUARD_TYPE);
- guardNode.setElement(((InteractionOperand)domainElement).getGuard());
+ guardNode.setElement(((InteractionOperand) domainElement).getGuard());
ViewUtil.insertChildView(node, guardNode, ViewUtil.APPEND, true);
return node;
}
+
+ @Override
+ public Node createBehaviorExecutionSpecification_3003(
+ EObject domainElement, View containerView, int index,
+ boolean persisted, PreferencesHint preferencesHint) {
+ Node node = super
+ .createBehaviorExecutionSpecification_3003(domainElement,
+ containerView, index, persisted, preferencesHint);
+ // Add a label for Behavior.
+ Node label = createLabel(node,
+ BehaviorExecutionSpecificationBehaviorEditPart.BEHAVIOR_TYPE);
+ Location location = NotationFactory.eINSTANCE.createLocation();
+ location.setX(18);
+ location.setY(18);
+ label.setLayoutConstraint(location);
+ return node;
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/DisplayBehaviorContributionItem.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/DisplayBehaviorContributionItem.java
new file mode 100644
index 00000000000..7f7cd36d9b7
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/DisplayBehaviorContributionItem.java
@@ -0,0 +1,112 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA
+ *
+ *
+ * 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:
+ * Soyatec - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.providers;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.action.ContributionItem;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BehaviorExecutionSpecificationBehaviorEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BehaviorExecutionSpecificationEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.util.BehaviorDisplayHelper;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.menus.IWorkbenchContribution;
+import org.eclipse.ui.services.IServiceLocator;
+
+
+/**
+ * @author Jin Liu (jin.liu@soyatec.com)
+ */
+public class DisplayBehaviorContributionItem extends ContributionItem implements IWorkbenchContribution {
+
+ private IServiceLocator serviceLocator;
+
+ /**
+ * @see org.eclipse.ui.menus.IWorkbenchContribution#initialize(org.eclipse.ui.services.IServiceLocator)
+ *
+ * @param serviceLocator
+ */
+ public void initialize(IServiceLocator serviceLocator) {
+ this.serviceLocator = serviceLocator;
+ }
+
+ @Override
+ public boolean isDynamic() {
+ return true;
+ }
+
+ private ISelection getSelection() {
+ if(serviceLocator == null) {
+ return null;
+ }
+ ISelectionService selectionService = (ISelectionService)serviceLocator.getService(ISelectionService.class);
+ if(selectionService != null) {
+ return selectionService.getSelection();
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.Menu, int)
+ *
+ * @param menu
+ * @param index
+ */
+ @Override
+ public void fill(Menu menu, int index) {
+ super.fill(menu, index);
+ ISelection selection = getSelection();
+ if(selection == null || selection.isEmpty()) {
+ return;
+ }
+ if(selection instanceof IStructuredSelection) {
+ Object firstElement = ((IStructuredSelection)selection).getFirstElement();
+ if(firstElement instanceof BehaviorExecutionSpecificationEditPart) {
+ final View view = ((BehaviorExecutionSpecificationEditPart)firstElement).getNotationView();
+ final TransactionalEditingDomain domain = ((BehaviorExecutionSpecificationEditPart)firstElement).getEditingDomain();
+ boolean displayBehavior = BehaviorDisplayHelper.shouldDisplayBehavior(view);
+ if(displayBehavior) {
+ MenuItem hide = new MenuItem(menu, SWT.NONE, 0);
+ hide.setText("Hide Behavior Label");
+ hide.addListener(SWT.Selection, new Listener() {
+
+ public void handleEvent(Event event) {
+ Command cmd = BehaviorDisplayHelper.getChangeDisplayBehaviorCommand(domain, view, false);
+ domain.getCommandStack().execute(cmd);
+ }
+ });
+ new MenuItem(menu, SWT.SEPARATOR, 1);
+ } else {
+ MenuItem show = new MenuItem(menu, SWT.NONE, 0);
+ show.setText("Display Behavior Label");
+ show.addListener(SWT.Selection, new Listener() {
+
+ public void handleEvent(Event event) {
+ Command cmd = BehaviorDisplayHelper.getChangeDisplayBehaviorCommand(domain, view, true);
+ domain.getCommandStack().execute(cmd);
+ }
+ });
+ new MenuItem(menu, SWT.SEPARATOR, 1);
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/BehaviorDisplayHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/BehaviorDisplayHelper.java
new file mode 100644
index 00000000000..21598053031
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/BehaviorDisplayHelper.java
@@ -0,0 +1,183 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA
+ *
+ *
+ * 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:
+ * Soyatec - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.util;
+
+import org.eclipse.core.databinding.observable.Diffs;
+import org.eclipse.core.databinding.observable.IObservable;
+import org.eclipse.core.databinding.observable.value.ValueDiff;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EModelElement;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.util.Util;
+import org.eclipse.papyrus.infra.emf.commands.CreateEAnnotationCommand;
+import org.eclipse.papyrus.infra.emf.databinding.AnnotationObservableValue;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper;
+import org.eclipse.papyrus.views.properties.Activator;
+import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
+import org.eclipse.papyrus.views.properties.modelelement.AnnotationModelElement;
+import org.eclipse.papyrus.views.properties.modelelement.ModelElement;
+import org.eclipse.papyrus.views.properties.modelelement.ModelElementFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * @author Jin Liu (jin.liu@soyatec.com)
+ */
+public class BehaviorDisplayHelper implements ModelElementFactory {
+
+ private static final String DISPLAY_BEHAVIOR = "displayBehavior";
+
+ /**
+ * @see org.eclipse.papyrus.views.properties.modelelement.ModelElementFactory#createFromSource(java.lang.Object,
+ * org.eclipse.papyrus.views.properties.contexts.DataContextElement)
+ *
+ * @param sourceElement
+ * @param context
+ * @return
+ */
+
+ public ModelElement createFromSource(Object sourceElement,
+ DataContextElement context) {
+ View source = NotationHelper.findView(sourceElement);
+ if (source == null) {
+ Activator.log
+ .warn("Unable to resolve the selected element to an EObject"); //$NON-NLS-1$
+ return null;
+ }
+ EditingDomain domain = EMFHelper.resolveEditingDomain(source);
+ return new AnnotationModelElement(source, domain, DISPLAY_BEHAVIOR) {
+
+ @Override
+ public IObservable doGetObservable(String propertyPath) {
+ return new BehaviorObservableValue(source, domain,
+ DISPLAY_BEHAVIOR, DISPLAY_BEHAVIOR);
+ }
+ };
+ }
+
+ public static Command getChangeDisplayBehaviorCommand(
+ TransactionalEditingDomain domain, View source, final Object display) {
+ return new CreateEAnnotationCommand(
+ (TransactionalEditingDomain) domain, source, DISPLAY_BEHAVIOR) {
+
+ @Override
+ protected void doExecute() {
+ EAnnotation annotation = createEAnnotation();
+ replaceEannotation(annotation, getObject());
+ replaceEntry(annotation, DISPLAY_BEHAVIOR, display == null ? ""
+ : display.toString());
+ }
+ };
+ }
+
+ public static final boolean isDisplayBehaviorChanged(Notification msg) {
+ if (msg == null || !(msg.getNewValue() instanceof EAnnotation)) {
+ return false;
+ }
+ EAnnotation anno = (EAnnotation) msg.getNewValue();
+ return DISPLAY_BEHAVIOR.equals(anno.getSource());
+ }
+
+ public static final boolean shouldDisplayBehavior(View view) {
+ if (view != null) {
+ EAnnotation anno = view.getEAnnotation(DISPLAY_BEHAVIOR);
+ if (anno != null) {
+ return !"false".equalsIgnoreCase(anno.getDetails().get(
+ DISPLAY_BEHAVIOR));
+ }
+ }
+ return true;
+ }
+
+ private static class BehaviorObservableValue extends
+ AnnotationObservableValue {
+
+ private Object cacheValue = "true";
+ private Adapter sourceListener;
+
+ public BehaviorObservableValue(EModelElement source,
+ EditingDomain domain, String annotationName, String key) {
+ super(source, domain, annotationName, key);
+ source.eAdapters().add(getSourceListener());
+ }
+
+ public Adapter getSourceListener() {
+ if (sourceListener == null) {
+ sourceListener = new EContentAdapter() {
+ @Override
+ public void notifyChanged(Notification msg) {
+ super.notifyChanged(msg);
+ if (msg.getNotifier() instanceof EAnnotation) {
+ Object feature = msg.getFeature();
+ if (EcorePackage.eINSTANCE.getEAnnotation_Details() == feature
+ && DISPLAY_BEHAVIOR
+ .equals(((EAnnotation) msg
+ .getNotifier()).getSource())) {
+ setValue(shouldDisplayBehavior((View) source));
+ }
+ }
+ }
+ };
+ }
+ return sourceListener;
+ }
+
+ @Override
+ protected void doSetValue(Object value) {
+ Object realValue = doGetValue();
+ if (!Util.equals(realValue, value)) {
+ source.eAdapters().remove(sourceListener);
+ super.doSetValue(value);
+ source.eAdapters().add(getSourceListener());
+ }
+ if (!Util.equals(cacheValue, value)) {
+ ValueDiff diff = Diffs.createValueDiff(cacheValue, value);
+ fireValueChange(diff);
+ cacheValue = value;
+ }
+ }
+
+ protected Command getCommand(final Object value) {
+ return getChangeDisplayBehaviorCommand(
+ (TransactionalEditingDomain) domain, (View) source, value);
+ }
+
+ @Override
+ protected Object doGetValue() {
+ Object value = super.doGetValue();
+ if (value == null) {
+ // By default, return true.
+ return "true";
+ }
+ return value;
+ }
+
+ @Override
+ public synchronized void dispose() {
+ if (source != null) {
+ source.eAdapters().remove(sourceListener);
+ }
+ super.dispose();
+ }
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/prop/Environment.xmi b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/prop/Environment.xmi
index e8934cad6db..926e37b589b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/prop/Environment.xmi
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/prop/Environment.xmi
@@ -5,5 +5,6 @@
<modelElementFactories name="Interaction Operand Factory" factoryClass="org.eclipse.papyrus.uml.diagram.sequence.util.InteractionOperandModelElementFactory"/>
<modelElementFactories name="Gate Factory" factoryClass="org.eclipse.papyrus.uml.diagram.sequence.util.GateModelElementFactory"/>
<modelElementFactories name="Link Route Factory" factoryClass="org.eclipse.papyrus.uml.diagram.sequence.util.LinkRouteModelElementFactory"/>
+ <modelElementFactories name="Behavior Factory" factoryClass="org.eclipse.papyrus.uml.diagram.sequence.util.BehaviorDisplayHelper"/>
<constraintTypes label="Duration Link Constraint" constraintClass="org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkConstraint"/>
</environment:Environment>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/prop/seq.ctx b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/prop/seq.ctx
index b174a33884b..52c1aa04741 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/prop/seq.ctx
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/prop/seq.ctx
@@ -14,11 +14,14 @@
<widget href="ui/InteractionOperandGuardVisibility.xwt#/"/>
</sections>
<sections name="LinkRoute" sectionFile="ui/LinkRoute.xwt">
- <widget href="ui/LinkRoute.xwt#/"/>
- </sections>
+ <widget href="ui/LinkRoute.xwt#/"/>
+ </sections>
<sections name="GateNameSection" sectionFile="ui/GateNameSection.xwt">
<widget href="ui/GateNameSection.xwt#/"/>
</sections>
+ <sections name="DisplayBehaviorSection" sectionFile="ui/DisplayBehaviorSection.xwt">
+ <widget href="ui/DisplayBehaviorSection.xwt#/"/>
+ </sections>
</tabs>
<views name="CombinedFragmentTitle" sections="//@tabs.0/@sections.0" automaticContext="true">
<constraints xsi:type="constraints:SimpleConstraint" name="isSingleCombinedFragment">
@@ -46,17 +49,23 @@
</constraints>
</views>
<views name="LinkRoute" sections="//@tabs.0/@sections.4">
- <constraints xsi:type="constraints:SimpleConstraint" name="isMLinkRoute">
- <constraintType href="ppe:/environment/org.eclipse.papyrus.uml.diagram.sequence/model/prop/Environment.xmi#//@constraintTypes.0"/>
- <properties xsi:type="constraints:ValueProperty" name="sourcePart" value="org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart"/>
- </constraints>
- </views>
+ <constraints xsi:type="constraints:SimpleConstraint" name="isMLinkRoute">
+ <constraintType href="ppe:/environment/org.eclipse.papyrus.uml.diagram.sequence/model/prop/Environment.xmi#//@constraintTypes.0"/>
+ <properties xsi:type="constraints:ValueProperty" name="sourcePart" value="org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart"/>
+ </constraints>
+ </views>
<views name="GateName" sections="//@tabs.0/@sections.5">
<constraints xsi:type="constraints:SimpleConstraint" name="isGate">
<constraintType href="ppe:/environment/org.eclipse.papyrus.uml.properties/Model/Environment.xmi#//@constraintTypes.0"/>
<properties xsi:type="constraints:ValueProperty" name="umlClassName" value="Gate"/>
</constraints>
</views>
+ <views name="DisplayBehavior" sections="//@tabs.0/@sections.6">
+ <constraints xsi:type="constraints:SimpleConstraint" name="isBehaviorExecutionSpecification">
+ <constraintType href="ppe:/environment/org.eclipse.papyrus.uml.properties/Model/Environment.xmi#//@constraintTypes.0"/>
+ <properties xsi:type="constraints:ValueProperty" name="umlClassName" value="BehaviorExecutionSpecification"/>
+ </constraints>
+ </views>
<dataContexts name="Preference" label="Preference">
<elements name="org.eclipse.papyrus.infra.gmfdiag.preferences">
<properties name="ELEMENT_PapyrusUMLSequenceDiagram_CombinedFragment_CombinedFragmentCompartment.compartment_name.visibility" label="Show name" type="Boolean" description="Show the Title in the diagram"/>
@@ -87,13 +96,17 @@
<modelElementFactory href="ppe:/environment/org.eclipse.papyrus.uml.diagram.sequence/model/prop/Environment.xmi#//@modelElementFactories.2"/>
</dataContexts>
<dataContexts name="LinkRoute" label="Link Route">
- <elements name="Routing">
- <properties name="style"/>
- </elements>
- <modelElementFactory href="ppe:/environment/org.eclipse.papyrus.uml.diagram.sequence/model/prop/Environment.xmi#//@modelElementFactories.4"/>
+ <elements name="Routing">
+ <properties name="style"/>
+ </elements>
+ <modelElementFactory href="ppe:/environment/org.eclipse.papyrus.uml.diagram.sequence/model/prop/Environment.xmi#//@modelElementFactories.4"/>
</dataContexts>
<dataContexts name="Gate" label="Gate">
<properties name="showName" label="Show Name" type="Boolean" description="Show name on diagram."/>
<modelElementFactory href="ppe:/environment/org.eclipse.papyrus.uml.diagram.sequence/model/prop/Environment.xmi#//@modelElementFactories.3"/>
</dataContexts>
+ <dataContexts name="Behavior" label="Behavior">
+ <properties name="displayBehavior" label="Display" type="Boolean" description="Display Behavior Label."/>
+ <modelElementFactory href="ppe:/environment/org.eclipse.papyrus.uml.diagram.sequence/model/prop/Environment.xmi#//@modelElementFactories.5"/>
+ </dataContexts>
</contexts:Context>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/prop/ui/DisplayBehaviorSection.xwt b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/prop/ui/DisplayBehaviorSection.xwt
new file mode 100644
index 00000000000..61618138542
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/prop/ui/DisplayBehaviorSection.xwt
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Composite
+ xmlns:ppel="clr-namespace:org.eclipse.papyrus.views.properties.widgets.layout"
+ xmlns:x="http://www.eclipse.org/xwt" xmlns:ppe="clr-namespace:org.eclipse.papyrus.views.properties.widgets"
+ xmlns="http://www.eclipse.org/xwt/presentation">
+ <Composite.layout>
+ <ppel:PropertiesLayout></ppel:PropertiesLayout>
+ </Composite.layout>
+ <ppe:BooleanCheckbox input="{Binding}"
+ property="Behavior:displayBehavior" customLabel="Display Behavior Label."></ppe:BooleanCheckbox>
+</Composite> \ No newline at end of file
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml
index 1d7186360a2..74f8bd91ea0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml
@@ -2016,6 +2016,10 @@
class="org.eclipse.papyrus.uml.diagram.sequence.providers.DurationConstraintContributionItem"
id="org.eclipse.papyrus.sequence.duraitonconstraint.DynamicMenu">
</dynamic>
+ <dynamic
+ class="org.eclipse.papyrus.uml.diagram.sequence.providers.DisplayBehaviorContributionItem"
+ id="org.eclipse.papyrus.uml.diagram.sequence.displayBehaviorMenu">
+ </dynamic>
</menuContribution>
</extension>
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}
*/
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/custom-src/org/eclipse/papyrus/uml/diagram/usecase/draw2d/StickMan.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/custom-src/org/eclipse/papyrus/uml/diagram/usecase/draw2d/StickMan.java
index 3d32e87d492..593a7c3a50b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/custom-src/org/eclipse/papyrus/uml/diagram/usecase/draw2d/StickMan.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/custom-src/org/eclipse/papyrus/uml/diagram/usecase/draw2d/StickMan.java
@@ -57,6 +57,7 @@ public class StickMan extends ShadowShape implements IPapyrusNodeNamedElementFig
/**
* Outlines the ellipse.
*/
+ @Override
protected void outlineShape(Graphics graphics, Rectangle bounds) {
PointList pl = setupPoints(bounds);
graphics.drawPolygon(pl);
@@ -67,13 +68,14 @@ public class StickMan extends ShadowShape implements IPapyrusNodeNamedElementFig
/**
* {@inheritDoc}
*/
+ @Override
public Dimension getPreferredSize(int wHint, int hHint) {
Dimension size = new Dimension(-1, -1);
- if (wHint < BASE_W) {
- size.width = (int) BASE_W;
+ if(wHint < BASE_W) {
+ size.width = (int)BASE_W;
}
- if (hHint < BASE_H) {
- size.height = (int) BASE_H;
+ if(hHint < BASE_H) {
+ size.height = (int)BASE_H;
}
if(is3D()) {
size.expand(SHADOW_SIZE, SHADOW_SIZE);
@@ -84,6 +86,7 @@ public class StickMan extends ShadowShape implements IPapyrusNodeNamedElementFig
/**
* Fills the ellipse.
*/
+ @Override
protected void fillShape(Graphics graphics, Rectangle bounds) {
PointList pl = setupPoints(bounds);
graphics.fillPolygon(pl);
@@ -158,82 +161,129 @@ public class StickMan extends ShadowShape implements IPapyrusNodeNamedElementFig
return pl;
}
+ @Override
public void setStereotypePropertiesInBrace(String stereotypeProperties) {
// TODO Auto-generated method stub
}
+ @Override
public void setStereotypePropertiesInCompartment(String stereotypeProperties) {
// TODO Auto-generated method stub
}
+ @Override
public Label getStereotypesLabel() {
// TODO Auto-generated method stub
return null;
}
+ @Override
public void setStereotypeDisplay(String stereotypes, Image image) {
// TODO Auto-generated method stub
}
+ @Override
public void setQualifiedName(String qualifiedName) {
// TODO Auto-generated method stub
}
+ @Override
public Label getQualifiedNameLabel() {
// TODO Auto-generated method stub
return null;
}
+ @Override
public Label getTaggedLabel() {
// TODO Auto-generated method stub
return null;
}
+ @Override
public void setDepth(int depth) {
// TODO Auto-generated method stub
}
+ @Override
public WrappingLabel getNameLabel() {
// TODO Auto-generated method stub
return null;
}
+ @Override
public void setNameLabelIcon(boolean displayNameLabelIcon) {
// TODO Auto-generated method stub
}
+ @Override
public Color getBorderColor() {
// TODO Auto-generated method stub
return null;
}
+ @Override
public boolean isShadow() {
// TODO Auto-generated method stub
return false;
}
+ @Override
public void setBorderColor(Color borderColor) {
// TODO Auto-generated method stub
-
+
}
+ @Override
public void setShadow(boolean shadow) {
// TODO Auto-generated method stub
-
+
}
+ @Override
public void setTransparency(int transparency) {
// TODO Auto-generated method stub
-
+
}
+ @Override
public void setGradientData(int gradientColor1, int gradientColor2, int gradientStyle) {
// TODO Auto-generated method stub
-
+
}
+ @Override
public void setIsUsingGradient(boolean b) {
// TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void restoreNameLabel() {
+ //Nothing. StickMan uses a floating label and should not implement this method
+ }
+
+ @Override
+ public void removeNameLabel() {
+ //Nothing. StickMan uses a floating label and should not implement this method
+ }
+
+ @Override
+ public void removeStereotypeLabel() {
+
+ }
+
+ @Override
+ public void restoreStereotypeLabel() {
+
+ }
+
+ @Override
+ public void restoreTaggedLabel() {
+
+ }
+
+ @Override
+ public void removeTaggedLabel() {
}
}
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/META-INF/MANIFEST.MF b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/META-INF/MANIFEST.MF
index a7de579937f..e07344f581f 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/META-INF/MANIFEST.MF
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.papyrus.uml.nattable.xtext.integration
Bundle-Version: 0.10.1.qualifier
-Bundle-Activator: org.eclipse.papyrus.infra.nattable.xtext.integration.Activator
+Bundle-Activator: org.eclipse.papyrus.uml.nattable.xtext.integration.Activator
Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
@@ -21,4 +21,6 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.gmf.runtime.common.ui.services
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.papyrus.infra.nattable.xtext.integration.celleditor
+Export-Package: org.eclipse.papyrus.uml.nattable.xtext.integration,
+ org.eclipse.papyrus.uml.nattable.xtext.integration.celleditor,
+ org.eclipse.papyrus.uml.nattable.xtext.integration.util
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/Activator.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/uml/nattable/xtext/integration/Activator.java
index 33574d1f36b..65877a33d92 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/Activator.java
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/uml/nattable/xtext/integration/Activator.java
@@ -1,4 +1,4 @@
-package org.eclipse.papyrus.infra.nattable.xtext.integration;
+package org.eclipse.papyrus.uml.nattable.xtext.integration;
import org.eclipse.papyrus.infra.core.log.LogHelper;
import org.eclipse.ui.plugin.AbstractUIPlugin;
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/celleditor/AbstractNatTableXTextCellEditor.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/uml/nattable/xtext/integration/celleditor/AbstractNatTableXTextCellEditor.java
index d068294aa8b..963d85c3fa7 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/celleditor/AbstractNatTableXTextCellEditor.java
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/uml/nattable/xtext/integration/celleditor/AbstractNatTableXTextCellEditor.java
@@ -11,7 +11,7 @@
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
*
*****************************************************************************/
-package org.eclipse.papyrus.infra.nattable.xtext.integration.celleditor;
+package org.eclipse.papyrus.uml.nattable.xtext.integration.celleditor;
import java.util.List;
@@ -25,7 +25,7 @@ import org.eclipse.papyrus.infra.nattable.celleditor.AbstractPapyrusStyledTextCe
import org.eclipse.papyrus.infra.nattable.manager.table.ITableAxisElementProvider;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableproblem.StringResolutionProblem;
-import org.eclipse.papyrus.infra.nattable.xtext.integration.util.XTextEditorResultWrapper;
+import org.eclipse.papyrus.uml.nattable.xtext.integration.util.XTextEditorResultWrapper;
import org.eclipse.papyrus.uml.xtext.integration.DefaultXtextDirectEditorConfiguration;
import org.eclipse.papyrus.uml.xtext.integration.XtextFakeResourceContext;
import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter;
@@ -179,8 +179,7 @@ public abstract class AbstractNatTableXTextCellEditor extends AbstractPapyrusSty
if(styledText != null) {
typedString = styledText.getText();
final IParserEditStatus result = parser.isValidEditString(null, typedString);
- System.out.println(result);
- if(result.isOK()) {
+ if(result!=null && result.isOK()) {
parseCommand = parser.getParseCommand(null, typedString, 0);
}
}
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/util/XTextEditorResultWrapper.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/uml/nattable/xtext/integration/util/XTextEditorResultWrapper.java
index 6c866a80702..4854a6115ef 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/util/XTextEditorResultWrapper.java
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/uml/nattable/xtext/integration/util/XTextEditorResultWrapper.java
@@ -1,4 +1,4 @@
-package org.eclipse.papyrus.infra.nattable.xtext.integration.util;
+package org.eclipse.papyrus.uml.nattable.xtext.integration.util;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
@@ -30,7 +30,7 @@ public class XTextEditorResultWrapper implements IAdaptable {
* the command to do the set value according to the typed text. Could be <code>null</code> if the text can't be parsed
*/
public XTextEditorResultWrapper(String text, ICommand parseCommand) {
- this.text = text;
+ this.text = text.trim();//to remove invalid /r/n at the end of the string, see bug 420495
this.parseCommand = parseCommand;
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ConnectorReorientCommand.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ConnectorReorientCommand.java
index 47fcabd0b7a..96a464caf0d 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ConnectorReorientCommand.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ConnectorReorientCommand.java
@@ -77,7 +77,11 @@ public class ConnectorReorientCommand extends ConnectorReorientSemanticCommand {
super.initFields();
reorientedEdgeView = RequestParameterUtils.getReconnectedEdge(getRequest());
newEndView = RequestParameterUtils.getReconnectedEndView(getRequest());
- oppositeEndView = (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) ? reorientedEdgeView.getTarget() : reorientedEdgeView.getSource();
+ if(this.reorientedEdgeView != null) {
+ oppositeEndView = (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) ? reorientedEdgeView.getTarget() : reorientedEdgeView.getSource();
+ } else {
+ oppositeEndView = null;
+ }
setNewPartWithPort(getNewPartWithPort());
setOppositePartWithPort(getOppositePartWithPort());
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ConnectorReorientSemanticCommand.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ConnectorReorientSemanticCommand.java
index f7887f3568e..1fa6881f9ee 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ConnectorReorientSemanticCommand.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/ConnectorReorientSemanticCommand.java
@@ -136,6 +136,9 @@ public class ConnectorReorientSemanticCommand extends EditElementCommand {
* <code>true</code> if the newRole can be used as role for connector
*/
private boolean canReorient(final EObject newRole, final EObject oppositeRole) {
+ if(newRole==null){
+ return true;//we allow to reinitialize the role
+ }
//the new role must be a connectable element
if(!(newRole instanceof ConnectableElement)) {
return false;
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/ClassifierUtils.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/ClassifierUtils.java
index 1ccdcebb614..a6c5e363374 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/ClassifierUtils.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/ClassifierUtils.java
@@ -14,6 +14,9 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.utils;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.emf.ecore.EObject;
import org.eclipse.uml2.uml.Artifact;
import org.eclipse.uml2.uml.Class;
@@ -45,6 +48,20 @@ public class ClassifierUtils {
}
/**
+ * This method provides a switch to ease the addition of a new Property in a Classifier.
+ *
+ * @param classifier
+ * the parent classifier.
+ * @param property
+ * the contained property.
+ * @return false if the addition fails.
+ */
+ public static List<Property> getOwnedAttributes(Classifier classifier) {
+ GetOwnedAttributesSwitch classifierSwitch = new GetOwnedAttributesSwitch();
+ return classifierSwitch.doSwitch(classifier);
+ }
+
+ /**
* Switch implementation for Property addition.
*/
private static class AddOwnedAttributeSwitch extends UMLSwitch<Boolean> {
@@ -98,4 +115,50 @@ public class ClassifierUtils {
return Boolean.FALSE;
}
};
+
+ /**
+ * Switch implementation for Property addition.
+ */
+ private static class GetOwnedAttributesSwitch extends UMLSwitch<List<Property>> {
+
+ public GetOwnedAttributesSwitch() {
+ super();
+ }
+
+ @Override
+ public List<Property> caseArtifact(Artifact object) {
+ return object.getOwnedAttributes();
+ }
+
+ @Override
+ public List<Property> caseDataType(DataType object) {
+ return object.getOwnedAttributes();
+ }
+
+ @Override
+ public List<Property> caseInterface(Interface object) {
+ return object.getOwnedAttributes();
+ }
+
+ @Override
+ public List<Property> caseSignal(Signal object) {
+ return object.getOwnedAttributes();
+ }
+
+ @Override
+ public List<Property> caseStructuredClassifier(StructuredClassifier object) {
+ return object.getOwnedAttributes();
+ }
+
+ @Override
+ public List<Property> caseClass(Class object) {
+ return object.getOwnedAttributes();
+ }
+
+ @Override
+ public List<Property> defaultCase(EObject object) {
+ return new ArrayList<Property>();
+ }
+ };
+
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/NamedElementHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/NamedElementHelper.java
index b728c97c4f2..b32eb5875a4 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/NamedElementHelper.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/NamedElementHelper.java
@@ -115,15 +115,21 @@ public class NamedElementHelper {
this.baseString = baseString;
}
- @SuppressWarnings("rawtypes")
- public static String getDefaultNameWithIncrementFromBase(String base, Collection contents) {
- return getDefaultNameWithIncrementFromBase(base, contents, null);
+ public static String getDefaultNameWithIncrementFromBase(String base, Collection<?> contents) {
+ return getDefaultNameWithIncrementFromBase(base, contents, null, "");
+ }
+
+ public static String getDefaultNameWithIncrementFromBase(String base, Collection<?> contents, String separator) {
+ return getDefaultNameWithIncrementFromBase(base, contents, null, separator);
}
- @SuppressWarnings("rawtypes")
- public static String getDefaultNameWithIncrementFromBase(String base, Collection contents, EObject elementToRename) {
- // Not change the name if elementToRename already present in the contents collection
- if (contents.contains(elementToRename)) {
+ public static String getDefaultNameWithIncrementFromBase(String base, Collection<?> contents, EObject elementToRename) {
+ return getDefaultNameWithIncrementFromBase(base, contents, elementToRename, "");
+ }
+
+ public static String getDefaultNameWithIncrementFromBase(String base, Collection<?> contents, EObject elementToRename, String separator) {
+ // Not change the name if elementToRename already present in the contents collection and already have a name
+ if (contents.contains(elementToRename) && EMFCoreUtil.getName(elementToRename) != null) {
if (elementToRename instanceof ENamedElement) {
return ((ENamedElement)elementToRename).getName();
}
@@ -136,7 +142,7 @@ public class NamedElementHelper {
if("property".equalsIgnoreCase(base)) {
base = "Attribute";
}
- int nextNumber = 1;
+ int nextNumber = 0;
for(Object o : contents) {
if(o instanceof EObject && o != elementToRename) {
@@ -157,6 +163,6 @@ public class NamedElementHelper {
}
}
- return base + nextNumber;
+ return nextNumber > 0 ? base + separator + nextNumber : base;
}
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ProfileApplicationEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ProfileApplicationEditor.java
index 9d434806108..2941d14fbac 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ProfileApplicationEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ProfileApplicationEditor.java
@@ -1,350 +1,353 @@
-/*****************************************************************************
- * Copyright (c) 2011, 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- * Christian W. Damus (CEA) - Refactoring package/profile import/apply UI for CDO
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.properties.widgets;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.widgets.editors.MultipleReferenceEditor;
-import org.eclipse.papyrus.uml.profile.definition.Version;
-import org.eclipse.papyrus.uml.profile.ui.dialogs.ElementImportTreeSelectionDialog.ImportSpec;
-import org.eclipse.papyrus.uml.profile.ui.dialogs.ProfileTreeSelectionDialog;
-import org.eclipse.papyrus.uml.profile.utils.Util;
-import org.eclipse.papyrus.uml.profile.validation.ProfileValidationHelper;
-import org.eclipse.papyrus.uml.properties.Activator;
-import org.eclipse.papyrus.uml.properties.messages.Messages;
-import org.eclipse.papyrus.uml.properties.profile.ui.dialogs.Message;
-import org.eclipse.papyrus.uml.properties.profile.ui.dialogs.RegisteredProfileSelectionDialog;
-import org.eclipse.papyrus.uml.tools.importsources.PackageImportSourceDialog;
-import org.eclipse.papyrus.uml.tools.utils.ProfileUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Profile;
-
-/**
- * An editor for Profile application
- *
- * @author Camille Letavernier
- */
-public class ProfileApplicationEditor extends MultipleReferenceEditor {
-
- /**
- * The button to add profiles from the list of registered ones
- */
- protected Button addRegisteredProfile;
-
- /**
- * The button to reapply a profile
- */
- protected Button reapplyProfile;
-
- /**
- * The umlPackage being edited
- */
- protected Package umlPackage;
-
- /**
- *
- * Constructor.
- *
- * @param parent
- * @param style
- */
- public ProfileApplicationEditor(Composite parent, int style) {
- super(parent, style);
-
- tree.setHeaderVisible(true);
- GridData treeData = new GridData(SWT.FILL, SWT.FILL, true, true);
- treeData.horizontalSpan = 2;
- treeData.minimumHeight = 140;
- tree.setLayoutData(treeData);
-
- TableLayout layout = new TableLayout(true);
- tree.setLayout(layout);
-
- TreeColumn nameColumn = new TreeColumn(tree, SWT.NONE);
- nameColumn.setText("Name");
- layout.addColumnData(new ColumnWeightData(40, 400, true));
-
- TreeColumn locationColumn = new TreeColumn(tree, SWT.NONE);
- locationColumn.setText("Location");
- layout.addColumnData(new ColumnWeightData(30, 300, true));
-
- TreeColumn versionColumn = new TreeColumn(tree, SWT.NONE);
- versionColumn.setText("Version");
- layout.addColumnData(new ColumnWeightData(10, 100, true));
- }
-
- @Override
- public void setToolTipText(String text) {
- //Override to avoid displaying a tooltip on the tree. It prevents the Cells tooltips from working
- super.setLabelToolTipText(text);
- }
-
- @Override
- public void setLabelProvider(ILabelProvider labelProvider) {
- super.setLabelProvider(new ProfileColumnsLabelProvider(labelProvider));
- }
-
- protected class ProfileColumnsLabelProvider extends ColumnLabelProvider {
-
- private ILabelProvider defaultLabelProvider;
-
- public ProfileColumnsLabelProvider(ILabelProvider defaultLabelProvider) {
- this.defaultLabelProvider = defaultLabelProvider;
- }
-
- @Override
- public void update(ViewerCell cell) {
- if(cell.getColumnIndex() == 0) {
- updateName(cell);
- return;
- }
-
- Profile profile;
- EObject element = EMFHelper.getEObject(cell.getElement());
-
- if(element instanceof Profile) {
- profile = (Profile)element;
- } else {
- cell.setText("");
- return;
- }
-
- switch(cell.getColumnIndex()) {
- case 1:
- updateLocation(cell, profile);
- break;
- case 2:
- updateVersion(cell, profile);
- break;
- }
-
- }
-
- public void updateName(ViewerCell cell) {
- cell.setImage(defaultLabelProvider.getImage(cell.getElement()));
- cell.setText(defaultLabelProvider.getText(cell.getElement()));
- }
-
- public void updateLocation(ViewerCell cell, Profile profile) {
- String location = "Unknown";
- if(profile.eResource() != null) {
- URI uri = profile.eResource().getURI();
- if(uri != null) {
- location = uri.toString();
- }
- }
-
- cell.setText(location);
- }
-
- public void updateVersion(ViewerCell cell, Profile profile) {
- String versionText = "";
- Version version = Util.getProfileDefinitionVersion(profile);
- if(version != Version.emptyVersion) {
- versionText = version.toString();
- }
-
- cell.setText(versionText);
- }
- }
-
- @Override
- protected void createListControls() {
- super.createListControls();
- up.dispose();
- down.dispose();
- edit.dispose();
- up = down = edit = null;
-
- add.setToolTipText(Messages.ProfileApplicationEditor_ApplyProfile);
- addRegisteredProfile = createButton(Activator.getDefault().getImage("/icons/AddReg.gif"), Messages.ProfileApplicationEditor_ApplyRegisteredProfile); //$NON-NLS-1$
-
- reapplyProfile = createButton(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("/icons/refresh.gif"), "Reapply profile");
- treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- updateControls();
- }
- });
- }
-
- /**
- * Applies a profile from workspace
- *
- * @see org.eclipse.papyrus.infra.widgets.editors.MultipleValueEditor#addAction()
- *
- */
- @Override
- protected void addAction() {
- //Code from org.eclipse.papyrus.uml.profile.ui.compositesformodel.AppliedProfileCompositeOnModel#applyProfileButtonPressed()
-
-
- // Create and open the dialog box
- // ResourceSelectionDialog dialog =
- // new ResourceSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), "Apply Profiles");
-
- Map<String, String> extensionFilters = new LinkedHashMap<String, String>();
- extensionFilters.put("*.profile.uml", "UML Profiles (*.profile.uml)");
- extensionFilters.put("*.uml", "UML (*.uml)");
- extensionFilters.put("*", "All (*)");
-
- Collection<Package> packages = PackageImportSourceDialog.open(getShell(), Messages.ProfileApplicationEditor_ApplyProfilesDialogTitle, Collections.singletonList(umlPackage), extensionFilters);
-
- // If nothing is selected : abort
- if((packages == null) || packages.isEmpty()) {
- return;
- }
-
- if(packages.size() > 0) {
- ProfileTreeSelectionDialog profileDialog = new ProfileTreeSelectionDialog(getShell(), packages);
-
- if(profileDialog.open() != Window.OK) {
- return;
- }
-
- if(profileDialog.getResult().isEmpty()) {
- return;
- }
-
- Collection<ImportSpec<Profile>> profilesImportToApply = profileDialog.getResult();
-
- Collection<Profile> profilesToApply = new LinkedList<Profile>();
- for(ImportSpec<Profile> importProfile : profilesImportToApply) {
- profilesToApply.add(importProfile.getElement());
- }
-
- if(!ProfileValidationHelper.checkApplicableProfiles(getShell(), profilesToApply)) {
- return;
- }
-
- Message message = new Message(Messages.ProfileApplicationEditor_WaitMessageTitle, Messages.ProfileApplicationEditor_WaitMessage);
- message.open();
- for(Profile profile : profilesToApply) {
- modelProperty.add(profile);
- }
- message.close();
- commit();
- }
- }
-
- /**
- * Applies a profile from the registry
- */
- protected void addRegisteredAction() {
- RegisteredProfileSelectionDialog profileSelectionDialog = new RegisteredProfileSelectionDialog(getShell(), umlPackage);
- List<Profile> profilesToApply = profileSelectionDialog.run();
- for(Profile profile : profilesToApply) {
- modelProperty.add(profile);
- }
-
- commit();
- }
-
- protected void reapplyProfileAction() {
- ISelection selectedElements = treeViewer.getSelection();
-
- //Filter profiles
- List<Profile> profilesToRefresh = new LinkedList<Profile>();
- if(!selectedElements.isEmpty() && selectedElements instanceof IStructuredSelection) {
- IStructuredSelection selection = (IStructuredSelection)selectedElements;
- Iterator<?> iterator = selection.iterator();
- while(iterator.hasNext()) {
- Object element = iterator.next();
- if(element instanceof Profile) {
- profilesToRefresh.add((Profile)element);
- }
- }
- }
-
- //Check validity
- if(ProfileValidationHelper.checkApplicableProfiles(getShell(), profilesToRefresh)) {
- //If everything is fine, refresh the profiles
- for(Profile profile : profilesToRefresh) {
- modelProperty.add(profile);
- }
-
- commit();
- }
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- super.widgetSelected(e);
- if(e.widget == addRegisteredProfile) {
- addRegisteredAction();
- }
- if(e.widget == reapplyProfile) {
- reapplyProfileAction();
- }
- }
-
- /**
- * Sets the package on which the profiles will be applied
- *
- * @param umlPackage
- */
- public void setPackage(Package umlPackage) {
- this.umlPackage = umlPackage;
- updateControls();
- }
-
- @Override
- protected void updateControls() {
- boolean enabled = modelProperty != null && umlPackage != null;
- add.setEnabled(enabled);
- addRegisteredProfile.setEnabled(enabled);
- remove.setEnabled(enabled);
-
- // check whether the selection can be reapplied
- IStructuredSelection selection = (IStructuredSelection)treeViewer.getSelection();
- enabled = false;
- Iterator<?> iterator = selection.iterator();
- while(iterator.hasNext()) {
- Object element = iterator.next();
- if(element instanceof Profile) {
- if(ProfileUtil.isDirty(umlPackage, (Profile)element)) {
- enabled = true; //At least one dirty profile is selected
- break;
- }
- }
- }
-
- reapplyProfile.setEnabled(enabled);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2011, 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - Refactoring package/profile import/apply UI for CDO
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.properties.widgets;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.widgets.editors.MultipleReferenceEditor;
+import org.eclipse.papyrus.uml.profile.definition.Version;
+import org.eclipse.papyrus.uml.profile.ui.dialogs.ElementImportTreeSelectionDialog.ImportSpec;
+import org.eclipse.papyrus.uml.profile.ui.dialogs.ProfileTreeSelectionDialog;
+import org.eclipse.papyrus.uml.profile.utils.Util;
+import org.eclipse.papyrus.uml.profile.validation.ProfileValidationHelper;
+import org.eclipse.papyrus.uml.properties.Activator;
+import org.eclipse.papyrus.uml.properties.messages.Messages;
+import org.eclipse.papyrus.uml.properties.profile.ui.dialogs.Message;
+import org.eclipse.papyrus.uml.properties.profile.ui.dialogs.RegisteredProfileSelectionDialog;
+import org.eclipse.papyrus.uml.tools.importsources.PackageImportSourceDialog;
+import org.eclipse.papyrus.uml.tools.utils.ProfileUtil;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+
+/**
+ * An editor for Profile application
+ *
+ * @author Camille Letavernier
+ */
+public class ProfileApplicationEditor extends MultipleReferenceEditor {
+
+ /**
+ * The button to add profiles from the list of registered ones
+ */
+ protected Button addRegisteredProfile;
+
+ /**
+ * The button to reapply a profile
+ */
+ protected Button reapplyProfile;
+
+ /**
+ * The umlPackage being edited
+ */
+ protected Package umlPackage;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parent
+ * @param style
+ */
+ public ProfileApplicationEditor(Composite parent, int style) {
+ super(parent, style);
+
+ tree.setHeaderVisible(true);
+ GridData treeData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ treeData.horizontalSpan = 2;
+ treeData.minimumHeight = 140;
+ tree.setLayoutData(treeData);
+
+ TableLayout layout = new TableLayout(true);
+ tree.setLayout(layout);
+
+ TreeColumn nameColumn = new TreeColumn(tree, SWT.NONE);
+ nameColumn.setText("Name");
+ layout.addColumnData(new ColumnWeightData(40, 400, true));
+
+ TreeColumn locationColumn = new TreeColumn(tree, SWT.NONE);
+ locationColumn.setText("Location");
+ layout.addColumnData(new ColumnWeightData(30, 300, true));
+
+ TreeColumn versionColumn = new TreeColumn(tree, SWT.NONE);
+ versionColumn.setText("Version");
+ layout.addColumnData(new ColumnWeightData(10, 100, true));
+ }
+
+ @Override
+ public void setToolTipText(String text) {
+ //Override to avoid displaying a tooltip on the tree. It prevents the Cells tooltips from working
+ super.setLabelToolTipText(text);
+ }
+
+ @Override
+ public void setLabelProvider(ILabelProvider labelProvider) {
+ super.setLabelProvider(new ProfileColumnsLabelProvider(labelProvider));
+ }
+
+ protected class ProfileColumnsLabelProvider extends ColumnLabelProvider {
+
+ private ILabelProvider defaultLabelProvider;
+
+ public ProfileColumnsLabelProvider(ILabelProvider defaultLabelProvider) {
+ this.defaultLabelProvider = defaultLabelProvider;
+ }
+
+ @Override
+ public void update(ViewerCell cell) {
+ if(cell.getColumnIndex() == 0) {
+ updateName(cell);
+ return;
+ }
+
+ Profile profile;
+ EObject element = EMFHelper.getEObject(cell.getElement());
+
+ if(element instanceof Profile) {
+ profile = (Profile)element;
+ } else {
+ cell.setText("");
+ return;
+ }
+
+ switch(cell.getColumnIndex()) {
+ case 1:
+ updateLocation(cell, profile);
+ break;
+ case 2:
+ updateVersion(cell, profile);
+ break;
+ }
+
+ }
+
+ public void updateName(ViewerCell cell) {
+ cell.setImage(defaultLabelProvider.getImage(cell.getElement()));
+ cell.setText(defaultLabelProvider.getText(cell.getElement()));
+ }
+
+ public void updateLocation(ViewerCell cell, Profile profile) {
+ String location = "Unknown";
+ if(profile.eIsProxy()) {
+ location = EcoreUtil.getURI(profile).trimFragment().toString();
+ } else if(profile.eResource() != null) {
+ URI uri = profile.eResource().getURI();
+ if(uri != null) {
+ location = uri.toString();
+ }
+ }
+
+ cell.setText(location);
+ }
+
+ public void updateVersion(ViewerCell cell, Profile profile) {
+ String versionText = "";
+ Version version = Util.getProfileDefinitionVersion(profile);
+ if(version != Version.emptyVersion) {
+ versionText = version.toString();
+ }
+
+ cell.setText(versionText);
+ }
+ }
+
+ @Override
+ protected void createListControls() {
+ super.createListControls();
+ up.dispose();
+ down.dispose();
+ edit.dispose();
+ up = down = edit = null;
+
+ add.setToolTipText(Messages.ProfileApplicationEditor_ApplyProfile);
+ addRegisteredProfile = createButton(Activator.getDefault().getImage("/icons/AddReg.gif"), Messages.ProfileApplicationEditor_ApplyRegisteredProfile); //$NON-NLS-1$
+
+ reapplyProfile = createButton(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("/icons/refresh.gif"), "Reapply profile");
+ treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateControls();
+ }
+ });
+ }
+
+ /**
+ * Applies a profile from workspace
+ *
+ * @see org.eclipse.papyrus.infra.widgets.editors.MultipleValueEditor#addAction()
+ *
+ */
+ @Override
+ protected void addAction() {
+ //Code from org.eclipse.papyrus.uml.profile.ui.compositesformodel.AppliedProfileCompositeOnModel#applyProfileButtonPressed()
+
+
+ // Create and open the dialog box
+ // ResourceSelectionDialog dialog =
+ // new ResourceSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), "Apply Profiles");
+
+ Map<String, String> extensionFilters = new LinkedHashMap<String, String>();
+ extensionFilters.put("*.profile.uml", "UML Profiles (*.profile.uml)");
+ extensionFilters.put("*.uml", "UML (*.uml)");
+ extensionFilters.put("*", "All (*)");
+
+ Collection<Package> packages = PackageImportSourceDialog.open(getShell(), Messages.ProfileApplicationEditor_ApplyProfilesDialogTitle, Collections.singletonList(umlPackage), extensionFilters);
+
+ // If nothing is selected : abort
+ if((packages == null) || packages.isEmpty()) {
+ return;
+ }
+
+ if(packages.size() > 0) {
+ ProfileTreeSelectionDialog profileDialog = new ProfileTreeSelectionDialog(getShell(), packages);
+
+ if(profileDialog.open() != Window.OK) {
+ return;
+ }
+
+ if(profileDialog.getResult().isEmpty()) {
+ return;
+ }
+
+ Collection<ImportSpec<Profile>> profilesImportToApply = profileDialog.getResult();
+
+ Collection<Profile> profilesToApply = new LinkedList<Profile>();
+ for(ImportSpec<Profile> importProfile : profilesImportToApply) {
+ profilesToApply.add(importProfile.getElement());
+ }
+
+ if(!ProfileValidationHelper.checkApplicableProfiles(getShell(), profilesToApply)) {
+ return;
+ }
+
+ Message message = new Message(Messages.ProfileApplicationEditor_WaitMessageTitle, Messages.ProfileApplicationEditor_WaitMessage);
+ message.open();
+ for(Profile profile : profilesToApply) {
+ modelProperty.add(profile);
+ }
+ message.close();
+ commit();
+ }
+ }
+
+ /**
+ * Applies a profile from the registry
+ */
+ protected void addRegisteredAction() {
+ RegisteredProfileSelectionDialog profileSelectionDialog = new RegisteredProfileSelectionDialog(getShell(), umlPackage);
+ List<Profile> profilesToApply = profileSelectionDialog.run();
+ for(Profile profile : profilesToApply) {
+ modelProperty.add(profile);
+ }
+
+ commit();
+ }
+
+ protected void reapplyProfileAction() {
+ ISelection selectedElements = treeViewer.getSelection();
+
+ //Filter profiles
+ List<Profile> profilesToRefresh = new LinkedList<Profile>();
+ if(!selectedElements.isEmpty() && selectedElements instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection)selectedElements;
+ Iterator<?> iterator = selection.iterator();
+ while(iterator.hasNext()) {
+ Object element = iterator.next();
+ if(element instanceof Profile) {
+ profilesToRefresh.add((Profile)element);
+ }
+ }
+ }
+
+ //Check validity
+ if(ProfileValidationHelper.checkApplicableProfiles(getShell(), profilesToRefresh)) {
+ //If everything is fine, refresh the profiles
+ for(Profile profile : profilesToRefresh) {
+ modelProperty.add(profile);
+ }
+
+ commit();
+ }
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
+ if(e.widget == addRegisteredProfile) {
+ addRegisteredAction();
+ }
+ if(e.widget == reapplyProfile) {
+ reapplyProfileAction();
+ }
+ }
+
+ /**
+ * Sets the package on which the profiles will be applied
+ *
+ * @param umlPackage
+ */
+ public void setPackage(Package umlPackage) {
+ this.umlPackage = umlPackage;
+ updateControls();
+ }
+
+ @Override
+ protected void updateControls() {
+ boolean enabled = modelProperty != null && umlPackage != null;
+ add.setEnabled(enabled);
+ addRegisteredProfile.setEnabled(enabled);
+ remove.setEnabled(enabled);
+
+ // check whether the selection can be reapplied
+ IStructuredSelection selection = (IStructuredSelection)treeViewer.getSelection();
+ enabled = false;
+ Iterator<?> iterator = selection.iterator();
+ while(iterator.hasNext()) {
+ Object element = iterator.next();
+ if(element instanceof Profile) {
+ if(ProfileUtil.isDirty(umlPackage, (Profile)element)) {
+ enabled = true; //At least one dirty profile is selected
+ break;
+ }
+ }
+ }
+
+ reapplyProfile.setEnabled(enabled);
+ }
+} \ No newline at end of file
diff --git a/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/META-INF/MANIFEST.MF b/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/META-INF/MANIFEST.MF
index e1347f5e498..c2c35eb38e4 100644
--- a/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/META-INF/MANIFEST.MF
+++ b/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/META-INF/MANIFEST.MF
@@ -14,10 +14,12 @@ Require-Bundle: org.eclipse.gef;bundle-version="3.9.0",
org.eclipse.papyrus.uml.xtext.integration.core;bundle-version="0.10.1";visibility:=reexport,
org.eclipse.papyrus.extensionpoints.editors;bundle-version="0.10.1";visibility:=reexport,
org.eclipse.uml2.uml;bundle-version="4.1.0",
- org.eclipse.papyrus.uml.tools.utils;bundle-version="0.10.1"
+ org.eclipse.papyrus.uml.tools.utils;bundle-version="0.10.1",
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.1"
Export-Package: org.eclipse.papyrus.uml.xtext.integration
Bundle-Vendor: Eclipse Modeling Project
Import-Package: org.eclipse.papyrus.infra.services.validation,
org.eclipse.papyrus.infra.services.validation.commands,
org.eclipse.papyrus.uml.extensionpoints.profile,
org.eclipse.papyrus.uml.extensionpoints.standard
+Bundle-Activator: org.eclipse.papyrus.uml.xtext.integration.ui.Activator
diff --git a/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/ui/Activator.java b/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/ui/Activator.java
new file mode 100644
index 00000000000..25f3f7a7fec
--- /dev/null
+++ b/plugins/uml/xtext/org.eclipse.papyrus.uml.xtext.integration.ui/src/org/eclipse/papyrus/uml/xtext/integration/ui/Activator.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.xtext.integration.ui;
+
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.uml.xtext.integration.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ public static LogHelper log;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}

Back to the top