diff options
author | Camille Letavernier | 2013-10-25 11:01:10 +0000 |
---|---|---|
committer | Camille Letavernier | 2013-10-25 11:01:10 +0000 |
commit | 97e44ada570ec3decfde3e73f0f6595effb33791 (patch) | |
tree | c19ae7a4d3adcb6357ee5443da8345eb20c990cc /plugins | |
parent | bd4533c4330ace059e27c929d311a6a033e666f8 (diff) | |
download | org.eclipse.papyrus-97e44ada570ec3decfde3e73f0f6595effb33791.tar.gz org.eclipse.papyrus-97e44ada570ec3decfde3e73f0f6595effb33791.tar.xz org.eclipse.papyrus-97e44ada570ec3decfde3e73f0f6595effb33791.zip |
419965: Display of the name must be optional
https://bugs.eclipse.org/bugs/show_bug.cgi?id=419965
Diffstat (limited to 'plugins')
3 files changed, 45 insertions, 50 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 c5dd18a04d1..45efd4385c7 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 @@ -16,7 +16,6 @@ package org.eclipse.papyrus.uml.diagram.common.editpolicies; import java.util.List; import org.eclipse.draw2d.Border; -import org.eclipse.draw2d.LineBorder; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.transaction.TransactionalEditingDomain; @@ -41,7 +40,7 @@ import org.eclipse.uml2.uml.NamedElement; */ public class BorderDisplayEditPolicy extends GraphicalEditPolicy implements NotificationListener, IPapyrusListener { - public static final String DISPLAY_BORDER = "BorderDisplay"; + public static final String DISPLAY_BORDER = "displayBorder"; /** key for this edit policy */ public final static String BORDER_DISPLAY_EDITPOLICY = "BORDER_DISPLAY_EDITPOLICY"; @@ -90,8 +89,8 @@ public class BorderDisplayEditPolicy extends GraphicalEditPolicy implements Noti getDiagramEventBroker().addNotificationListener(hostSemanticNamedElement, this); if(getHost() instanceof NamedElementEditPart) { NamedElementEditPart namedElementEditPart = (NamedElementEditPart)getHost(); - defaultBorder=namedElementEditPart.getPrimaryShape().getBorder(); - + defaultBorder = namedElementEditPart.getPrimaryShape().getBorder(); + } refreshBorder(); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/NameDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/NameDisplayEditPolicy.java index e0491647224..2b4983fc353 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/NameDisplayEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/NameDisplayEditPolicy.java @@ -13,15 +13,13 @@ *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.common.editpolicies; -import org.eclipse.draw2d.Border; +import org.eclipse.draw2d.IFigure; import org.eclipse.emf.common.notify.Notification; 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.NotationPackage; import org.eclipse.gmf.runtime.notation.View; @@ -35,14 +33,11 @@ import org.eclipse.papyrus.uml.diagram.common.figure.node.NodeNamedElementFigure */ public class NameDisplayEditPolicy extends GraphicalEditPolicy implements NotificationListener, IPapyrusListener { - public static final String DISPLAY_NAME = "NameDisplay"; + public static final String DISPLAY_NAME = "displayName"; /** key for this edit policy */ public final static String NAME_DISPLAY_EDITPOLICY = "NAME_DISPLAY_EDITPOLICY"; - - private Border defaultBorder; - /** * Creates a new QualifiedNameDisplayEditPolicy */ @@ -66,26 +61,26 @@ public class NameDisplayEditPolicy extends GraphicalEditPolicy implements Notifi // editpart getDiagramEventBroker().addNotificationListener(view, this); - if(getHost() instanceof NamedElementEditPart) { - NamedElementEditPart namedElementEditPart = (NamedElementEditPart)getHost(); - defaultBorder=namedElementEditPart.getPrimaryShape().getBorder(); - - } - refreshBorder(); + refreshNameDisplay(); } /** * refresh the qualified name */ - protected void refreshBorder() { + protected void refreshNameDisplay() { if(getHost() instanceof NamedElementEditPart) { NamedElementEditPart namedElementEditPart = (NamedElementEditPart)getHost(); - BooleanValueStyle nameStyle = getBorderStyle(namedElementEditPart.getNotationView()); - if(nameStyle != null && nameStyle.isBooleanValue() == false) { - ((NodeNamedElementFigure)namedElementEditPart.getPrimaryShape()).removeNameLabel(); - } else { - ((NodeNamedElementFigure)namedElementEditPart.getPrimaryShape()).restoreNameLabel(); + IFigure primaryShape = namedElementEditPart.getPrimaryShape(); + if(primaryShape instanceof NodeNamedElementFigure) { + + BooleanValueStyle nameStyle = getDisplayNameStyle(namedElementEditPart.getNotationView()); + if(nameStyle != null && nameStyle.isBooleanValue() == false) { + + ((NodeNamedElementFigure)primaryShape).removeNameLabel(); + } else { + ((NodeNamedElementFigure)primaryShape).restoreNameLabel(); + } } } } @@ -95,7 +90,7 @@ public class NameDisplayEditPolicy extends GraphicalEditPolicy implements Notifi * @param currentView * @return the current Style that repersent the boder */ - protected BooleanValueStyle getBorderStyle(View currentView) { + protected BooleanValueStyle getDisplayNameStyle(View currentView) { return (BooleanValueStyle)currentView.getNamedStyle(NotationPackage.eINSTANCE.getBooleanValueStyle(), DISPLAY_NAME); } @@ -134,7 +129,7 @@ public class NameDisplayEditPolicy extends GraphicalEditPolicy implements Notifi * {@inheritDoc} */ public void notifyChanged(Notification notification) { - refreshBorder(); + refreshNameDisplay(); } 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 d8560626afe..3517c36eee8 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,43 +91,45 @@ public class NodeNamedElementFigure extends PapyrusNodeFigure implements IPapyru @Override public void setBorder(Border border) { - 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); } @@ -174,13 +174,14 @@ public class NodeNamedElementFigure extends PapyrusNodeFigure implements IPapyru 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); + } } /** @@ -537,10 +538,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; } @@ -659,8 +660,8 @@ public class NodeNamedElementFigure extends PapyrusNodeFigure implements IPapyru return position; } - - + + /** * Returns the position of the stereotype properties location. this is just |