Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2013-10-23 11:33:46 -0400
committerCamille Letavernier2013-10-23 11:33:46 -0400
commita1179807d265b8c27e6d675cd515147ea1e023a7 (patch)
treecbfb13c66de6640edbc9072bb490e568baca0380
parent788c36ded6127d2b70900fc39a15c90990c1f21d (diff)
downloadorg.eclipse.papyrus-a1179807d265b8c27e6d675cd515147ea1e023a7.tar.gz
org.eclipse.papyrus-a1179807d265b8c27e6d675cd515147ea1e023a7.tar.xz
org.eclipse.papyrus-a1179807d265b8c27e6d675cd515147ea1e023a7.zip
420173: [All diagrams] Symbol may be displayed without respect ratio
https://bugs.eclipse.org/bugs/show_bug.cgi?id=420173 419965: Display of the name must be optional https://bugs.eclipse.org/bugs/show_bug.cgi?id=419965
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/BorderDisplayEditPolicy.java54
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaintainSymbolRatioEditPolicy.java51
2 files changed, 51 insertions, 54 deletions
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
index bf69f75dc6f..b0a42c813d3 100644
--- 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
@@ -26,9 +26,10 @@ 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.NotationPackage;
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.infra.emf.utils.EMFHelper;
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;
@@ -63,6 +64,7 @@ public class BorderDisplayEditPolicy extends GraphicalEditPolicy implements Noti
*
* {@inheritDoc}
*/
+ @Override
public void activate() {
// retrieve the view and the element managed by the edit part
View view = (View)getHost().getModel();
@@ -74,6 +76,11 @@ public class BorderDisplayEditPolicy extends GraphicalEditPolicy implements Noti
// editpart
getDiagramEventBroker().addNotificationListener(view, this);
+ EObject semanticElement = EMFHelper.getEObject(getHost());
+ if(semanticElement instanceof NamedElement) {
+ hostSemanticNamedElement = (NamedElement)semanticElement;
+ }
+
if(hostSemanticNamedElement == null) {
return;
}
@@ -87,52 +94,43 @@ public class BorderDisplayEditPolicy extends GraphicalEditPolicy implements Noti
*/
protected void refreshBorder() {
if(getHost() instanceof NamedElementEditPart) {
- NamedElementEditPart namedElementEditPart=(NamedElementEditPart)getHost();
- BooleanValueStyle boderStyle=getBorderStyle(namedElementEditPart.getNotationView());
- if(boderStyle!=null && boderStyle.isBooleanValue()==false){
+ 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){
+ if(currentEditPart instanceof ResizableCompartmentEditPart) {
((ResizableCompartmentEditPart)currentEditPart).getFigure().setBorder(null);
}
-
+
}
-
- }
- else{
+
+ } else {
namedElementEditPart.getPrimaryShape().setBorder(new LineBorder());
for(Object currentEditPart : namedElementEditPart.getChildren()) {
- if(currentEditPart instanceof ResizableCompartmentEditPart){
+ 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;
-
+ /**
+ *
+ * @param currentView
+ * @return the current Style that repersent the boder
+ */
+ protected BooleanValueStyle getBorderStyle(View currentView) {
+ return (BooleanValueStyle)currentView.getNamedStyle(NotationPackage.eINSTANCE.getBooleanValueStyle(), DISPLAY_BORDER);
}
+
/**
*
* {@inheritDoc}
*/
+ @Override
public void deactivate() {
// retrieve the view and the element managed by the edit part
View view = (View)getHost().getModel();
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaintainSymbolRatioEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaintainSymbolRatioEditPolicy.java
index 981a8f61e37..d5cd7701e43 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaintainSymbolRatioEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaintainSymbolRatioEditPolicy.java
@@ -23,8 +23,10 @@ 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.notation.BooleanValueStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.core.listenerservice.IPapyrusListener;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ShapeDisplayCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart;
import org.eclipse.papyrus.uml.diagram.common.figure.node.NodeNamedElementFigure;
@@ -60,6 +62,7 @@ public class MaintainSymbolRatioEditPolicy extends GraphicalEditPolicy implement
*
* {@inheritDoc}
*/
+ @Override
public void activate() {
// retrieve the view and the element managed by the edit part
View view = (View)getHost().getModel();
@@ -71,6 +74,11 @@ public class MaintainSymbolRatioEditPolicy extends GraphicalEditPolicy implement
// editpart
getDiagramEventBroker().addNotificationListener(view, this);
+ EObject semanticElement = EMFHelper.getEObject(getHost());
+ if(semanticElement instanceof NamedElement) {
+ hostSemanticNamedElement = (NamedElement)semanticElement;
+ }
+
if(hostSemanticNamedElement == null) {
return;
}
@@ -84,49 +92,40 @@ public class MaintainSymbolRatioEditPolicy extends GraphicalEditPolicy implement
*/
protected void refreshSymbolCompartment() {
if(getHost() instanceof NamedElementEditPart) {
- NamedElementEditPart namedElementEditPart=(NamedElementEditPart)getHost();
- BooleanValueStyle maintainRatio=getMaintainSymbolRatioStyle(namedElementEditPart.getNotationView());
- if(maintainRatio!=null && maintainRatio.isBooleanValue()==false){
+ NamedElementEditPart namedElementEditPart = (NamedElementEditPart)getHost();
+ BooleanValueStyle maintainRatio = getMaintainSymbolRatioStyle(namedElementEditPart.getNotationView());
+ if(maintainRatio != null && maintainRatio.isBooleanValue() == false) {
for(Object currentEditPart : namedElementEditPart.getChildren()) {
- if(currentEditPart instanceof ShapeDisplayCompartmentEditPart){
+ if(currentEditPart instanceof ShapeDisplayCompartmentEditPart) {
((ShapeDisplayCompartmentEditPart)currentEditPart).maintainRatio(false);
}
}
-
- }
- else{
+
+ } else {
for(Object currentEditPart : namedElementEditPart.getChildren()) {
- if(currentEditPart instanceof ShapeDisplayCompartmentEditPart){
+ if(currentEditPart instanceof ShapeDisplayCompartmentEditPart) {
((ShapeDisplayCompartmentEditPart)currentEditPart).maintainRatio(true);
}
-
+
}
}
}
}
-/**
- *
- * @param currentView
- * @return the current Style that reperesent the boder
- */
- protected BooleanValueStyle getMaintainSymbolRatioStyle(View currentView){
- List<?> viewStyle=currentView.getStyles();
- for(Object currentStyle : viewStyle) {
- if( currentStyle instanceof BooleanValueStyle){
- if(((BooleanValueStyle)currentStyle).getName().equals(MAINTAIN_SYMBOL_RATIO)){
- return (BooleanValueStyle)currentStyle;
- }
- }
- }
-
- return null;
-
+ /**
+ *
+ * @param currentView
+ * @return the current Style that reperesent the boder
+ */
+ protected BooleanValueStyle getMaintainSymbolRatioStyle(View currentView) {
+ return (BooleanValueStyle)currentView.getNamedStyle(NotationPackage.eINSTANCE.getBooleanValueStyle(), MAINTAIN_SYMBOL_RATIO);
}
+
/**
*
* {@inheritDoc}
*/
+ @Override
public void deactivate() {
// retrieve the view and the element managed by the edit part
View view = (View)getHost().getModel();

Back to the top