diff options
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts')
96 files changed, 8498 insertions, 6289 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactCompositeCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactCompositeCompartmentEditPart.java index a6eb383c1e0..ec4d7ce047c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactCompositeCompartmentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactCompositeCompartmentEditPart.java @@ -42,7 +42,7 @@ public class ArtifactCompositeCompartmentEditPart extends LinkLFShapeCompartment /** * @generated */ - public static final String VISUAL_ID = "26"; + public static final String VISUAL_ID = "Artifact_NestedArtifactCompartment"; /** * @generated @@ -72,6 +72,7 @@ public class ArtifactCompositeCompartmentEditPart extends LinkLFShapeCompartment installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.deployment.edit.policies.ArtifactCompositeCompartmentCanonicalEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(BorderDisplayEditPolicy.BORDER_DISPLAY_EDITPOLICY, new BorderDisplayEditPolicy()); @@ -82,7 +83,7 @@ public class ArtifactCompositeCompartmentEditPart extends LinkLFShapeCompartment */ @Override protected void setRatio(Double ratio) { - if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -92,6 +93,7 @@ public class ArtifactCompositeCompartmentEditPart extends LinkLFShapeCompartment */ @Override public EditPart getTargetEditPart(Request request) { + return super.getTargetEditPart(request); } @@ -101,7 +103,10 @@ public class ArtifactCompositeCompartmentEditPart extends LinkLFShapeCompartment @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) + || NotationPackage.eINSTANCE.getSize_Height().equals(feature) + || NotationPackage.eINSTANCE.getLocation_X().equals(feature) + || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -111,13 +116,13 @@ public class ArtifactCompositeCompartmentEditPart extends LinkLFShapeCompartment * @generated */ protected void refreshBounds() { - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactCompositeCompartmentEditPartACN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactCompositeCompartmentEditPartACN.java index 2eabee8af09..07bca9b3c0d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactCompositeCompartmentEditPartACN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactCompositeCompartmentEditPartACN.java @@ -42,7 +42,7 @@ public class ArtifactCompositeCompartmentEditPartACN extends LinkLFShapeCompartm /** * @generated */ - public static final String VISUAL_ID = "34"; + public static final String VISUAL_ID = "Artifact_NestedArtifactCompartment_ACN"; /** * @generated @@ -72,6 +72,7 @@ public class ArtifactCompositeCompartmentEditPartACN extends LinkLFShapeCompartm installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.deployment.edit.policies.ArtifactCompositeCompartmentCanonicalEditPolicyACN()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(BorderDisplayEditPolicy.BORDER_DISPLAY_EDITPOLICY, new BorderDisplayEditPolicy()); @@ -82,7 +83,7 @@ public class ArtifactCompositeCompartmentEditPartACN extends LinkLFShapeCompartm */ @Override protected void setRatio(Double ratio) { - if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -92,6 +93,7 @@ public class ArtifactCompositeCompartmentEditPartACN extends LinkLFShapeCompartm */ @Override public EditPart getTargetEditPart(Request request) { + return super.getTargetEditPart(request); } @@ -101,7 +103,10 @@ public class ArtifactCompositeCompartmentEditPartACN extends LinkLFShapeCompartm @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) + || NotationPackage.eINSTANCE.getSize_Height().equals(feature) + || NotationPackage.eINSTANCE.getLocation_X().equals(feature) + || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -111,13 +116,13 @@ public class ArtifactCompositeCompartmentEditPartACN extends LinkLFShapeCompartm * @generated */ protected void refreshBounds() { - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactCompositeCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactCompositeCompartmentEditPartCN.java index 928b68744ce..21713fb9fc2 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactCompositeCompartmentEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactCompositeCompartmentEditPartCN.java @@ -42,7 +42,7 @@ public class ArtifactCompositeCompartmentEditPartCN extends LinkLFShapeCompartme /** * @generated */ - public static final String VISUAL_ID = "33"; + public static final String VISUAL_ID = "Artifact_NestedArtifactCompartment_CCN"; /** * @generated @@ -72,6 +72,7 @@ public class ArtifactCompositeCompartmentEditPartCN extends LinkLFShapeCompartme installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.deployment.edit.policies.ArtifactCompositeCompartmentCanonicalEditPolicyCN()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(BorderDisplayEditPolicy.BORDER_DISPLAY_EDITPOLICY, new BorderDisplayEditPolicy()); @@ -82,7 +83,7 @@ public class ArtifactCompositeCompartmentEditPartCN extends LinkLFShapeCompartme */ @Override protected void setRatio(Double ratio) { - if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -92,6 +93,7 @@ public class ArtifactCompositeCompartmentEditPartCN extends LinkLFShapeCompartme */ @Override public EditPart getTargetEditPart(Request request) { + return super.getTargetEditPart(request); } @@ -101,7 +103,10 @@ public class ArtifactCompositeCompartmentEditPartCN extends LinkLFShapeCompartme @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) + || NotationPackage.eINSTANCE.getSize_Height().equals(feature) + || NotationPackage.eINSTANCE.getLocation_X().equals(feature) + || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -111,13 +116,13 @@ public class ArtifactCompositeCompartmentEditPartCN extends LinkLFShapeCompartme * @generated */ protected void refreshBounds() { - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactEditPart.java index 4e70b36101f..02c4d92b6f8 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactEditPart.java @@ -64,7 +64,7 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { /** * @generated */ - public static final String VISUAL_ID = "2006"; + public static final String VISUAL_ID = "Artifact_Shape"; /** * @generated @@ -90,13 +90,18 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); - installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, + new ShowHideClassifierContentsEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); @@ -112,16 +117,16 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View)child.getModel(); + View childView = (View) child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if(vid != null) { - switch(vid) { + if (vid != null) { + switch (vid) { case ArtifactFloatingLabelEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -129,7 +134,7 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -159,16 +164,17 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View)getModel()).getChildren(); - if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if(modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View) getModel()).getChildren(); + if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if (modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); + } /** @@ -186,23 +192,25 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { */ @Override public ArtifactFigure getPrimaryShape() { - return (ArtifactFigure)primaryShape; + return (ArtifactFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ArtifactNameEditPart) { - ((ArtifactNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof ArtifactNameEditPart) { + ((ArtifactNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if(childEditPart instanceof ArtifactCompositeCompartmentEditPart) { + + if (childEditPart instanceof ArtifactCompositeCompartmentEditPart) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((ArtifactCompositeCompartmentEditPart)childEditPart).getFigure()); + pane.add(((ArtifactCompositeCompartmentEditPart) childEditPart).getFigure()); return true; } + return false; } @@ -210,12 +218,12 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ArtifactNameEditPart) { + if (childEditPart instanceof ArtifactNameEditPart) { return true; } - if(childEditPart instanceof ArtifactCompositeCompartmentEditPart) { + if (childEditPart instanceof ArtifactCompositeCompartmentEditPart) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); - pane.remove(((ArtifactCompositeCompartmentEditPart)childEditPart).getFigure()); + pane.remove(((ArtifactCompositeCompartmentEditPart) childEditPart).getFigure()); return true; } return false; @@ -226,7 +234,7 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -237,7 +245,7 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -248,10 +256,10 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof ArtifactCompositeCompartmentEditPart) { + if (editPart instanceof ArtifactCompositeCompartmentEditPart) { return getPrimaryShape().getCompositeCompartmentFigure(); } - if(editPart instanceof IBorderItemEditPart) { + if (editPart instanceof IBorderItemEditPart) { return getBorderedFigure().getBorderItemContainer(); } return getContentPane(); @@ -262,7 +270,7 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if(borderItemEditPart instanceof ArtifactFloatingLabelEditPart) { + if (borderItemEditPart instanceof ArtifactFloatingLabelEditPart) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -290,6 +298,7 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { @Override protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -302,7 +311,7 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -315,7 +324,7 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -326,7 +335,7 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -344,8 +353,8 @@ public class ArtifactEditPart extends RoundedCompartmentEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactEditPartACN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactEditPartACN.java index a968374e82e..b47ec0804d4 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactEditPartACN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactEditPartACN.java @@ -64,7 +64,7 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { /** * @generated */ - public static final String VISUAL_ID = "28"; + public static final String VISUAL_ID = "Artifact_Shape_ACN"; /** * @generated @@ -90,13 +90,18 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); - installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, + new ShowHideClassifierContentsEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); @@ -112,16 +117,16 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View)child.getModel(); + View childView = (View) child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if(vid != null) { - switch(vid) { + if (vid != null) { + switch (vid) { case ArtifactFloatingLabelEditPartACN.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -129,7 +134,7 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -159,16 +164,17 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View)getModel()).getChildren(); - if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if(modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View) getModel()).getChildren(); + if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if (modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); + } /** @@ -186,23 +192,25 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { */ @Override public ArtifactFigure getPrimaryShape() { - return (ArtifactFigure)primaryShape; + return (ArtifactFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ArtifactNameEditPartACN) { - ((ArtifactNameEditPartACN)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof ArtifactNameEditPartACN) { + ((ArtifactNameEditPartACN) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if(childEditPart instanceof ArtifactCompositeCompartmentEditPartACN) { + + if (childEditPart instanceof ArtifactCompositeCompartmentEditPartACN) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((ArtifactCompositeCompartmentEditPartACN)childEditPart).getFigure()); + pane.add(((ArtifactCompositeCompartmentEditPartACN) childEditPart).getFigure()); return true; } + return false; } @@ -210,12 +218,12 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ArtifactNameEditPartACN) { + if (childEditPart instanceof ArtifactNameEditPartACN) { return true; } - if(childEditPart instanceof ArtifactCompositeCompartmentEditPartACN) { + if (childEditPart instanceof ArtifactCompositeCompartmentEditPartACN) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); - pane.remove(((ArtifactCompositeCompartmentEditPartACN)childEditPart).getFigure()); + pane.remove(((ArtifactCompositeCompartmentEditPartACN) childEditPart).getFigure()); return true; } return false; @@ -226,7 +234,7 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -237,7 +245,7 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -248,10 +256,10 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof ArtifactCompositeCompartmentEditPartACN) { + if (editPart instanceof ArtifactCompositeCompartmentEditPartACN) { return getPrimaryShape().getCompositeCompartmentFigure(); } - if(editPart instanceof IBorderItemEditPart) { + if (editPart instanceof IBorderItemEditPart) { return getBorderedFigure().getBorderItemContainer(); } return getContentPane(); @@ -262,7 +270,7 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if(borderItemEditPart instanceof ArtifactFloatingLabelEditPartACN) { + if (borderItemEditPart instanceof ArtifactFloatingLabelEditPartACN) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -290,6 +298,7 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { @Override protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -302,7 +311,7 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -315,7 +324,7 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -326,7 +335,7 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -344,8 +353,8 @@ public class ArtifactEditPartACN extends RoundedCompartmentEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactEditPartCN.java index 1554df6d783..a97909526e9 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactEditPartCN.java @@ -64,7 +64,7 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { /** * @generated */ - public static final String VISUAL_ID = "25"; + public static final String VISUAL_ID = "Artifact_Shape_CCN"; /** * @generated @@ -90,13 +90,18 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); - installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, + new ShowHideClassifierContentsEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); @@ -112,16 +117,16 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View)child.getModel(); + View childView = (View) child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if(vid != null) { - switch(vid) { + if (vid != null) { + switch (vid) { case ArtifactFloatingLabelEditPartCN.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -129,7 +134,7 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -159,16 +164,17 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View)getModel()).getChildren(); - if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if(modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View) getModel()).getChildren(); + if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if (modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); + } /** @@ -186,23 +192,25 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { */ @Override public ArtifactFigure getPrimaryShape() { - return (ArtifactFigure)primaryShape; + return (ArtifactFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ArtifactNameEditPartCN) { - ((ArtifactNameEditPartCN)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof ArtifactNameEditPartCN) { + ((ArtifactNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if(childEditPart instanceof ArtifactCompositeCompartmentEditPartCN) { + + if (childEditPart instanceof ArtifactCompositeCompartmentEditPartCN) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((ArtifactCompositeCompartmentEditPartCN)childEditPart).getFigure()); + pane.add(((ArtifactCompositeCompartmentEditPartCN) childEditPart).getFigure()); return true; } + return false; } @@ -210,12 +218,12 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ArtifactNameEditPartCN) { + if (childEditPart instanceof ArtifactNameEditPartCN) { return true; } - if(childEditPart instanceof ArtifactCompositeCompartmentEditPartCN) { + if (childEditPart instanceof ArtifactCompositeCompartmentEditPartCN) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); - pane.remove(((ArtifactCompositeCompartmentEditPartCN)childEditPart).getFigure()); + pane.remove(((ArtifactCompositeCompartmentEditPartCN) childEditPart).getFigure()); return true; } return false; @@ -226,7 +234,7 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -237,7 +245,7 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -248,10 +256,10 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof ArtifactCompositeCompartmentEditPartCN) { + if (editPart instanceof ArtifactCompositeCompartmentEditPartCN) { return getPrimaryShape().getCompositeCompartmentFigure(); } - if(editPart instanceof IBorderItemEditPart) { + if (editPart instanceof IBorderItemEditPart) { return getBorderedFigure().getBorderItemContainer(); } return getContentPane(); @@ -262,7 +270,7 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if(borderItemEditPart instanceof ArtifactFloatingLabelEditPartCN) { + if (borderItemEditPart instanceof ArtifactFloatingLabelEditPartCN) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -290,6 +298,7 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { @Override protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -302,7 +311,7 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -315,7 +324,7 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -326,7 +335,7 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -344,8 +353,8 @@ public class ArtifactEditPartCN extends RoundedCompartmentEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactFloatingLabelEditPart.java index 9f2d32d0c89..127ee4cbf7a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactFloatingLabelEditPart.java @@ -63,6 +63,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimar import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editparts.FloatingLabelEditPart; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; @@ -84,12 +85,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { +public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart + implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated */ - public static final String VISUAL_ID = "61"; + public static final String VISUAL_ID = "Artifact_FloatingNameLabel"; /** * @generated @@ -128,7 +130,10 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ArtifactFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ArtifactFloatingLabelEditPart.VISUAL_ID), + new Point(0, 0)); } /** @@ -155,9 +160,9 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if(parentFigure != null && parentFigure.getLayoutManager() != null) { + if (parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator)constraint; + return (IBorderItemLocator) constraint; } return null; } @@ -167,10 +172,10 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme */ @Override public void refreshBounds() { - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -178,12 +183,12 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -191,12 +196,12 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -204,12 +209,12 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -217,12 +222,12 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -280,10 +285,11 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -296,12 +302,12 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -310,10 +316,11 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -332,22 +339,26 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), + ArtifactFloatingLabelEditPart.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -359,10 +370,10 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -378,8 +389,8 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Artifact_2006, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ArtifactFloatingLabelEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Artifact_Shape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -388,8 +399,10 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -418,8 +431,8 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -427,8 +440,8 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -439,46 +452,58 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -500,12 +525,13 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -536,20 +562,20 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -557,15 +583,15 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -574,9 +600,9 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -585,9 +611,10 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme */ @Override 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)); + 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); } } @@ -605,11 +632,11 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -621,8 +648,8 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -635,7 +662,7 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -661,13 +688,14 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -679,7 +707,7 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -701,12 +729,15 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -717,10 +748,13 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -739,12 +773,15 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -763,24 +800,27 @@ public class ArtifactFloatingLabelEditPart extends FloatingLabelEditPart impleme @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactFloatingLabelEditPartACN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactFloatingLabelEditPartACN.java index fe18c4def07..cf6681cfde9 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactFloatingLabelEditPartACN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactFloatingLabelEditPartACN.java @@ -63,6 +63,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimar import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editparts.FloatingLabelEditPart; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; @@ -84,12 +85,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { +public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart + implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated */ - public static final String VISUAL_ID = "60"; + public static final String VISUAL_ID = "Artifact_FloatingNameLabel_ACN"; /** * @generated @@ -128,7 +130,10 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ArtifactFloatingLabelEditPartACN.VISUAL_ID), new Point(0, 0)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ArtifactFloatingLabelEditPartACN.VISUAL_ID), + new Point(0, 0)); } /** @@ -155,9 +160,9 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if(parentFigure != null && parentFigure.getLayoutManager() != null) { + if (parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator)constraint; + return (IBorderItemLocator) constraint; } return null; } @@ -167,10 +172,10 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl */ @Override public void refreshBounds() { - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -178,12 +183,12 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -191,12 +196,12 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -204,12 +209,12 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -217,12 +222,12 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -280,10 +285,11 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -296,12 +302,12 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -310,10 +316,11 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -332,22 +339,28 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + ArtifactFloatingLabelEditPartACN.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -359,10 +372,10 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -378,8 +391,8 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Artifact_28, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ArtifactFloatingLabelEditPartACN.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Artifact_Shape_ACN, getParserElement(), this, VISUAL_ID); } return parser; } @@ -388,8 +401,10 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -418,8 +433,8 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -427,8 +442,8 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -439,46 +454,58 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -500,12 +527,13 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -536,20 +564,20 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -557,15 +585,15 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -574,9 +602,9 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -585,9 +613,10 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl */ @Override 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)); + 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); } } @@ -605,11 +634,11 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -621,8 +650,8 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -635,7 +664,7 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -661,13 +690,14 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -679,7 +709,7 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -701,12 +731,15 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -717,10 +750,13 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -739,12 +775,15 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -763,24 +802,27 @@ public class ArtifactFloatingLabelEditPartACN extends FloatingLabelEditPart impl @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactFloatingLabelEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactFloatingLabelEditPartCN.java index f8ccdcfec2a..e02615c0b98 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactFloatingLabelEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactFloatingLabelEditPartCN.java @@ -63,6 +63,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimar import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editparts.FloatingLabelEditPart; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; @@ -84,12 +85,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { +public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart + implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated */ - public static final String VISUAL_ID = "59"; + public static final String VISUAL_ID = "Artifact_FloatingNameLabel_CCN"; /** * @generated @@ -128,7 +130,10 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ArtifactFloatingLabelEditPartCN.VISUAL_ID), new Point(0, 0)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ArtifactFloatingLabelEditPartCN.VISUAL_ID), + new Point(0, 0)); } /** @@ -155,9 +160,9 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if(parentFigure != null && parentFigure.getLayoutManager() != null) { + if (parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator)constraint; + return (IBorderItemLocator) constraint; } return null; } @@ -167,10 +172,10 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple */ @Override public void refreshBounds() { - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -178,12 +183,12 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -191,12 +196,12 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -204,12 +209,12 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -217,12 +222,12 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -280,10 +285,11 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -296,12 +302,12 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -310,10 +316,11 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -332,22 +339,26 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), + ArtifactFloatingLabelEditPartCN.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -359,10 +370,10 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -378,8 +389,8 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Artifact_25, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ArtifactFloatingLabelEditPartCN.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Artifact_Shape_CCN, getParserElement(), this, VISUAL_ID); } return parser; } @@ -388,8 +399,10 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -418,8 +431,8 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -427,8 +440,8 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -439,46 +452,58 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -500,12 +525,13 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -536,20 +562,20 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -557,15 +583,15 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -574,9 +600,9 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -585,9 +611,10 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple */ @Override 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)); + 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); } } @@ -605,11 +632,11 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -621,8 +648,8 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -635,7 +662,7 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -661,13 +688,14 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -679,7 +707,7 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -701,12 +729,15 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -717,10 +748,13 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -739,12 +773,15 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -763,24 +800,27 @@ public class ArtifactFloatingLabelEditPartCN extends FloatingLabelEditPart imple @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactNameEditPart.java index 8b473f85c1b..a3e7d62ee22 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactNameEditPart.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class ArtifactNameEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "8"; + public static final String VISUAL_ID = "Artifact_NameLabel"; /** * @generated @@ -144,12 +146,12 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,25 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), ArtifactNameEditPart.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +333,10 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +352,8 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Artifact_2006, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ArtifactNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Artifact_Shape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +362,10 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +394,8 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +403,8 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +415,58 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +488,13 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +525,12 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +539,12 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +552,15 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +569,9 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +580,10 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements */ @Override 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)); + 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); } } @@ -578,11 +601,11 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +617,8 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +631,7 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +657,14 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +676,7 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +698,15 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +717,13 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +742,15 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +788,27 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +845,8 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +856,7 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +864,6 @@ public class ArtifactNameEditPart extends PapyrusCompartmentEditPart implements */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactNameEditPartACN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactNameEditPartACN.java index 6d896e0e4f5..24a47ce8e89 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactNameEditPartACN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactNameEditPartACN.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "29"; + public static final String VISUAL_ID = "Artifact_NameLabel_ACN"; /** * @generated @@ -144,12 +146,12 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,25 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), ArtifactNameEditPartACN.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +333,10 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +352,8 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Artifact_28, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ArtifactNameEditPartACN.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Artifact_Shape_ACN, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +362,10 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +394,8 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +403,8 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +415,58 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +488,13 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +525,12 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +539,12 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +552,15 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +569,9 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +580,10 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen */ @Override 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)); + 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); } } @@ -578,11 +601,11 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +617,8 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +631,7 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +657,14 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +676,7 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +698,15 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +717,13 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +742,15 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +788,27 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +845,8 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +856,7 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +864,6 @@ public class ArtifactNameEditPartACN extends PapyrusCompartmentEditPart implemen */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactNameEditPartCN.java index d85239e2d2e..7c085e21ee9 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactNameEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ArtifactNameEditPartCN.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "27"; + public static final String VISUAL_ID = "Artifact_NameLabel_CCN"; /** * @generated @@ -144,12 +146,12 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,25 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), ArtifactNameEditPartCN.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +333,10 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +352,8 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Artifact_25, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ArtifactNameEditPartCN.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Artifact_Shape_CCN, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +362,10 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +394,8 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +403,8 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +415,58 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +488,13 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +525,12 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +539,12 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +552,15 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +569,9 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +580,10 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement */ @Override 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)); + 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); } } @@ -578,11 +601,11 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +617,8 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +631,7 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +657,14 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +676,7 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +698,15 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +717,13 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +742,15 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +788,27 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +845,8 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +856,7 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +864,6 @@ public class ArtifactNameEditPartCN extends PapyrusCompartmentEditPart implement */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentAnnotatedElementEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentAnnotatedElementEditPart.java index 34d89446fcd..797c0bb3393 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentAnnotatedElementEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentAnnotatedElementEditPart.java @@ -27,7 +27,7 @@ public class CommentAnnotatedElementEditPart extends UMLConnectionNodeEditPart i /** * @generated */ - public static final String VISUAL_ID = "4008"; + public static final String VISUAL_ID = "Comment_AnnotatedElementEdge"; /** * @generated @@ -63,6 +63,6 @@ public class CommentAnnotatedElementEditPart extends UMLConnectionNodeEditPart i */ @Override public SimpleDashedEdgeFigure getPrimaryShape() { - return (SimpleDashedEdgeFigure)getFigure(); + return (SimpleDashedEdgeFigure) getFigure(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentBodyEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentBodyEditPart.java index 43ec629dde5..5bdee74088f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentBodyEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentBodyEditPart.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class CommentBodyEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "1"; + public static final String VISUAL_ID = "Comment_BodyLabel"; /** * @generated @@ -144,12 +146,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,25 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), CommentBodyEditPart.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +333,10 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +352,8 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Comment_2001, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.CommentBodyEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Comment_Shape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +362,10 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +394,8 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +403,8 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +415,58 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +488,13 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +525,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +539,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +552,15 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +569,9 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +580,10 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I */ @Override 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)); + 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); } } @@ -578,11 +601,11 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +617,8 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +631,7 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +657,14 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +676,7 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +698,15 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +717,13 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +742,15 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +788,27 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +845,8 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +856,7 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +864,6 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements I */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentBodyEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentBodyEditPartCN.java index 9465b1939eb..8beae8a85c6 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentBodyEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentBodyEditPartCN.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "55"; + public static final String VISUAL_ID = "Comment_BodyLabel_CN"; /** * @generated @@ -144,12 +146,12 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,25 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), CommentBodyEditPartCN.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +333,10 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +352,8 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Comment_54, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.CommentBodyEditPartCN.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Comment_Shape_CN, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +362,10 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +394,8 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +403,8 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +415,58 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +488,13 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +525,12 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +539,12 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +552,15 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +569,9 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +580,10 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements */ @Override 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)); + 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); } } @@ -578,11 +601,11 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +617,8 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +631,7 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +657,14 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +676,7 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +698,15 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +717,13 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +742,15 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +788,27 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +845,8 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +856,7 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +864,6 @@ public class CommentBodyEditPartCN extends PapyrusCompartmentEditPart implements */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentEditPart.java index c7b91e97c1f..83f1488e07f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentEditPart.java @@ -48,7 +48,7 @@ public class CommentEditPart extends AbstractCommentEditPart { /** * @generated */ - public static final String VISUAL_ID = "2001"; + public static final String VISUAL_ID = "Comment_Shape"; /** * @generated @@ -74,9 +74,12 @@ public class CommentEditPart extends AbstractCommentEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusReflowableShapeEditPolicy()); @@ -93,7 +96,7 @@ public class CommentEditPart extends AbstractCommentEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -120,6 +123,7 @@ public class CommentEditPart extends AbstractCommentEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); + } /** @@ -137,17 +141,18 @@ public class CommentEditPart extends AbstractCommentEditPart { */ @Override public HTMLCornerBentFigure getPrimaryShape() { - return (HTMLCornerBentFigure)primaryShape; + return (HTMLCornerBentFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof CommentBodyEditPart) { - ((CommentBodyEditPart)childEditPart).setLabel(getPrimaryShape().getCornerBentFigure()); + if (childEditPart instanceof CommentBodyEditPart) { + ((CommentBodyEditPart) childEditPart).setLabel(getPrimaryShape().getCornerBentFigure()); return true; } + return false; } @@ -155,7 +160,7 @@ public class CommentEditPart extends AbstractCommentEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof CommentBodyEditPart) { + if (childEditPart instanceof CommentBodyEditPart) { return true; } return false; @@ -166,7 +171,7 @@ public class CommentEditPart extends AbstractCommentEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -177,7 +182,7 @@ public class CommentEditPart extends AbstractCommentEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -211,6 +216,7 @@ public class CommentEditPart extends AbstractCommentEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -223,7 +229,7 @@ public class CommentEditPart extends AbstractCommentEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -236,7 +242,7 @@ public class CommentEditPart extends AbstractCommentEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -247,7 +253,7 @@ public class CommentEditPart extends AbstractCommentEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -265,8 +271,8 @@ public class CommentEditPart extends AbstractCommentEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentEditPartCN.java index e1f6f894528..3532668834b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommentEditPartCN.java @@ -48,7 +48,7 @@ public class CommentEditPartCN extends AbstractCommentEditPart { /** * @generated */ - public static final String VISUAL_ID = "54"; + public static final String VISUAL_ID = "Comment_Shape_CN"; /** * @generated @@ -74,9 +74,12 @@ public class CommentEditPartCN extends AbstractCommentEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusReflowableShapeEditPolicy()); @@ -93,7 +96,7 @@ public class CommentEditPartCN extends AbstractCommentEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -120,6 +123,7 @@ public class CommentEditPartCN extends AbstractCommentEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); + } /** @@ -137,17 +141,18 @@ public class CommentEditPartCN extends AbstractCommentEditPart { */ @Override public HTMLCornerBentFigure getPrimaryShape() { - return (HTMLCornerBentFigure)primaryShape; + return (HTMLCornerBentFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof CommentBodyEditPartCN) { - ((CommentBodyEditPartCN)childEditPart).setLabel(getPrimaryShape().getCornerBentFigure()); + if (childEditPart instanceof CommentBodyEditPartCN) { + ((CommentBodyEditPartCN) childEditPart).setLabel(getPrimaryShape().getCornerBentFigure()); return true; } + return false; } @@ -155,7 +160,7 @@ public class CommentEditPartCN extends AbstractCommentEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof CommentBodyEditPartCN) { + if (childEditPart instanceof CommentBodyEditPartCN) { return true; } return false; @@ -166,7 +171,7 @@ public class CommentEditPartCN extends AbstractCommentEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -177,7 +182,7 @@ public class CommentEditPartCN extends AbstractCommentEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -211,6 +216,7 @@ public class CommentEditPartCN extends AbstractCommentEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -223,7 +229,7 @@ public class CommentEditPartCN extends AbstractCommentEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -236,7 +242,7 @@ public class CommentEditPartCN extends AbstractCommentEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -247,7 +253,7 @@ public class CommentEditPartCN extends AbstractCommentEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -265,8 +271,8 @@ public class CommentEditPartCN extends AbstractCommentEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommunicationPathAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommunicationPathAppliedStereotypeEditPart.java index 6fb53dfa98b..bc8dee72b7e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommunicationPathAppliedStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommunicationPathAppliedStereotypeEditPart.java @@ -62,6 +62,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -82,12 +83,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "6002"; + public static final String VISUAL_ID = "CommunicationPath_StereotypeLabel"; /** * @generated @@ -124,7 +126,10 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.CommunicationPathAppliedStereotypeEditPart.VISUAL_ID), new Point(0, 60)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.CommunicationPathAppliedStereotypeEditPart.VISUAL_ID), + new Point(0, 60)); } /** @@ -156,12 +161,12 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -169,12 +174,12 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -182,12 +187,12 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -195,12 +200,12 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -256,10 +261,11 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -271,12 +277,12 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -284,10 +290,11 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -305,22 +312,27 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + CommunicationPathAppliedStereotypeEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -331,10 +343,10 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -348,8 +360,8 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.CommunicationPath_4011, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.CommunicationPathAppliedStereotypeEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.CommunicationPath_Edge, getParserElement(), this, VISUAL_ID); } return parser; } @@ -358,8 +370,10 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -388,8 +402,8 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -397,8 +411,8 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -408,46 +422,58 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -469,12 +495,13 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -504,20 +531,20 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -525,15 +552,15 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -542,9 +569,9 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -552,9 +579,10 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ 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)); + 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); } } @@ -570,11 +598,11 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -585,8 +613,8 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -598,7 +626,7 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -624,13 +652,14 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -642,7 +671,7 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -663,12 +692,15 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -678,10 +710,13 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -698,12 +733,15 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -721,30 +759,34 @@ public class CommunicationPathAppliedStereotypeEditPart extends PapyrusLabelEdit */ protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } + super.handleNotificationEvent(event); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommunicationPathEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommunicationPathEditPart.java index efe01f17bf7..8c9cb191712 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommunicationPathEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommunicationPathEditPart.java @@ -30,7 +30,7 @@ public class CommunicationPathEditPart extends UMLConnectionNodeEditPart impleme /** * @generated */ - public static final String VISUAL_ID = "4011"; + public static final String VISUAL_ID = "CommunicationPath_Edge"; /** * @generated @@ -45,7 +45,8 @@ public class CommunicationPathEditPart extends UMLConnectionNodeEditPart impleme protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeLinkLabelDisplayEditPolicy()); installEditPolicy(ShowHideLabelEditPolicy.SHOW_HIDE_LABEL_ROLE, new ShowHideLabelEditPolicy()); } @@ -53,11 +54,12 @@ public class CommunicationPathEditPart extends UMLConnectionNodeEditPart impleme * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof CommunicationPathNameEditPart) { - ((CommunicationPathNameEditPart)childEditPart).setLabel(getPrimaryShape().getAssociationNameLabel()); + if (childEditPart instanceof CommunicationPathNameEditPart) { + ((CommunicationPathNameEditPart) childEditPart).setLabel(getPrimaryShape().getAssociationNameLabel()); } - if(childEditPart instanceof CommunicationPathAppliedStereotypeEditPart) { - ((CommunicationPathAppliedStereotypeEditPart)childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel()); + if (childEditPart instanceof CommunicationPathAppliedStereotypeEditPart) { + ((CommunicationPathAppliedStereotypeEditPart) childEditPart) + .setLabel(getPrimaryShape().getAppliedStereotypeLabel()); } return false; } @@ -66,7 +68,7 @@ public class CommunicationPathEditPart extends UMLConnectionNodeEditPart impleme * @generated */ protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -76,10 +78,10 @@ public class CommunicationPathEditPart extends UMLConnectionNodeEditPart impleme * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof CommunicationPathNameEditPart) { + if (childEditPart instanceof CommunicationPathNameEditPart) { return true; } - if(childEditPart instanceof CommunicationPathAppliedStereotypeEditPart) { + if (childEditPart instanceof CommunicationPathAppliedStereotypeEditPart) { return true; } return false; @@ -89,7 +91,7 @@ public class CommunicationPathEditPart extends UMLConnectionNodeEditPart impleme * @generated */ protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -111,6 +113,6 @@ public class CommunicationPathEditPart extends UMLConnectionNodeEditPart impleme * @generated */ public AssociationFigure getPrimaryShape() { - return (AssociationFigure)getFigure(); + return (AssociationFigure) getFigure(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommunicationPathNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommunicationPathNameEditPart.java index 31da062671c..13810a8aae2 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommunicationPathNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/CommunicationPathNameEditPart.java @@ -62,6 +62,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -82,12 +83,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class CommunicationPathNameEditPart extends PapyrusLabelEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "6001"; + public static final String VISUAL_ID = "CommunicationPath_NameLabel"; /** * @generated @@ -124,7 +126,10 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.CommunicationPathNameEditPart.VISUAL_ID), new Point(0, 40)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.CommunicationPathNameEditPart.VISUAL_ID), + new Point(0, 40)); } /** @@ -156,12 +161,12 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -169,12 +174,12 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -182,12 +187,12 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -195,12 +200,12 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -256,10 +261,11 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -271,12 +277,12 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -284,10 +290,11 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -305,22 +312,26 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), + CommunicationPathNameEditPart.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -331,10 +342,10 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -348,8 +359,8 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.CommunicationPath_4011, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.CommunicationPathNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.CommunicationPath_Edge, getParserElement(), this, VISUAL_ID); } return parser; } @@ -358,8 +369,10 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -388,8 +401,8 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -397,8 +410,8 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -408,46 +421,58 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -469,12 +494,13 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -504,20 +530,20 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -525,15 +551,15 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -542,9 +568,9 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -552,9 +578,10 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ 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)); + 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); } } @@ -570,11 +597,11 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -585,8 +612,8 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -598,7 +625,7 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -624,13 +651,14 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -642,7 +670,7 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -663,12 +691,15 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -678,10 +709,13 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -698,12 +732,15 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -721,30 +758,34 @@ public class CommunicationPathNameEditPart extends PapyrusLabelEditPart implemen */ protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } + super.handleNotificationEvent(event); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintConstrainedElementEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintConstrainedElementEditPart.java index 43dc9039641..024a41af975 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintConstrainedElementEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintConstrainedElementEditPart.java @@ -27,7 +27,7 @@ public class ConstraintConstrainedElementEditPart extends UMLConnectionNodeEditP /** * @generated */ - public static final String VISUAL_ID = "4009"; + public static final String VISUAL_ID = "Constraint_ConstrainedElementEdge"; /** * @generated @@ -63,6 +63,6 @@ public class ConstraintConstrainedElementEditPart extends UMLConnectionNodeEditP */ @Override public SimpleDashedEdgeFigure getPrimaryShape() { - return (SimpleDashedEdgeFigure)getFigure(); + return (SimpleDashedEdgeFigure) getFigure(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintEditPart.java index 9876135110e..29b4f7772ba 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintEditPart.java @@ -47,7 +47,7 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { /** * @generated */ - public static final String VISUAL_ID = "2005"; + public static final String VISUAL_ID = "Constraint_Shape"; /** * @generated @@ -73,9 +73,12 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies @@ -91,7 +94,7 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -118,6 +121,7 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); + } /** @@ -135,21 +139,22 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { */ @Override public ConstraintFigure getPrimaryShape() { - return (ConstraintFigure)primaryShape; + return (ConstraintFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ConstraintNameEditPart) { - ((ConstraintNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof ConstraintNameEditPart) { + ((ConstraintNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if(childEditPart instanceof ConstraintSpecificationEditPart) { - ((ConstraintSpecificationEditPart)childEditPart).setLabel(getPrimaryShape().getConstraintFigure()); + if (childEditPart instanceof ConstraintSpecificationEditPart) { + ((ConstraintSpecificationEditPart) childEditPart).setLabel(getPrimaryShape().getConstraintFigure()); return true; } + return false; } @@ -157,10 +162,10 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ConstraintNameEditPart) { + if (childEditPart instanceof ConstraintNameEditPart) { return true; } - if(childEditPart instanceof ConstraintSpecificationEditPart) { + if (childEditPart instanceof ConstraintSpecificationEditPart) { return true; } return false; @@ -171,7 +176,7 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -182,7 +187,7 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -216,6 +221,7 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -228,7 +234,7 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -241,7 +247,7 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -252,7 +258,7 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -270,8 +276,8 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintEditPartCN.java index 35ef64380db..eb5e1d4c0e6 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintEditPartCN.java @@ -47,7 +47,7 @@ public class ConstraintEditPartCN extends AbstractConstraintEditPart { /** * @generated */ - public static final String VISUAL_ID = "56"; + public static final String VISUAL_ID = "Constraint_Shape_CN"; /** * @generated @@ -73,9 +73,12 @@ public class ConstraintEditPartCN extends AbstractConstraintEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies @@ -91,7 +94,7 @@ public class ConstraintEditPartCN extends AbstractConstraintEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -118,6 +121,7 @@ public class ConstraintEditPartCN extends AbstractConstraintEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); + } /** @@ -135,21 +139,22 @@ public class ConstraintEditPartCN extends AbstractConstraintEditPart { */ @Override public ConstraintFigure getPrimaryShape() { - return (ConstraintFigure)primaryShape; + return (ConstraintFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ConstraintNameEditPartCN) { - ((ConstraintNameEditPartCN)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof ConstraintNameEditPartCN) { + ((ConstraintNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if(childEditPart instanceof ConstraintSpecificationEditPartCN) { - ((ConstraintSpecificationEditPartCN)childEditPart).setLabel(getPrimaryShape().getConstraintFigure()); + if (childEditPart instanceof ConstraintSpecificationEditPartCN) { + ((ConstraintSpecificationEditPartCN) childEditPart).setLabel(getPrimaryShape().getConstraintFigure()); return true; } + return false; } @@ -157,10 +162,10 @@ public class ConstraintEditPartCN extends AbstractConstraintEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ConstraintNameEditPartCN) { + if (childEditPart instanceof ConstraintNameEditPartCN) { return true; } - if(childEditPart instanceof ConstraintSpecificationEditPartCN) { + if (childEditPart instanceof ConstraintSpecificationEditPartCN) { return true; } return false; @@ -171,7 +176,7 @@ public class ConstraintEditPartCN extends AbstractConstraintEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -182,7 +187,7 @@ public class ConstraintEditPartCN extends AbstractConstraintEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -216,6 +221,7 @@ public class ConstraintEditPartCN extends AbstractConstraintEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -228,7 +234,7 @@ public class ConstraintEditPartCN extends AbstractConstraintEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -241,7 +247,7 @@ public class ConstraintEditPartCN extends AbstractConstraintEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -252,7 +258,7 @@ public class ConstraintEditPartCN extends AbstractConstraintEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -270,8 +276,8 @@ public class ConstraintEditPartCN extends AbstractConstraintEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintNameEditPart.java index 934cb97a611..6b3d737abf5 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintNameEditPart.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class ConstraintNameEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "2"; + public static final String VISUAL_ID = "Constraint_NameLabel"; /** * @generated @@ -144,12 +146,12 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,25 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), ConstraintNameEditPart.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +333,10 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +352,8 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Constraint_2005, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ConstraintNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Constraint_Shape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +362,10 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +394,8 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +403,8 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +415,58 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +488,13 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +525,12 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +539,12 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +552,15 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +569,9 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +580,10 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement */ @Override 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)); + 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); } } @@ -578,11 +601,11 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +617,8 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +631,7 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +657,14 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +676,7 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +698,15 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +717,13 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +742,15 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +788,27 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +845,8 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +856,7 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +864,6 @@ public class ConstraintNameEditPart extends PapyrusCompartmentEditPart implement */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintNameEditPartCN.java index 50c4f1d12ba..dd1f096cf5a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintNameEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintNameEditPartCN.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "57"; + public static final String VISUAL_ID = "Constraint_NameLabel_CN"; /** * @generated @@ -144,12 +146,12 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,25 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), ConstraintNameEditPartCN.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +333,10 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +352,8 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Constraint_56, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ConstraintNameEditPartCN.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Constraint_Shape_CN, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +362,10 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +394,8 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +403,8 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +415,58 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +488,13 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +525,12 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +539,12 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +552,15 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +569,9 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +580,10 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme */ @Override 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)); + 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); } } @@ -578,11 +601,11 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +617,8 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +631,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +657,14 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +676,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +698,15 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +717,13 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +742,15 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +788,27 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +845,8 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +856,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +864,6 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintSpecificationEditPart.java index 2e059a1d2fd..00bae402acf 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintSpecificationEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintSpecificationEditPart.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "3"; + public static final String VISUAL_ID = "Constraint_BodyLabel"; /** * @generated @@ -144,12 +146,12 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,26 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), + ConstraintSpecificationEditPart.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +334,10 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +353,8 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Constraint_2005, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ConstraintSpecificationEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Constraint_Shape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +363,10 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +395,8 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +404,8 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +416,58 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +489,13 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +526,12 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +540,12 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +553,15 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +570,9 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +581,10 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart */ @Override 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)); + 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); } } @@ -578,11 +602,11 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +618,8 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +632,7 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +658,14 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +677,7 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +699,15 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +718,13 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +743,15 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +789,27 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +846,8 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +857,7 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +865,6 @@ public class ConstraintSpecificationEditPart extends PapyrusCompartmentEditPart */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintSpecificationEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintSpecificationEditPartCN.java index 3a7004fbd1b..385c5ca592a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintSpecificationEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ConstraintSpecificationEditPartCN.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "58"; + public static final String VISUAL_ID = "Constraint_BodyLabel_CN"; /** * @generated @@ -144,12 +146,12 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,28 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + ConstraintSpecificationEditPartCN.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +336,10 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +355,8 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Constraint_56, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ConstraintSpecificationEditPartCN.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Constraint_Shape_CN, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +365,10 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +397,8 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +406,8 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +418,58 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +491,13 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +528,12 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +542,12 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +555,15 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +572,9 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +583,10 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar */ @Override 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)); + 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); } } @@ -578,11 +604,11 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +620,8 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +634,7 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +660,14 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +679,7 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +701,15 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +720,13 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +745,15 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +791,27 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +848,8 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +859,7 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +867,6 @@ public class ConstraintSpecificationEditPartCN extends PapyrusCompartmentEditPar */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DefaultNamedElementEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DefaultNamedElementEditPart.java index 7e685885c30..a6272d69863 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DefaultNamedElementEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DefaultNamedElementEditPart.java @@ -50,7 +50,7 @@ public class DefaultNamedElementEditPart extends NamedElementEditPart { /** * @generated */ - public static final String VISUAL_ID = "2012"; + public static final String VISUAL_ID = "NamedElement_DefaultShape"; /** * @generated @@ -76,12 +76,16 @@ public class DefaultNamedElementEditPart extends NamedElementEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(ChangeStereotypedShapeEditPolicy.CHANGE_SHAPE_POLICY, new DeploymentDiagramChangeStereotypedShapeEditpolicy()); + installEditPolicy(ChangeStereotypedShapeEditPolicy.CHANGE_SHAPE_POLICY, + new DeploymentDiagramChangeStereotypedShapeEditpolicy()); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomDefaultNamedElementItemSemanticEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); @@ -96,7 +100,7 @@ public class DefaultNamedElementEditPart extends NamedElementEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -123,6 +127,7 @@ public class DefaultNamedElementEditPart extends NamedElementEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); + } /** @@ -140,17 +145,18 @@ public class DefaultNamedElementEditPart extends NamedElementEditPart { */ @Override public NodeNamedElementFigure getPrimaryShape() { - return (NodeNamedElementFigure)primaryShape; + return (NodeNamedElementFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DefaultNamedElementNameEditPart) { - ((DefaultNamedElementNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof DefaultNamedElementNameEditPart) { + ((DefaultNamedElementNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } + return false; } @@ -158,7 +164,7 @@ public class DefaultNamedElementEditPart extends NamedElementEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DefaultNamedElementNameEditPart) { + if (childEditPart instanceof DefaultNamedElementNameEditPart) { return true; } return false; @@ -169,7 +175,7 @@ public class DefaultNamedElementEditPart extends NamedElementEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -180,7 +186,7 @@ public class DefaultNamedElementEditPart extends NamedElementEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -214,6 +220,7 @@ public class DefaultNamedElementEditPart extends NamedElementEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -226,7 +233,7 @@ public class DefaultNamedElementEditPart extends NamedElementEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -239,7 +246,7 @@ public class DefaultNamedElementEditPart extends NamedElementEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -250,7 +257,7 @@ public class DefaultNamedElementEditPart extends NamedElementEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -268,8 +275,8 @@ public class DefaultNamedElementEditPart extends NamedElementEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DefaultNamedElementNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DefaultNamedElementNameEditPart.java index 839daa28025..ecf378d6d6c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DefaultNamedElementNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DefaultNamedElementNameEditPart.java @@ -64,6 +64,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -85,12 +86,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "53"; + public static final String VISUAL_ID = "NamedElement_NameLabel"; /** * @generated @@ -148,12 +150,12 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -161,12 +163,12 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -174,12 +176,12 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -187,12 +189,12 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -243,12 +245,12 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart */ protected Image getLabelIcon() { EObject parserElement = getParserElement(); - if(parserElement == null) { + if (parserElement == null) { return null; } List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer()); - for(View view : views) { - if(AppearanceHelper.showElementIcon(view)) { + for (View view : views) { + if (AppearanceHelper.showElementIcon(view)) { return UMLElementTypes.getImage(parserElement.eClass()); } } @@ -261,10 +263,11 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -277,12 +280,12 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -291,10 +294,11 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -313,22 +317,26 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), + DefaultNamedElementNameEditPart.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -340,10 +348,10 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -359,8 +367,9 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.NamedElement_2012, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DefaultNamedElementNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.NamedElement_DefaultShape, getParserElement(), this, + VISUAL_ID); } return parser; } @@ -369,8 +378,10 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -399,8 +410,8 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -408,8 +419,8 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -420,46 +431,58 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -481,12 +504,13 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -517,12 +541,12 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -531,12 +555,12 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -544,15 +568,15 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -561,9 +585,9 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -572,9 +596,10 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart */ @Override 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)); + 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); } } @@ -592,11 +617,11 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -608,8 +633,8 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -622,7 +647,7 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -648,13 +673,14 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -666,7 +692,7 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -688,12 +714,15 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -704,10 +733,13 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -726,12 +758,15 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -769,31 +804,35 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } - if(event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation)event.getNewValue()).getSource())) { + if (event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON + .equals(((EAnnotation) event.getNewValue()).getSource())) { refreshLabel(); } super.handleNotificationEvent(event); @@ -826,7 +865,8 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -836,6 +876,7 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -843,5 +884,6 @@ public class DefaultNamedElementNameEditPart extends PapyrusCompartmentEditPart */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyAppliedStereotypeEditPart.java index 7bf37fb925e..7ea06d4a961 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyAppliedStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyAppliedStereotypeEditPart.java @@ -62,6 +62,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; @@ -83,12 +84,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { +public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { /** * @generated */ - public static final String VISUAL_ID = "15"; + public static final String VISUAL_ID = "Dependency_StereotypeLabel"; /** * @generated @@ -127,7 +129,10 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DependencyAppliedStereotypeEditPart.VISUAL_ID), new Point(0, 60)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DependencyAppliedStereotypeEditPart.VISUAL_ID), + new Point(0, 60)); } /** @@ -160,12 +165,12 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -173,12 +178,12 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -186,12 +191,12 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -199,12 +204,12 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -263,10 +268,11 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -279,12 +285,12 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -293,10 +299,11 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -315,22 +322,28 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + DependencyAppliedStereotypeEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -342,10 +355,10 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -361,8 +374,8 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Dependency_4004, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DependencyAppliedStereotypeEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Dependency_Edge, getParserElement(), this, VISUAL_ID); } return parser; } @@ -371,8 +384,10 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -401,8 +416,8 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -410,8 +425,8 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -422,46 +437,58 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -483,12 +510,13 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -519,20 +547,20 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -540,15 +568,15 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -557,9 +585,9 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -568,9 +596,10 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override 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)); + 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); } } @@ -588,11 +617,11 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -604,8 +633,8 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -618,7 +647,7 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -644,13 +673,14 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -662,7 +692,7 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -684,12 +714,15 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -700,10 +733,13 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -722,12 +758,15 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -746,30 +785,34 @@ public class DependencyAppliedStereotypeEditPart extends PapyrusLabelEditPart im @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } + super.handleNotificationEvent(event); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyBranchEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyBranchEditPart.java index 6e612bad06e..3608d19e91d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyBranchEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyBranchEditPart.java @@ -29,7 +29,7 @@ public class DependencyBranchEditPart extends UMLConnectionNodeEditPart implemen /** * @generated */ - public static final String VISUAL_ID = "4010"; + public static final String VISUAL_ID = "Dependency_BranchEdge"; /** * @generated @@ -66,6 +66,6 @@ public class DependencyBranchEditPart extends UMLConnectionNodeEditPart implemen */ @Override public DashedEdgeFigure getPrimaryShape() { - return (DashedEdgeFigure)getFigure(); + return (DashedEdgeFigure) getFigure(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyEditPart.java index 4eb7b30df1f..b1541618c58 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyEditPart.java @@ -32,7 +32,7 @@ public class DependencyEditPart extends UMLConnectionNodeEditPart implements ITr /** * @generated */ - public static final String VISUAL_ID = "4004"; + public static final String VISUAL_ID = "Dependency_Edge"; /** * @generated @@ -48,7 +48,8 @@ public class DependencyEditPart extends UMLConnectionNodeEditPart implements ITr protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeLinkLabelDisplayEditPolicy()); installEditPolicy(ShowHideLabelEditPolicy.SHOW_HIDE_LABEL_ROLE, new ShowHideLabelEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); } @@ -57,11 +58,12 @@ public class DependencyEditPart extends UMLConnectionNodeEditPart implements ITr * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DependencyNameEditPart) { - ((DependencyNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof DependencyNameEditPart) { + ((DependencyNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); } - if(childEditPart instanceof DependencyAppliedStereotypeEditPart) { - ((DependencyAppliedStereotypeEditPart)childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel()); + if (childEditPart instanceof DependencyAppliedStereotypeEditPart) { + ((DependencyAppliedStereotypeEditPart) childEditPart) + .setLabel(getPrimaryShape().getAppliedStereotypeLabel()); } return false; } @@ -71,7 +73,7 @@ public class DependencyEditPart extends UMLConnectionNodeEditPart implements ITr */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -81,10 +83,10 @@ public class DependencyEditPart extends UMLConnectionNodeEditPart implements ITr * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DependencyNameEditPart) { + if (childEditPart instanceof DependencyNameEditPart) { return true; } - if(childEditPart instanceof DependencyAppliedStereotypeEditPart) { + if (childEditPart instanceof DependencyAppliedStereotypeEditPart) { return true; } return false; @@ -95,7 +97,7 @@ public class DependencyEditPart extends UMLConnectionNodeEditPart implements ITr */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -119,6 +121,6 @@ public class DependencyEditPart extends UMLConnectionNodeEditPart implements ITr */ @Override public DashedEdgeFigure getPrimaryShape() { - return (DashedEdgeFigure)getFigure(); + return (DashedEdgeFigure) getFigure(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyNameEditPart.java index fb28ab9d160..490e5e0910c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyNameEditPart.java @@ -62,6 +62,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; @@ -83,12 +84,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { +public class DependencyNameEditPart extends PapyrusLabelEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { /** * @generated */ - public static final String VISUAL_ID = "12"; + public static final String VISUAL_ID = "Dependency_NameLabel"; /** * @generated @@ -127,7 +129,10 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DependencyNameEditPart.VISUAL_ID), new Point(0, 40)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DependencyNameEditPart.VISUAL_ID), + new Point(0, 40)); } /** @@ -160,12 +165,12 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -173,12 +178,12 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -186,12 +191,12 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -199,12 +204,12 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -263,10 +268,11 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -279,12 +285,12 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -293,10 +299,11 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -315,22 +322,25 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), DependencyNameEditPart.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -342,10 +352,10 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -361,8 +371,8 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Dependency_4004, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DependencyNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Dependency_Edge, getParserElement(), this, VISUAL_ID); } return parser; } @@ -371,8 +381,10 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -401,8 +413,8 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -410,8 +422,8 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -422,46 +434,58 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -483,12 +507,13 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -519,20 +544,20 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -540,15 +565,15 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -557,9 +582,9 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -568,9 +593,10 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override 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)); + 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); } } @@ -588,11 +614,11 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -604,8 +630,8 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -618,7 +644,7 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -644,13 +670,14 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -662,7 +689,7 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -684,12 +711,15 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -700,10 +730,13 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -722,12 +755,15 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -746,30 +782,34 @@ public class DependencyNameEditPart extends PapyrusLabelEditPart implements ITex @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } + super.handleNotificationEvent(event); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyNodeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyNodeEditPart.java index b1c081a0cf9..9f2e79155af 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyNodeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DependencyNodeEditPart.java @@ -52,7 +52,7 @@ public class DependencyNodeEditPart extends NodeEditPart { /** * @generated */ - public static final String VISUAL_ID = "2011"; + public static final String VISUAL_ID = "Dependency_Shape"; /** * @generated @@ -78,7 +78,9 @@ public class DependencyNodeEditPart extends NodeEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); installEditPolicy(ShowHideLabelEditPolicy.SHOW_HIDE_LABEL_ROLE, new ShowHideLabelEditPolicy()); @@ -94,16 +96,16 @@ public class DependencyNodeEditPart extends NodeEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View)child.getModel(); + View childView = (View) child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if(vid != null) { - switch(vid) { + if (vid != null) { + switch (vid) { case MultiDependencyLabelEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -111,7 +113,7 @@ public class DependencyNodeEditPart extends NodeEditPart { } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -145,7 +147,7 @@ public class DependencyNodeEditPart extends NodeEditPart { */ @Override public DependencyNodeFigure getPrimaryShape() { - return (DependencyNodeFigure)primaryShape; + return (DependencyNodeFigure) primaryShape; } /** @@ -153,7 +155,7 @@ public class DependencyNodeEditPart extends NodeEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if(borderItemEditPart instanceof MultiDependencyLabelEditPart) { + if (borderItemEditPart instanceof MultiDependencyLabelEditPart) { BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH); locator.setBorderItemOffset(new Dimension(-20, -20)); borderItemContainer.add(borderItemEditPart.getFigure(), locator); @@ -182,6 +184,7 @@ public class DependencyNodeEditPart extends NodeEditPart { @Override protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -202,7 +205,7 @@ public class DependencyNodeEditPart extends NodeEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -213,7 +216,7 @@ public class DependencyNodeEditPart extends NodeEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -231,8 +234,8 @@ public class DependencyNodeEditPart extends NodeEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentAppliedStereotypeEditPart.java index 9c47fe0b69d..01875584c0b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentAppliedStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentAppliedStereotypeEditPart.java @@ -62,6 +62,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; @@ -83,12 +84,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { +public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { /** * @generated */ - public static final String VISUAL_ID = "14"; + public static final String VISUAL_ID = "Deployment_StereotypeLabel"; /** * @generated @@ -127,7 +129,10 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentAppliedStereotypeEditPart.VISUAL_ID), new Point(0, 60)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentAppliedStereotypeEditPart.VISUAL_ID), + new Point(0, 60)); } /** @@ -160,12 +165,12 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -173,12 +178,12 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -186,12 +191,12 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -199,12 +204,12 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -263,10 +268,11 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -279,12 +285,12 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -293,10 +299,11 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -315,22 +322,28 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + DeploymentAppliedStereotypeEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -342,10 +355,10 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -361,8 +374,8 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Deployment_4001, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentAppliedStereotypeEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Deployment_Edge, getParserElement(), this, VISUAL_ID); } return parser; } @@ -371,8 +384,10 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -401,8 +416,8 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -410,8 +425,8 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -422,46 +437,58 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -483,12 +510,13 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -519,20 +547,20 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -540,15 +568,15 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -557,9 +585,9 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -568,9 +596,10 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override 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)); + 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); } } @@ -588,11 +617,11 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -604,8 +633,8 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -618,7 +647,7 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -644,13 +673,14 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -662,7 +692,7 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -684,12 +714,15 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -700,10 +733,13 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -722,12 +758,15 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -746,30 +785,34 @@ public class DeploymentAppliedStereotypeEditPart extends PapyrusLabelEditPart im @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } + super.handleNotificationEvent(event); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentDiagramEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentDiagramEditPart.java index f5bd1084568..3a481824e6a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentDiagramEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentDiagramEditPart.java @@ -33,7 +33,7 @@ public class DeploymentDiagramEditPart extends PapyrusDiagramEditPart { /** * @generated */ - public static final String VISUAL_ID = "1000"; + public static final String VISUAL_ID = "Package_DeploymentDiagram"; /** * @generated @@ -48,11 +48,14 @@ public class DeploymentDiagramEditPart extends PapyrusDiagramEditPart { @Override protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy()); installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultCompartmentSemanticEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.deployment.edit.policies.ModelCanonicalEditPolicy()); + installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentEditPart.java index 85f94ee4070..b90dbd45099 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentEditPart.java @@ -30,7 +30,7 @@ public class DeploymentEditPart extends UMLConnectionNodeEditPart implements ITr /** * @generated */ - public static final String VISUAL_ID = "4001"; + public static final String VISUAL_ID = "Deployment_Edge"; /** * @generated @@ -46,7 +46,8 @@ public class DeploymentEditPart extends UMLConnectionNodeEditPart implements ITr protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeLinkLabelDisplayEditPolicy()); installEditPolicy(ShowHideLabelEditPolicy.SHOW_HIDE_LABEL_ROLE, new ShowHideLabelEditPolicy()); } @@ -54,11 +55,12 @@ public class DeploymentEditPart extends UMLConnectionNodeEditPart implements ITr * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DeploymentNameEditPart) { - ((DeploymentNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof DeploymentNameEditPart) { + ((DeploymentNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); } - if(childEditPart instanceof DeploymentAppliedStereotypeEditPart) { - ((DeploymentAppliedStereotypeEditPart)childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel()); + if (childEditPart instanceof DeploymentAppliedStereotypeEditPart) { + ((DeploymentAppliedStereotypeEditPart) childEditPart) + .setLabel(getPrimaryShape().getAppliedStereotypeLabel()); } return false; } @@ -68,7 +70,7 @@ public class DeploymentEditPart extends UMLConnectionNodeEditPart implements ITr */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -78,10 +80,10 @@ public class DeploymentEditPart extends UMLConnectionNodeEditPart implements ITr * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DeploymentNameEditPart) { + if (childEditPart instanceof DeploymentNameEditPart) { return true; } - if(childEditPart instanceof DeploymentAppliedStereotypeEditPart) { + if (childEditPart instanceof DeploymentAppliedStereotypeEditPart) { return true; } return false; @@ -92,7 +94,7 @@ public class DeploymentEditPart extends UMLConnectionNodeEditPart implements ITr */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -116,6 +118,6 @@ public class DeploymentEditPart extends UMLConnectionNodeEditPart implements ITr */ @Override public DashedEdgeFigure getPrimaryShape() { - return (DashedEdgeFigure)getFigure(); + return (DashedEdgeFigure) getFigure(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentNameEditPart.java index 6b17c6fb877..69e0f7e587a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentNameEditPart.java @@ -62,6 +62,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; @@ -83,12 +84,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { +public class DeploymentNameEditPart extends PapyrusLabelEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { /** * @generated */ - public static final String VISUAL_ID = "13"; + public static final String VISUAL_ID = "Deployment_NameLabel"; /** * @generated @@ -127,7 +129,10 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentNameEditPart.VISUAL_ID), new Point(0, 60)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentNameEditPart.VISUAL_ID), + new Point(0, 60)); } /** @@ -160,12 +165,12 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -173,12 +178,12 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -186,12 +191,12 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -199,12 +204,12 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -263,10 +268,11 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -279,12 +285,12 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -293,10 +299,11 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -315,22 +322,25 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), DeploymentNameEditPart.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -342,10 +352,10 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -361,8 +371,8 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Deployment_4001, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Deployment_Edge, getParserElement(), this, VISUAL_ID); } return parser; } @@ -371,8 +381,10 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -401,8 +413,8 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -410,8 +422,8 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -422,46 +434,58 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -483,12 +507,13 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -519,20 +544,20 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -540,15 +565,15 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -557,9 +582,9 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -568,9 +593,10 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override 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)); + 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); } } @@ -588,11 +614,11 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -604,8 +630,8 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -618,7 +644,7 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -644,13 +670,14 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -662,7 +689,7 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -684,12 +711,15 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -700,10 +730,13 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -722,12 +755,15 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -746,30 +782,34 @@ public class DeploymentNameEditPart extends PapyrusLabelEditPart implements ITex @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } + super.handleNotificationEvent(event); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsClassifierEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsClassifierEditPart.java index 818ceca2c8d..11c4f45f25f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsClassifierEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsClassifierEditPart.java @@ -63,7 +63,7 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa /** * @generated */ - public static final String VISUAL_ID = "2014"; + public static final String VISUAL_ID = "DeploymentSpecification_Shape_CCN"; /** * @generated @@ -88,10 +88,13 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -108,16 +111,16 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View)child.getModel(); + View childView = (View) child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if(vid != null) { - switch(vid) { + if (vid != null) { + switch (vid) { case DeploymentSpecAsClassifierFloatingLabelEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -125,7 +128,7 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -153,16 +156,17 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View)getModel()).getChildren(); - if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if(modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View) getModel()).getChildren(); + if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if (modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); + } /** @@ -177,17 +181,18 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa * @generated */ public DeploymentSpecificationFigure getPrimaryShape() { - return (DeploymentSpecificationFigure)primaryShape; + return (DeploymentSpecificationFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DeploymentSpecAsClassifierNameEditPart) { - ((DeploymentSpecAsClassifierNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof DeploymentSpecAsClassifierNameEditPart) { + ((DeploymentSpecAsClassifierNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } + return false; } @@ -195,7 +200,7 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DeploymentSpecAsClassifierNameEditPart) { + if (childEditPart instanceof DeploymentSpecAsClassifierNameEditPart) { return true; } return false; @@ -205,7 +210,7 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa * @generated */ protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -215,7 +220,7 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa * @generated */ protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -225,7 +230,7 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa * @generated */ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof IBorderItemEditPart) { + if (editPart instanceof IBorderItemEditPart) { return getBorderedFigure().getBorderItemContainer(); } return getContentPane(); @@ -235,7 +240,7 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa * @generated */ protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if(borderItemEditPart instanceof DeploymentSpecAsClassifierFloatingLabelEditPart) { + if (borderItemEditPart instanceof DeploymentSpecAsClassifierFloatingLabelEditPart) { BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH); locator.setBorderItemOffset(new Dimension(-20, -20)); borderItemContainer.add(borderItemEditPart.getFigure(), locator); @@ -259,6 +264,7 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa */ protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -268,7 +274,7 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa * @generated */ protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -280,7 +286,7 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa * @generated */ public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -290,7 +296,7 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa * @generated */ protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -306,8 +312,8 @@ public class DeploymentSpecAsClassifierEditPart extends RoundedCompartmentEditPa * @generated */ protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsClassifierFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsClassifierFloatingLabelEditPart.java index 83c3c3474a6..11a8ab7b366 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsClassifierFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsClassifierFloatingLabelEditPart.java @@ -63,6 +63,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimar import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editparts.FloatingLabelEditPart; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; @@ -84,12 +85,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { +public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLabelEditPart + implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated */ - public static final String VISUAL_ID = "65"; + public static final String VISUAL_ID = "DeploymentSpecification_FloatingNameLabel_CCN"; /** * @generated @@ -128,7 +130,10 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecAsClassifierFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecAsClassifierFloatingLabelEditPart.VISUAL_ID), + new Point(0, 0)); } /** @@ -153,9 +158,9 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab */ public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if(parentFigure != null && parentFigure.getLayoutManager() != null) { + if (parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator)constraint; + return (IBorderItemLocator) constraint; } return null; } @@ -164,10 +169,10 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ public void refreshBounds() { - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -175,12 +180,12 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -188,12 +193,12 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -201,12 +206,12 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -214,12 +219,12 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -275,10 +280,11 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -290,12 +296,12 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -303,10 +309,11 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -324,22 +331,27 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + DeploymentSpecAsClassifierFloatingLabelEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -350,10 +362,10 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -367,8 +379,9 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.DeploymentSpecification_2014, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecAsClassifierFloatingLabelEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.DeploymentSpecification_Shape_CCN, getParserElement(), this, + VISUAL_ID); } return parser; } @@ -377,8 +390,10 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -407,8 +422,8 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -416,8 +431,8 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -427,46 +442,58 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -488,12 +515,13 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -523,20 +551,20 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -544,15 +572,15 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -561,9 +589,9 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -571,9 +599,10 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ 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)); + 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); } } @@ -589,11 +618,11 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -604,8 +633,8 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -617,7 +646,7 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -643,13 +672,14 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -661,7 +691,7 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -683,12 +713,15 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -699,10 +732,13 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -721,12 +757,15 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -744,24 +783,27 @@ public class DeploymentSpecAsClassifierFloatingLabelEditPart extends FloatingLab */ protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsClassifierNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsClassifierNameEditPart.java index deacd177693..b379d3fbbaf 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsClassifierNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsClassifierNameEditPart.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "64"; + public static final String VISUAL_ID = "DeploymentSpecification_NameLabel_CCN"; /** * @generated @@ -141,12 +143,12 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -154,12 +156,12 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -167,12 +169,12 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -180,12 +182,12 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -241,10 +243,11 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -256,12 +259,12 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -269,10 +272,11 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -290,22 +294,28 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + DeploymentSpecAsClassifierNameEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -316,10 +326,10 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -333,8 +343,9 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.DeploymentSpecification_2014, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecAsClassifierNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.DeploymentSpecification_Shape_CCN, getParserElement(), this, + VISUAL_ID); } return parser; } @@ -343,8 +354,10 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -373,8 +386,8 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -382,8 +395,8 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -393,46 +406,58 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -454,12 +479,13 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -489,12 +515,12 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -503,12 +529,12 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -516,15 +542,15 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -533,9 +559,9 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -543,9 +569,10 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ 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)); + 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); } } @@ -561,11 +588,11 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -576,8 +603,8 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -589,7 +616,7 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -615,13 +642,14 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -633,7 +661,7 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -654,12 +682,15 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -669,10 +700,13 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -689,12 +723,15 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -729,24 +766,27 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -781,7 +821,8 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -790,6 +831,7 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -797,5 +839,6 @@ public class DeploymentSpecAsClassifierNameEditPart extends PapyrusCompartmentEd */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsNestedArtifactEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsNestedArtifactEditPart.java index a0f5bbaa852..0ed71d57bcc 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsNestedArtifactEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsNestedArtifactEditPart.java @@ -63,7 +63,7 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd /** * @generated */ - public static final String VISUAL_ID = "2016"; + public static final String VISUAL_ID = "DeploymentSpecification_Shape_ACN"; /** * @generated @@ -88,10 +88,13 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -108,16 +111,16 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View)child.getModel(); + View childView = (View) child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if(vid != null) { - switch(vid) { + if (vid != null) { + switch (vid) { case DeploymentSpecAsNestedArtifactFloatingLabelEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -125,7 +128,7 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -153,16 +156,17 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View)getModel()).getChildren(); - if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if(modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View) getModel()).getChildren(); + if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if (modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); + } /** @@ -177,17 +181,18 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd * @generated */ public DeploymentSpecificationFigure getPrimaryShape() { - return (DeploymentSpecificationFigure)primaryShape; + return (DeploymentSpecificationFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DeploymentSpecAsNestedArtifactNameEditPart) { - ((DeploymentSpecAsNestedArtifactNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof DeploymentSpecAsNestedArtifactNameEditPart) { + ((DeploymentSpecAsNestedArtifactNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } + return false; } @@ -195,7 +200,7 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DeploymentSpecAsNestedArtifactNameEditPart) { + if (childEditPart instanceof DeploymentSpecAsNestedArtifactNameEditPart) { return true; } return false; @@ -205,7 +210,7 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd * @generated */ protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -215,7 +220,7 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd * @generated */ protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -225,7 +230,7 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd * @generated */ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof IBorderItemEditPart) { + if (editPart instanceof IBorderItemEditPart) { return getBorderedFigure().getBorderItemContainer(); } return getContentPane(); @@ -235,7 +240,7 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd * @generated */ protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if(borderItemEditPart instanceof DeploymentSpecAsNestedArtifactFloatingLabelEditPart) { + if (borderItemEditPart instanceof DeploymentSpecAsNestedArtifactFloatingLabelEditPart) { BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH); locator.setBorderItemOffset(new Dimension(-20, -20)); borderItemContainer.add(borderItemEditPart.getFigure(), locator); @@ -259,6 +264,7 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd */ protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -268,7 +274,7 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd * @generated */ protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -280,7 +286,7 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd * @generated */ public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -290,7 +296,7 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd * @generated */ protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -306,8 +312,8 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd * @generated */ protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } @@ -315,6 +321,7 @@ public class DeploymentSpecAsNestedArtifactEditPart extends RoundedCompartmentEd * @generated */ public EditPart getPrimaryChildEditPart() { - return getChildBySemanticHint(UMLVisualIDRegistry.getType(DeploymentSpecAsNestedArtifactNameEditPart.VISUAL_ID)); + return getChildBySemanticHint( + UMLVisualIDRegistry.getType(DeploymentSpecAsNestedArtifactNameEditPart.VISUAL_ID)); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsNestedArtifactFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsNestedArtifactFloatingLabelEditPart.java index db8e2c63b6f..c7ee67a609c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsNestedArtifactFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsNestedArtifactFloatingLabelEditPart.java @@ -63,6 +63,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimar import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editparts.FloatingLabelEditPart; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; @@ -84,12 +85,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { +public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends FloatingLabelEditPart + implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated */ - public static final String VISUAL_ID = "69"; + public static final String VISUAL_ID = "DeploymentSpecification_FloatingNameLabel_ACN"; /** * @generated @@ -128,7 +130,10 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecAsNestedArtifactFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecAsNestedArtifactFloatingLabelEditPart.VISUAL_ID), + new Point(0, 0)); } /** @@ -153,9 +158,9 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin */ public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if(parentFigure != null && parentFigure.getLayoutManager() != null) { + if (parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator)constraint; + return (IBorderItemLocator) constraint; } return null; } @@ -164,10 +169,10 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ public void refreshBounds() { - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -175,12 +180,12 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -188,12 +193,12 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -201,12 +206,12 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -214,12 +219,12 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -275,10 +280,11 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -290,12 +296,12 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -303,10 +309,11 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -324,22 +331,27 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + DeploymentSpecAsNestedArtifactFloatingLabelEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -350,10 +362,10 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -367,8 +379,9 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.DeploymentSpecification_2016, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecAsNestedArtifactFloatingLabelEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.DeploymentSpecification_Shape_ACN, getParserElement(), this, + VISUAL_ID); } return parser; } @@ -377,8 +390,10 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -407,8 +422,8 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -416,8 +431,8 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -427,46 +442,58 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -488,12 +515,13 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -523,20 +551,20 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -544,15 +572,15 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -561,9 +589,9 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -571,9 +599,10 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ 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)); + 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); } } @@ -589,11 +618,11 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -604,8 +633,8 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -617,7 +646,7 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -643,13 +672,14 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -661,7 +691,7 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -683,12 +713,15 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -699,10 +732,13 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -721,12 +757,15 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -744,24 +783,27 @@ public class DeploymentSpecAsNestedArtifactFloatingLabelEditPart extends Floatin */ protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsNestedArtifactNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsNestedArtifactNameEditPart.java index 1440e846878..d925b7b030d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsNestedArtifactNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsNestedArtifactNameEditPart.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "68"; + public static final String VISUAL_ID = "DeploymentSpecification_NameLabel_ACN"; /** * @generated @@ -141,12 +143,12 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -154,12 +156,12 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -167,12 +169,12 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -180,12 +182,12 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -241,10 +243,11 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -256,12 +259,12 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -269,10 +272,11 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -290,22 +294,27 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + DeploymentSpecAsNestedArtifactNameEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -316,10 +325,10 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -333,8 +342,9 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.DeploymentSpecification_2016, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecAsNestedArtifactNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.DeploymentSpecification_Shape_ACN, getParserElement(), this, + VISUAL_ID); } return parser; } @@ -343,8 +353,10 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -373,8 +385,8 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -382,8 +394,8 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -393,46 +405,58 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -454,12 +478,13 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -489,12 +514,12 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -503,12 +528,12 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -516,15 +541,15 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -533,9 +558,9 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -543,9 +568,10 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ 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)); + 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); } } @@ -561,11 +587,11 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -576,8 +602,8 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -589,7 +615,7 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -615,13 +641,14 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -633,7 +660,7 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -654,12 +681,15 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -669,10 +699,13 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -689,12 +722,15 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -729,24 +765,27 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -781,7 +820,8 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -790,6 +830,7 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -797,5 +838,6 @@ public class DeploymentSpecAsNestedArtifactNameEditPart extends PapyrusCompartme */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsPackageableElEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsPackageableElEditPart.java index 8cb8aca86ac..2aaa1f8cf1c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsPackageableElEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsPackageableElEditPart.java @@ -63,7 +63,7 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi /** * @generated */ - public static final String VISUAL_ID = "2015"; + public static final String VISUAL_ID = "DeploymentSpecification_Shape_CN"; /** * @generated @@ -88,10 +88,13 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -108,16 +111,16 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View)child.getModel(); + View childView = (View) child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if(vid != null) { - switch(vid) { + if (vid != null) { + switch (vid) { case DeploymentSpecAsPackageableElFloatingLabelEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -125,7 +128,7 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -153,16 +156,17 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View)getModel()).getChildren(); - if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if(modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View) getModel()).getChildren(); + if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if (modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); + } /** @@ -177,17 +181,18 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi * @generated */ public DeploymentSpecificationFigure getPrimaryShape() { - return (DeploymentSpecificationFigure)primaryShape; + return (DeploymentSpecificationFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DeploymentSpecAsPackageableElNameEditPart) { - ((DeploymentSpecAsPackageableElNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof DeploymentSpecAsPackageableElNameEditPart) { + ((DeploymentSpecAsPackageableElNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } + return false; } @@ -195,7 +200,7 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DeploymentSpecAsPackageableElNameEditPart) { + if (childEditPart instanceof DeploymentSpecAsPackageableElNameEditPart) { return true; } return false; @@ -205,7 +210,7 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi * @generated */ protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -215,7 +220,7 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi * @generated */ protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -225,7 +230,7 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi * @generated */ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof IBorderItemEditPart) { + if (editPart instanceof IBorderItemEditPart) { return getBorderedFigure().getBorderItemContainer(); } return getContentPane(); @@ -235,7 +240,7 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi * @generated */ protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if(borderItemEditPart instanceof DeploymentSpecAsPackageableElFloatingLabelEditPart) { + if (borderItemEditPart instanceof DeploymentSpecAsPackageableElFloatingLabelEditPart) { BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH); locator.setBorderItemOffset(new Dimension(-20, -20)); borderItemContainer.add(borderItemEditPart.getFigure(), locator); @@ -259,6 +264,7 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi */ protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -268,7 +274,7 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi * @generated */ protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -280,7 +286,7 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi * @generated */ public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -290,7 +296,7 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi * @generated */ protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -306,8 +312,8 @@ public class DeploymentSpecAsPackageableElEditPart extends RoundedCompartmentEdi * @generated */ protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsPackageableElFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsPackageableElFloatingLabelEditPart.java index 4c0a6bbddd4..d4a340efbd5 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsPackageableElFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsPackageableElFloatingLabelEditPart.java @@ -63,6 +63,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimar import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editparts.FloatingLabelEditPart; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; @@ -84,12 +85,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { +public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends FloatingLabelEditPart + implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated */ - public static final String VISUAL_ID = "67"; + public static final String VISUAL_ID = "DeploymentSpecification_FloatingNameLabel_CN"; /** * @generated @@ -128,7 +130,10 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecAsPackageableElFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecAsPackageableElFloatingLabelEditPart.VISUAL_ID), + new Point(0, 0)); } /** @@ -153,9 +158,9 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating */ public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if(parentFigure != null && parentFigure.getLayoutManager() != null) { + if (parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator)constraint; + return (IBorderItemLocator) constraint; } return null; } @@ -164,10 +169,10 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ public void refreshBounds() { - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -175,12 +180,12 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -188,12 +193,12 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -201,12 +206,12 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -214,12 +219,12 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -275,10 +280,11 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -290,12 +296,12 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -303,10 +309,11 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -324,22 +331,27 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + DeploymentSpecAsPackageableElFloatingLabelEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -350,10 +362,10 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -367,8 +379,9 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.DeploymentSpecification_2015, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecAsPackageableElFloatingLabelEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.DeploymentSpecification_Shape_CN, getParserElement(), this, + VISUAL_ID); } return parser; } @@ -377,8 +390,10 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -407,8 +422,8 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -416,8 +431,8 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -427,46 +442,58 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -488,12 +515,13 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -523,20 +551,20 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -544,15 +572,15 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -561,9 +589,9 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -571,9 +599,10 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ 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)); + 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); } } @@ -589,11 +618,11 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -604,8 +633,8 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -617,7 +646,7 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -643,13 +672,14 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -661,7 +691,7 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -683,12 +713,15 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -699,10 +732,13 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -721,12 +757,15 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -744,24 +783,27 @@ public class DeploymentSpecAsPackageableElFloatingLabelEditPart extends Floating */ protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsPackageableElNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsPackageableElNameEditPart.java index 510fc7b479b..ec83f3bcb9a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsPackageableElNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecAsPackageableElNameEditPart.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "66"; + public static final String VISUAL_ID = "DeploymentSpecification_NameLabel_CN"; /** * @generated @@ -141,12 +143,12 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -154,12 +156,12 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -167,12 +169,12 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -180,12 +182,12 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -241,10 +243,11 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -256,12 +259,12 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -269,10 +272,11 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -290,22 +294,27 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + DeploymentSpecAsPackageableElNameEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -316,10 +325,10 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -333,8 +342,9 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.DeploymentSpecification_2015, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecAsPackageableElNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.DeploymentSpecification_Shape_CN, getParserElement(), this, + VISUAL_ID); } return parser; } @@ -343,8 +353,10 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -373,8 +385,8 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -382,8 +394,8 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -393,46 +405,58 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -454,12 +478,13 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -489,12 +514,12 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -503,12 +528,12 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -516,15 +541,15 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -533,9 +558,9 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -543,9 +568,10 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ 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)); + 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); } } @@ -561,11 +587,11 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -576,8 +602,8 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -589,7 +615,7 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -615,13 +641,14 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -633,7 +660,7 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -654,12 +681,15 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -669,10 +699,13 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -689,12 +722,15 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -729,24 +765,27 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -781,7 +820,8 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -790,6 +830,7 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -797,5 +838,6 @@ public class DeploymentSpecAsPackageableElNameEditPart extends PapyrusCompartmen */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecificationEditPart.java index 501ccebd461..fda4258abca 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecificationEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecificationEditPart.java @@ -62,7 +62,7 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart /** * @generated */ - public static final String VISUAL_ID = "2013"; + public static final String VISUAL_ID = "DeploymentSpecification_Shape"; /** * @generated @@ -87,10 +87,13 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -107,16 +110,16 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View)child.getModel(); + View childView = (View) child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if(vid != null) { - switch(vid) { + if (vid != null) { + switch (vid) { case DeploymentSpecificationFloatingLabelEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -124,7 +127,7 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -152,16 +155,17 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View)getModel()).getChildren(); - if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if(modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View) getModel()).getChildren(); + if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if (modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); + } /** @@ -176,17 +180,18 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart * @generated */ public DeploymentSpecificationFigure getPrimaryShape() { - return (DeploymentSpecificationFigure)primaryShape; + return (DeploymentSpecificationFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DeploymentSpecificationNameEditPart) { - ((DeploymentSpecificationNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof DeploymentSpecificationNameEditPart) { + ((DeploymentSpecificationNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } + return false; } @@ -194,7 +199,7 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DeploymentSpecificationNameEditPart) { + if (childEditPart instanceof DeploymentSpecificationNameEditPart) { return true; } return false; @@ -204,7 +209,7 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart * @generated */ protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -214,7 +219,7 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart * @generated */ protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -224,7 +229,7 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart * @generated */ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof IBorderItemEditPart) { + if (editPart instanceof IBorderItemEditPart) { return getBorderedFigure().getBorderItemContainer(); } return getContentPane(); @@ -234,7 +239,7 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart * @generated */ protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if(borderItemEditPart instanceof DeploymentSpecificationFloatingLabelEditPart) { + if (borderItemEditPart instanceof DeploymentSpecificationFloatingLabelEditPart) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -257,6 +262,7 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart */ protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -266,7 +272,7 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart * @generated */ protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -278,7 +284,7 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart * @generated */ public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -288,7 +294,7 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart * @generated */ protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -304,8 +310,8 @@ public class DeploymentSpecificationEditPart extends RoundedCompartmentEditPart * @generated */ protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecificationFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecificationFloatingLabelEditPart.java index ef43996c980..07435b85278 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecificationFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecificationFloatingLabelEditPart.java @@ -63,6 +63,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimar import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editparts.FloatingLabelEditPart; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; @@ -84,12 +85,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { +public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelEditPart + implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated */ - public static final String VISUAL_ID = "63"; + public static final String VISUAL_ID = "DeploymentSpecification_FloatingNameLabel"; /** * @generated @@ -128,7 +130,10 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecificationFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecificationFloatingLabelEditPart.VISUAL_ID), + new Point(0, 0)); } /** @@ -153,9 +158,9 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE */ public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if(parentFigure != null && parentFigure.getLayoutManager() != null) { + if (parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator)constraint; + return (IBorderItemLocator) constraint; } return null; } @@ -164,10 +169,10 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ public void refreshBounds() { - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -175,12 +180,12 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -188,12 +193,12 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -201,12 +206,12 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -214,12 +219,12 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -275,10 +280,11 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -290,12 +296,12 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -303,10 +309,11 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -324,22 +331,27 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + DeploymentSpecificationFloatingLabelEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -350,10 +362,10 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -367,8 +379,9 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.DeploymentSpecification_2013, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecificationFloatingLabelEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.DeploymentSpecification_Shape, getParserElement(), this, + VISUAL_ID); } return parser; } @@ -377,8 +390,10 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -407,8 +422,8 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -416,8 +431,8 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -427,46 +442,58 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -488,12 +515,13 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -523,20 +551,20 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -544,15 +572,15 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -561,9 +589,9 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -571,9 +599,10 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ 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)); + 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); } } @@ -589,11 +618,11 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -604,8 +633,8 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -617,7 +646,7 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -643,13 +672,14 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -661,7 +691,7 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -683,12 +713,15 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -699,10 +732,13 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -721,12 +757,15 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -744,24 +783,27 @@ public class DeploymentSpecificationFloatingLabelEditPart extends FloatingLabelE */ protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecificationNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecificationNameEditPart.java index c18f3ac16bb..5327e04871a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecificationNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeploymentSpecificationNameEditPart.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "62"; + public static final String VISUAL_ID = "DeploymentSpecification_NameLabel"; /** * @generated @@ -141,12 +143,12 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -154,12 +156,12 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -167,12 +169,12 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -180,12 +182,12 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -241,10 +243,11 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -256,12 +259,12 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -269,10 +272,11 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -290,22 +294,28 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + DeploymentSpecificationNameEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -316,10 +326,10 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -333,8 +343,9 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.DeploymentSpecification_2013, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeploymentSpecificationNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.DeploymentSpecification_Shape, getParserElement(), this, + VISUAL_ID); } return parser; } @@ -343,8 +354,10 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -373,8 +386,8 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -382,8 +395,8 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -393,46 +406,58 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -454,12 +479,13 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -489,12 +515,12 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -503,12 +529,12 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -516,15 +542,15 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -533,9 +559,9 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -543,9 +569,10 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ 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)); + 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); } } @@ -561,11 +588,11 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -576,8 +603,8 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -589,7 +616,7 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -615,13 +642,14 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -633,7 +661,7 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -654,12 +682,15 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -669,10 +700,13 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -689,12 +723,15 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -729,24 +766,27 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -781,7 +821,8 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -790,6 +831,7 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -797,5 +839,6 @@ public class DeploymentSpecificationNameEditPart extends PapyrusCompartmentEditP */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceCompositeCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceCompositeCompartmentEditPart.java index 9c30c979506..ee450dbff00 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceCompositeCompartmentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceCompositeCompartmentEditPart.java @@ -40,7 +40,7 @@ public class DeviceCompositeCompartmentEditPart extends LinkLFShapeCompartmentEd /** * @generated */ - public static final String VISUAL_ID = "17"; + public static final String VISUAL_ID = "Device_NestedNodeCompartment"; /** * @generated @@ -69,6 +69,7 @@ public class DeviceCompositeCompartmentEditPart extends LinkLFShapeCompartmentEd installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.deployment.edit.policies.DeviceCompositeCompartmentCanonicalEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); } @@ -78,7 +79,7 @@ public class DeviceCompositeCompartmentEditPart extends LinkLFShapeCompartmentEd */ @Override protected void setRatio(Double ratio) { - if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -88,6 +89,7 @@ public class DeviceCompositeCompartmentEditPart extends LinkLFShapeCompartmentEd */ @Override public EditPart getTargetEditPart(Request request) { + return super.getTargetEditPart(request); } @@ -97,7 +99,10 @@ public class DeviceCompositeCompartmentEditPart extends LinkLFShapeCompartmentEd @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) + || NotationPackage.eINSTANCE.getSize_Height().equals(feature) + || NotationPackage.eINSTANCE.getLocation_X().equals(feature) + || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -107,13 +112,13 @@ public class DeviceCompositeCompartmentEditPart extends LinkLFShapeCompartmentEd * @generated */ protected void refreshBounds() { - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceCompositeCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceCompositeCompartmentEditPartCN.java index c574021eda6..f323b2c2da3 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceCompositeCompartmentEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceCompositeCompartmentEditPartCN.java @@ -41,7 +41,7 @@ public class DeviceCompositeCompartmentEditPartCN extends LinkLFShapeCompartment /** * @generated */ - public static final String VISUAL_ID = "30"; + public static final String VISUAL_ID = "Device_NestedNodeCompartment_CN"; /** * @generated @@ -71,6 +71,7 @@ public class DeviceCompositeCompartmentEditPartCN extends LinkLFShapeCompartment installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.deployment.edit.policies.DeviceCompositeCompartmentCanonicalEditPolicyCN()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); } @@ -80,7 +81,7 @@ public class DeviceCompositeCompartmentEditPartCN extends LinkLFShapeCompartment */ @Override protected void setRatio(Double ratio) { - if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -90,6 +91,7 @@ public class DeviceCompositeCompartmentEditPartCN extends LinkLFShapeCompartment */ @Override public EditPart getTargetEditPart(Request request) { + return super.getTargetEditPart(request); } @@ -99,7 +101,10 @@ public class DeviceCompositeCompartmentEditPartCN extends LinkLFShapeCompartment @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) + || NotationPackage.eINSTANCE.getSize_Height().equals(feature) + || NotationPackage.eINSTANCE.getLocation_X().equals(feature) + || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -109,13 +114,13 @@ public class DeviceCompositeCompartmentEditPartCN extends LinkLFShapeCompartment * @generated */ protected void refreshBounds() { - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceEditPart.java index be5b84b3d4f..2db866f919d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceEditPart.java @@ -52,7 +52,7 @@ public class DeviceEditPart extends NamedElementEditPart { /** * @generated */ - public static final String VISUAL_ID = "2003"; + public static final String VISUAL_ID = "Device_Shape"; /** * @generated @@ -78,13 +78,18 @@ public class DeviceEditPart extends NamedElementEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); - installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, + new ShowHideClassifierContentsEditPolicy()); installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -101,7 +106,7 @@ public class DeviceEditPart extends NamedElementEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -128,6 +133,7 @@ public class DeviceEditPart extends NamedElementEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); + } /** @@ -145,23 +151,25 @@ public class DeviceEditPart extends NamedElementEditPart { */ @Override public DeviceFigure getPrimaryShape() { - return (DeviceFigure)primaryShape; + return (DeviceFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DeviceNameEditPart) { - ((DeviceNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof DeviceNameEditPart) { + ((DeviceNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if(childEditPart instanceof DeviceCompositeCompartmentEditPart) { + + if (childEditPart instanceof DeviceCompositeCompartmentEditPart) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((DeviceCompositeCompartmentEditPart)childEditPart).getFigure()); + pane.add(((DeviceCompositeCompartmentEditPart) childEditPart).getFigure()); return true; } + return false; } @@ -169,12 +177,12 @@ public class DeviceEditPart extends NamedElementEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DeviceNameEditPart) { + if (childEditPart instanceof DeviceNameEditPart) { return true; } - if(childEditPart instanceof DeviceCompositeCompartmentEditPart) { + if (childEditPart instanceof DeviceCompositeCompartmentEditPart) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); - pane.remove(((DeviceCompositeCompartmentEditPart)childEditPart).getFigure()); + pane.remove(((DeviceCompositeCompartmentEditPart) childEditPart).getFigure()); return true; } return false; @@ -185,7 +193,7 @@ public class DeviceEditPart extends NamedElementEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -196,7 +204,7 @@ public class DeviceEditPart extends NamedElementEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -207,7 +215,7 @@ public class DeviceEditPart extends NamedElementEditPart { */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof DeviceCompositeCompartmentEditPart) { + if (editPart instanceof DeviceCompositeCompartmentEditPart) { return getPrimaryShape().getCompositeCompartmentFigure(); } return getContentPane(); @@ -233,6 +241,7 @@ public class DeviceEditPart extends NamedElementEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -245,7 +254,7 @@ public class DeviceEditPart extends NamedElementEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -258,7 +267,7 @@ public class DeviceEditPart extends NamedElementEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -269,7 +278,7 @@ public class DeviceEditPart extends NamedElementEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -287,8 +296,8 @@ public class DeviceEditPart extends NamedElementEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceEditPartCN.java index 0d7bdeba7e1..6e878a0eceb 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceEditPartCN.java @@ -52,7 +52,7 @@ public class DeviceEditPartCN extends NamedElementEditPart { /** * @generated */ - public static final String VISUAL_ID = "16"; + public static final String VISUAL_ID = "Device_Shape_CCN"; /** * @generated @@ -78,13 +78,18 @@ public class DeviceEditPartCN extends NamedElementEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); - installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, + new ShowHideClassifierContentsEditPolicy()); installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -101,7 +106,7 @@ public class DeviceEditPartCN extends NamedElementEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -128,6 +133,7 @@ public class DeviceEditPartCN extends NamedElementEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); + } /** @@ -145,17 +151,18 @@ public class DeviceEditPartCN extends NamedElementEditPart { */ @Override public DeviceFigure getPrimaryShape() { - return (DeviceFigure)primaryShape; + return (DeviceFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DeviceNameEditPartCN) { - ((DeviceNameEditPartCN)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof DeviceNameEditPartCN) { + ((DeviceNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } + return false; } @@ -163,7 +170,7 @@ public class DeviceEditPartCN extends NamedElementEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof DeviceNameEditPartCN) { + if (childEditPart instanceof DeviceNameEditPartCN) { return true; } return false; @@ -174,7 +181,7 @@ public class DeviceEditPartCN extends NamedElementEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -185,7 +192,7 @@ public class DeviceEditPartCN extends NamedElementEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -219,6 +226,7 @@ public class DeviceEditPartCN extends NamedElementEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -231,7 +239,7 @@ public class DeviceEditPartCN extends NamedElementEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -244,7 +252,7 @@ public class DeviceEditPartCN extends NamedElementEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -255,7 +263,7 @@ public class DeviceEditPartCN extends NamedElementEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -273,8 +281,8 @@ public class DeviceEditPartCN extends NamedElementEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceNameEditPart.java index d8c7681976a..5ac0ccd60c8 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceNameEditPart.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class DeviceNameEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "6"; + public static final String VISUAL_ID = "Device_NameLabel"; /** * @generated @@ -144,12 +146,12 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,25 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), DeviceNameEditPart.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +333,10 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +352,8 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Device_2003, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeviceNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Device_Shape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +362,10 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +394,8 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +403,8 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +415,58 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +488,13 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +525,12 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +539,12 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +552,15 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +569,9 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +580,10 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT */ @Override 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)); + 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); } } @@ -578,11 +601,11 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +617,8 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +631,7 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +657,14 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +676,7 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +698,15 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +717,13 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +742,15 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +788,27 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +845,8 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +856,7 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +864,6 @@ public class DeviceNameEditPart extends PapyrusCompartmentEditPart implements IT */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceNameEditPartCN.java index 544786af33d..addd5285cbf 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceNameEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/DeviceNameEditPartCN.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "20"; + public static final String VISUAL_ID = "Device_NameLabel_CCN"; /** * @generated @@ -144,12 +146,12 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,25 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), DeviceNameEditPartCN.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +333,10 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +352,8 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Device_16, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.DeviceNameEditPartCN.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Device_Shape_CCN, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +362,10 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +394,8 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +403,8 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +415,58 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +488,13 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +525,12 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +539,12 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +552,15 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +569,9 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +580,10 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override 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)); + 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); } } @@ -578,11 +601,11 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +617,8 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +631,7 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +657,14 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +676,7 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +698,15 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +717,13 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +742,15 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +788,27 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +845,8 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +856,7 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +864,6 @@ public class DeviceNameEditPartCN extends PapyrusCompartmentEditPart implements */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentCompositeCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentCompositeCompartmentEditPart.java index a0ca9da1020..bfe032a9316 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentCompositeCompartmentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentCompositeCompartmentEditPart.java @@ -40,7 +40,7 @@ public class ExecutionEnvironmentCompositeCompartmentEditPart extends LinkLFShap /** * @generated */ - public static final String VISUAL_ID = "18"; + public static final String VISUAL_ID = "ExecutionEnvironment_NestedNodeCompartment"; /** * @generated @@ -69,6 +69,7 @@ public class ExecutionEnvironmentCompositeCompartmentEditPart extends LinkLFShap installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.deployment.edit.policies.ExecutionEnvironmentCompositeCompartmentCanonicalEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); } @@ -78,7 +79,7 @@ public class ExecutionEnvironmentCompositeCompartmentEditPart extends LinkLFShap */ @Override protected void setRatio(Double ratio) { - if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -88,6 +89,7 @@ public class ExecutionEnvironmentCompositeCompartmentEditPart extends LinkLFShap */ @Override public EditPart getTargetEditPart(Request request) { + return super.getTargetEditPart(request); } @@ -97,7 +99,10 @@ public class ExecutionEnvironmentCompositeCompartmentEditPart extends LinkLFShap @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) + || NotationPackage.eINSTANCE.getSize_Height().equals(feature) + || NotationPackage.eINSTANCE.getLocation_X().equals(feature) + || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -107,13 +112,13 @@ public class ExecutionEnvironmentCompositeCompartmentEditPart extends LinkLFShap * @generated */ protected void refreshBounds() { - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentCompositeCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentCompositeCompartmentEditPartCN.java index 9265afc53b6..2feb9119f4a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentCompositeCompartmentEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentCompositeCompartmentEditPartCN.java @@ -41,7 +41,7 @@ public class ExecutionEnvironmentCompositeCompartmentEditPartCN extends LinkLFSh /** * @generated */ - public static final String VISUAL_ID = "31"; + public static final String VISUAL_ID = "ExecutionEnvironment_NestedNodeCompartment_CN"; /** * @generated @@ -71,6 +71,7 @@ public class ExecutionEnvironmentCompositeCompartmentEditPartCN extends LinkLFSh installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.deployment.edit.policies.ExecutionEnvironmentCompositeCompartmentCanonicalEditPolicyCN()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); } @@ -80,7 +81,7 @@ public class ExecutionEnvironmentCompositeCompartmentEditPartCN extends LinkLFSh */ @Override protected void setRatio(Double ratio) { - if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -90,6 +91,7 @@ public class ExecutionEnvironmentCompositeCompartmentEditPartCN extends LinkLFSh */ @Override public EditPart getTargetEditPart(Request request) { + return super.getTargetEditPart(request); } @@ -99,7 +101,10 @@ public class ExecutionEnvironmentCompositeCompartmentEditPartCN extends LinkLFSh @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) + || NotationPackage.eINSTANCE.getSize_Height().equals(feature) + || NotationPackage.eINSTANCE.getLocation_X().equals(feature) + || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -109,13 +114,13 @@ public class ExecutionEnvironmentCompositeCompartmentEditPartCN extends LinkLFSh * @generated */ protected void refreshBounds() { - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentEditPart.java index d937444f712..4887c345098 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentEditPart.java @@ -52,7 +52,7 @@ public class ExecutionEnvironmentEditPart extends NamedElementEditPart { /** * @generated */ - public static final String VISUAL_ID = "2002"; + public static final String VISUAL_ID = "ExecutionEnvironment_Shape"; /** * @generated @@ -78,13 +78,18 @@ public class ExecutionEnvironmentEditPart extends NamedElementEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); - installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, + new ShowHideClassifierContentsEditPolicy()); installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -101,7 +106,7 @@ public class ExecutionEnvironmentEditPart extends NamedElementEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -128,6 +133,7 @@ public class ExecutionEnvironmentEditPart extends NamedElementEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); + } /** @@ -145,23 +151,25 @@ public class ExecutionEnvironmentEditPart extends NamedElementEditPart { */ @Override public ExecutionEnvironmentFigure getPrimaryShape() { - return (ExecutionEnvironmentFigure)primaryShape; + return (ExecutionEnvironmentFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ExecutionEnvironmentNameEditPart) { - ((ExecutionEnvironmentNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof ExecutionEnvironmentNameEditPart) { + ((ExecutionEnvironmentNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if(childEditPart instanceof ExecutionEnvironmentCompositeCompartmentEditPart) { + + if (childEditPart instanceof ExecutionEnvironmentCompositeCompartmentEditPart) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((ExecutionEnvironmentCompositeCompartmentEditPart)childEditPart).getFigure()); + pane.add(((ExecutionEnvironmentCompositeCompartmentEditPart) childEditPart).getFigure()); return true; } + return false; } @@ -169,12 +177,12 @@ public class ExecutionEnvironmentEditPart extends NamedElementEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ExecutionEnvironmentNameEditPart) { + if (childEditPart instanceof ExecutionEnvironmentNameEditPart) { return true; } - if(childEditPart instanceof ExecutionEnvironmentCompositeCompartmentEditPart) { + if (childEditPart instanceof ExecutionEnvironmentCompositeCompartmentEditPart) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); - pane.remove(((ExecutionEnvironmentCompositeCompartmentEditPart)childEditPart).getFigure()); + pane.remove(((ExecutionEnvironmentCompositeCompartmentEditPart) childEditPart).getFigure()); return true; } return false; @@ -185,7 +193,7 @@ public class ExecutionEnvironmentEditPart extends NamedElementEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -196,7 +204,7 @@ public class ExecutionEnvironmentEditPart extends NamedElementEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -207,7 +215,7 @@ public class ExecutionEnvironmentEditPart extends NamedElementEditPart { */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof ExecutionEnvironmentCompositeCompartmentEditPart) { + if (editPart instanceof ExecutionEnvironmentCompositeCompartmentEditPart) { return getPrimaryShape().getCompositeCompartmentFigure(); } return getContentPane(); @@ -233,6 +241,7 @@ public class ExecutionEnvironmentEditPart extends NamedElementEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -245,7 +254,7 @@ public class ExecutionEnvironmentEditPart extends NamedElementEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -258,7 +267,7 @@ public class ExecutionEnvironmentEditPart extends NamedElementEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -269,7 +278,7 @@ public class ExecutionEnvironmentEditPart extends NamedElementEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -287,8 +296,8 @@ public class ExecutionEnvironmentEditPart extends NamedElementEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentEditPartCN.java index 91ce2469036..38055996602 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentEditPartCN.java @@ -52,7 +52,7 @@ public class ExecutionEnvironmentEditPartCN extends NamedElementEditPart { /** * @generated */ - public static final String VISUAL_ID = "21"; + public static final String VISUAL_ID = "ExecutionEnvironment_Shape_CCN"; /** * @generated @@ -78,13 +78,18 @@ public class ExecutionEnvironmentEditPartCN extends NamedElementEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); - installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, + new ShowHideClassifierContentsEditPolicy()); installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -101,7 +106,7 @@ public class ExecutionEnvironmentEditPartCN extends NamedElementEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -128,6 +133,7 @@ public class ExecutionEnvironmentEditPartCN extends NamedElementEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); + } /** @@ -145,17 +151,18 @@ public class ExecutionEnvironmentEditPartCN extends NamedElementEditPart { */ @Override public ExecutionEnvironmentFigure getPrimaryShape() { - return (ExecutionEnvironmentFigure)primaryShape; + return (ExecutionEnvironmentFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ExecutionEnvironmentNameEditPartCN) { - ((ExecutionEnvironmentNameEditPartCN)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof ExecutionEnvironmentNameEditPartCN) { + ((ExecutionEnvironmentNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } + return false; } @@ -163,7 +170,7 @@ public class ExecutionEnvironmentEditPartCN extends NamedElementEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ExecutionEnvironmentNameEditPartCN) { + if (childEditPart instanceof ExecutionEnvironmentNameEditPartCN) { return true; } return false; @@ -174,7 +181,7 @@ public class ExecutionEnvironmentEditPartCN extends NamedElementEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -185,7 +192,7 @@ public class ExecutionEnvironmentEditPartCN extends NamedElementEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -219,6 +226,7 @@ public class ExecutionEnvironmentEditPartCN extends NamedElementEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -231,7 +239,7 @@ public class ExecutionEnvironmentEditPartCN extends NamedElementEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -244,7 +252,7 @@ public class ExecutionEnvironmentEditPartCN extends NamedElementEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -255,7 +263,7 @@ public class ExecutionEnvironmentEditPartCN extends NamedElementEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -273,8 +281,8 @@ public class ExecutionEnvironmentEditPartCN extends NamedElementEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentNameEditPart.java index 4cdeb6809aa..2083b9fe2ac 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentNameEditPart.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "5"; + public static final String VISUAL_ID = "ExecutionEnvironment_NameLabel"; /** * @generated @@ -144,12 +146,12 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,28 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + ExecutionEnvironmentNameEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +336,10 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +355,9 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.ExecutionEnvironment_2002, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ExecutionEnvironmentNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.ExecutionEnvironment_Shape, getParserElement(), this, + VISUAL_ID); } return parser; } @@ -355,8 +366,10 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +398,8 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +407,8 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +419,58 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +492,13 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +529,12 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +543,12 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +556,15 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +573,9 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +584,10 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart */ @Override 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)); + 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); } } @@ -578,11 +605,11 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +621,8 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +635,7 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +661,14 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +680,7 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +702,15 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +721,13 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +746,15 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +792,27 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +849,8 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +860,7 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +868,6 @@ public class ExecutionEnvironmentNameEditPart extends PapyrusCompartmentEditPart */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentNameEditPartCN.java index 7be5adea4ec..c984369c3d6 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentNameEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ExecutionEnvironmentNameEditPartCN.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "22"; + public static final String VISUAL_ID = "ExecutionEnvironment_NameLabel_CCN"; /** * @generated @@ -144,12 +146,12 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,28 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + ExecutionEnvironmentNameEditPartCN.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +336,10 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +355,9 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.ExecutionEnvironment_21, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ExecutionEnvironmentNameEditPartCN.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.ExecutionEnvironment_Shape_CCN, getParserElement(), this, + VISUAL_ID); } return parser; } @@ -355,8 +366,10 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +398,8 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +407,8 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +419,58 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +492,13 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +529,12 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +543,12 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +556,15 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +573,9 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +584,10 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa */ @Override 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)); + 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); } } @@ -578,11 +605,11 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +621,8 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +635,7 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +661,14 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +680,7 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +702,15 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +721,13 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +746,15 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +792,27 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +849,8 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +860,7 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +868,6 @@ public class ExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPa */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/GeneralizationAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/GeneralizationAppliedStereotypeEditPart.java index 5fbe6cf73aa..c8857f8cc74 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/GeneralizationAppliedStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/GeneralizationAppliedStereotypeEditPart.java @@ -62,6 +62,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; @@ -83,12 +84,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { +public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { /** * @generated */ - public static final String VISUAL_ID = "4"; + public static final String VISUAL_ID = "Generalization_StereotypeLabel"; /** * @generated @@ -127,7 +129,10 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.GeneralizationAppliedStereotypeEditPart.VISUAL_ID), new Point(0, 60)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.GeneralizationAppliedStereotypeEditPart.VISUAL_ID), + new Point(0, 60)); } /** @@ -160,12 +165,12 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -173,12 +178,12 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -186,12 +191,12 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -199,12 +204,12 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -263,10 +268,11 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -279,12 +285,12 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -293,10 +299,11 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -315,22 +322,28 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + GeneralizationAppliedStereotypeEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -342,10 +355,10 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -361,8 +374,8 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Generalization_4003, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.GeneralizationAppliedStereotypeEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Generalization_Edge, getParserElement(), this, VISUAL_ID); } return parser; } @@ -371,8 +384,10 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -401,8 +416,8 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -410,8 +425,8 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -422,46 +437,58 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -483,12 +510,13 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -519,20 +547,20 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -540,15 +568,15 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -557,9 +585,9 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -568,9 +596,10 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar */ @Override 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)); + 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); } } @@ -588,11 +617,11 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -604,8 +633,8 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -618,7 +647,7 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -655,7 +684,7 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -677,12 +706,15 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -693,10 +725,13 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -715,12 +750,15 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -739,30 +777,34 @@ public class GeneralizationAppliedStereotypeEditPart extends PapyrusLabelEditPar @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } + super.handleNotificationEvent(event); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/GeneralizationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/GeneralizationEditPart.java index 03038347cc6..c6348744709 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/GeneralizationEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/GeneralizationEditPart.java @@ -30,7 +30,7 @@ public class GeneralizationEditPart extends UMLConnectionNodeEditPart implements /** * @generated */ - public static final String VISUAL_ID = "4003"; + public static final String VISUAL_ID = "Generalization_Edge"; /** * @generated @@ -46,7 +46,8 @@ public class GeneralizationEditPart extends UMLConnectionNodeEditPart implements protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeLinkLabelDisplayEditPolicy()); installEditPolicy(ShowHideLabelEditPolicy.SHOW_HIDE_LABEL_ROLE, new ShowHideLabelEditPolicy()); } @@ -54,8 +55,9 @@ public class GeneralizationEditPart extends UMLConnectionNodeEditPart implements * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof GeneralizationAppliedStereotypeEditPart) { - ((GeneralizationAppliedStereotypeEditPart)childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel()); + if (childEditPart instanceof GeneralizationAppliedStereotypeEditPart) { + ((GeneralizationAppliedStereotypeEditPart) childEditPart) + .setLabel(getPrimaryShape().getAppliedStereotypeLabel()); } return false; } @@ -65,7 +67,7 @@ public class GeneralizationEditPart extends UMLConnectionNodeEditPart implements */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -75,7 +77,7 @@ public class GeneralizationEditPart extends UMLConnectionNodeEditPart implements * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof GeneralizationAppliedStereotypeEditPart) { + if (childEditPart instanceof GeneralizationAppliedStereotypeEditPart) { return true; } return false; @@ -86,7 +88,7 @@ public class GeneralizationEditPart extends UMLConnectionNodeEditPart implements */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -110,6 +112,6 @@ public class GeneralizationEditPart extends UMLConnectionNodeEditPart implements */ @Override public GeneralizationFigure getPrimaryShape() { - return (GeneralizationFigure)getFigure(); + return (GeneralizationFigure) getFigure(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/LinkDescriptorEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/LinkDescriptorEditPart.java index a0e2cc13682..6093902759d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/LinkDescriptorEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/LinkDescriptorEditPart.java @@ -28,7 +28,7 @@ public class LinkDescriptorEditPart extends ConnectionEditPart implements ITreeB /** * @generated */ - public static final String VISUAL_ID = "4005"; + public static final String VISUAL_ID = "Link_DescriptorEdge"; /** * @generated @@ -65,6 +65,6 @@ public class LinkDescriptorEditPart extends ConnectionEditPart implements ITreeB */ @Override public SimpleDashedEdgeFigure getPrimaryShape() { - return (SimpleDashedEdgeFigure)getFigure(); + return (SimpleDashedEdgeFigure) getFigure(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ManifestationAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ManifestationAppliedStereotypeEditPart.java index eead68b7913..46957a6063f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ManifestationAppliedStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ManifestationAppliedStereotypeEditPart.java @@ -62,6 +62,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; @@ -83,12 +84,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { +public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { /** * @generated */ - public static final String VISUAL_ID = "11"; + public static final String VISUAL_ID = "Manifestation_StereotypeLabel"; /** * @generated @@ -127,7 +129,10 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ManifestationAppliedStereotypeEditPart.VISUAL_ID), new Point(0, 30)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ManifestationAppliedStereotypeEditPart.VISUAL_ID), + new Point(0, 30)); } /** @@ -160,12 +165,12 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -173,12 +178,12 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -186,12 +191,12 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -199,12 +204,12 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -263,10 +268,11 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -279,12 +285,12 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -293,10 +299,11 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -315,22 +322,28 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + ManifestationAppliedStereotypeEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -342,10 +355,10 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -361,8 +374,8 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Manifestation_4002, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ManifestationAppliedStereotypeEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Manifestation_Edge, getParserElement(), this, VISUAL_ID); } return parser; } @@ -371,8 +384,10 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -401,8 +416,8 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -410,8 +425,8 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -422,46 +437,58 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -483,12 +510,13 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -519,20 +547,20 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -540,15 +568,15 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -557,9 +585,9 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -568,9 +596,10 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override 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)); + 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); } } @@ -588,11 +617,11 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -604,8 +633,8 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -618,7 +647,7 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -644,13 +673,14 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -662,7 +692,7 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -684,12 +714,15 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -700,10 +733,13 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -722,12 +758,15 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -746,30 +785,34 @@ public class ManifestationAppliedStereotypeEditPart extends PapyrusLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } + super.handleNotificationEvent(event); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ManifestationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ManifestationEditPart.java index 192be56707e..ef9b6fdedd7 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ManifestationEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ManifestationEditPart.java @@ -30,7 +30,7 @@ public class ManifestationEditPart extends UMLConnectionNodeEditPart implements /** * @generated */ - public static final String VISUAL_ID = "4002"; + public static final String VISUAL_ID = "Manifestation_Edge"; /** * @generated @@ -46,7 +46,8 @@ public class ManifestationEditPart extends UMLConnectionNodeEditPart implements protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeLinkLabelDisplayEditPolicy()); installEditPolicy(ShowHideLabelEditPolicy.SHOW_HIDE_LABEL_ROLE, new ShowHideLabelEditPolicy()); } @@ -54,11 +55,12 @@ public class ManifestationEditPart extends UMLConnectionNodeEditPart implements * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ManifestationNameEditPart) { - ((ManifestationNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof ManifestationNameEditPart) { + ((ManifestationNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); } - if(childEditPart instanceof ManifestationAppliedStereotypeEditPart) { - ((ManifestationAppliedStereotypeEditPart)childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel()); + if (childEditPart instanceof ManifestationAppliedStereotypeEditPart) { + ((ManifestationAppliedStereotypeEditPart) childEditPart) + .setLabel(getPrimaryShape().getAppliedStereotypeLabel()); } return false; } @@ -68,7 +70,7 @@ public class ManifestationEditPart extends UMLConnectionNodeEditPart implements */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -78,10 +80,10 @@ public class ManifestationEditPart extends UMLConnectionNodeEditPart implements * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ManifestationNameEditPart) { + if (childEditPart instanceof ManifestationNameEditPart) { return true; } - if(childEditPart instanceof ManifestationAppliedStereotypeEditPart) { + if (childEditPart instanceof ManifestationAppliedStereotypeEditPart) { return true; } return false; @@ -92,7 +94,7 @@ public class ManifestationEditPart extends UMLConnectionNodeEditPart implements */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -116,6 +118,6 @@ public class ManifestationEditPart extends UMLConnectionNodeEditPart implements */ @Override public DashedEdgeFigure getPrimaryShape() { - return (DashedEdgeFigure)getFigure(); + return (DashedEdgeFigure) getFigure(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ManifestationNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ManifestationNameEditPart.java index 37cdbe1c569..759a5f3f2da 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ManifestationNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ManifestationNameEditPart.java @@ -62,6 +62,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; @@ -83,12 +84,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ManifestationNameEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { +public class ManifestationNameEditPart extends PapyrusLabelEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { /** * @generated */ - public static final String VISUAL_ID = "10"; + public static final String VISUAL_ID = "Manifestation_NameLabel"; /** * @generated @@ -127,7 +129,10 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ManifestationNameEditPart.VISUAL_ID), new Point(0, 60)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ManifestationNameEditPart.VISUAL_ID), + new Point(0, 60)); } /** @@ -160,12 +165,12 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -173,12 +178,12 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -186,12 +191,12 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -199,12 +204,12 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -263,10 +268,11 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -279,12 +285,12 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -293,10 +299,11 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -315,22 +322,25 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), ManifestationNameEditPart.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -342,10 +352,10 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -361,8 +371,8 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Manifestation_4002, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ManifestationNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Manifestation_Edge, getParserElement(), this, VISUAL_ID); } return parser; } @@ -371,8 +381,10 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -401,8 +413,8 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -410,8 +422,8 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -422,46 +434,58 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -483,12 +507,13 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -519,20 +544,20 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -540,15 +565,15 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -557,9 +582,9 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -568,9 +593,10 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I */ @Override 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)); + 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); } } @@ -588,11 +614,11 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -604,8 +630,8 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -618,7 +644,7 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -644,13 +670,14 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -662,7 +689,7 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -684,12 +711,15 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -700,10 +730,13 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -722,12 +755,15 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -746,30 +782,34 @@ public class ManifestationNameEditPart extends PapyrusLabelEditPart implements I @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } + super.handleNotificationEvent(event); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelEditPart.java index d2ff87126de..59988ea5c52 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelEditPart.java @@ -49,7 +49,7 @@ public class ModelEditPart extends PackageEditPart { /** * @generated */ - public static final String VISUAL_ID = "2010"; + public static final String VISUAL_ID = "Model_Shape"; /** * @generated @@ -75,10 +75,14 @@ public class ModelEditPart extends PackageEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -95,7 +99,7 @@ public class ModelEditPart extends PackageEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -122,6 +126,7 @@ public class ModelEditPart extends PackageEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); + } /** @@ -139,23 +144,25 @@ public class ModelEditPart extends PackageEditPart { */ @Override public PackageFigure getPrimaryShape() { - return (PackageFigure)primaryShape; + return (PackageFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ModelNameEditPart) { - ((ModelNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof ModelNameEditPart) { + ((ModelNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if(childEditPart instanceof ModelPackageableElementCompartmentEditPart) { + + if (childEditPart instanceof ModelPackageableElementCompartmentEditPart) { IFigure pane = getPrimaryShape().getPackageableElementFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((ModelPackageableElementCompartmentEditPart)childEditPart).getFigure()); + pane.add(((ModelPackageableElementCompartmentEditPart) childEditPart).getFigure()); return true; } + return false; } @@ -163,12 +170,12 @@ public class ModelEditPart extends PackageEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ModelNameEditPart) { + if (childEditPart instanceof ModelNameEditPart) { return true; } - if(childEditPart instanceof ModelPackageableElementCompartmentEditPart) { + if (childEditPart instanceof ModelPackageableElementCompartmentEditPart) { IFigure pane = getPrimaryShape().getPackageableElementFigure(); - pane.remove(((ModelPackageableElementCompartmentEditPart)childEditPart).getFigure()); + pane.remove(((ModelPackageableElementCompartmentEditPart) childEditPart).getFigure()); return true; } return false; @@ -179,7 +186,7 @@ public class ModelEditPart extends PackageEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -190,7 +197,7 @@ public class ModelEditPart extends PackageEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -201,7 +208,7 @@ public class ModelEditPart extends PackageEditPart { */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof ModelPackageableElementCompartmentEditPart) { + if (editPart instanceof ModelPackageableElementCompartmentEditPart) { return getPrimaryShape().getPackageableElementFigure(); } return getContentPane(); @@ -227,6 +234,7 @@ public class ModelEditPart extends PackageEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -239,7 +247,7 @@ public class ModelEditPart extends PackageEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -252,7 +260,7 @@ public class ModelEditPart extends PackageEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -263,7 +271,7 @@ public class ModelEditPart extends PackageEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -281,8 +289,8 @@ public class ModelEditPart extends PackageEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelEditPartCN.java index 47c9b62f17c..c585817ef62 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelEditPartCN.java @@ -49,7 +49,7 @@ public class ModelEditPartCN extends PackageEditPart { /** * @generated */ - public static final String VISUAL_ID = "49"; + public static final String VISUAL_ID = "Model_Shape_CN"; /** * @generated @@ -75,10 +75,14 @@ public class ModelEditPartCN extends PackageEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -95,7 +99,7 @@ public class ModelEditPartCN extends PackageEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -122,6 +126,7 @@ public class ModelEditPartCN extends PackageEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); + } /** @@ -139,23 +144,25 @@ public class ModelEditPartCN extends PackageEditPart { */ @Override public PackageFigure getPrimaryShape() { - return (PackageFigure)primaryShape; + return (PackageFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ModelNameEditPartCN) { - ((ModelNameEditPartCN)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof ModelNameEditPartCN) { + ((ModelNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if(childEditPart instanceof ModelPackageableElementCompartmentEditPartCN) { + + if (childEditPart instanceof ModelPackageableElementCompartmentEditPartCN) { IFigure pane = getPrimaryShape().getPackageableElementFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((ModelPackageableElementCompartmentEditPartCN)childEditPart).getFigure()); + pane.add(((ModelPackageableElementCompartmentEditPartCN) childEditPart).getFigure()); return true; } + return false; } @@ -163,12 +170,12 @@ public class ModelEditPartCN extends PackageEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof ModelNameEditPartCN) { + if (childEditPart instanceof ModelNameEditPartCN) { return true; } - if(childEditPart instanceof ModelPackageableElementCompartmentEditPartCN) { + if (childEditPart instanceof ModelPackageableElementCompartmentEditPartCN) { IFigure pane = getPrimaryShape().getPackageableElementFigure(); - pane.remove(((ModelPackageableElementCompartmentEditPartCN)childEditPart).getFigure()); + pane.remove(((ModelPackageableElementCompartmentEditPartCN) childEditPart).getFigure()); return true; } return false; @@ -179,7 +186,7 @@ public class ModelEditPartCN extends PackageEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -190,7 +197,7 @@ public class ModelEditPartCN extends PackageEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -201,7 +208,7 @@ public class ModelEditPartCN extends PackageEditPart { */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof ModelPackageableElementCompartmentEditPartCN) { + if (editPart instanceof ModelPackageableElementCompartmentEditPartCN) { return getPrimaryShape().getPackageableElementFigure(); } return getContentPane(); @@ -227,6 +234,7 @@ public class ModelEditPartCN extends PackageEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -239,7 +247,7 @@ public class ModelEditPartCN extends PackageEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -252,7 +260,7 @@ public class ModelEditPartCN extends PackageEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -263,7 +271,7 @@ public class ModelEditPartCN extends PackageEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -281,8 +289,8 @@ public class ModelEditPartCN extends PackageEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelNameEditPart.java index 7efcb381eb7..6731681e85e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelNameEditPart.java @@ -64,6 +64,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -85,12 +86,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class ModelNameEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "48"; + public static final String VISUAL_ID = "Model_NameLabel"; /** * @generated @@ -148,12 +150,12 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -161,12 +163,12 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -174,12 +176,12 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -187,12 +189,12 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -243,12 +245,12 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe */ protected Image getLabelIcon() { EObject parserElement = getParserElement(); - if(parserElement == null) { + if (parserElement == null) { return null; } List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer()); - for(View view : views) { - if(AppearanceHelper.showElementIcon(view)) { + for (View view : views) { + if (AppearanceHelper.showElementIcon(view)) { return UMLElementTypes.getImage(parserElement.eClass()); } } @@ -261,10 +263,11 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -277,12 +280,12 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -291,10 +294,11 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -313,22 +317,26 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), ModelNameEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -340,10 +348,10 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -359,8 +367,8 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Model_2010, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ModelNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Model_Shape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -369,8 +377,10 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -399,8 +409,8 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -408,8 +418,8 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -420,46 +430,58 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -481,12 +503,13 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -517,12 +540,12 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -531,12 +554,12 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -544,15 +567,15 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -561,9 +584,9 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -572,9 +595,10 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe */ @Override 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)); + 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); } } @@ -592,11 +616,11 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -608,8 +632,8 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -622,7 +646,7 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -648,13 +672,14 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -666,7 +691,7 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -688,12 +713,15 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -704,10 +732,13 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -726,12 +757,15 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -769,31 +803,35 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } - if(event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation)event.getNewValue()).getSource())) { + if (event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON + .equals(((EAnnotation) event.getNewValue()).getSource())) { refreshLabel(); } super.handleNotificationEvent(event); @@ -826,7 +864,8 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -836,6 +875,7 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -843,5 +883,6 @@ public class ModelNameEditPart extends PapyrusCompartmentEditPart implements ITe */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelNameEditPartCN.java index f1e51b7a424..30ec827e4fd 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelNameEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelNameEditPartCN.java @@ -64,6 +64,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -85,12 +86,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class ModelNameEditPartCN extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "50"; + public static final String VISUAL_ID = "Model_NameLabel_CN"; /** * @generated @@ -148,12 +150,12 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -161,12 +163,12 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -174,12 +176,12 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -187,12 +189,12 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -243,12 +245,12 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I */ protected Image getLabelIcon() { EObject parserElement = getParserElement(); - if(parserElement == null) { + if (parserElement == null) { return null; } List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer()); - for(View view : views) { - if(AppearanceHelper.showElementIcon(view)) { + for (View view : views) { + if (AppearanceHelper.showElementIcon(view)) { return UMLElementTypes.getImage(parserElement.eClass()); } } @@ -261,10 +263,11 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -277,12 +280,12 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -291,10 +294,11 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -313,22 +317,25 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), ModelNameEditPartCN.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -340,10 +347,10 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -359,8 +366,8 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Model_49, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.ModelNameEditPartCN.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Model_Shape_CN, getParserElement(), this, VISUAL_ID); } return parser; } @@ -369,8 +376,10 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -399,8 +408,8 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -408,8 +417,8 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -420,46 +429,58 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -481,12 +502,13 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -517,12 +539,12 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -531,12 +553,12 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -544,15 +566,15 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -561,9 +583,9 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -572,9 +594,10 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I */ @Override 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)); + 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); } } @@ -592,11 +615,11 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -608,8 +631,8 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -622,7 +645,7 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -648,13 +671,14 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -666,7 +690,7 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -688,12 +712,15 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -704,10 +731,13 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -726,12 +756,15 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -769,31 +802,35 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } - if(event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation)event.getNewValue()).getSource())) { + if (event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON + .equals(((EAnnotation) event.getNewValue()).getSource())) { refreshLabel(); } super.handleNotificationEvent(event); @@ -826,7 +863,8 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -836,6 +874,7 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -843,5 +882,6 @@ public class ModelNameEditPartCN extends PapyrusCompartmentEditPart implements I */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelPackageableElementCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelPackageableElementCompartmentEditPart.java index 9de50b4046f..75aae6a45b0 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelPackageableElementCompartmentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelPackageableElementCompartmentEditPart.java @@ -41,7 +41,7 @@ public class ModelPackageableElementCompartmentEditPart extends LinkLFShapeCompa /** * @generated */ - public static final String VISUAL_ID = "51"; + public static final String VISUAL_ID = "Model_PackagedElementCompartment"; /** * @generated @@ -70,6 +70,7 @@ public class ModelPackageableElementCompartmentEditPart extends LinkLFShapeCompa installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.deployment.edit.policies.ModelPackageableElementCompartmentCanonicalEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(BorderDisplayEditPolicy.BORDER_DISPLAY_EDITPOLICY, new BorderDisplayEditPolicy()); @@ -80,7 +81,7 @@ public class ModelPackageableElementCompartmentEditPart extends LinkLFShapeCompa */ @Override protected void setRatio(Double ratio) { - if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -90,6 +91,7 @@ public class ModelPackageableElementCompartmentEditPart extends LinkLFShapeCompa */ @Override public EditPart getTargetEditPart(Request request) { + return super.getTargetEditPart(request); } @@ -99,7 +101,10 @@ public class ModelPackageableElementCompartmentEditPart extends LinkLFShapeCompa @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) + || NotationPackage.eINSTANCE.getSize_Height().equals(feature) + || NotationPackage.eINSTANCE.getLocation_X().equals(feature) + || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -109,13 +114,13 @@ public class ModelPackageableElementCompartmentEditPart extends LinkLFShapeCompa * @generated */ protected void refreshBounds() { - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelPackageableElementCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelPackageableElementCompartmentEditPartCN.java index 0b094521b6e..bd9068e4d59 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelPackageableElementCompartmentEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/ModelPackageableElementCompartmentEditPartCN.java @@ -41,7 +41,7 @@ public class ModelPackageableElementCompartmentEditPartCN extends LinkLFShapeCom /** * @generated */ - public static final String VISUAL_ID = "52"; + public static final String VISUAL_ID = "Model_PackagedElementCompartment_CN"; /** * @generated @@ -70,6 +70,7 @@ public class ModelPackageableElementCompartmentEditPartCN extends LinkLFShapeCom installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.deployment.edit.policies.ModelPackageableElementCompartmentCanonicalEditPolicyCN()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(BorderDisplayEditPolicy.BORDER_DISPLAY_EDITPOLICY, new BorderDisplayEditPolicy()); @@ -80,7 +81,7 @@ public class ModelPackageableElementCompartmentEditPartCN extends LinkLFShapeCom */ @Override protected void setRatio(Double ratio) { - if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -90,6 +91,7 @@ public class ModelPackageableElementCompartmentEditPartCN extends LinkLFShapeCom */ @Override public EditPart getTargetEditPart(Request request) { + return super.getTargetEditPart(request); } @@ -99,7 +101,10 @@ public class ModelPackageableElementCompartmentEditPartCN extends LinkLFShapeCom @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) + || NotationPackage.eINSTANCE.getSize_Height().equals(feature) + || NotationPackage.eINSTANCE.getLocation_X().equals(feature) + || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -109,13 +114,13 @@ public class ModelPackageableElementCompartmentEditPartCN extends LinkLFShapeCom * @generated */ protected void refreshBounds() { - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/MultiDependencyLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/MultiDependencyLabelEditPart.java index 1934a1352a1..c9eee85d960 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/MultiDependencyLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/MultiDependencyLabelEditPart.java @@ -63,6 +63,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimaryDragRoleEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -83,12 +84,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { +public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart + implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated */ - public static final String VISUAL_ID = "7"; + public static final String VISUAL_ID = "Dependency_MultiNameLabel"; /** * @generated @@ -127,7 +129,10 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement * @generated */ static { - registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.MultiDependencyLabelEditPart.VISUAL_ID), new Point(0, 0)); + registerSnapBackPosition( + UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.deployment.edit.parts.MultiDependencyLabelEditPart.VISUAL_ID), + new Point(0, 0)); } /** @@ -154,9 +159,9 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if(parentFigure != null && parentFigure.getLayoutManager() != null) { + if (parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator)constraint; + return (IBorderItemLocator) constraint; } return null; } @@ -166,10 +171,10 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement */ @Override public void refreshBounds() { - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -177,12 +182,12 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -190,12 +195,12 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -203,12 +208,12 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -216,12 +221,12 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -279,10 +284,11 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -295,12 +301,12 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -309,10 +315,11 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -331,22 +338,26 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult( + parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), + MultiDependencyLabelEditPart.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -358,10 +369,10 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -377,8 +388,8 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Dependency_2011, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.MultiDependencyLabelEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Dependency_Shape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -387,8 +398,10 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -417,8 +430,8 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -426,8 +439,8 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -438,46 +451,58 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -499,12 +524,13 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -535,20 +561,20 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -556,15 +582,15 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -573,9 +599,9 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -584,9 +610,10 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement */ @Override 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)); + 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); } } @@ -604,11 +631,11 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -620,8 +647,8 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -634,7 +661,7 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -660,13 +687,14 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -678,7 +706,7 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -700,12 +728,15 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -716,10 +747,13 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -738,12 +772,15 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -762,24 +799,27 @@ public class MultiDependencyLabelEditPart extends PapyrusLabelEditPart implement @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedArtifactNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedArtifactNameEditPart.java index c0bbfe8cccd..b5a70958eab 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedArtifactNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedArtifactNameEditPart.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "41"; + public static final String VISUAL_ID = "Artifact_NameLabel_CN"; /** * @generated @@ -144,12 +146,12 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,25 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), NestedArtifactNameEditPart.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +333,10 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +352,8 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Artifact_40, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.NestedArtifactNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Artifact_Shape_CN, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +362,10 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +394,8 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +403,8 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +415,58 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +488,13 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +525,12 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +539,12 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +552,15 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +569,9 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +580,10 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple */ @Override 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)); + 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); } } @@ -578,11 +601,11 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +617,8 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +631,7 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +657,14 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +676,7 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +698,15 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +717,13 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +742,15 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +788,27 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +845,8 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +856,7 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +864,6 @@ public class NestedArtifactNameEditPart extends PapyrusCompartmentEditPart imple */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedArtifactNodeEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedArtifactNodeEditPartCN.java index a842c6522e8..7e31cc13c5c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedArtifactNodeEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedArtifactNodeEditPartCN.java @@ -50,7 +50,7 @@ public class NestedArtifactNodeEditPartCN extends NodeEditPart { /** * @generated */ - public static final String VISUAL_ID = "40"; + public static final String VISUAL_ID = "Artifact_Shape_CN"; /** * @generated @@ -76,13 +76,18 @@ public class NestedArtifactNodeEditPartCN extends NodeEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); - installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, + new ShowHideClassifierContentsEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies @@ -98,7 +103,7 @@ public class NestedArtifactNodeEditPartCN extends NodeEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -132,17 +137,18 @@ public class NestedArtifactNodeEditPartCN extends NodeEditPart { */ @Override public ArtifactFigure getPrimaryShape() { - return (ArtifactFigure)primaryShape; + return (ArtifactFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof NestedArtifactNameEditPart) { - ((NestedArtifactNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof NestedArtifactNameEditPart) { + ((NestedArtifactNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } + return false; } @@ -150,7 +156,7 @@ public class NestedArtifactNodeEditPartCN extends NodeEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof NestedArtifactNameEditPart) { + if (childEditPart instanceof NestedArtifactNameEditPart) { return true; } return false; @@ -161,7 +167,7 @@ public class NestedArtifactNodeEditPartCN extends NodeEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -172,7 +178,7 @@ public class NestedArtifactNodeEditPartCN extends NodeEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -206,6 +212,7 @@ public class NestedArtifactNodeEditPartCN extends NodeEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -218,7 +225,7 @@ public class NestedArtifactNodeEditPartCN extends NodeEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -231,7 +238,7 @@ public class NestedArtifactNodeEditPartCN extends NodeEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -242,7 +249,7 @@ public class NestedArtifactNodeEditPartCN extends NodeEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -260,8 +267,8 @@ public class NestedArtifactNodeEditPartCN extends NodeEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedDeviceEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedDeviceEditPartCN.java index d292db19f38..5f02d9ecd21 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedDeviceEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedDeviceEditPartCN.java @@ -51,7 +51,7 @@ public class NestedDeviceEditPartCN extends NodeEditPart { /** * @generated */ - public static final String VISUAL_ID = "44"; + public static final String VISUAL_ID = "Device_Shape_CN"; /** * @generated @@ -77,13 +77,18 @@ public class NestedDeviceEditPartCN extends NodeEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); - installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, + new ShowHideClassifierContentsEditPolicy()); installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -100,7 +105,7 @@ public class NestedDeviceEditPartCN extends NodeEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -134,23 +139,25 @@ public class NestedDeviceEditPartCN extends NodeEditPart { */ @Override public DeviceFigure getPrimaryShape() { - return (DeviceFigure)primaryShape; + return (DeviceFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof NestedDeviceNameEditPartCN) { - ((NestedDeviceNameEditPartCN)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof NestedDeviceNameEditPartCN) { + ((NestedDeviceNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if(childEditPart instanceof DeviceCompositeCompartmentEditPartCN) { + + if (childEditPart instanceof DeviceCompositeCompartmentEditPartCN) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((DeviceCompositeCompartmentEditPartCN)childEditPart).getFigure()); + pane.add(((DeviceCompositeCompartmentEditPartCN) childEditPart).getFigure()); return true; } + return false; } @@ -158,12 +165,12 @@ public class NestedDeviceEditPartCN extends NodeEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof NestedDeviceNameEditPartCN) { + if (childEditPart instanceof NestedDeviceNameEditPartCN) { return true; } - if(childEditPart instanceof DeviceCompositeCompartmentEditPartCN) { + if (childEditPart instanceof DeviceCompositeCompartmentEditPartCN) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); - pane.remove(((DeviceCompositeCompartmentEditPartCN)childEditPart).getFigure()); + pane.remove(((DeviceCompositeCompartmentEditPartCN) childEditPart).getFigure()); return true; } return false; @@ -174,7 +181,7 @@ public class NestedDeviceEditPartCN extends NodeEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -185,7 +192,7 @@ public class NestedDeviceEditPartCN extends NodeEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -196,7 +203,7 @@ public class NestedDeviceEditPartCN extends NodeEditPart { */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof DeviceCompositeCompartmentEditPartCN) { + if (editPart instanceof DeviceCompositeCompartmentEditPartCN) { return getPrimaryShape().getCompositeCompartmentFigure(); } return getContentPane(); @@ -222,6 +229,7 @@ public class NestedDeviceEditPartCN extends NodeEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -234,7 +242,7 @@ public class NestedDeviceEditPartCN extends NodeEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -247,7 +255,7 @@ public class NestedDeviceEditPartCN extends NodeEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -258,7 +266,7 @@ public class NestedDeviceEditPartCN extends NodeEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -276,8 +284,8 @@ public class NestedDeviceEditPartCN extends NodeEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedDeviceNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedDeviceNameEditPartCN.java index a86b20b888c..4a43aedd272 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedDeviceNameEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedDeviceNameEditPartCN.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "45"; + public static final String VISUAL_ID = "Device_NameLabel_CN"; /** * @generated @@ -144,12 +146,12 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,25 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), NestedDeviceNameEditPartCN.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +333,10 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +352,8 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Device_44, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.NestedDeviceNameEditPartCN.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Device_Shape_CN, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +362,10 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +394,8 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +403,8 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +415,58 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +488,13 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +525,12 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +539,12 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +552,15 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +569,9 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +580,10 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple */ @Override 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)); + 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); } } @@ -578,11 +601,11 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +617,8 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +631,7 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +657,14 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +676,7 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +698,15 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +717,13 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +742,15 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +788,27 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +845,8 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +856,7 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +864,6 @@ public class NestedDeviceNameEditPartCN extends PapyrusCompartmentEditPart imple */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedExecutionEnvironmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedExecutionEnvironmentEditPartCN.java index 478dc5312db..5fddf4bd8e5 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedExecutionEnvironmentEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedExecutionEnvironmentEditPartCN.java @@ -51,7 +51,7 @@ public class NestedExecutionEnvironmentEditPartCN extends NodeEditPart { /** * @generated */ - public static final String VISUAL_ID = "46"; + public static final String VISUAL_ID = "ExecutionEnvironment_Shape_CN"; /** * @generated @@ -77,13 +77,18 @@ public class NestedExecutionEnvironmentEditPartCN extends NodeEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); - installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, + new ShowHideClassifierContentsEditPolicy()); installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -100,7 +105,7 @@ public class NestedExecutionEnvironmentEditPartCN extends NodeEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -134,23 +139,25 @@ public class NestedExecutionEnvironmentEditPartCN extends NodeEditPart { */ @Override public ExecutionEnvironmentFigure getPrimaryShape() { - return (ExecutionEnvironmentFigure)primaryShape; + return (ExecutionEnvironmentFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof NestedExecutionEnvironmentNameEditPartCN) { - ((NestedExecutionEnvironmentNameEditPartCN)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof NestedExecutionEnvironmentNameEditPartCN) { + ((NestedExecutionEnvironmentNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if(childEditPart instanceof ExecutionEnvironmentCompositeCompartmentEditPartCN) { + + if (childEditPart instanceof ExecutionEnvironmentCompositeCompartmentEditPartCN) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((ExecutionEnvironmentCompositeCompartmentEditPartCN)childEditPart).getFigure()); + pane.add(((ExecutionEnvironmentCompositeCompartmentEditPartCN) childEditPart).getFigure()); return true; } + return false; } @@ -158,12 +165,12 @@ public class NestedExecutionEnvironmentEditPartCN extends NodeEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof NestedExecutionEnvironmentNameEditPartCN) { + if (childEditPart instanceof NestedExecutionEnvironmentNameEditPartCN) { return true; } - if(childEditPart instanceof ExecutionEnvironmentCompositeCompartmentEditPartCN) { + if (childEditPart instanceof ExecutionEnvironmentCompositeCompartmentEditPartCN) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); - pane.remove(((ExecutionEnvironmentCompositeCompartmentEditPartCN)childEditPart).getFigure()); + pane.remove(((ExecutionEnvironmentCompositeCompartmentEditPartCN) childEditPart).getFigure()); return true; } return false; @@ -174,7 +181,7 @@ public class NestedExecutionEnvironmentEditPartCN extends NodeEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -185,7 +192,7 @@ public class NestedExecutionEnvironmentEditPartCN extends NodeEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -196,7 +203,7 @@ public class NestedExecutionEnvironmentEditPartCN extends NodeEditPart { */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof ExecutionEnvironmentCompositeCompartmentEditPartCN) { + if (editPart instanceof ExecutionEnvironmentCompositeCompartmentEditPartCN) { return getPrimaryShape().getCompositeCompartmentFigure(); } return getContentPane(); @@ -222,6 +229,7 @@ public class NestedExecutionEnvironmentEditPartCN extends NodeEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -234,7 +242,7 @@ public class NestedExecutionEnvironmentEditPartCN extends NodeEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -247,7 +255,7 @@ public class NestedExecutionEnvironmentEditPartCN extends NodeEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -258,7 +266,7 @@ public class NestedExecutionEnvironmentEditPartCN extends NodeEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -276,8 +284,8 @@ public class NestedExecutionEnvironmentEditPartCN extends NodeEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedExecutionEnvironmentNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedExecutionEnvironmentNameEditPartCN.java index e0bf3326168..03bfb38fa3c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedExecutionEnvironmentNameEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedExecutionEnvironmentNameEditPartCN.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "47"; + public static final String VISUAL_ID = "ExecutionEnvironment_NameLabel_CN"; /** * @generated @@ -144,12 +146,12 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,27 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + NestedExecutionEnvironmentNameEditPartCN.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +335,10 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +354,9 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.ExecutionEnvironment_46, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.NestedExecutionEnvironmentNameEditPartCN.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.ExecutionEnvironment_Shape_CN, getParserElement(), this, + VISUAL_ID); } return parser; } @@ -355,8 +365,10 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +397,8 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +406,8 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +418,58 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +491,13 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +528,12 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +542,12 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +555,15 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +572,9 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +583,10 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment */ @Override 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)); + 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); } } @@ -578,11 +604,11 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +620,8 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +634,7 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +660,14 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +679,7 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +701,15 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +720,13 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +745,15 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +791,27 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +848,8 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +859,7 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +867,6 @@ public class NestedExecutionEnvironmentNameEditPartCN extends PapyrusCompartment */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedNodeEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedNodeEditPartCN.java index 388e8062db9..ad0db63d124 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedNodeEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedNodeEditPartCN.java @@ -50,7 +50,7 @@ public class NestedNodeEditPartCN extends NodeEditPart { /** * @generated */ - public static final String VISUAL_ID = "42"; + public static final String VISUAL_ID = "Node_Shape_CN"; /** * @generated @@ -76,13 +76,18 @@ public class NestedNodeEditPartCN extends NodeEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); - installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, + new ShowHideClassifierContentsEditPolicy()); installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -99,7 +104,7 @@ public class NestedNodeEditPartCN extends NodeEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -133,23 +138,25 @@ public class NestedNodeEditPartCN extends NodeEditPart { */ @Override public NodeFigure getPrimaryShape() { - return (NodeFigure)primaryShape; + return (NodeFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof NestedNodeNameEditPart) { - ((NestedNodeNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof NestedNodeNameEditPart) { + ((NestedNodeNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if(childEditPart instanceof NodeCompositeCompartmentEditPartCN) { + + if (childEditPart instanceof NodeCompositeCompartmentEditPartCN) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((NodeCompositeCompartmentEditPartCN)childEditPart).getFigure()); + pane.add(((NodeCompositeCompartmentEditPartCN) childEditPart).getFigure()); return true; } + return false; } @@ -157,12 +164,12 @@ public class NestedNodeEditPartCN extends NodeEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof NestedNodeNameEditPart) { + if (childEditPart instanceof NestedNodeNameEditPart) { return true; } - if(childEditPart instanceof NodeCompositeCompartmentEditPartCN) { + if (childEditPart instanceof NodeCompositeCompartmentEditPartCN) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); - pane.remove(((NodeCompositeCompartmentEditPartCN)childEditPart).getFigure()); + pane.remove(((NodeCompositeCompartmentEditPartCN) childEditPart).getFigure()); return true; } return false; @@ -173,7 +180,7 @@ public class NestedNodeEditPartCN extends NodeEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -184,7 +191,7 @@ public class NestedNodeEditPartCN extends NodeEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -195,7 +202,7 @@ public class NestedNodeEditPartCN extends NodeEditPart { */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof NodeCompositeCompartmentEditPartCN) { + if (editPart instanceof NodeCompositeCompartmentEditPartCN) { return getPrimaryShape().getCompositeCompartmentFigure(); } return getContentPane(); @@ -221,6 +228,7 @@ public class NestedNodeEditPartCN extends NodeEditPart { @Override protected org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -233,7 +241,7 @@ public class NestedNodeEditPartCN extends NodeEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -246,7 +254,7 @@ public class NestedNodeEditPartCN extends NodeEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -257,7 +265,7 @@ public class NestedNodeEditPartCN extends NodeEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -275,8 +283,8 @@ public class NestedNodeEditPartCN extends NodeEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedNodeNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedNodeNameEditPart.java index c51a5e3ee3e..b3a6d2e5dde 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedNodeNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NestedNodeNameEditPart.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "43"; + public static final String VISUAL_ID = "Node_NameLabel_CN"; /** * @generated @@ -144,12 +146,12 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,25 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), NestedNodeNameEditPart.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +333,10 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +352,8 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Node_42, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.NestedNodeNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Node_Shape_CN, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +362,10 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +394,8 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +403,8 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +415,58 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +488,13 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +525,12 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +539,12 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +552,15 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +569,9 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +580,10 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement */ @Override 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)); + 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); } } @@ -578,11 +601,11 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +617,8 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +631,7 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +657,14 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +676,7 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +698,15 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +717,13 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +742,15 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +788,27 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +845,8 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +856,7 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +864,6 @@ public class NestedNodeNameEditPart extends PapyrusCompartmentEditPart implement */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeCompositeCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeCompositeCompartmentEditPart.java index e58c83eecba..a5afcadbaba 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeCompositeCompartmentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeCompositeCompartmentEditPart.java @@ -40,7 +40,7 @@ public class NodeCompositeCompartmentEditPart extends LinkLFShapeCompartmentEdit /** * @generated */ - public static final String VISUAL_ID = "19"; + public static final String VISUAL_ID = "Node_NestedNodeCompartment"; /** * @generated @@ -69,6 +69,7 @@ public class NodeCompositeCompartmentEditPart extends LinkLFShapeCompartmentEdit installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.deployment.edit.policies.NodeCompositeCompartmentCanonicalEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); } @@ -78,7 +79,7 @@ public class NodeCompositeCompartmentEditPart extends LinkLFShapeCompartmentEdit */ @Override protected void setRatio(Double ratio) { - if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -88,6 +89,7 @@ public class NodeCompositeCompartmentEditPart extends LinkLFShapeCompartmentEdit */ @Override public EditPart getTargetEditPart(Request request) { + return super.getTargetEditPart(request); } @@ -97,7 +99,10 @@ public class NodeCompositeCompartmentEditPart extends LinkLFShapeCompartmentEdit @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) + || NotationPackage.eINSTANCE.getSize_Height().equals(feature) + || NotationPackage.eINSTANCE.getLocation_X().equals(feature) + || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -107,13 +112,13 @@ public class NodeCompositeCompartmentEditPart extends LinkLFShapeCompartmentEdit * @generated */ protected void refreshBounds() { - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeCompositeCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeCompositeCompartmentEditPartCN.java index aa473e33704..0a5cecc28b1 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeCompositeCompartmentEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeCompositeCompartmentEditPartCN.java @@ -41,7 +41,7 @@ public class NodeCompositeCompartmentEditPartCN extends LinkLFShapeCompartmentEd /** * @generated */ - public static final String VISUAL_ID = "32"; + public static final String VISUAL_ID = "Node_NestedNodeCompartment_CN"; /** * @generated @@ -71,6 +71,7 @@ public class NodeCompositeCompartmentEditPartCN extends LinkLFShapeCompartmentEd installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.deployment.edit.policies.NodeCompositeCompartmentCanonicalEditPolicyCN()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); } @@ -80,7 +81,7 @@ public class NodeCompositeCompartmentEditPartCN extends LinkLFShapeCompartmentEd */ @Override protected void setRatio(Double ratio) { - if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -90,6 +91,7 @@ public class NodeCompositeCompartmentEditPartCN extends LinkLFShapeCompartmentEd */ @Override public EditPart getTargetEditPart(Request request) { + return super.getTargetEditPart(request); } @@ -99,7 +101,10 @@ public class NodeCompositeCompartmentEditPartCN extends LinkLFShapeCompartmentEd @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) + || NotationPackage.eINSTANCE.getSize_Height().equals(feature) + || NotationPackage.eINSTANCE.getLocation_X().equals(feature) + || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -109,13 +114,13 @@ public class NodeCompositeCompartmentEditPartCN extends LinkLFShapeCompartmentEd * @generated */ protected void refreshBounds() { - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeEditPart.java index 9b8f3765ddd..79bf6263923 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeEditPart.java @@ -51,7 +51,7 @@ public class NodeEditPart extends NamedElementEditPart { /** * @generated */ - public static final String VISUAL_ID = "2008"; + public static final String VISUAL_ID = "Node_Shape"; /** * @generated @@ -77,13 +77,18 @@ public class NodeEditPart extends NamedElementEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); - installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, + new ShowHideClassifierContentsEditPolicy()); installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -100,7 +105,7 @@ public class NodeEditPart extends NamedElementEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -127,6 +132,7 @@ public class NodeEditPart extends NamedElementEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); + } /** @@ -144,23 +150,25 @@ public class NodeEditPart extends NamedElementEditPart { */ @Override public NodeFigure getPrimaryShape() { - return (NodeFigure)primaryShape; + return (NodeFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof NodeNameEditPart) { - ((NodeNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof NodeNameEditPart) { + ((NodeNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if(childEditPart instanceof NodeCompositeCompartmentEditPart) { + + if (childEditPart instanceof NodeCompositeCompartmentEditPart) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((NodeCompositeCompartmentEditPart)childEditPart).getFigure()); + pane.add(((NodeCompositeCompartmentEditPart) childEditPart).getFigure()); return true; } + return false; } @@ -168,12 +176,12 @@ public class NodeEditPart extends NamedElementEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof NodeNameEditPart) { + if (childEditPart instanceof NodeNameEditPart) { return true; } - if(childEditPart instanceof NodeCompositeCompartmentEditPart) { + if (childEditPart instanceof NodeCompositeCompartmentEditPart) { IFigure pane = getPrimaryShape().getCompositeCompartmentFigure(); - pane.remove(((NodeCompositeCompartmentEditPart)childEditPart).getFigure()); + pane.remove(((NodeCompositeCompartmentEditPart) childEditPart).getFigure()); return true; } return false; @@ -184,7 +192,7 @@ public class NodeEditPart extends NamedElementEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -195,7 +203,7 @@ public class NodeEditPart extends NamedElementEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -206,7 +214,7 @@ public class NodeEditPart extends NamedElementEditPart { */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof NodeCompositeCompartmentEditPart) { + if (editPart instanceof NodeCompositeCompartmentEditPart) { return getPrimaryShape().getCompositeCompartmentFigure(); } return getContentPane(); @@ -232,6 +240,7 @@ public class NodeEditPart extends NamedElementEditPart { @Override protected org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -244,7 +253,7 @@ public class NodeEditPart extends NamedElementEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -257,7 +266,7 @@ public class NodeEditPart extends NamedElementEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -268,7 +277,7 @@ public class NodeEditPart extends NamedElementEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -286,8 +295,8 @@ public class NodeEditPart extends NamedElementEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeEditPartCN.java index 793d44dabf8..983bccaf937 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeEditPartCN.java @@ -51,7 +51,7 @@ public class NodeEditPartCN extends NamedElementEditPart { /** * @generated */ - public static final String VISUAL_ID = "23"; + public static final String VISUAL_ID = "Node_Shape_CCN"; /** * @generated @@ -77,13 +77,18 @@ public class NodeEditPartCN extends NamedElementEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); installEditPolicy("REMOVE_ORPHAN_VIEW", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); - installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, + new ShowHideClassifierContentsEditPolicy()); installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -100,7 +105,7 @@ public class NodeEditPartCN extends NamedElementEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -127,6 +132,7 @@ public class NodeEditPartCN extends NamedElementEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); + } /** @@ -144,17 +150,18 @@ public class NodeEditPartCN extends NamedElementEditPart { */ @Override public NodeFigure getPrimaryShape() { - return (NodeFigure)primaryShape; + return (NodeFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof NodeNameEditPartCN) { - ((NodeNameEditPartCN)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof NodeNameEditPartCN) { + ((NodeNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } + return false; } @@ -162,7 +169,7 @@ public class NodeEditPartCN extends NamedElementEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof NodeNameEditPartCN) { + if (childEditPart instanceof NodeNameEditPartCN) { return true; } return false; @@ -173,7 +180,7 @@ public class NodeEditPartCN extends NamedElementEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -184,7 +191,7 @@ public class NodeEditPartCN extends NamedElementEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -218,6 +225,7 @@ public class NodeEditPartCN extends NamedElementEditPart { @Override protected org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -230,7 +238,7 @@ public class NodeEditPartCN extends NamedElementEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -243,7 +251,7 @@ public class NodeEditPartCN extends NamedElementEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -254,7 +262,7 @@ public class NodeEditPartCN extends NamedElementEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -272,8 +280,8 @@ public class NodeEditPartCN extends NamedElementEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeNameEditPart.java index 2560dfb2d8b..57803c95f17 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeNameEditPart.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class NodeNameEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "9"; + public static final String VISUAL_ID = "Node_NameLabel"; /** * @generated @@ -144,12 +146,12 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,26 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), NodeNameEditPart.this), + (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +334,10 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +353,8 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Node_2008, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.NodeNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Node_Shape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +363,10 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +395,8 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +404,8 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +416,58 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +489,13 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +526,12 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +540,12 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +553,15 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +570,9 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +581,10 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex */ @Override 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)); + 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); } } @@ -578,11 +602,11 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +618,8 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +632,7 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +658,14 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +677,7 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +699,15 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +718,13 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +743,15 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +789,27 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +846,8 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +857,7 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +865,6 @@ public class NodeNameEditPart extends PapyrusCompartmentEditPart implements ITex */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeNameEditPartCN.java index e840ac1c719..e2ec1283e70 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeNameEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/NodeNameEditPartCN.java @@ -61,6 +61,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -81,12 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class NodeNameEditPartCN extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "24"; + public static final String VISUAL_ID = "Node_NameLabel_CCN"; /** * @generated @@ -144,12 +146,12 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -157,12 +159,12 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -170,12 +172,12 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -183,12 +185,12 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -247,10 +249,11 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -263,12 +266,12 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -277,10 +280,11 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -299,22 +303,25 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), NodeNameEditPartCN.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -326,10 +333,10 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -345,8 +352,8 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Node_23, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.NodeNameEditPartCN.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Node_Shape_CCN, getParserElement(), this, VISUAL_ID); } return parser; } @@ -355,8 +362,10 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -385,8 +394,8 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -394,8 +403,8 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -406,46 +415,58 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -467,12 +488,13 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -503,12 +525,12 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -517,12 +539,12 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -530,15 +552,15 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -547,9 +569,9 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -558,9 +580,10 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT */ @Override 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)); + 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); } } @@ -578,11 +601,11 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -594,8 +617,8 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -608,7 +631,7 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -634,13 +657,14 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -652,7 +676,7 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -674,12 +698,15 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -690,10 +717,13 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -712,12 +742,15 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -755,24 +788,27 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -809,7 +845,8 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -819,6 +856,7 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -826,5 +864,6 @@ public class NodeNameEditPartCN extends PapyrusCompartmentEditPart implements IT */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageEditPart.java index a74e208c796..13a7268c692 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageEditPart.java @@ -48,7 +48,7 @@ public class PackageEditPart extends org.eclipse.papyrus.uml.diagram.common.edit /** * @generated */ - public static final String VISUAL_ID = "2009"; + public static final String VISUAL_ID = "Package_Shape"; /** * @generated @@ -74,10 +74,14 @@ public class PackageEditPart extends org.eclipse.papyrus.uml.diagram.common.edit protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -94,7 +98,7 @@ public class PackageEditPart extends org.eclipse.papyrus.uml.diagram.common.edit @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -121,6 +125,7 @@ public class PackageEditPart extends org.eclipse.papyrus.uml.diagram.common.edit @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); + } /** @@ -138,23 +143,25 @@ public class PackageEditPart extends org.eclipse.papyrus.uml.diagram.common.edit */ @Override public PackageFigure getPrimaryShape() { - return (PackageFigure)primaryShape; + return (PackageFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof PackageNameEditPart) { - ((PackageNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof PackageNameEditPart) { + ((PackageNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if(childEditPart instanceof PackagePackageableElementCompartmentEditPart) { + + if (childEditPart instanceof PackagePackageableElementCompartmentEditPart) { IFigure pane = getPrimaryShape().getPackageableElementFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((PackagePackageableElementCompartmentEditPart)childEditPart).getFigure()); + pane.add(((PackagePackageableElementCompartmentEditPart) childEditPart).getFigure()); return true; } + return false; } @@ -162,12 +169,12 @@ public class PackageEditPart extends org.eclipse.papyrus.uml.diagram.common.edit * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof PackageNameEditPart) { + if (childEditPart instanceof PackageNameEditPart) { return true; } - if(childEditPart instanceof PackagePackageableElementCompartmentEditPart) { + if (childEditPart instanceof PackagePackageableElementCompartmentEditPart) { IFigure pane = getPrimaryShape().getPackageableElementFigure(); - pane.remove(((PackagePackageableElementCompartmentEditPart)childEditPart).getFigure()); + pane.remove(((PackagePackageableElementCompartmentEditPart) childEditPart).getFigure()); return true; } return false; @@ -178,7 +185,7 @@ public class PackageEditPart extends org.eclipse.papyrus.uml.diagram.common.edit */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -189,7 +196,7 @@ public class PackageEditPart extends org.eclipse.papyrus.uml.diagram.common.edit */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -200,7 +207,7 @@ public class PackageEditPart extends org.eclipse.papyrus.uml.diagram.common.edit */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof PackagePackageableElementCompartmentEditPart) { + if (editPart instanceof PackagePackageableElementCompartmentEditPart) { return getPrimaryShape().getPackageableElementFigure(); } return getContentPane(); @@ -226,6 +233,7 @@ public class PackageEditPart extends org.eclipse.papyrus.uml.diagram.common.edit @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -238,7 +246,7 @@ public class PackageEditPart extends org.eclipse.papyrus.uml.diagram.common.edit */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -251,7 +259,7 @@ public class PackageEditPart extends org.eclipse.papyrus.uml.diagram.common.edit */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -262,7 +270,7 @@ public class PackageEditPart extends org.eclipse.papyrus.uml.diagram.common.edit */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -280,8 +288,8 @@ public class PackageEditPart extends org.eclipse.papyrus.uml.diagram.common.edit */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageEditPartCN.java index 94382074e45..5ab8adcc18a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageEditPartCN.java @@ -49,7 +49,7 @@ public class PackageEditPartCN extends PackageEditPart { /** * @generated */ - public static final String VISUAL_ID = "36"; + public static final String VISUAL_ID = "Package_Shape_CN"; /** * @generated @@ -75,10 +75,14 @@ public class PackageEditPartCN extends PackageEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, + new ShowHideCompartmentEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy("RESIZE_BORDER_ITEMS", new ConstrainedItemBorderLayoutEditPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomGraphicalNodeEditPolicy()); @@ -95,7 +99,7 @@ public class PackageEditPartCN extends PackageEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(result == null) { + if (result == null) { result = new NonResizableEditPolicy(); } return result; @@ -122,6 +126,7 @@ public class PackageEditPartCN extends PackageEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); + } /** @@ -139,23 +144,25 @@ public class PackageEditPartCN extends PackageEditPart { */ @Override public PackageFigure getPrimaryShape() { - return (PackageFigure)primaryShape; + return (PackageFigure) primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if(childEditPart instanceof PackageNameEditPartCN) { - ((PackageNameEditPartCN)childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if (childEditPart instanceof PackageNameEditPartCN) { + ((PackageNameEditPartCN) childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if(childEditPart instanceof PackagePackageableElementCompartmentEditPartCN) { + + if (childEditPart instanceof PackagePackageableElementCompartmentEditPartCN) { IFigure pane = getPrimaryShape().getPackageableElementFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((PackagePackageableElementCompartmentEditPartCN)childEditPart).getFigure()); + pane.add(((PackagePackageableElementCompartmentEditPartCN) childEditPart).getFigure()); return true; } + return false; } @@ -163,12 +170,12 @@ public class PackageEditPartCN extends PackageEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if(childEditPart instanceof PackageNameEditPartCN) { + if (childEditPart instanceof PackageNameEditPartCN) { return true; } - if(childEditPart instanceof PackagePackageableElementCompartmentEditPartCN) { + if (childEditPart instanceof PackagePackageableElementCompartmentEditPartCN) { IFigure pane = getPrimaryShape().getPackageableElementFigure(); - pane.remove(((PackagePackageableElementCompartmentEditPartCN)childEditPart).getFigure()); + pane.remove(((PackagePackageableElementCompartmentEditPartCN) childEditPart).getFigure()); return true; } return false; @@ -179,7 +186,7 @@ public class PackageEditPartCN extends PackageEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if(addFixedChild(childEditPart)) { + if (addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -190,7 +197,7 @@ public class PackageEditPartCN extends PackageEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if(removeFixedChild(childEditPart)) { + if (removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -201,7 +208,7 @@ public class PackageEditPartCN extends PackageEditPart { */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if(editPart instanceof PackagePackageableElementCompartmentEditPartCN) { + if (editPart instanceof PackagePackageableElementCompartmentEditPartCN) { return getPrimaryShape().getPackageableElementFigure(); } return getContentPane(); @@ -227,6 +234,7 @@ public class PackageEditPartCN extends PackageEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); + } /** @@ -239,7 +247,7 @@ public class PackageEditPartCN extends PackageEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if(nodeShape.getLayoutManager() == null) { + if (nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -252,7 +260,7 @@ public class PackageEditPartCN extends PackageEditPart { */ @Override public IFigure getContentPane() { - if(contentPane != null) { + if (contentPane != null) { return contentPane; } return super.getContentPane(); @@ -263,7 +271,7 @@ public class PackageEditPartCN extends PackageEditPart { */ @Override protected void setForegroundColor(Color color) { - if(primaryShape != null) { + if (primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -281,8 +289,8 @@ public class PackageEditPartCN extends PackageEditPart { */ @Override protected void setLineType(int style) { - if(primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageNameEditPart.java index d4feb88bce8..6dc72a7dbe6 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageNameEditPart.java @@ -64,6 +64,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -85,12 +86,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PackageNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class PackageNameEditPart extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "35"; + public static final String VISUAL_ID = "Package_NameLabel"; /** * @generated @@ -148,12 +150,12 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -161,12 +163,12 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -174,12 +176,12 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -187,12 +189,12 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -243,12 +245,12 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I */ protected Image getLabelIcon() { EObject parserElement = getParserElement(); - if(parserElement == null) { + if (parserElement == null) { return null; } List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer()); - for(View view : views) { - if(AppearanceHelper.showElementIcon(view)) { + for (View view : views) { + if (AppearanceHelper.showElementIcon(view)) { return UMLElementTypes.getImage(parserElement.eClass()); } } @@ -261,10 +263,11 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -277,12 +280,12 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -291,10 +294,11 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -313,22 +317,25 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), PackageNameEditPart.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -340,10 +347,10 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -359,8 +366,8 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Package_2009, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.PackageNameEditPart.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Package_Shape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -369,8 +376,10 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -399,8 +408,8 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -408,8 +417,8 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -420,46 +429,58 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -481,12 +502,13 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -517,12 +539,12 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -531,12 +553,12 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -544,15 +566,15 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -561,9 +583,9 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -572,9 +594,10 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I */ @Override 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)); + 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); } } @@ -592,11 +615,11 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -608,8 +631,8 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -622,7 +645,7 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -648,13 +671,14 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -666,7 +690,7 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -688,12 +712,15 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -704,10 +731,13 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -726,12 +756,15 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -769,31 +802,35 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } - if(event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation)event.getNewValue()).getSource())) { + if (event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON + .equals(((EAnnotation) event.getNewValue()).getSource())) { refreshLabel(); } super.handleNotificationEvent(event); @@ -826,7 +863,8 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -836,6 +874,7 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -843,5 +882,6 @@ public class PackageNameEditPart extends PapyrusCompartmentEditPart implements I */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageNameEditPartCN.java index 21ca07b4f34..cd9afb68eaf 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageNameEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackageNameEditPartCN.java @@ -64,6 +64,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirect import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; 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; @@ -85,12 +86,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { +public class PackageNameEditPartCN extends PapyrusCompartmentEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated */ - public static final String VISUAL_ID = "37"; + public static final String VISUAL_ID = "Package_NameLabel_CN"; /** * @generated @@ -148,12 +150,12 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected String getLabelTextHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getText(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getText(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getText(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getText(); } else { - return ((Label)figure).getText(); + return ((Label) figure).getText(); } } @@ -161,12 +163,12 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setText(text); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setText(text); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setText(text); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setText(text); } else { - ((Label)figure).setText(text); + ((Label) figure).setText(text); } } @@ -174,12 +176,12 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if(figure instanceof WrappingLabel) { - return ((WrappingLabel)figure).getIcon(); - } else if(figure instanceof ILabelFigure) { - return ((ILabelFigure)figure).getIcon(); + if (figure instanceof WrappingLabel) { + return ((WrappingLabel) figure).getIcon(); + } else if (figure instanceof ILabelFigure) { + return ((ILabelFigure) figure).getIcon(); } else { - return ((Label)figure).getIcon(); + return ((Label) figure).getIcon(); } } @@ -187,12 +189,12 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if(figure instanceof WrappingLabel) { - ((WrappingLabel)figure).setIcon(icon); - } else if(figure instanceof ILabelFigure) { - ((ILabelFigure)figure).setIcon(icon); + if (figure instanceof WrappingLabel) { + ((WrappingLabel) figure).setIcon(icon); + } else if (figure instanceof ILabelFigure) { + ((ILabelFigure) figure).setIcon(icon); } else { - ((Label)figure).setIcon(icon); + ((Label) figure).setIcon(icon); } } @@ -243,12 +245,12 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements */ protected Image getLabelIcon() { EObject parserElement = getParserElement(); - if(parserElement == null) { + if (parserElement == null) { return null; } List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer()); - for(View view : views) { - if(AppearanceHelper.showElementIcon(view)) { + for (View view : views) { + if (AppearanceHelper.showElementIcon(view)) { return UMLElementTypes.getImage(parserElement.eClass()); } } @@ -261,10 +263,11 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if(parserElement != null && getParser() != null) { - text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + if (parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } - if(text == null || text.length() == 0) { + if (text == null || text.length() == 0) { text = defaultText; } return text; @@ -277,12 +280,12 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -291,10 +294,11 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override public String getEditText() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), + getParserOptions().intValue()); } /** @@ -313,22 +317,25 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements @Override public String isValid(final Object value) { - if(value instanceof String) { + if (value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); - } - }); + IParserEditStatus valid = (IParserEditStatus) getEditingDomain() + .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), PackageNameEditPartCN.this), (String) value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } + // shouldn't get here return null; } @@ -340,10 +347,10 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override public IContentAssistProcessor getCompletionProcessor() { - if(getParserElement() == null || getParser() == null) { + if (getParserElement() == null || getParser() == null) { return null; } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); } /** @@ -359,8 +366,8 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override public IParser getParser() { - if(parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Package_36, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.PackageNameEditPartCN.VISUAL_ID)); + if (parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Package_Shape_CN, getParserElement(), this, VISUAL_ID); } return parser; } @@ -369,8 +376,10 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected DirectEditManager getManager() { - if(manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + if (manager == null) { + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -399,8 +408,8 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void performDirectEdit(Point eventLocation) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); } } @@ -408,8 +417,8 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void performDirectEdit(char initialCharacter) { - if(getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager)getManager()).show(initialCharacter); + if (getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager) getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -420,46 +429,58 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override protected void performDirectEditRequest(Request request) { + final Request theRequest = request; - if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + + if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch(directEditionMode) { + 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) { + if (configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, + MultilineLabelDirectEditManager.getTextCellEditorClass(this), + UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if(configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); + if (configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if(configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); + } else 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(), configuration.getTextToEdit(resolveSemanticElement()), configuration); + } 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(), + configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - if(Window.OK == dialog.open()) { + + 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()); + configuration.postEditAction(resolveSemanticElement(), + ((ILabelEditorDialog) finalDialog).getValue()); + } }; domain.getCommandStack().execute(command); @@ -481,12 +502,13 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { - @Override public void run() { - if(isActive() && isEditable()) { - if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + if (isActive() && isEditable()) { + if (request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { + Character initialChar = (Character) request.getExtendedData() + .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); performDirectEdit(initialChar.charValue()); } else { performDirectEdit(); @@ -517,12 +539,12 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if(maskLabelPolicy == null) { + if (maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if(maskLabelPolicy == null) { - View view = (View)getModel(); - if(view.isVisible()) { + if (maskLabelPolicy == null) { + View view = (View) getModel(); + if (view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -531,12 +553,12 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); } } @@ -544,15 +566,15 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + 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); + if (resolveSemanticElement() instanceof Feature) { + if (((Feature) resolveSemanticElement()).isStatic()) { + ((WrappingLabel) getFigure()).setTextUnderline(true); } else { - ((WrappingLabel)getFigure()).setTextUnderline(false); + ((WrappingLabel) getFigure()).setTextUnderline(false); } } } @@ -561,9 +583,9 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if(style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -572,9 +594,10 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override 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)); + 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); } } @@ -592,11 +615,11 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override protected void addSemanticListeners() { - if(getParser() instanceof ISemanticParser) { + 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$ + 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(); @@ -608,8 +631,8 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override protected void removeSemanticListeners() { - if(parserElements != null) { - for(int i = 0; i < parserElements.size(); i++) { + if (parserElements != null) { + for (int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -622,7 +645,7 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if(accessibleEP == null) { + if (accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -648,13 +671,14 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ public int getDirectEditionType() { - if(checkExtendedEditor()) { + if (checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if(checkDefaultEdition()) { + if (checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } + // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -666,7 +690,7 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected boolean checkExtendedEditor() { - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -688,12 +712,15 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ 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(), this); + 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(), + this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, + resolveSemanticElement(), this); } } } @@ -704,10 +731,13 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); - } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString( + IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if (languagePreferred != null && !languagePreferred.equals("") + && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), + this); + } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -726,12 +756,15 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements @Override 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); + 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; + } else if ((theRequest instanceof DirectEditRequest) + && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest) theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -769,31 +802,35 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer)event.getNewValue(); + 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)) { + } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } 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)) { + } 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())) { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if(getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser)getParser(); - if(modelParser.areSemanticElementsAffected(null, event)) { + if (getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser) getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if(resolveSemanticElement() != null) { + if (resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } - if(event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation)event.getNewValue()).getSource())) { + if (event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON + .equals(((EAnnotation) event.getNewValue()).getSource())) { refreshLabel(); } super.handleNotificationEvent(event); @@ -826,7 +863,8 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); + addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); + } /** @@ -836,6 +874,7 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements public void deactivate() { removeOwnerElementListeners(); super.deactivate(); + } /** @@ -843,5 +882,6 @@ public class PackageNameEditPartCN extends PapyrusCompartmentEditPart implements */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackagePackageableElementCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackagePackageableElementCompartmentEditPart.java index 4e5180346bb..ba37b9a74e7 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackagePackageableElementCompartmentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackagePackageableElementCompartmentEditPart.java @@ -41,7 +41,7 @@ public class PackagePackageableElementCompartmentEditPart extends LinkLFShapeCom /** * @generated */ - public static final String VISUAL_ID = "38"; + public static final String VISUAL_ID = "Package_PackagedElementCompartment"; /** * @generated @@ -70,6 +70,7 @@ public class PackagePackageableElementCompartmentEditPart extends LinkLFShapeCom installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.deployment.edit.policies.PackagePackageableElementCompartmentCanonicalEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(BorderDisplayEditPolicy.BORDER_DISPLAY_EDITPOLICY, new BorderDisplayEditPolicy()); @@ -80,7 +81,7 @@ public class PackagePackageableElementCompartmentEditPart extends LinkLFShapeCom */ @Override protected void setRatio(Double ratio) { - if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -90,6 +91,7 @@ public class PackagePackageableElementCompartmentEditPart extends LinkLFShapeCom */ @Override public EditPart getTargetEditPart(Request request) { + return super.getTargetEditPart(request); } @@ -99,7 +101,10 @@ public class PackagePackageableElementCompartmentEditPart extends LinkLFShapeCom @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) + || NotationPackage.eINSTANCE.getSize_Height().equals(feature) + || NotationPackage.eINSTANCE.getLocation_X().equals(feature) + || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -109,13 +114,13 @@ public class PackagePackageableElementCompartmentEditPart extends LinkLFShapeCom * @generated */ protected void refreshBounds() { - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackagePackageableElementCompartmentEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackagePackageableElementCompartmentEditPartCN.java index 7738572f2d8..9de61947d9a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackagePackageableElementCompartmentEditPartCN.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/PackagePackageableElementCompartmentEditPartCN.java @@ -41,7 +41,7 @@ public class PackagePackageableElementCompartmentEditPartCN extends LinkLFShapeC /** * @generated */ - public static final String VISUAL_ID = "39"; + public static final String VISUAL_ID = "Package_PackagedElementCompartment_CN"; /** * @generated @@ -70,6 +70,7 @@ public class PackagePackageableElementCompartmentEditPartCN extends LinkLFShapeC installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.deployment.edit.policies.PackagePackageableElementCompartmentCanonicalEditPolicyCN()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomDiagramDragDropEditPolicy()); installEditPolicy(BorderDisplayEditPolicy.BORDER_DISPLAY_EDITPOLICY, new BorderDisplayEditPolicy()); @@ -80,7 +81,7 @@ public class PackagePackageableElementCompartmentEditPartCN extends LinkLFShapeC */ @Override protected void setRatio(Double ratio) { - if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -90,6 +91,7 @@ public class PackagePackageableElementCompartmentEditPartCN extends LinkLFShapeC */ @Override public EditPart getTargetEditPart(Request request) { + return super.getTargetEditPart(request); } @@ -99,7 +101,10 @@ public class PackagePackageableElementCompartmentEditPartCN extends LinkLFShapeC @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) + || NotationPackage.eINSTANCE.getSize_Height().equals(feature) + || NotationPackage.eINSTANCE.getLocation_X().equals(feature) + || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -109,13 +114,13 @@ public class PackagePackageableElementCompartmentEditPartCN extends LinkLFShapeC * @generated */ protected void refreshBounds() { - int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/UMLEditPartFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/UMLEditPartFactory.java index fe5e571f7e5..12d885bf811 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/UMLEditPartFactory.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/edit/parts/UMLEditPartFactory.java @@ -35,199 +35,295 @@ public class UMLEditPartFactory implements EditPartFactory { */ @Override public EditPart createEditPart(EditPart context, Object model) { - if(model instanceof View) { - View view = (View)model; - switch(UMLVisualIDRegistry.getVisualID(view)) { + if (model instanceof View) { + View view = (View) model; + switch (UMLVisualIDRegistry.getVisualID(view)) { + case DeploymentDiagramEditPart.VISUAL_ID: return new DeploymentDiagramEditPart(view); + case DependencyNodeEditPart.VISUAL_ID: return new DependencyNodeEditPart(view); + case MultiDependencyLabelEditPart.VISUAL_ID: return new MultiDependencyLabelEditPart(view); + case ModelEditPart.VISUAL_ID: return new ModelEditPart(view); + case ModelNameEditPart.VISUAL_ID: return new ModelNameEditPart(view); + case PackageEditPart.VISUAL_ID: return new PackageEditPart(view); + case PackageNameEditPart.VISUAL_ID: return new PackageNameEditPart(view); + case ConstraintEditPart.VISUAL_ID: return new ConstraintEditPart(view); + case ConstraintNameEditPart.VISUAL_ID: return new ConstraintNameEditPart(view); + case ConstraintSpecificationEditPart.VISUAL_ID: return new ConstraintSpecificationEditPart(view); + case CommentEditPart.VISUAL_ID: return new CommentEditPart(view); + case CommentBodyEditPart.VISUAL_ID: return new CommentBodyEditPart(view); + case ExecutionEnvironmentEditPart.VISUAL_ID: return new ExecutionEnvironmentEditPart(view); + case ExecutionEnvironmentNameEditPart.VISUAL_ID: return new ExecutionEnvironmentNameEditPart(view); + case DeviceEditPart.VISUAL_ID: return new DeviceEditPart(view); + case DeviceNameEditPart.VISUAL_ID: return new DeviceNameEditPart(view); + case ArtifactEditPart.VISUAL_ID: return new ArtifactEditPart(view); + case ArtifactNameEditPart.VISUAL_ID: return new ArtifactNameEditPart(view); + case ArtifactFloatingLabelEditPart.VISUAL_ID: return new ArtifactFloatingLabelEditPart(view); + case NodeEditPart.VISUAL_ID: return new NodeEditPart(view); + case NodeNameEditPart.VISUAL_ID: return new NodeNameEditPart(view); + case DefaultNamedElementEditPart.VISUAL_ID: return new DefaultNamedElementEditPart(view); + case DefaultNamedElementNameEditPart.VISUAL_ID: return new DefaultNamedElementNameEditPart(view); + case DeploymentSpecificationEditPart.VISUAL_ID: return new DeploymentSpecificationEditPart(view); + case DeploymentSpecificationNameEditPart.VISUAL_ID: return new DeploymentSpecificationNameEditPart(view); + case DeploymentSpecificationFloatingLabelEditPart.VISUAL_ID: return new DeploymentSpecificationFloatingLabelEditPart(view); + case ModelEditPartCN.VISUAL_ID: return new ModelEditPartCN(view); + case ModelNameEditPartCN.VISUAL_ID: return new ModelNameEditPartCN(view); + case PackageEditPartCN.VISUAL_ID: return new PackageEditPartCN(view); + case PackageNameEditPartCN.VISUAL_ID: return new PackageNameEditPartCN(view); + case DeviceEditPartCN.VISUAL_ID: return new DeviceEditPartCN(view); + case DeviceNameEditPartCN.VISUAL_ID: return new DeviceNameEditPartCN(view); + case NestedDeviceEditPartCN.VISUAL_ID: return new NestedDeviceEditPartCN(view); + case NestedDeviceNameEditPartCN.VISUAL_ID: return new NestedDeviceNameEditPartCN(view); + case ExecutionEnvironmentEditPartCN.VISUAL_ID: return new ExecutionEnvironmentEditPartCN(view); + case ExecutionEnvironmentNameEditPartCN.VISUAL_ID: return new ExecutionEnvironmentNameEditPartCN(view); + case NestedExecutionEnvironmentEditPartCN.VISUAL_ID: return new NestedExecutionEnvironmentEditPartCN(view); + case NestedExecutionEnvironmentNameEditPartCN.VISUAL_ID: return new NestedExecutionEnvironmentNameEditPartCN(view); + case NodeEditPartCN.VISUAL_ID: return new NodeEditPartCN(view); + case NodeNameEditPartCN.VISUAL_ID: return new NodeNameEditPartCN(view); + case NestedNodeEditPartCN.VISUAL_ID: return new NestedNodeEditPartCN(view); + case NestedNodeNameEditPart.VISUAL_ID: return new NestedNodeNameEditPart(view); + case ArtifactEditPartCN.VISUAL_ID: return new ArtifactEditPartCN(view); + case ArtifactNameEditPartCN.VISUAL_ID: return new ArtifactNameEditPartCN(view); + case ArtifactFloatingLabelEditPartCN.VISUAL_ID: return new ArtifactFloatingLabelEditPartCN(view); + case ArtifactEditPartACN.VISUAL_ID: return new ArtifactEditPartACN(view); + case ArtifactNameEditPartACN.VISUAL_ID: return new ArtifactNameEditPartACN(view); + case ArtifactFloatingLabelEditPartACN.VISUAL_ID: return new ArtifactFloatingLabelEditPartACN(view); + case NestedArtifactNodeEditPartCN.VISUAL_ID: return new NestedArtifactNodeEditPartCN(view); + case NestedArtifactNameEditPart.VISUAL_ID: return new NestedArtifactNameEditPart(view); + case CommentEditPartCN.VISUAL_ID: return new CommentEditPartCN(view); + case CommentBodyEditPartCN.VISUAL_ID: return new CommentBodyEditPartCN(view); + case ConstraintEditPartCN.VISUAL_ID: return new ConstraintEditPartCN(view); + case ConstraintNameEditPartCN.VISUAL_ID: return new ConstraintNameEditPartCN(view); + case ConstraintSpecificationEditPartCN.VISUAL_ID: return new ConstraintSpecificationEditPartCN(view); + case DeploymentSpecAsClassifierEditPart.VISUAL_ID: return new DeploymentSpecAsClassifierEditPart(view); + case DeploymentSpecAsClassifierNameEditPart.VISUAL_ID: return new DeploymentSpecAsClassifierNameEditPart(view); + case DeploymentSpecAsClassifierFloatingLabelEditPart.VISUAL_ID: return new DeploymentSpecAsClassifierFloatingLabelEditPart(view); + case DeploymentSpecAsPackageableElEditPart.VISUAL_ID: return new DeploymentSpecAsPackageableElEditPart(view); + case DeploymentSpecAsPackageableElNameEditPart.VISUAL_ID: return new DeploymentSpecAsPackageableElNameEditPart(view); + case DeploymentSpecAsPackageableElFloatingLabelEditPart.VISUAL_ID: return new DeploymentSpecAsPackageableElFloatingLabelEditPart(view); + case DeploymentSpecAsNestedArtifactEditPart.VISUAL_ID: return new DeploymentSpecAsNestedArtifactEditPart(view); + case DeploymentSpecAsNestedArtifactNameEditPart.VISUAL_ID: return new DeploymentSpecAsNestedArtifactNameEditPart(view); + case DeploymentSpecAsNestedArtifactFloatingLabelEditPart.VISUAL_ID: return new DeploymentSpecAsNestedArtifactFloatingLabelEditPart(view); + case ModelPackageableElementCompartmentEditPart.VISUAL_ID: return new ModelPackageableElementCompartmentEditPart(view); + case PackagePackageableElementCompartmentEditPart.VISUAL_ID: return new PackagePackageableElementCompartmentEditPart(view); + case DeviceCompositeCompartmentEditPart.VISUAL_ID: return new DeviceCompositeCompartmentEditPart(view); + case ExecutionEnvironmentCompositeCompartmentEditPart.VISUAL_ID: return new ExecutionEnvironmentCompositeCompartmentEditPart(view); + case NodeCompositeCompartmentEditPart.VISUAL_ID: return new NodeCompositeCompartmentEditPart(view); + case ArtifactCompositeCompartmentEditPart.VISUAL_ID: return new ArtifactCompositeCompartmentEditPart(view); + case ModelPackageableElementCompartmentEditPartCN.VISUAL_ID: return new ModelPackageableElementCompartmentEditPartCN(view); + case PackagePackageableElementCompartmentEditPartCN.VISUAL_ID: return new PackagePackageableElementCompartmentEditPartCN(view); + case DeviceCompositeCompartmentEditPartCN.VISUAL_ID: return new DeviceCompositeCompartmentEditPartCN(view); + case ExecutionEnvironmentCompositeCompartmentEditPartCN.VISUAL_ID: return new ExecutionEnvironmentCompositeCompartmentEditPartCN(view); + case NodeCompositeCompartmentEditPartCN.VISUAL_ID: return new NodeCompositeCompartmentEditPartCN(view); + case ArtifactCompositeCompartmentEditPartCN.VISUAL_ID: return new ArtifactCompositeCompartmentEditPartCN(view); + case ArtifactCompositeCompartmentEditPartACN.VISUAL_ID: return new ArtifactCompositeCompartmentEditPartACN(view); + case LinkDescriptorEditPart.VISUAL_ID: return new LinkDescriptorEditPart(view); + case CommentAnnotatedElementEditPart.VISUAL_ID: return new CommentAnnotatedElementEditPart(view); + case ConstraintConstrainedElementEditPart.VISUAL_ID: return new ConstraintConstrainedElementEditPart(view); + case DeploymentEditPart.VISUAL_ID: return new DeploymentEditPart(view); + case DeploymentNameEditPart.VISUAL_ID: return new DeploymentNameEditPart(view); + case DeploymentAppliedStereotypeEditPart.VISUAL_ID: return new DeploymentAppliedStereotypeEditPart(view); + case ManifestationEditPart.VISUAL_ID: return new ManifestationEditPart(view); + case ManifestationNameEditPart.VISUAL_ID: return new ManifestationNameEditPart(view); + case ManifestationAppliedStereotypeEditPart.VISUAL_ID: return new ManifestationAppliedStereotypeEditPart(view); + case GeneralizationEditPart.VISUAL_ID: return new GeneralizationEditPart(view); + case GeneralizationAppliedStereotypeEditPart.VISUAL_ID: return new GeneralizationAppliedStereotypeEditPart(view); + case DependencyEditPart.VISUAL_ID: return new DependencyEditPart(view); + case DependencyNameEditPart.VISUAL_ID: return new DependencyNameEditPart(view); + case DependencyAppliedStereotypeEditPart.VISUAL_ID: return new DependencyAppliedStereotypeEditPart(view); + case DependencyBranchEditPart.VISUAL_ID: return new DependencyBranchEditPart(view); + case CommunicationPathEditPart.VISUAL_ID: return new CommunicationPathEditPart(view); + case CommunicationPathNameEditPart.VISUAL_ID: return new CommunicationPathNameEditPart(view); + case CommunicationPathAppliedStereotypeEditPart.VISUAL_ID: return new CommunicationPathAppliedStereotypeEditPart(view); + } } return createUnrecognizedEditPart(context, model); @@ -245,10 +341,11 @@ public class UMLEditPartFactory implements EditPartFactory { * @generated */ public static CellEditorLocator getTextCellEditorLocator(ITextAwareEditPart source) { - if(source.getFigure() instanceof IMultilineEditableFigure) { - return new MultilineCellEditorLocator((IMultilineEditableFigure)source.getFigure()); + if (source.getFigure() instanceof IMultilineEditableFigure) { + return new MultilineCellEditorLocator((IMultilineEditableFigure) source.getFigure()); } else { return CellEditorLocatorAccess.INSTANCE.getTextCellEditorLocator(source); + } } @@ -281,15 +378,15 @@ public class UMLEditPartFactory implements EditPartFactory { */ @Override public void relocate(CellEditor celleditor) { - Text text = (Text)celleditor.getControl(); + Text text = (Text) celleditor.getControl(); Rectangle rect = getMultilineEditableFigure().getBounds().getCopy(); rect.x = getMultilineEditableFigure().getEditionLocation().x; rect.y = getMultilineEditableFigure().getEditionLocation().y; getMultilineEditableFigure().translateToAbsolute(rect); - if(getMultilineEditableFigure().getText().length() > 0) { + if (getMultilineEditableFigure().getText().length() > 0) { rect.setSize(new Dimension(text.computeSize(rect.width, SWT.DEFAULT))); } - if(!rect.equals(new Rectangle(text.getBounds()))) { + if (!rect.equals(new Rectangle(text.getBounds()))) { text.setBounds(rect.x, rect.y, rect.width, rect.height); } } |