diff options
author | Benoit Maggi | 2017-05-15 13:42:51 +0000 |
---|---|---|
committer | Benoit Maggi | 2017-06-01 05:11:06 +0000 |
commit | fdf5650b204a1e3a625a08735d91bf1d8df0e098 (patch) | |
tree | fbbca998ceafa9642d475aa14fb342fcad29cd28 /plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus | |
parent | 735a84b375cb02b7c58c9a6540d4d070d1728822 (diff) | |
download | org.eclipse.papyrus-fdf5650b204a1e3a625a08735d91bf1d8df0e098.tar.gz org.eclipse.papyrus-fdf5650b204a1e3a625a08735d91bf1d8df0e098.tar.xz org.eclipse.papyrus-fdf5650b204a1e3a625a08735d91bf1d8df0e098.zip |
Bug 516687 - [SysML 1.1] Move SysML 1.1 to an independent repository
- remove sysml 1.1 plugins and feature from master branch
- note: some weak reference are still in the code a simple sysml grep
will show all remaining typos
Change-Id: I00173658659cfb5f3cec47391c6a3b1216bafcff
Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
Diffstat (limited to 'plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus')
48 files changed, 0 insertions, 8177 deletions
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/dnd/helper/LinkMappingHelper.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/dnd/helper/LinkMappingHelper.java deleted file mode 100644 index 0f4f2fca2a9..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/dnd/helper/LinkMappingHelper.java +++ /dev/null @@ -1,158 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.dnd.helper; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.papyrus.gmf.diagram.common.edit.policy.ILinkMappingHelper; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.util.UMLSwitch; - -/** - * Original class {@link org.eclipse.papyrus.uml.diagram.common.helper.LinkMappingHelper} slightly - * modified to use EObject instead of UML Element in its interface. - */ -public class LinkMappingHelper implements ILinkMappingHelper { - - /** - * {@inheritDoc} - */ - @Override - public Collection<?> getSource(Element link) { - CommonSourceUMLSwitch umlSwitch = new CommonSourceUMLSwitch(); - return umlSwitch.doSwitch(link); - } - - /** - * {@inheritDoc} - */ - @Override - public Collection<?> getTarget(Element link) { - CommonTargetUMLSwitch umlSwitch = new CommonTargetUMLSwitch(); - return umlSwitch.doSwitch(link); - } - - /** - * Contains diagrams common behavior that need to be redefined - * - * @author eperico - */ - public static class CommonSourceUMLSwitch extends UMLSwitch<Collection<?>> { - - @Override - public java.util.Collection<?> caseAssociation(org.eclipse.uml2.uml.Association object) { - return object.getEndTypes(); - }; - - @Override - public java.util.Collection<?> caseComment(org.eclipse.uml2.uml.Comment object) { - ArrayList<EObject> result = new ArrayList<EObject>(); - result.add(object); - return result; - }; - - @Override - public Collection<?> caseDependency(org.eclipse.uml2.uml.Dependency object) { - return object.getClients(); - }; - - @Override - public java.util.Collection<?> caseGeneralization(org.eclipse.uml2.uml.Generalization object) { - ArrayList<EObject> result = new ArrayList<EObject>(); - result.add(object.getOwner()); - return result; - }; - - @Override - public java.util.Collection<?> casePackageMerge(org.eclipse.uml2.uml.PackageMerge object) { - ArrayList<EObject> result = new ArrayList<EObject>(); - result.add(object.getReceivingPackage()); - return result; - }; - - @Override - public java.util.Collection<?> casePackageImport(org.eclipse.uml2.uml.PackageImport object) { - ArrayList<EObject> result = new ArrayList<EObject>(); - result.add(object.getImportingNamespace()); - return result; - }; - - @Override - public Collection<?> caseInformationFlow(org.eclipse.uml2.uml.InformationFlow object) { - return object.getInformationSources(); - }; - - @Override - public Collection<?> defaultCase(org.eclipse.emf.ecore.EObject object) { - return Collections.EMPTY_LIST; - }; - } - - /** - * Contains diagrams common behavior that need to be redefined - * - * @author eperico - */ - public static class CommonTargetUMLSwitch extends UMLSwitch<Collection<?>> { - - @Override - public java.util.Collection<?> caseAssociation(org.eclipse.uml2.uml.Association object) { - return object.getEndTypes(); - }; - - @Override - public java.util.Collection<?> caseComment(org.eclipse.uml2.uml.Comment object) { - return object.getAnnotatedElements(); - }; - - @Override - public Collection<?> caseDependency(org.eclipse.uml2.uml.Dependency object) { - return object.getSuppliers(); - }; - - @Override - public java.util.Collection<?> caseGeneralization(org.eclipse.uml2.uml.Generalization object) { - ArrayList<EObject> result = new ArrayList<EObject>(); - result.add(object.getGeneral()); - return result; - }; - - @Override - public java.util.Collection<?> casePackageMerge(org.eclipse.uml2.uml.PackageMerge object) { - ArrayList<EObject> result = new ArrayList<EObject>(); - result.add(object.getMergedPackage()); - return result; - }; - - @Override - public java.util.Collection<?> casePackageImport(org.eclipse.uml2.uml.PackageImport object) { - ArrayList<EObject> result = new ArrayList<EObject>(); - result.add(object.getImportedPackage()); - return result; - }; - - @Override - public Collection<?> caseInformationFlow(org.eclipse.uml2.uml.InformationFlow object) { - return object.getInformationTargets(); - }; - - @Override - public Collection<?> defaultCase(org.eclipse.emf.ecore.EObject object) { - return Collections.EMPTY_LIST; - }; - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementBorderEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementBorderEditPart.java deleted file mode 100644 index 64c394c0004..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementBorderEditPart.java +++ /dev/null @@ -1,235 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * Vincent Lorenzo (CEA-LIST) - vincent.lorenzo@cea.fr (bug 493876) - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.StackLayout; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.editpolicies.LayoutEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; -import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; -import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities; -import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure; -import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; -import org.eclipse.gmf.runtime.notation.Edge; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.linklf.LinkLFNodeFigure; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper; -import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter; -import org.eclipse.papyrus.sysml.diagram.common.Activator; -import org.eclipse.papyrus.uml.diagram.common.editparts.AbstractBorderEditPart; -import org.eclipse.papyrus.uml.diagram.common.figure.node.AffixedNamedElementFigure; -import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper; -import org.eclipse.swt.graphics.Color; - -/** - * Abstract non-diagram specific edit part for border node. - * This class is adapted from edit parts generated by GMF Tooling. - */ -public abstract class AbstractElementBorderEditPart extends AbstractBorderEditPart { - - protected IFigure contentPane; - - protected IFigure primaryShape; - - public AbstractElementBorderEditPart(View view) { - super(view); - } - - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - } - - protected abstract LayoutEditPolicy createLayoutEditPolicy(); - - protected IFigure createNodeShape() { - return primaryShape = new AffixedNamedElementFigure(); - } - - @Override - public AffixedNamedElementFigure getPrimaryShape() { - return (AffixedNamedElementFigure) primaryShape; - } - - /** - * {@inheritDoc} - */ - @Override - public IBorderItemLocator getBorderItemLocator() { - IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { - Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - protected void handleNotificationEvent(Notification event) { - // When a node has external node labels, the methods refreshChildren() removes the label's - // edit part from the registry. Once removed from the registry the visibility cannot be set back to visible. - - // Copied from generated code for Affixed nodes to fix: - // 366504: [SysML Block Definition Diagram] Cannot make masked labels of border items (Port) visible - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=366504 - // 366503: [SysML Internal Block Diagram] Cannot make masked labels of border items (Port) visible - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=366503 - - // (this sounds strange as the "Show all labels" manages to get labels back without trouble...). - if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { - Object notifier = event.getNotifier(); - List<?> modelChildren = ((View) getModel()).getChildren(); - if (!(notifier instanceof Edge)) { - if (modelChildren.contains(event.getNotifier())) { - return; - } - } - } - super.handleNotificationEvent(event); - } - - /** - * {@inheritDoc} - */ - @Override - protected void refreshBounds() { - if (getBorderItemLocator() != null) { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - Point loc = new Point(x, y); - - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); - Dimension size = new Dimension(width, height); - - // Update locator constraint - IBorderItemLocator locator = getBorderItemLocator(); - locator.setConstraint(new Rectangle(loc, size)); - - // Set new constraint on parent figure - getFigure().getParent().setConstraint(getFigure(), locator); - - } else { - super.refreshBounds(); - } - } - - protected NodeFigure createNodePlate() { - String prefElementId = getNotationView().getType(); - IPreferenceStore store = Activator.getInstance().getPreferenceStore(); - String preferenceConstantWitdh = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferencesConstantsHelper.WIDTH); - String preferenceConstantHeight = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferencesConstantsHelper.HEIGHT); - DefaultSizeNodeFigure result = new LinkLFNodeFigure(this,store.getInt(preferenceConstantWitdh), store.getInt(preferenceConstantHeight)); - - // FIXME: workaround for #154536 - result.getBounds().setSize(result.getPreferredSize()); - return result; - } - - @Override - protected NodeFigure createMainFigure() { - NodeFigure figure = createNodePlate(); - figure.setLayoutManager(new StackLayout()); - IFigure shape = createNodeShape(); - figure.add(shape); - contentPane = setupContentPane(shape); - return figure; - } - - protected IFigure setupContentPane(IFigure nodeShape) { - return nodeShape; // use nodeShape itself as contentPane - } - - /** - * @generated - */ - @Override - public IFigure getContentPane() { - if (contentPane != null) { - return contentPane; - } - return super.getContentPane(); - } - - @Override - protected void setForegroundColor(Color color) { - if (primaryShape != null) { - primaryShape.setForegroundColor(color); - } - } - - @Override - public abstract EditPart getPrimaryChildEditPart(); - - @Override - public Object getPreferredValue(EStructuralFeature feature) { - String prefKey = getNotationView().getType(); - - IPreferenceStore store = (IPreferenceStore) getDiagramPreferencesHint().getPreferenceStore(); - Object result = null; - - if (feature == NotationPackage.eINSTANCE.getLineStyle_LineColor() || feature == NotationPackage.eINSTANCE.getFontStyle_FontColor() || feature == NotationPackage.eINSTANCE.getFillStyle_FillColor()) { - - String prefColor = null; - if (feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()) { - prefColor = PreferencesConstantsHelper.getElementConstant(prefKey, PreferencesConstantsHelper.COLOR_LINE); - - } else if (feature == NotationPackage.eINSTANCE.getFontStyle_FontColor()) { - prefColor = PreferencesConstantsHelper.getElementConstant(prefKey, PreferencesConstantsHelper.COLOR_FONT); - - } else if (feature == NotationPackage.eINSTANCE.getFillStyle_FillColor()) { - prefColor = PreferencesConstantsHelper.getElementConstant(prefKey, PreferencesConstantsHelper.COLOR_FILL); - - } - result = FigureUtilities.RGBToInteger(PreferenceConverter.getColor(store, prefColor)); - - } else if (feature == NotationPackage.eINSTANCE.getFillStyle_Transparency() || feature == NotationPackage.eINSTANCE.getFillStyle_Gradient()) { - - String prefGradient = PreferencesConstantsHelper.getElementConstant(prefKey, PreferencesConstantsHelper.COLOR_GRADIENT); - GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(store.getString(prefGradient)); - if (feature == NotationPackage.eINSTANCE.getFillStyle_Transparency()) { - result = new Integer(gradientPreferenceConverter.getTransparency()); - - } else if (feature == NotationPackage.eINSTANCE.getFillStyle_Gradient()) { - result = gradientPreferenceConverter.getGradientData(); - - } - } - - if (result == null) { - result = getStructuralFeatureValue(feature); - } - return result; - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementChildLabelEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementChildLabelEditPart.java deleted file mode 100644 index 6f7f077df5c..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementChildLabelEditPart.java +++ /dev/null @@ -1,889 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EAnnotation; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.RunnableWithResult; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.AccessibleEditPart; -import org.eclipse.gef.DragTracker; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.requests.DirectEditRequest; -import org.eclipse.gef.requests.DropRequest; -import org.eclipse.gef.requests.ReconnectRequest; -import org.eclipse.gef.requests.SelectionRequest; -import org.eclipse.gef.tools.DirectEditManager; -import org.eclipse.gef.tools.SelectEditPartTracker; -import org.eclipse.gmf.runtime.common.core.util.Log; -import org.eclipse.gmf.runtime.common.core.util.Trace; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; -import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; -import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.INodeEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConnectionHandleEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIDebugOptions; -import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIPlugin; -import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIStatusCodes; -import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; -import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; -import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; -import org.eclipse.gmf.runtime.draw2d.ui.figures.IAnchorableFigure; -import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; -import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; -import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; -import org.eclipse.gmf.runtime.notation.Anchor; -import org.eclipse.gmf.runtime.notation.Edge; -import org.eclipse.gmf.runtime.notation.FontStyle; -import org.eclipse.gmf.runtime.notation.IdentityAnchor; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.jface.viewers.ICellEditorValidator; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog; -import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog; -import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper; -import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; -import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; -import org.eclipse.papyrus.gmf.diagram.common.edit.part.ITextAwareEditPart; -import org.eclipse.papyrus.gmf.diagram.common.edit.policy.LabelDirectEditPolicy; -import org.eclipse.papyrus.gmf.diagram.common.edit.policy.TextNonResizableEditPolicy; -import org.eclipse.papyrus.gmf.diagram.common.edit.policy.TextSelectionEditPolicy; -import org.eclipse.papyrus.gmf.diagram.common.locator.CellEditorLocatorUtil; -import org.eclipse.papyrus.infra.emf.appearance.helper.NameLabelIconHelper; -import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusAnchorableWrappingLabel; -import org.eclipse.papyrus.sysml.diagram.common.Activator; -import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; -import org.eclipse.papyrus.sysml.diagram.common.preferences.LabelPreferenceHelper; -import org.eclipse.papyrus.uml.diagram.common.commands.SemanticAdapter; -import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; -import org.eclipse.papyrus.uml.diagram.common.edit.policy.MaskManagedLabelEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; -import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; -import org.eclipse.papyrus.uml.diagram.common.parser.DefaultParserHintAdapter; -import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.accessibility.AccessibleEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.PlatformUI; - -/** - * Abstract non-diagram specific edit part for child label node. - * This class is adapted from edit parts generated by GMF Tooling. - */ -public class AbstractElementChildLabelEditPart extends GraphicalEditPart implements ITextAwareEditPart, IPrimaryEditPart, INodeEditPart { - - private DirectEditManager manager; - - protected IParser parser; - - private List<?> parserElements; - - private String defaultText; - - protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR; - - protected IDirectEditorConfiguration configuration; - - /** Constructor */ - public AbstractElementChildLabelEditPart(View view) { - super(view); - } - - @Override - public DragTracker getDragTracker(Request request) { - if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) { - return null; - } - // return new DragEditPartsTrackerEx(this); - // Disable current child label DnD as this is not correctly handled by Papyrus. - return new SelectEditPartTracker(this); - } - - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new MaskManagedLabelEditPolicy()); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new TextNonResizableEditPolicy()); - installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy()); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE, new ConnectionHandleEditPolicy()); - } - - protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); - } else { - return ((Label) figure).getText(); - } - } - - protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); - } else { - ((Label) figure).setText(text); - } - } - - protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); - } else { - return ((Label) figure).getIcon(); - } - } - - protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); - } else { - ((Label) figure).setIcon(icon); - } - } - - public void setLabel(IFigure figure) { - unregisterVisuals(); - setFigure(figure); - defaultText = getLabelTextHelper(figure); - registerVisuals(); - refreshVisuals(); - } - - @Override - protected List getModelChildren() { - return Collections.EMPTY_LIST; - } - - @Override - public IGraphicalEditPart getChildBySemanticHint(String semanticHint) { - return null; - } - - @Override - public EObject getParserElement() { - return resolveSemanticElement(); - } - - protected Image getLabelIcon() { - EObject parserElement = getParserElement(); - if (parserElement == null) { - return null; - } - - List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer()); - for (View view : views) { - if (NameLabelIconHelper.showLabelIcon(view)) { - return Activator.getInstance().getLabelProvider().getImage(parserElement); - } - } - return null; - - } - - protected String getLabelText() { - String text = null; - EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(new SemanticAdapter(parserElement, getNotationView()), getParserOptions().intValue()); - } - if (text == null || text.length() == 0) { - text = defaultText; - } - return text; - } - - @Override - public void setLabelText(String text) { - setLabelTextHelper(getFigure(), text); - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof TextSelectionEditPolicy) { - ((TextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof TextSelectionEditPolicy) { - ((TextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - @Override - public String getEditText() { - if (getParserElement() == null || getParser() == null) { - return ""; //$NON-NLS-1$ - } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); - } - - protected boolean isEditable() { - return getParser() != null; - } - - @Override - public ICellEditorValidator getEditTextValidator() { - return new ICellEditorValidator() { - - @Override - public String isValid(final Object value) { - if (value instanceof String) { - final EObject element = getParserElement(); - final IParser parser = getParser(); - try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value)); - } - }); - return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); - } catch (InterruptedException ie) { - ie.printStackTrace(); - } - } - - // shouldn't get here - return null; - } - }; - } - - @Override - public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { - return null; - } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); - } - - @Override - public ParserOptions getParserOptions() { - if (getNotationView() == null || getNotationView().getDiagram() == null) { - return ParserOptions.NONE; - } - - // int displayOptions = AppearanceHelper.getLabelDisplay(getNotationView()); - - EAnnotation display = getNotationView().getEAnnotation(VisualInformationPapyrusConstants.CUSTOM_APPEARENCE_ANNOTATION); - if (display == null) { - return getDefaultParserOptions(); - } - - // display != null - int displayOptions = Integer.parseInt(display.getDetails().get(VisualInformationPapyrusConstants.CUSTOM_APPEARANCE_MASK_VALUE)); - return new ParserOptions(displayOptions); - } - - @Override - public ParserOptions getDefaultParserOptions() { - - if (getNotationView() == null || getNotationView().getDiagram() == null) { - return ParserOptions.NONE; - } - - IPreferenceStore store = org.eclipse.papyrus.infra.gmfdiag.preferences.Activator.getDefault().getPreferenceStore(); - int displayOptions = store.getInt(LabelPreferenceHelper.getPreferenceConstant(getLabelPreferenceKey(), ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE)); - if (displayOptions == 0) { - return ParserOptions.NONE; - } - - return new ParserOptions(displayOptions); - } - - @Override - public IParser getParser() { - if (parser == null) { - parser = ParserService.getInstance().getParser(new DefaultParserHintAdapter(getNotationView().getDiagram(), resolveSemanticElement(), getNotationView().getType())); - } - return parser; - } - - protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), CellEditorLocatorUtil.getTextCellEditorLocator(this))); - } - return manager; - } - - /** - * @generated - */ - protected void setManager(DirectEditManager manager) { - this.manager = manager; - } - - /** - * @generated - */ - protected void performDirectEdit() { - getManager().show(); - } - - /** - * @generated - */ - protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); - } - } - - /** - * @generated - */ - private void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); - } else { - performDirectEdit(); - } - } - - /** - * @generated - */ - @Override - protected void performDirectEditRequest(Request request) { - - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { - directEditionMode = getDirectEditionType(); - } - switch (directEditionMode) { - case IDirectEdition.NO_DIRECT_EDITION: - // no direct edition mode => does nothing - return; - case IDirectEdition.EXTENDED_DIRECT_EDITOR: - updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { - performDefaultDirectEditorEdit(theRequest); - } else { - configuration.preEditAction(resolveSemanticElement()); - Dialog dialog = null; - if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this); - helper.showEditor(); - return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); - } else { - return; - } - final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { - TransactionalEditingDomain domain = getEditingDomain(); - RecordingCommand command = new RecordingCommand(domain, "Edit Label") { - - @Override - protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue()); - - } - }; - domain.getCommandStack().execute(command); - } - } - break; - case IDirectEdition.DEFAULT_DIRECT_EDITOR: - - // initialize the direct edit manager - try { - getEditingDomain().runExclusive(new Runnable() { - - @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); - performDirectEdit(initialChar.charValue()); - } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { - DirectEditRequest editRequest = (DirectEditRequest) theRequest; - performDirectEdit(editRequest.getLocation()); - } else { - performDirectEdit(); - } - } - } - }); - } catch (InterruptedException e) { - e.printStackTrace(); - } - break; - default: - break; - } - } - - @Override - protected void refreshVisuals() { - super.refreshVisuals(); - refreshLabel(); - refreshFont(); - refreshFontColor(); - refreshUnderline(); - refreshStrikeThrough(); - } - - protected void refreshLabel() { - - setLabelTextHelper(getFigure(), getLabelText()); - setLabelIconHelper(getFigure(), getLabelIcon()); - - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof TextSelectionEditPolicy) { - ((TextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof TextSelectionEditPolicy) { - ((TextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - protected void refreshUnderline() { - FontStyle style = (FontStyle) getView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); - } - } - - protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); - } - } - - @Override - protected void refreshFont() { - FontStyle style = (FontStyle) getView().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); - } - } - - @Override - protected void setFontColor(Color color) { - getFigure().setForegroundColor(color); - } - - @Override - protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { - EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ - } - } else { - super.addSemanticListeners(); - } - } - - @Override - protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { - removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ - } - } else { - super.removeSemanticListeners(); - } - } - - @Override - protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { - accessibleEP = new AccessibleGraphicalEditPart() { - - @Override - public void getName(AccessibleEvent e) { - e.result = getLabelTextHelper(getFigure()); - } - }; - } - return accessibleEP; - } - - private View getView() { - return (View) getModel(); - } - - public int getDirectEditionType() { - if (checkExtendedEditor()) { - initExtendedEditorConfiguration(); - return IDirectEdition.EXTENDED_DIRECT_EDITOR; - } - if (checkDefaultEdition()) { - return IDirectEdition.DEFAULT_DIRECT_EDITOR; - } - - // not a named element. no specific editor => do nothing - return IDirectEdition.NO_DIRECT_EDITION; - } - - protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { - return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName()); - } - return false; - } - - protected boolean checkDefaultEdition() { - return (getParser() != null); - } - - protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getInstance().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); - } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName()); - } - } - } - - protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getInstance().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") && languagePreferred != configuration.getLanguage()) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { - configuration = null; - } - } - - protected void performDefaultDirectEditorEdit(final Request theRequest) { - // initialize the direct edit manager - try { - getEditingDomain().runExclusive(new Runnable() { - - @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); - performDirectEdit(initialChar.charValue()); - } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { - DirectEditRequest editRequest = (DirectEditRequest) theRequest; - performDirectEdit(editRequest.getLocation()); - } else { - performDirectEdit(); - } - } - } - }); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - @Override - protected void addNotationalListeners() { - super.addNotationalListeners(); - addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$ - } - - @Override - protected void removeNotationalListeners() { - super.removeNotationalListeners(); - removeListenerFilter("PrimaryView"); //$NON-NLS-1$ - } - - @Override - protected void handleNotificationEvent(Notification event) { - Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); - setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { - refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { - refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { - refreshFont(); - } else if (NotationPackage.eINSTANCE.getView_SourceEdges().equals(feature)) { - refreshSourceConnections(); - } else if (NotationPackage.eINSTANCE.getView_TargetEdges().equals(feature)) { - refreshTargetConnections(); - } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { - refreshLabel(); - } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { - removeSemanticListeners(); - if (resolveSemanticElement() != null) { - addSemanticListeners(); - } - refreshLabel(); - } - } - } - super.handleNotificationEvent(event); - } - - @Override - protected IFigure createFigure() { - IFigure label = createFigurePrim(); - defaultText = getLabelTextHelper(label); - return label; - } - - protected IFigure createFigurePrim() { - return new FigureDescriptor(); - } - - static final Font THIS_FONT = new Font(Display.getCurrent(), "Arial", 10, SWT.NORMAL); - - public class FigureDescriptor extends PapyrusAnchorableWrappingLabel { - - public FigureDescriptor() { - this.setText(""); - this.setFont(THIS_FONT); - } - } - - private String getLabelPreferenceKey() { - String diagramType = getNotationView().getDiagram().getType(); - String labelType = getNotationView().getType(); - return diagramType + "_" + labelType; - } - - /* - * (non-Javadoc) - * Copied from @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart#getModelSourceConnections() - * - * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelSourceConnections() - */ - @Override - protected List getModelSourceConnections() { - return ViewUtil.getSourceConnectionsConnectingVisibleViews((View) getModel()); - } - - /* - * (non-Javadoc) - * Copied from @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart#getModelTargetConnections() - * - * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelTargetConnections() - */ - @Override - protected List getModelTargetConnections() { - return ViewUtil.getTargetConnectionsConnectingVisibleViews((View) getModel()); - } - - - /* - * (non-Javadoc) - * Copied from @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart#getSourceConnectionAnchor() - * - * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart) - */ - @Override - public ConnectionAnchor getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart connEditPart) { - final org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart connection = (org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart) connEditPart; - String t = ""; //$NON-NLS-1$ - try { - t = (String) getEditingDomain().runExclusive(new RunnableWithResult.Impl() { - - @Override - public void run() { - Anchor a = ((Edge) connection.getModel()).getSourceAnchor(); - if (a instanceof IdentityAnchor) { - setResult(((IdentityAnchor) a).getId()); - } else { - setResult(""); //$NON-NLS-1$ - } - } - }); - } catch (InterruptedException e) { - Trace.catching(DiagramUIPlugin.getInstance(), DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(), "getSourceConnectionAnchor", e); //$NON-NLS-1$ - Log.error(DiagramUIPlugin.getInstance(), DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING, "getSourceConnectionAnchor", e); //$NON-NLS-1$ - } - return getAnchorableFigure().getConnectionAnchor(t); - } - - /* - * (non-Javadoc) - * Copied from @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart#getAnchorableFigure() - * - * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.Request) - */ - protected IAnchorableFigure getAnchorableFigure() { - IFigure myFigure = getFigure(); - if (myFigure instanceof IAnchorableFigure) { - return (IAnchorableFigure) myFigure; - } - throw new RuntimeException("The figure of this element should be an IAnchorable Figure");// - } - - - /* - * (non-Javadoc) - * Copied from @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart#getSourceConnectionAnchor() - * - * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.Request) - */ - @Override - public ConnectionAnchor getSourceConnectionAnchor(Request request) { - if (request instanceof ReconnectRequest) { - if (((DropRequest) request).getLocation() == null) { - return getAnchorableFigure().getSourceConnectionAnchorAt(null); - } - Point pt = ((DropRequest) request).getLocation().getCopy(); - return getAnchorableFigure().getSourceConnectionAnchorAt(pt); - } else if (request instanceof DropRequest) { - return getAnchorableFigure().getSourceConnectionAnchorAt(((DropRequest) request).getLocation()); - } - return getAnchorableFigure().getSourceConnectionAnchorAt(null); - } - - - /* - * (non-Javadoc) - * Copied from @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart#getTargetConnectionAnchor() - * - * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.ConnectionEditPart) - */ - @Override - public ConnectionAnchor getTargetConnectionAnchor(org.eclipse.gef.ConnectionEditPart connEditPart) { - final org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart connection = (org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart) connEditPart; - - String t = ""; //$NON-NLS-1$ - try { - t = (String) getEditingDomain().runExclusive(new RunnableWithResult.Impl() { - - @Override - public void run() { - Anchor a = ((Edge) connection.getModel()).getTargetAnchor(); - if (a instanceof IdentityAnchor) { - setResult(((IdentityAnchor) a).getId()); - } else { - setResult(""); //$NON-NLS-1$ - } - } - }); - } catch (InterruptedException e) { - Trace.catching(DiagramUIPlugin.getInstance(), DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(), "getTargetConnectionAnchor", e); //$NON-NLS-1$ - Log.error(DiagramUIPlugin.getInstance(), DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING, "getTargetConnectionAnchor", e); //$NON-NLS-1$ - } - - return getAnchorableFigure().getConnectionAnchor(t); - } - - - - - /* - * (non-Javadoc) - * Copied from @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart#getTargetConnectionAnchor() - * - * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.Request) - */ - @Override - public ConnectionAnchor getTargetConnectionAnchor(Request request) { - if (request instanceof ReconnectRequest) { - if (((DropRequest) request).getLocation() == null) { - return getAnchorableFigure().getTargetConnectionAnchorAt(null); - } - Point pt = ((DropRequest) request).getLocation().getCopy(); - return getAnchorableFigure().getTargetConnectionAnchorAt(pt); - } else if (request instanceof DropRequest) { - return getAnchorableFigure().getTargetConnectionAnchorAt(((DropRequest) request).getLocation()); - } - return getAnchorableFigure().getTargetConnectionAnchorAt(null); - } - - - /* - * (non-Javadoc) - * Copied from @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart#mapConnectionAnchorToTerminal() - * - * @see org.eclipse.gmf.runtime.diagram.ui.editparts.INodeEditPart#mapConnectionAnchorToTerminal(org.eclipse.draw2d.ConnectionAnchor) - */ - @Override - final public String mapConnectionAnchorToTerminal(ConnectionAnchor c) { - return getAnchorableFigure().getConnectionAnchorTerminal(c); - } - - /* - * (non-Javadoc) - * Copied from @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart#mapTerminalToConnectionAnchor() - * - * @see org.eclipse.gmf.runtime.diagram.ui.editparts.INodeEditPart#mapTerminalToConnectionAnchor(java.lang.String) - */ - @Override - final public ConnectionAnchor mapTerminalToConnectionAnchor(String terminal) { - return getAnchorableFigure().getConnectionAnchor(terminal); - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.gmf.runtime.diagram.ui.editparts.INotableEditPart#canAttachNote() - * Copied from @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart#canAttachNote() - */ - @Override - public boolean canAttachNote() { - return true; - } - - - -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementEditPart.java deleted file mode 100644 index 2a8cb2f6702..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementEditPart.java +++ /dev/null @@ -1,191 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.editpolicies.LayoutEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; -import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout; -import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities; -import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure; -import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper; -import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter; -import org.eclipse.papyrus.sysml.diagram.common.Activator; -import org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart; -import org.eclipse.papyrus.uml.diagram.common.figure.node.ClassifierFigure; -import org.eclipse.papyrus.uml.diagram.common.figure.node.NodeNamedElementFigure; -import org.eclipse.papyrus.uml.diagram.common.helper.BasicClassifierCompartmentLayoutHelper; -import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper; -import org.eclipse.swt.graphics.Color; - -/** - * Abstract non-diagram specific edit part for nodes. - * This class is adapted from edit parts generated by GMF Tooling. - */ -public abstract class AbstractElementEditPart extends NamedElementEditPart { - - protected IFigure contentPane; - - protected IFigure primaryShape; - - public AbstractElementEditPart(View view) { - super(view); - setCompartmentLayoutHelper(BasicClassifierCompartmentLayoutHelper.getInstances()); - } - - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy()); - } - - protected abstract LayoutEditPolicy createLayoutEditPolicy(); - - @Override - protected IFigure createNodeShape() { - return primaryShape = new ClassifierFigure(); - } - - @Override - public NodeNamedElementFigure getPrimaryShape() { - return (NodeNamedElementFigure) primaryShape; - } - - protected abstract boolean addFixedChild(EditPart childEditPart); - - protected abstract boolean removeFixedChild(EditPart childEditPart); - - @Override - protected void addChildVisual(EditPart childEditPart, int index) { - if (addFixedChild(childEditPart)) { - return; - } - super.addChildVisual(childEditPart, -1); - } - - @Override - protected void removeChildVisual(EditPart childEditPart) { - if (removeFixedChild(childEditPart)) { - return; - } - super.removeChildVisual(childEditPart); - } - - @Override - protected abstract IFigure getContentPaneFor(IGraphicalEditPart editPart); - - - @Override - protected NodeFigure createNodePlate() { - String prefElementId = getNotationView().getType(); - IPreferenceStore store = Activator.getInstance().getPreferenceStore(); - String preferenceConstantWitdh = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferencesConstantsHelper.WIDTH); - String preferenceConstantHeight = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferencesConstantsHelper.HEIGHT); - DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(store.getInt(preferenceConstantWitdh), store.getInt(preferenceConstantHeight)); - - return result; - } - - @Override - protected NodeFigure createMainFigure() { - return createMainFigureWithSVG(); - } - - @Override - protected IFigure setupContentPane(IFigure nodeShape) { - if (nodeShape.getLayoutManager() == null) { - ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); - layout.setSpacing(5); - nodeShape.setLayoutManager(layout); - } - return nodeShape; // use nodeShape itself as contentPane - } - - @Override - public IFigure getContentPane() { - if (contentPane != null) { - return contentPane; - } - return super.getContentPane(); - } - - @Override - protected void setForegroundColor(Color color) { - if (primaryShape != null) { - primaryShape.setForegroundColor(color); - } - } - - @Override - public abstract EditPart getPrimaryChildEditPart(); - - @Override - public EditPart getTargetEditPart(Request request) { - return super.getTargetEditPart(request); - } - - @Override - public Object getPreferredValue(EStructuralFeature feature) { - String prefKey = getNotationView().getType(); - - IPreferenceStore store = (IPreferenceStore) getDiagramPreferencesHint().getPreferenceStore(); - Object result = null; - - if (feature == NotationPackage.eINSTANCE.getLineStyle_LineColor() || feature == NotationPackage.eINSTANCE.getFontStyle_FontColor() || feature == NotationPackage.eINSTANCE.getFillStyle_FillColor()) { - - String prefColor = null; - if (feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()) { - prefColor = PreferencesConstantsHelper.getElementConstant(prefKey, PreferencesConstantsHelper.COLOR_LINE); - - } else if (feature == NotationPackage.eINSTANCE.getFontStyle_FontColor()) { - prefColor = PreferencesConstantsHelper.getElementConstant(prefKey, PreferencesConstantsHelper.COLOR_FONT); - - } else if (feature == NotationPackage.eINSTANCE.getFillStyle_FillColor()) { - prefColor = PreferencesConstantsHelper.getElementConstant(prefKey, PreferencesConstantsHelper.COLOR_FILL); - - } - result = FigureUtilities.RGBToInteger(PreferenceConverter.getColor(store, prefColor)); - - } else if (feature == NotationPackage.eINSTANCE.getFillStyle_Transparency() || feature == NotationPackage.eINSTANCE.getFillStyle_Gradient()) { - - String prefGradient = PreferencesConstantsHelper.getElementConstant(prefKey, PreferencesConstantsHelper.COLOR_GRADIENT); - GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(store.getString(prefGradient)); - if (feature == NotationPackage.eINSTANCE.getFillStyle_Transparency()) { - result = new Integer(gradientPreferenceConverter.getTransparency()); - - } else if (feature == NotationPackage.eINSTANCE.getFillStyle_Gradient()) { - result = gradientPreferenceConverter.getGradientData(); - - } - } - - if (result == null) { - result = getStructuralFeatureValue(feature); - } - return result; - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementLabelEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementLabelEditPart.java deleted file mode 100644 index 9269beb8406..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementLabelEditPart.java +++ /dev/null @@ -1,688 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.draw2d.ConnectionLocator; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EAnnotation; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.RunnableWithResult; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.AccessibleEditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.requests.DirectEditRequest; -import org.eclipse.gef.tools.DirectEditManager; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; -import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; -import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; -import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; -import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; -import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; -import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; -import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; -import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; -import org.eclipse.gmf.runtime.notation.FontStyle; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.jface.viewers.ICellEditorValidator; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.extensionpoints.editors.Activator; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog; -import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog; -import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper; -import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; -import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; -import org.eclipse.papyrus.gmf.diagram.common.edit.part.ITextAwareEditPart; -import org.eclipse.papyrus.gmf.diagram.common.edit.policy.DefaultSnapBackEditPolicy; -import org.eclipse.papyrus.gmf.diagram.common.edit.policy.LabelDefaultSemanticEditPolicy; -import org.eclipse.papyrus.gmf.diagram.common.edit.policy.LabelDirectEditPolicy; -import org.eclipse.papyrus.gmf.diagram.common.edit.policy.TextSelectionEditPolicy; -import org.eclipse.papyrus.gmf.diagram.common.locator.TextCellEditorLocator; -import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants; -import org.eclipse.papyrus.infra.gmfdiag.common.commands.SemanticAdapter; -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.preferences.PreferencesConstantsHelper; -import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; -import org.eclipse.papyrus.sysml.diagram.common.preferences.LabelPreferenceHelper; -import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; -import org.eclipse.papyrus.uml.diagram.common.edit.policy.MaskManagedLabelEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; -import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; -import org.eclipse.papyrus.uml.diagram.common.parser.DefaultParserHintAdapter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.accessibility.AccessibleEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.PlatformUI; - -/** - * Abstract non-diagram specific edit part for labels. - * This class is adapted from edit parts generated by GMF Tooling. - */ -public abstract class AbstractElementLabelEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, ILabelRoleProvider { - - private DirectEditManager manager; - - private IParser parser; - - private List<?> parserElements; - - protected String defaultText; - - /** - * direct edition mode (default, undefined, registered editor, etc.) - */ - protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR; - - /** - * configuration from a registered edit dialog - */ - protected IDirectEditorConfiguration configuration; - - /** Constructor */ - public AbstractElementLabelEditPart(View view) { - super(view); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new MaskManagedLabelEditPolicy()); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new TextSelectionEditPolicy()); - installEditPolicy(EditPolicyRoles.SNAP_FEEDBACK_ROLE, new DefaultSnapBackEditPolicy()); - installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new LabelDefaultSemanticEditPolicy()); - } - - /** - * {@inheritDoc} - */ - @Override - public int getKeyPoint() { - return ConnectionLocator.MIDDLE; - } - - protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); - } else { - return ((Label) figure).getText(); - } - } - - protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); - } else { - ((Label) figure).setText(text); - } - } - - protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); - } else { - return ((Label) figure).getIcon(); - } - } - - protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); - } else { - ((Label) figure).setIcon(icon); - } - } - - public void setLabel(WrappingLabel figure) { - unregisterVisuals(); - setFigure(figure); - defaultText = getLabelTextHelper(figure); - registerVisuals(); - refreshVisuals(); - } - - @Override - protected List<?> getModelChildren() { - return Collections.EMPTY_LIST; - } - - @Override - public IGraphicalEditPart getChildBySemanticHint(String semanticHint) { - return null; - } - - @Override - public EObject getParserElement() { - return resolveSemanticElement(); - } - - protected Image getLabelIcon() { - return null; - } - - protected String getLabelText() { - String text = null; - EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(new SemanticAdapter(parserElement, getNotationView()), getParserOptions().intValue()); - } - if (text == null || text.length() == 0) { - text = defaultText; - } - return text; - } - - @Override - public void setLabelText(String text) { - setLabelTextHelper(getFigure(), text); - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof TextSelectionEditPolicy) { - ((TextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof TextSelectionEditPolicy) { - ((TextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - @Override - public String getEditText() { - if (getParserElement() == null || getParser() == null) { - return ""; //$NON-NLS-1$ - } - return getParser().getEditString(new SemanticAdapter(getParserElement(), getNotationView()), getParserOptions().intValue()); - } - - protected boolean isEditable() { - return getParser() != null; - } - - @Override - public ICellEditorValidator getEditTextValidator() { - return new ICellEditorValidator() { - - @Override - public String isValid(final Object value) { - if (value instanceof String) { - final EObject element = getParserElement(); - final IParser parser = getParser(); - try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl<IParserEditStatus>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value)); - } - }); - return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); - } catch (InterruptedException ie) { - ie.printStackTrace(); - } - } - - // shouldn't get here - return null; - } - }; - } - - @Override - public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { - return null; - } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); - } - - @Override - public ParserOptions getParserOptions() { - - if (getNotationView() == null || getNotationView().getDiagram() == null) { - return ParserOptions.NONE; - } - - EAnnotation display = getNotationView().getEAnnotation(VisualInformationPapyrusConstants.CUSTOM_APPEARENCE_ANNOTATION); - if (display == null) { - return getDefaultParserOptions(); - } - - // display != null - int displayOptions = Integer.parseInt(display.getDetails().get(VisualInformationPapyrusConstants.CUSTOM_APPEARANCE_MASK_VALUE)); - return new ParserOptions(displayOptions); - } - - @Override - public ParserOptions getDefaultParserOptions() { - - if (getNotationView() == null || getNotationView().getDiagram() == null) { - return ParserOptions.NONE; - } - - IPreferenceStore store = org.eclipse.papyrus.infra.gmfdiag.preferences.Activator.getDefault().getPreferenceStore(); - int displayOptions = store.getInt(LabelPreferenceHelper.getPreferenceConstant(getLabelPreferenceKey(), ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE)); - if (displayOptions == 0) { - return ParserOptions.NONE; - } - - return new ParserOptions(displayOptions); - } - - @Override - public IParser getParser() { - if (parser == null) { - parser = ParserService.getInstance().getParser(new DefaultParserHintAdapter(getNotationView().getDiagram(), getParserElement(), getNotationView().getType())); - } - return parser; - } - - protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), new TextCellEditorLocator((WrappingLabel) this.getFigure()))); - } - return manager; - } - - protected void setManager(DirectEditManager manager) { - this.manager = manager; - } - - protected void performDirectEdit() { - getManager().show(); - } - - protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); - } - } - - private void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); - } else { - performDirectEdit(); - } - } - - @Override - protected void performDirectEditRequest(Request request) { - - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { - directEditionMode = getDirectEditionType(); - } - switch (directEditionMode) { - case IDirectEdition.NO_DIRECT_EDITION: - // no direct edition mode => does nothing - return; - case IDirectEdition.EXTENDED_DIRECT_EDITOR: - updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { - performDefaultDirectEditorEdit(theRequest); - } else { - configuration.preEditAction(resolveSemanticElement()); - Dialog dialog = null; - if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this); - helper.showEditor(); - return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); - } else { - return; - } - final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { - TransactionalEditingDomain domain = getEditingDomain(); - RecordingCommand command = new RecordingCommand(domain, "Edit Label") { //$NON-NLS-1$ - - @Override - protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue()); - - } - }; - domain.getCommandStack().execute(command); - } - } - break; - case IDirectEdition.DEFAULT_DIRECT_EDITOR: - - // initialize the direct edit manager - try { - getEditingDomain().runExclusive(new Runnable() { - - @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); - performDirectEdit(initialChar.charValue()); - } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { - DirectEditRequest editRequest = (DirectEditRequest) theRequest; - performDirectEdit(editRequest.getLocation()); - } else { - performDirectEdit(); - } - } - } - }); - } catch (InterruptedException e) { - e.printStackTrace(); - } - break; - default: - break; - } - } - - @Override - protected void refreshVisuals() { - super.refreshVisuals(); - refreshLabel(); - refreshFont(); - refreshFontColor(); - refreshUnderline(); - refreshStrikeThrough(); - } - - protected void refreshLabel() { - - setLabelTextHelper(getFigure(), getLabelText()); - setLabelIconHelper(getFigure(), getLabelIcon()); - - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof TextSelectionEditPolicy) { - ((TextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof TextSelectionEditPolicy) { - ((TextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); - } - } - - protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); - } - } - - @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)); - setFont(fontData); - } - } - - @Override - protected void setFontColor(Color color) { - getFigure().setForegroundColor(color); - } - - @Override - protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { - EObject element = getParserElement(); - 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(); - } - } - - @Override - protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { - removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ - } - } else { - super.removeSemanticListeners(); - } - } - - @Override - protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { - accessibleEP = new AccessibleGraphicalEditPart() { - - @Override - public void getName(AccessibleEvent e) { - e.result = getLabelTextHelper(getFigure()); - } - }; - } - return accessibleEP; - } - - private View getFontStyleOwnerView() { - return getPrimaryView(); - } - - /** - * Returns the kind of associated editor for direct edition. - * - * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition - */ - public int getDirectEditionType() { - if (checkExtendedEditor()) { - initExtendedEditorConfiguration(); - return IDirectEdition.EXTENDED_DIRECT_EDITOR; - } - if (checkDefaultEdition()) { - return IDirectEdition.DEFAULT_DIRECT_EDITOR; - } - - // not a named element. no specific editor => do nothing - return IDirectEdition.NO_DIRECT_EDITION; - } - - /** - * Checks if an extended editor is present. - * - * @return <code>true</code> if an extended editor is present. - */ - protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { - return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName()); - } - return false; - } - - /** - * Checks if a default direct edition is available - * - * @return <code>true</code> if a default direct edition is available - */ - protected boolean checkDefaultEdition() { - return (getParser() != null); - } - - /** - * Initializes the extended editor configuration - */ - 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("")) { //$NON-NLS-1$ - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); - } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName()); - } - } - } - - /** - * Updates the preference configuration - */ - protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") && languagePreferred != configuration.getLanguage()) { //$NON-NLS-1$ - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { - configuration = null; - } - } - - /** - * Performs the direct edit usually used by GMF editors. - * - * @param theRequest - * the direct edit request that starts the direct edit system - */ - protected void performDefaultDirectEditorEdit(final Request theRequest) { - // initialize the direct edit manager - try { - getEditingDomain().runExclusive(new Runnable() { - - @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); - performDirectEdit(initialChar.charValue()); - } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { - DirectEditRequest editRequest = (DirectEditRequest) theRequest; - performDirectEdit(editRequest.getLocation()); - } else { - performDirectEdit(); - } - } - } - }); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - @Override - protected void handleNotificationEvent(Notification event) { - Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); - setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { - refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { - refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { - refreshFont(); - } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { - refreshLabel(); - } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { - removeSemanticListeners(); - if (resolveSemanticElement() != null) { - addSemanticListeners(); - } - // Bug 457470 : The label refreshment is not done if the following method is not called - // This call was comment to fix a text alignment issue (Bug 440226) - refreshLabel(); //Comment to fix text alignment issue - } - } - } - - super.handleNotificationEvent(event); - } - - @Override - protected IFigure createFigure() { - // Parent should assign one using setLabel() method - return null; - } - - protected void addSnapBackLocation() { - // Use default view position as snap back position - IPreferenceStore store = org.eclipse.papyrus.infra.gmfdiag.preferences.Activator.getDefault().getPreferenceStore(); - - String xKey = PreferencesConstantsHelper.getElementConstant(getLabelPreferenceKey(), PreferencesConstantsHelper.LOCATION_X); - String yKey = PreferencesConstantsHelper.getElementConstant(getLabelPreferenceKey(), PreferencesConstantsHelper.LOCATION_Y); - - Point snapBackPosition = new Point(store.getInt(xKey), store.getInt(yKey)); - - registerSnapBackPosition(getLabelPreferenceKey(), snapBackPosition); - } - - private String getLabelPreferenceKey() { - String diagramType = getNotationView().getDiagram().getType(); - String parentType = ViewUtil.getViewContainer(getNotationView()).getType(); - String labelType = getNotationView().getType(); - return diagramType + "_" + parentType + "-" + labelType; //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * {@inheritDoc} - */ - @Override - public abstract String getLabelRole(); - - /** - * {@inheritDoc} - */ - @Override - public abstract String getIconPathRole(); -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementLinkEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementLinkEditPart.java deleted file mode 100644 index 126bb18e566..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementLinkEditPart.java +++ /dev/null @@ -1,246 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.PolygonDecoration; -import org.eclipse.draw2d.PolylineDecoration; -import org.eclipse.draw2d.RotatableDecoration; -import org.eclipse.draw2d.geometry.PointList; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.figure.EdgeDecorationType; - -/** - * Abstract non-diagram specific edit part for links. - * This class is adapted from edit parts generated by GMF Tooling. - */ -public abstract class AbstractElementLinkEditPart extends UMLConnectionNodeEditPart { - - /** - * Constructor. - */ - public AbstractElementLinkEditPart(View view) { - super(view); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); - } - - /** - * Add fixed child edit part. - */ - protected boolean addFixedChild(EditPart childEditPart) { - if (childEditPart instanceof AppliedStereotypeLinkLabelEditPart) { - ((AppliedStereotypeLinkLabelEditPart) childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel()); - return true; - } - return false; - } - - /** - * Remove fixed child edit part. - */ - protected boolean removeFixedChild(EditPart childEditPart) { - if (childEditPart instanceof AppliedStereotypeLinkLabelEditPart) { - return true; - } - return false; - } - - /** - * {@inheritDoc} - */ - @Override - protected void addChildVisual(EditPart childEditPart, int index) { - if (addFixedChild(childEditPart)) { - return; - } - super.addChildVisual(childEditPart, -1); - } - - /** - * {@inheritDoc} - */ - @Override - protected void removeChildVisual(EditPart childEditPart) { - if (removeFixedChild(childEditPart)) { - return; - } - super.removeChildVisual(childEditPart); - } - - /** - * {@inheritDoc} - */ - @Override - protected void handleNotificationEvent(Notification event) { - super.handleNotificationEvent(event); - - // Update the figure when the line width changes - Object feature = event.getFeature(); - if ((getModel() != null) && (getModel() == event.getNotifier())) { - - if (NotationPackage.eINSTANCE.getLineStyle_LineWidth().equals(feature)) { - refreshLineWidth(); - refreshArrowSource(); - refreshArrowTarget(); - } else if (NotationPackage.eINSTANCE.getLineTypeStyle_LineType().equals(feature)) { - refreshLineType(); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - protected void refreshVisuals() { - super.refreshVisuals(); - refreshLineType(); - refreshLineWidth(); - refreshArrowSource(); - refreshArrowTarget(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void setLineWidth(int width) { - if (width < 0) { - width = 1; - } - getPrimaryShape().setLineWidth(width); - } - - /** - * {@inheritDoc} - */ - @Override - protected void setLineType(int style) { - getPrimaryShape().setLineStyle(style); - } - - /** - * {@inheritDoc} - */ - @Override - protected void setArrowSource(RotatableDecoration arrowDecoration) { - getPrimaryShape().setSourceDecoration(arrowDecoration); - } - - /** - * {@inheritDoc} - */ - @Override - protected void setArrowTarget(RotatableDecoration arrowDecoration) { - getPrimaryShape().setTargetDecoration(arrowDecoration); - } - - /** - * <pre> - * {@inheritDoc} - * - * This method override parent implementation to add a new set of - * predefined decoration type. - * - * The arrowType available constants are given in {@link EdgeDecorationType}. - * </pre> - */ - @Override - protected RotatableDecoration getArrowDecoration(int arrowType) { - RotatableDecoration decoration = null; - int width = getLineWidth(); - if (width < 0) { - width = 1; - } - if (arrowType == EdgeDecorationType.OPEN_ARROW) { - IMapMode mm = getMapMode(); - decoration = new PolylineDecoration(); - ((PolylineDecoration) decoration).setScale(mm.DPtoLP(15 + width), mm.DPtoLP(5 + width)); - ((PolylineDecoration) decoration).setTemplate(PolylineDecoration.TRIANGLE_TIP); - ((PolylineDecoration) decoration).setLineWidth(mm.DPtoLP(width)); - - } else if (arrowType == EdgeDecorationType.SOLID_ARROW_FILLED) { - IMapMode mm = getMapMode(); - decoration = new PolygonDecoration(); - ((PolygonDecoration) decoration).setScale(mm.DPtoLP(15 + width), mm.DPtoLP(5 + width)); - ((PolygonDecoration) decoration).setTemplate(PolygonDecoration.TRIANGLE_TIP); - ((PolygonDecoration) decoration).setLineWidth(mm.DPtoLP(width)); - ((PolygonDecoration) decoration).setFill(true); - - } else if (arrowType == EdgeDecorationType.SOLID_ARROW_EMPTY) { - IMapMode mm = getMapMode(); - decoration = new PolygonDecoration(); - ((PolygonDecoration) decoration).setScale(mm.DPtoLP(15 + width), mm.DPtoLP(5 + width)); - ((PolygonDecoration) decoration).setTemplate(PolygonDecoration.TRIANGLE_TIP); - ((PolygonDecoration) decoration).setLineWidth(mm.DPtoLP(width)); - - // Not really empty... filled with white color. - ((PolygonDecoration) decoration).setFill(true); - ((PolygonDecoration) decoration).setBackgroundColor(ColorConstants.white); - - } else if (arrowType == EdgeDecorationType.SOLID_DIAMOND_FILLED) { - IMapMode mm = getMapMode(); - decoration = new PolygonDecoration(); - ((PolygonDecoration) decoration).setScale(mm.DPtoLP(12 + width), mm.DPtoLP(6 + width)); - - PointList diamondPointList = new PointList(); - diamondPointList.addPoint(0, 0); - diamondPointList.addPoint(-1, 1); - diamondPointList.addPoint(-2, 0); - diamondPointList.addPoint(-1, -1); - - ((PolygonDecoration) decoration).setTemplate(diamondPointList); - ((PolygonDecoration) decoration).setLineWidth(mm.DPtoLP(width)); - ((PolygonDecoration) decoration).setFill(true); - - } else if (arrowType == EdgeDecorationType.SOLID_DIAMOND_EMPTY) { - IMapMode mm = getMapMode(); - decoration = new PolygonDecoration(); - ((PolygonDecoration) decoration).setScale(mm.DPtoLP(12 + width), mm.DPtoLP(6 + width)); - - PointList diamondPointList = new PointList(); - diamondPointList.addPoint(0, 0); - diamondPointList.addPoint(-1, 1); - diamondPointList.addPoint(-2, 0); - diamondPointList.addPoint(-1, -1); - - ((PolygonDecoration) decoration).setTemplate(diamondPointList); - ((PolygonDecoration) decoration).setLineWidth(mm.DPtoLP(width)); - - // Not really empty... filled with white color. - ((PolygonDecoration) decoration).setFill(true); - ((PolygonDecoration) decoration).setBackgroundColor(ColorConstants.white); - } - - return decoration; - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementNodeLabelEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementNodeLabelEditPart.java deleted file mode 100644 index 08ca11eb035..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractElementNodeLabelEditPart.java +++ /dev/null @@ -1,744 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EAnnotation; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.RunnableWithResult; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.AccessibleEditPart; -import org.eclipse.gef.DragTracker; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.requests.DirectEditRequest; -import org.eclipse.gef.requests.SelectionRequest; -import org.eclipse.gef.tools.DirectEditManager; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; -import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; -import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.TopGraphicEditPart; -import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; -import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; -import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; -import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; -import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; -import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; -import org.eclipse.gmf.runtime.gef.ui.internal.tools.DelegatingDragEditPartsTracker; -import org.eclipse.gmf.runtime.notation.FontStyle; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.jface.viewers.ICellEditorValidator; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.extensionpoints.editors.Activator; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog; -import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog; -import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper; -import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; -import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; -import org.eclipse.papyrus.gmf.diagram.common.edit.part.ITextAwareEditPart; -import org.eclipse.papyrus.gmf.diagram.common.edit.policy.LabelDirectEditPolicy; -import org.eclipse.papyrus.gmf.diagram.common.edit.policy.TextNonResizableEditPolicy; -import org.eclipse.papyrus.gmf.diagram.common.edit.policy.TextSelectionEditPolicy; -import org.eclipse.papyrus.gmf.diagram.common.locator.TextCellEditorLocator; -import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper; -import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants; -import org.eclipse.papyrus.infra.gmfdiag.common.commands.SemanticAdapter; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; -import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; -import org.eclipse.papyrus.sysml.diagram.common.preferences.LabelPreferenceHelper; -import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; -import org.eclipse.papyrus.uml.diagram.common.edit.policy.MaskManagedLabelEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; -import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; -import org.eclipse.papyrus.uml.diagram.common.parser.DefaultParserHintAdapter; -import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.accessibility.AccessibleEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.PlatformUI; - -/** - * Abstract non-diagram specific edit part for labels. - * This class is adapted from edit parts generated by GMF Tooling. - */ -public abstract class AbstractElementNodeLabelEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, ILabelRoleProvider { - - private DirectEditManager manager; - - private IParser parser; - - private List<?> parserElements; - - protected String defaultText; - - /** - * direct edition mode (default, undefined, registered editor, etc.) - */ - protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR; - - /** - * configuration from a registered edit dialog - */ - protected IDirectEditorConfiguration configuration; - - /** Constructor */ - public AbstractElementNodeLabelEditPart(View view) { - super(view); - } - - /** - * Compartment-like isSelectable implementation. - * - * By default, the edit parts get selectable only if - * the compartment's top level container matches the top level - * container of the editpart that currently has the keyboard focus - * i.e: you need to select the shape first before selecting a this label. - * - * @see CompartmentEditPart#isSelectable() - */ - @Override - public boolean isSelectable() { - if (super.isSelectable()) { - EditPart focusPart = getViewer().getFocusEditPart(); - if (focusPart instanceof IGraphicalEditPart) { - TopGraphicEditPart focusTopEP = ((IGraphicalEditPart) focusPart).getTopGraphicEditPart(); - TopGraphicEditPart myTopEP = getTopGraphicEditPart(); - if (myTopEP == focusTopEP) { - // check if the selection contains only editparts belonging to - // the same top level editpart - Iterator<?> selection = getViewer().getSelectedEditParts().iterator(); - while (selection.hasNext()) { - Object editPart = selection.next(); - if (editPart instanceof IGraphicalEditPart && (((IGraphicalEditPart) editPart).getTopGraphicEditPart() != myTopEP)) { - return false; - } - } - return true; - } - } - } - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public DragTracker getDragTracker(Request request) { - if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) { - return null; - } - // Delegate to the main edit part. - return new DelegatingDragEditPartsTracker(this, getTopGraphicEditPart()); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new MaskManagedLabelEditPolicy()); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new TextNonResizableEditPolicy()); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); - } - - protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); - } else { - return ((Label) figure).getText(); - } - } - - protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); - } else { - ((Label) figure).setText(text); - } - } - - protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); - } else { - return ((Label) figure).getIcon(); - } - } - - protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); - } else { - ((Label) figure).setIcon(icon); - } - } - - public void setLabel(WrappingLabel figure) { - unregisterVisuals(); - setFigure(figure); - defaultText = getLabelTextHelper(figure); - registerVisuals(); - refreshVisuals(); - } - - @Override - protected List<?> getModelChildren() { - return Collections.emptyList(); - } - - @Override - public IGraphicalEditPart getChildBySemanticHint(String semanticHint) { - return null; - } - - @Override - public EObject getParserElement() { - return resolveSemanticElement(); - } - - protected Image getLabelIcon() { - EObject parserElement = getParserElement(); - if (parserElement == null) { - return null; - } - - List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer()); - for (View view : views) { - if (AppearanceHelper.showElementIcon(view)) { - return org.eclipse.papyrus.sysml.diagram.common.Activator.getInstance().getLabelProvider().getImage(parserElement); - } - } - return null; - - } - - protected String getLabelText() { - String text = null; - EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(new SemanticAdapter(parserElement, getNotationView()), getParserOptions().intValue()); - } - if (text == null || text.length() == 0) { - text = defaultText; - } - return text; - } - - @Override - public void setLabelText(String text) { - setLabelTextHelper(getFigure(), text); - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof TextSelectionEditPolicy) { - ((TextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof TextSelectionEditPolicy) { - ((TextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - @Override - public String getEditText() { - if (getParserElement() == null || getParser() == null) { - return ""; //$NON-NLS-1$ - } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); - } - - protected boolean isEditable() { - return getParser() != null; - } - - @Override - public ICellEditorValidator getEditTextValidator() { - return new ICellEditorValidator() { - - @Override - public String isValid(final Object value) { - if (value instanceof String) { - final EObject element = getParserElement(); - final IParser parser = getParser(); - try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl<IParserEditStatus>() { - - @Override - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value)); - } - }); - return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); - } catch (InterruptedException ie) { - ie.printStackTrace(); - } - } - - // shouldn't get here - return null; - } - }; - } - - @Override - public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { - return null; - } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); - } - - @Override - public ParserOptions getParserOptions() { - - if (getNotationView() == null || getNotationView().getDiagram() == null) { - return ParserOptions.NONE; - } - - EAnnotation display = getNotationView().getEAnnotation(VisualInformationPapyrusConstants.CUSTOM_APPEARENCE_ANNOTATION); - if (display == null) { - return getDefaultParserOptions(); - } - - // display != null - int displayOptions = Integer.parseInt(display.getDetails().get(VisualInformationPapyrusConstants.CUSTOM_APPEARANCE_MASK_VALUE)); - return new ParserOptions(displayOptions); - } - - @Override - public ParserOptions getDefaultParserOptions() { - - if (getNotationView() == null || getNotationView().getDiagram() == null) { - return ParserOptions.NONE; - } - - IPreferenceStore store = org.eclipse.papyrus.infra.gmfdiag.preferences.Activator.getDefault().getPreferenceStore(); - int displayOptions = store.getInt(LabelPreferenceHelper.getPreferenceConstant(getLabelPreferenceKey(), ILabelPreferenceConstants.LABEL_DISPLAY_PREFERENCE)); - if (displayOptions == 0) { - return ParserOptions.NONE; - } - - return new ParserOptions(displayOptions); - } - - @Override - public IParser getParser() { - if (parser == null) { - parser = ParserService.getInstance().getParser(new DefaultParserHintAdapter(getNotationView().getDiagram(), getParserElement(), getNotationView().getType())); - } - return parser; - } - - protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), new TextCellEditorLocator((WrappingLabel) this.getFigure()))); - } - return manager; - } - - protected void setManager(DirectEditManager manager) { - this.manager = manager; - } - - protected void performDirectEdit() { - getManager().show(); - } - - protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); - } - } - - private void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); - } else { - performDirectEdit(); - } - } - - @Override - protected void performDirectEditRequest(Request request) { - - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { - directEditionMode = getDirectEditionType(); - } - switch (directEditionMode) { - case IDirectEdition.NO_DIRECT_EDITION: - // no direct edition mode => does nothing - return; - case IDirectEdition.EXTENDED_DIRECT_EDITOR: - updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { - performDefaultDirectEditorEdit(theRequest); - } else { - configuration.preEditAction(resolveSemanticElement()); - Dialog dialog = null; - if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this); - helper.showEditor(); - return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); - } else { - return; - } - final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { - TransactionalEditingDomain domain = getEditingDomain(); - RecordingCommand command = new RecordingCommand(domain, "Edit Label") { - - @Override - protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue()); - - } - }; - domain.getCommandStack().execute(command); - } - } - break; - case IDirectEdition.DEFAULT_DIRECT_EDITOR: - - // initialize the direct edit manager - try { - getEditingDomain().runExclusive(new Runnable() { - - @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); - performDirectEdit(initialChar.charValue()); - } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { - DirectEditRequest editRequest = (DirectEditRequest) theRequest; - performDirectEdit(editRequest.getLocation()); - } else { - performDirectEdit(); - } - } - } - }); - } catch (InterruptedException e) { - e.printStackTrace(); - } - break; - default: - break; - } - } - - @Override - protected void refreshVisuals() { - super.refreshVisuals(); - refreshLabel(); - refreshFont(); - refreshFontColor(); - refreshUnderline(); - refreshStrikeThrough(); - } - - protected void refreshLabel() { - - setLabelTextHelper(getFigure(), getLabelText()); - setLabelIconHelper(getFigure(), getLabelIcon()); - - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof TextSelectionEditPolicy) { - ((TextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof TextSelectionEditPolicy) { - ((TextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); - } - } - - protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); - } - } - - @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)); - setFont(fontData); - } - } - - @Override - protected void setFontColor(Color color) { - getFigure().setForegroundColor(color); - } - - @Override - protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { - EObject element = getParserElement(); - 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(); - } - } - - @Override - protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { - removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ - } - } else { - super.removeSemanticListeners(); - } - } - - @Override - protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { - accessibleEP = new AccessibleGraphicalEditPart() { - - @Override - public void getName(AccessibleEvent e) { - e.result = getLabelTextHelper(getFigure()); - } - }; - } - return accessibleEP; - } - - private View getFontStyleOwnerView() { - return getPrimaryView(); - } - - /** - * Returns the kind of associated editor for direct edition. - * - * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition - */ - public int getDirectEditionType() { - if (checkExtendedEditor()) { - initExtendedEditorConfiguration(); - return IDirectEdition.EXTENDED_DIRECT_EDITOR; - } - if (checkDefaultEdition()) { - return IDirectEdition.DEFAULT_DIRECT_EDITOR; - } - - // not a named element. no specific editor => do nothing - return IDirectEdition.NO_DIRECT_EDITION; - } - - /** - * Checks if an extended editor is present. - * - * @return <code>true</code> if an extended editor is present. - */ - protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { - return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName()); - } - return false; - } - - /** - * Checks if a default direct edition is available - * - * @return <code>true</code> if a default direct edition is available - */ - protected boolean checkDefaultEdition() { - return (getParser() != null); - } - - /** - * Initializes the extended editor configuration - */ - protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); - } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName()); - } - } - } - - /** - * Updates the preference configuration - */ - protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") && languagePreferred != configuration.getLanguage()) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { - configuration = null; - } - } - - /** - * Performs the direct edit usually used by GMF editors. - * - * @param theRequest - * the direct edit request that starts the direct edit system - */ - protected void performDefaultDirectEditorEdit(final Request theRequest) { - // initialize the direct edit manager - try { - getEditingDomain().runExclusive(new Runnable() { - - @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); - performDirectEdit(initialChar.charValue()); - } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { - DirectEditRequest editRequest = (DirectEditRequest) theRequest; - performDirectEdit(editRequest.getLocation()); - } else { - performDirectEdit(); - } - } - } - }); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - @Override - protected void handleNotificationEvent(Notification event) { - Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); - setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { - refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { - refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { - refreshFont(); - } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { - refreshLabel(); - } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { - removeSemanticListeners(); - if (resolveSemanticElement() != null) { - addSemanticListeners(); - } - refreshLabel(); - } - } - } - - if (event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation) event.getNewValue()).getSource())) { - refreshLabel(); - } - - super.handleNotificationEvent(event); - } - - @Override - protected void addNotationalListeners() { - super.addNotationalListeners(); - addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$ - } - - @Override - protected void removeNotationalListeners() { - super.removeNotationalListeners(); - removeListenerFilter("PrimaryView"); //$NON-NLS-1$ - } - - @Override - protected IFigure createFigure() { - // Parent should assign one using setLabel() method - return null; - } - - public String getLabelPreferenceKey() { - String diagramType = getNotationView().getDiagram().getType(); - String parentType = ViewUtil.getViewContainer(getNotationView()).getType(); - String labelType = getNotationView().getType(); - return diagramType + "_" + parentType + "-" + labelType; - } - - /** - * {@inheritDoc} - */ - @Override - public abstract String getLabelRole(); - - /** - * {@inheritDoc} - */ - @Override - public abstract String getIconPathRole(); -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractShapeCompartmentEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractShapeCompartmentEditPart.java deleted file mode 100644 index 8da57dd5969..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AbstractShapeCompartmentEditPart.java +++ /dev/null @@ -1,137 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.gef.DragTracker; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.gef.requests.SelectionRequest; -import org.eclipse.gef.tools.DeselectAllTracker; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableCompartmentEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.internal.tools.RubberbandDragTracker; -import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.linklf.LinkLFShapeCompartmentEditPart; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCompartmentSemanticEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.CustomContainerEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.PasteEditPolicy; - -/** - * Abstract non-diagram specific edit part for shape compartment. - * This class is adapted from edit parts generated by GMF Tooling. - */ -public abstract class AbstractShapeCompartmentEditPart extends LinkLFShapeCompartmentEditPart { - - public AbstractShapeCompartmentEditPart(View view) { - super(view); - } - - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultCompartmentSemanticEditPolicy()); - installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy()); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableCompartmentEditPolicy()); - installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new CustomContainerEditPolicy()); - } - - @Override - protected void setRatio(Double ratio) { - if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { - super.setRatio(ratio); - } - } - - @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)) { - refreshBounds(); - } - super.handleNotificationEvent(notification); - } - - protected void refreshBounds() { - 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(); - Point loc = new Point(x, y); - ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); - } - - @Override - protected void refreshVisuals() { - super.refreshVisuals(); - refreshBounds(); - } - - /** - * Install a drag tracker supporting double click (necessary for navigation). - */ - @Override - public DragTracker getDragTracker(Request req) { - if (!supportsDragSelection()) { - return super.getDragTracker(req); - } - - if (req instanceof SelectionRequest - && ((SelectionRequest) req).getLastButtonPressed() == 3) { - return new DeselectAllTracker(this) { - - @Override - protected boolean handleButtonDown(int button) { - getCurrentViewer().select(AbstractShapeCompartmentEditPart.this); - return true; - } - }; - } - - return new RubberbandDragTracker() { - - /* - * this method has been respecified in order to allow double click - * on the compartment. - * hence it allows the navigation by double click - */ - @Override - protected boolean handleDoubleClick(int button) { - SelectionRequest request = new SelectionRequest(); - request.setLocation(getLocation()); - request.setType(RequestConstants.REQ_OPEN); - performRequest(request); - return true; - } - - @Override - protected void handleFinished() { - if (getViewer().getSelectedEditParts().isEmpty()) { - getViewer().select(AbstractShapeCompartmentEditPart.this); - } - } - - }; - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AppliedStereotypeAffixedLabelEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AppliedStereotypeAffixedLabelEditPart.java deleted file mode 100644 index fca51315244..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AppliedStereotypeAffixedLabelEditPart.java +++ /dev/null @@ -1,116 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; -import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeExternalNodeEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; -import org.eclipse.papyrus.uml.diagram.common.figure.node.AppliedStereotypeWrappingLabelFigure; - -/** - * This class implements an affixed label edit part for applied stereotype representation on border items. - */ -public class AppliedStereotypeAffixedLabelEditPart extends AbstractElementLabelEditPart implements IBorderItemEditPart, IPapyrusEditPart { - - /** Constructor */ - public AppliedStereotypeAffixedLabelEditPart(View view) { - super(view); - addSnapBackLocation(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeEditPolicy()); - } - - @Override - public IBorderItemLocator getBorderItemLocator() { - IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { - Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return constraint instanceof IBorderItemLocator ? (IBorderItemLocator) constraint : null; - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - protected IFigure createFigure() { - IFigure label = createFigurePrim(); - defaultText = getLabelTextHelper(label); - return label; - } - - protected IFigure createFigurePrim() { - return new AppliedStereotypeWrappingLabelFigure(); - } - - @Override - public IFigure getPrimaryShape() { - return getFigure(); - } - - /** - * {@inheritDoc} - */ - @Override - protected boolean isEditable() { - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public ParserOptions getParserOptions() { - return ParserOptions.NONE; - } - - /** - * Forbid direct edition on this label. - */ - @Override - public int getDirectEditionType() { - // The label is read-only (defined in GMFGen model) - return IDirectEdition.NO_DIRECT_EDITION; - } - - /** - * {@inheritDoc} - */ - @Override - public String getLabelRole() { - return "Stereotype";//$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - public String getIconPathRole() { - return "";//$NON-NLS-1$ - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AppliedStereotypeLinkLabelEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AppliedStereotypeLinkLabelEditPart.java deleted file mode 100644 index ed7894be2d6..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AppliedStereotypeLinkLabelEditPart.java +++ /dev/null @@ -1,83 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; - -/** - * Abstract non-diagram specific edit part for link label representing applied stereotypes. - * This class is adapted from edit parts generated by GMF Tooling. - */ -public class AppliedStereotypeLinkLabelEditPart extends AbstractElementLabelEditPart { - - /** Constructor */ - public AppliedStereotypeLinkLabelEditPart(View view) { - super(view); - addSnapBackLocation(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusLinkLabelDragPolicy()); - } - - /** - * {@inheritDoc} - */ - @Override - protected boolean isEditable() { - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public ParserOptions getParserOptions() { - return ParserOptions.NONE; - } - - /** - * Forbid direct edition on this label. - */ - @Override - public int getDirectEditionType() { - // The label is read-only (defined in GMFGen model) - return IDirectEdition.NO_DIRECT_EDITION; - } - - /** - * {@inheritDoc} - */ - @Override - public String getLabelRole() { - return "Stereotype";//$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - public String getIconPathRole() { - return "";//$NON-NLS-1$ - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AssociationLinkLabelSourceMultiplicityEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AssociationLinkLabelSourceMultiplicityEditPart.java deleted file mode 100644 index 9475db9dc26..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AssociationLinkLabelSourceMultiplicityEditPart.java +++ /dev/null @@ -1,97 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.draw2d.ConnectionLocator; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; -import org.eclipse.papyrus.uml.diagram.common.utils.AssociationViewUtils; -import org.eclipse.uml2.uml.Association; - -/** - * Edit Part for link label showing {@link Association} source multiplicity. - */ -public class AssociationLinkLabelSourceMultiplicityEditPart extends AbstractElementLabelEditPart { - - /** Constructor */ - public AssociationLinkLabelSourceMultiplicityEditPart(View view) { - super(view); - addSnapBackLocation(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusLinkLabelDragPolicy()); - } - - /** - * {@inheritDoc} - */ - @Override - public int getKeyPoint() { - return ConnectionLocator.SOURCE; - } - - /** - * {@inheritDoc} - */ - @Override - public EObject getParserElement() { - EObject semanticElement = resolveSemanticElement(); - if (!(semanticElement instanceof Association)) { - return null; - } - Association association = (Association) semanticElement; - if ((getNotationView() != null) && (ViewUtil.getContainerView(getNotationView()) != null)) { - View owner = ViewUtil.getContainerView(getNotationView()); - - if ((association != null) && (association.getMemberEnds().size() == 2)) { - return AssociationViewUtils.getSourceSemanticEnd(owner); - } - } - - return null; - } - - /** - * {@inheritDoc} - */ - @Override - protected boolean isEditable() { - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public String getLabelRole() { - return "SourceMultiplicity"; //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - public String getIconPathRole() { - return ""; //$NON-NLS-1$ - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AssociationLinkLabelSourceRoleEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AssociationLinkLabelSourceRoleEditPart.java deleted file mode 100644 index deff0c57a04..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AssociationLinkLabelSourceRoleEditPart.java +++ /dev/null @@ -1,89 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.draw2d.ConnectionLocator; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; -import org.eclipse.papyrus.uml.diagram.common.utils.AssociationViewUtils; -import org.eclipse.uml2.uml.Association; - -/** - * Edit Part for link label showing {@link Association} source role. - */ -public class AssociationLinkLabelSourceRoleEditPart extends AbstractElementLabelEditPart { - - /** Constructor */ - public AssociationLinkLabelSourceRoleEditPart(View view) { - super(view); - addSnapBackLocation(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusLinkLabelDragPolicy()); - } - - /** - * {@inheritDoc} - */ - @Override - public int getKeyPoint() { - return ConnectionLocator.SOURCE; - } - - /** - * {@inheritDoc} - */ - @Override - public EObject getParserElement() { - EObject semanticElement = resolveSemanticElement(); - if (!(semanticElement instanceof Association)) { - return null; - } - Association association = (Association) semanticElement; - if ((getNotationView() != null) && (ViewUtil.getContainerView(getNotationView()) != null)) { - View owner = ViewUtil.getContainerView(getNotationView()); - - if ((association != null) && (association.getMemberEnds().size() == 2)) { - return AssociationViewUtils.getSourceSemanticEnd(owner); - } - } - - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String getLabelRole() { - return "SourceRole"; //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - public String getIconPathRole() { - return ""; //$NON-NLS-1$ - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AssociationLinkLabelTargetMultiplicityEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AssociationLinkLabelTargetMultiplicityEditPart.java deleted file mode 100644 index 8a6ed49d0ec..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AssociationLinkLabelTargetMultiplicityEditPart.java +++ /dev/null @@ -1,97 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.draw2d.ConnectionLocator; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; -import org.eclipse.papyrus.uml.diagram.common.utils.AssociationViewUtils; -import org.eclipse.uml2.uml.Association; - -/** - * Edit Part for link label showing {@link Association} target multiplicity. - */ -public class AssociationLinkLabelTargetMultiplicityEditPart extends AbstractElementLabelEditPart { - - /** Constructor */ - public AssociationLinkLabelTargetMultiplicityEditPart(View view) { - super(view); - addSnapBackLocation(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusLinkLabelDragPolicy()); - } - - /** - * {@inheritDoc} - */ - @Override - public int getKeyPoint() { - return ConnectionLocator.TARGET; - } - - /** - * {@inheritDoc} - */ - @Override - public EObject getParserElement() { - EObject semanticElement = resolveSemanticElement(); - if (!(semanticElement instanceof Association)) { - return null; - } - Association association = (Association) semanticElement; - if ((getNotationView() != null) && (ViewUtil.getContainerView(getNotationView()) != null)) { - View owner = ViewUtil.getContainerView(getNotationView()); - - if ((association != null) && (association.getMemberEnds().size() == 2)) { - return AssociationViewUtils.getTargetSemanticEnd(owner); - } - } - - return null; - } - - /** - * {@inheritDoc} - */ - @Override - protected boolean isEditable() { - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public String getLabelRole() { - return "TargetMultiplicity"; //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - public String getIconPathRole() { - return ""; //$NON-NLS-1$ - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AssociationLinkLabelTargetRoleEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AssociationLinkLabelTargetRoleEditPart.java deleted file mode 100644 index d87bef97665..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/AssociationLinkLabelTargetRoleEditPart.java +++ /dev/null @@ -1,89 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.draw2d.ConnectionLocator; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; -import org.eclipse.papyrus.uml.diagram.common.utils.AssociationViewUtils; -import org.eclipse.uml2.uml.Association; - -/** - * Edit Part for link label showing {@link Association} target role. - */ -public class AssociationLinkLabelTargetRoleEditPart extends AbstractElementLabelEditPart { - - /** Constructor */ - public AssociationLinkLabelTargetRoleEditPart(View view) { - super(view); - addSnapBackLocation(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusLinkLabelDragPolicy()); - } - - /** - * {@inheritDoc} - */ - @Override - public int getKeyPoint() { - return ConnectionLocator.TARGET; - } - - /** - * {@inheritDoc} - */ - @Override - public EObject getParserElement() { - EObject semanticElement = resolveSemanticElement(); - if (!(semanticElement instanceof Association)) { - return null; - } - Association association = (Association) semanticElement; - if ((getNotationView() != null) && (ViewUtil.getContainerView(getNotationView()) != null)) { - View owner = ViewUtil.getContainerView(getNotationView()); - - if ((association != null) && (association.getMemberEnds().size() == 2)) { - return AssociationViewUtils.getTargetSemanticEnd(owner); - } - } - - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String getLabelRole() { - return "TargetRole"; //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - public String getIconPathRole() { - return ""; //$NON-NLS-1$ - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/ConnectorLinkLabelEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/ConnectorLinkLabelEditPart.java deleted file mode 100644 index 2249fb48cac..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/ConnectorLinkLabelEditPart.java +++ /dev/null @@ -1,55 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; - -/** - * Edit Part for link label showing {@link Connector} label. - */ -public class ConnectorLinkLabelEditPart extends AbstractElementLabelEditPart { - - /** Constructor */ - public ConnectorLinkLabelEditPart(View view) { - super(view); - addSnapBackLocation(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusLinkLabelDragPolicy()); - } - - /** - * {@inheritDoc} - */ - @Override - public String getLabelRole() { - return "Label"; //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - public String getIconPathRole() { - return ""; //$NON-NLS-1$ - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/ConnectorLinkLabelSourceMultiplicityEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/ConnectorLinkLabelSourceMultiplicityEditPart.java deleted file mode 100644 index e55d3f0cb2f..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/ConnectorLinkLabelSourceMultiplicityEditPart.java +++ /dev/null @@ -1,93 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.draw2d.ConnectionLocator; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; -import org.eclipse.uml2.uml.Connector; -import org.eclipse.uml2.uml.ConnectorEnd; - -/** - * Edit Part for link label showing {@link Connector} source {@link ConnectorEnd} multiplicity. - */ -public class ConnectorLinkLabelSourceMultiplicityEditPart extends AbstractElementLabelEditPart { - - /** Constructor */ - public ConnectorLinkLabelSourceMultiplicityEditPart(View view) { - super(view); - addSnapBackLocation(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusLinkLabelDragPolicy()); - } - - /** - * {@inheritDoc} - */ - @Override - public int getKeyPoint() { - return ConnectionLocator.SOURCE; - } - - /** - * {@inheritDoc} - */ - @Override - public EObject getParserElement() { - Connector connector = (Connector) resolveSemanticElement(); - if ((getNotationView() != null) && (ViewUtil.getContainerView(getNotationView()) != null)) { - View owner = ViewUtil.getContainerView(getNotationView()); - - if ((connector != null) && (connector.getEnds().size() == 2)) { - return connector.getEnds().get(0); - } - } - - return null; - } - - /** - * {@inheritDoc} - */ - @Override - protected boolean isEditable() { - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public String getLabelRole() { - return "SourceMultiplicity"; //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - public String getIconPathRole() { - return ""; //$NON-NLS-1$ - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/ConnectorLinkLabelTargetMultiplicityEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/ConnectorLinkLabelTargetMultiplicityEditPart.java deleted file mode 100644 index e628c640486..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/ConnectorLinkLabelTargetMultiplicityEditPart.java +++ /dev/null @@ -1,93 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.draw2d.ConnectionLocator; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; -import org.eclipse.uml2.uml.Connector; -import org.eclipse.uml2.uml.ConnectorEnd; - -/** - * Edit Part for link label showing {@link Connector} target {@link ConnectorEnd} multiplicity. - */ -public class ConnectorLinkLabelTargetMultiplicityEditPart extends AbstractElementLabelEditPart { - - /** Constructor */ - public ConnectorLinkLabelTargetMultiplicityEditPart(View view) { - super(view); - addSnapBackLocation(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusLinkLabelDragPolicy()); - } - - /** - * {@inheritDoc} - */ - @Override - public int getKeyPoint() { - return ConnectionLocator.TARGET; - } - - /** - * {@inheritDoc} - */ - @Override - public EObject getParserElement() { - Connector connector = (Connector) resolveSemanticElement(); - if ((getNotationView() != null) && (ViewUtil.getContainerView(getNotationView()) != null)) { - View owner = ViewUtil.getContainerView(getNotationView()); - - if ((connector != null) && (connector.getEnds().size() == 2)) { - connector.getEnds().get(1); - } - } - - return null; - } - - /** - * {@inheritDoc} - */ - @Override - protected boolean isEditable() { - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public String getLabelRole() { - return "TargetMultiplicity"; //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - public String getIconPathRole() { - return ""; //$NON-NLS-1$ - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/ConstraintNodeLabelEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/ConstraintNodeLabelEditPart.java deleted file mode 100644 index 9fec4daad7b..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/ConstraintNodeLabelEditPart.java +++ /dev/null @@ -1,789 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.RunnableWithResult; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.AccessibleEditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.requests.DirectEditRequest; -import org.eclipse.gef.tools.DirectEditManager; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; -import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; -import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; -import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; -import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; -import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; -import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; -import org.eclipse.gmf.runtime.notation.FontStyle; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.edit.policies.DefaultNodeLabelDragPolicy; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.jface.viewers.ICellEditorValidator; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.extensionpoints.editors.Activator; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog; -import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog; -import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper; -import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; -import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; -import org.eclipse.papyrus.infra.gmfdiag.common.commands.SemanticAdapter; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; -import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; -import org.eclipse.papyrus.uml.diagram.composite.edit.parts.UMLEditPartFactory; -import org.eclipse.papyrus.uml.diagram.composite.edit.policies.UMLTextSelectionEditPolicy; -import org.eclipse.papyrus.uml.diagram.composite.part.UMLVisualIDRegistry; -import org.eclipse.papyrus.uml.diagram.composite.providers.UMLElementTypes; -import org.eclipse.papyrus.uml.diagram.composite.providers.UMLParserProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.accessibility.AccessibleEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.PlatformUI; -import org.eclipse.uml2.uml.Constraint; -import org.eclipse.uml2.uml.Feature; - -/** - * Abstract non-diagram specific edit part for node label representing {@link Constraint}. - * This class is adapted from edit parts generated by GMF Tooling. - */ -public class ConstraintNodeLabelEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart { - - /** - * @generated - */ - private DirectEditManager manager; - - /** - * @generated - */ - private IParser parser; - - /** - * @generated - */ - private List<?> parserElements; - - /** - * direct edition mode (default, undefined, registered editor, etc.) - * - * @generated - */ - protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR; - - /** - * configuration from a registered edit dialog - * - * @generated - */ - protected IDirectEditorConfiguration configuration; - - /** - * @generated - */ - public ConstraintNodeLabelEditPart(View view) { - super(view); - } - - /** - * @generated - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy()); - } - - /** - * @generated - */ - protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); - } else { - return ((Label) figure).getText(); - } - } - - /** - * @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); - } else { - ((Label) figure).setText(text); - } - } - - /** - * @generated - */ - protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); - } else { - return ((Label) figure).getIcon(); - } - } - - /** - * @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); - } else { - ((Label) figure).setIcon(icon); - } - } - - /** - * @generated - */ - public void setLabel(WrappingLabel figure) { - unregisterVisuals(); - setFigure(figure); - registerVisuals(); - refreshVisuals(); - } - - /** - * @generated - */ - @Override - @SuppressWarnings("rawtypes") - protected List getModelChildren() { - return Collections.EMPTY_LIST; - } - - /** - * @generated - */ - @Override - public IGraphicalEditPart getChildBySemanticHint(String semanticHint) { - return null; - } - - /** - * @generated - */ - protected EObject getParserElement() { - return resolveSemanticElement(); - } - - /** - * @generated - */ - protected Image getLabelIcon() { - return null; - } - - /** - * @generated - */ - protected String getLabelText() { - String text = null; - EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(new SemanticAdapter(parserElement, getNotationView()), getParserOptions().intValue()); - } - if (text == null) { - text = ""; - } - return text; - } - - /** - * @generated - */ - @Override - public void setLabelText(String text) { - setLabelTextHelper(getFigure(), text); - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - /** - * @generated - */ - @Override - public String getEditText() { - if (getParserElement() == null || getParser() == null) { - return ""; //$NON-NLS-1$ - } - return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); - } - - /** - * @generated - */ - protected boolean isEditable() { - return getParser() != null; - } - - /** - * @generated - */ - @Override - public ICellEditorValidator getEditTextValidator() { - return new ICellEditorValidator() { - - @Override - @SuppressWarnings("rawtypes") - public String isValid(final Object value) { - if (value instanceof String) { - final EObject element = getParserElement(); - final IParser parser = getParser(); - try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl() { - - @Override - @SuppressWarnings("unchecked") - public void run() { - setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value)); - } - }); - return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); - } catch (InterruptedException ie) { - ie.printStackTrace(); - } - } - // shouldn't get here - return null; - } - }; - } - - /** - * @generated - */ - @Override - public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { - return null; - } - return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); - } - - /** - * @generated - */ - @Override - public ParserOptions getParserOptions() { - return ParserOptions.NONE; - } - - /** - * @generated - */ - @Override - public IParser getParser() { - if (parser == null) { - parser = UMLParserProvider.getParser(UMLElementTypes.Constraint_Shape_CN, getParserElement(), UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.composite.edit.parts.ConstraintSpecificationEditPartCN.VISUAL_ID)); - } - return parser; - } - - /** - * @generated - */ - protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); - } - return manager; - } - - /** - * @generated - */ - protected void setManager(DirectEditManager manager) { - this.manager = manager; - } - - /** - * @generated - */ - protected void performDirectEdit() { - getManager().show(); - } - - /** - * @generated - */ - protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); - } - } - - /** - * @generated - */ - private void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); - } else { - performDirectEdit(); - } - } - - /** - * @generated - */ - @Override - protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { - directEditionMode = getDirectEditionType(); - } - switch (directEditionMode) { - case IDirectEdition.NO_DIRECT_EDITION: - // no direct edition mode => does nothing - return; - case IDirectEdition.EXTENDED_DIRECT_EDITOR: - updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { - performDefaultDirectEditorEdit(theRequest); - } else { - configuration.preEditAction(resolveSemanticElement()); - Dialog dialog = null; - if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration).createPopupEditorHelper(this); - helper.showEditor(); - return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); - } else { - return; - } - final Dialog finalDialog = dialog; - if (Window.OK == dialog.open()) { - TransactionalEditingDomain domain = getEditingDomain(); - RecordingCommand command = new RecordingCommand(domain, "Edit Label") { - - @Override - protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog) finalDialog).getValue()); - } - }; - domain.getCommandStack().execute(command); - } - } - break; - case IDirectEdition.DEFAULT_DIRECT_EDITOR: - // initialize the direct edit manager - try { - getEditingDomain().runExclusive(new Runnable() { - - @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); - performDirectEdit(initialChar.charValue()); - } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { - DirectEditRequest editRequest = (DirectEditRequest) theRequest; - performDirectEdit(editRequest.getLocation()); - } else { - performDirectEdit(); - } - } - } - }); - } catch (InterruptedException e) { - e.printStackTrace(); - } - break; - default: - break; - } - } - - /** - * @generated - */ - @Override - protected void refreshVisuals() { - super.refreshVisuals(); - refreshLabel(); - refreshFont(); - refreshFontColor(); - refreshUnderline(); - refreshStrikeThrough(); - } - - /** - * @generated - */ - protected void refreshLabel() { - EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { - setLabelTextHelper(getFigure(), getLabelText()); - setLabelIconHelper(getFigure(), getLabelIcon()); - } - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - /** - * @generated - */ - protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); - } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); - } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); - } - } - } - - /** - * @generated - */ - protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); - } - } - - /** - * @generated - */ - @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)); - setFont(fontData); - } - } - - /** - * @generated - */ - @Override - protected void setFontColor(Color color) { - getFigure().setForegroundColor(color); - } - - @Override - protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { - EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ - } - addListenerFilter("SemanticModelConstraintOwner", this, element); // in order to refresh label when ConstraintSpecification creation - } else { - super.addSemanticListeners(); - } - } - - /** - * @generated - */ - @Override - protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { - removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ - } - } else { - super.removeSemanticListeners(); - } - } - - /** - * @generated - */ - @Override - protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { - accessibleEP = new AccessibleGraphicalEditPart() { - - @Override - public void getName(AccessibleEvent e) { - e.result = getLabelTextHelper(getFigure()); - } - }; - } - return accessibleEP; - } - - /** - * @generated - */ - private View getFontStyleOwnerView() { - return getPrimaryView(); - } - - /** - * Returns the kind of associated editor for direct edition. - * - * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition - * @generated - */ - public int getDirectEditionType() { - if (checkExtendedEditor()) { - initExtendedEditorConfiguration(); - return IDirectEdition.EXTENDED_DIRECT_EDITOR; - } - if (checkDefaultEdition()) { - return IDirectEdition.DEFAULT_DIRECT_EDITOR; - } - // not a named element. no specific editor => do nothing - return IDirectEdition.NO_DIRECT_EDITION; - } - - /** - * Checks if an extended editor is present. - * - * @return <code>true</code> if an extended editor is present. - * @generated - */ - protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { - return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement().eClass().getInstanceClassName()); - } - return false; - } - - /** - * Checks if a default direct edition is available - * - * @return <code>true</code> if a default direct edition is available - * @generated - */ - protected boolean checkDefaultEdition() { - return (getParser() != null); - } - - /** - * Initializes the extended editor configuration - * - * @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().eClass().getInstanceClassName()); - } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement().eClass().getInstanceClassName()); - } - } - } - - /** - * Updates the preference configuration - * - * @generated - */ - protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") && languagePreferred != configuration.getLanguage()) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName()); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { - configuration = null; - } - } - - /** - * Performs the direct edit usually used by GMF editors. - * - * @param theRequest - * the direct edit request that starts the direct edit system - * @generated - */ - protected void performDefaultDirectEditorEdit(final Request theRequest) { - // initialize the direct edit manager - try { - getEditingDomain().runExclusive(new Runnable() { - - @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); - performDirectEdit(initialChar.charValue()); - } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { - DirectEditRequest editRequest = (DirectEditRequest) theRequest; - performDirectEdit(editRequest.getLocation()); - } else { - performDirectEdit(); - } - } - } - }); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - /** - * @generated - */ - @Override - protected void addNotationalListeners() { - super.addNotationalListeners(); - addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$ - } - - /** - * @generated - */ - @Override - protected void removeNotationalListeners() { - super.removeNotationalListeners(); - removeListenerFilter("PrimaryView"); //$NON-NLS-1$ - } - - /** - * @generated - */ - @Override - protected void handleNotificationEvent(Notification event) { - refreshLabel(); - Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); - setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { - refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { - refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { - refreshFont(); - } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { - refreshLabel(); - } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { - removeSemanticListeners(); - if (resolveSemanticElement() != null) { - addSemanticListeners(); - } - refreshLabel(); - } - } - } - super.handleNotificationEvent(event); - } - - /** - * @generated - */ - @Override - protected IFigure createFigure() { - // Parent should assign one using setLabel() method - return null; - } - - /** - * @generated - */ - private static final String ADD_PARENT_MODEL = "AddParentModel"; - - /** - * @generated - */ - @Override - public void activate() { - super.activate(); - addOwnerElementListeners(); - } - - /** - * @generated - */ - protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); - } - - /** - * @generated - */ - @Override - public void deactivate() { - removeOwnerElementListeners(); - super.deactivate(); - } - - /** - * @generated - */ - protected void removeOwnerElementListeners() { - removeListenerFilter(ADD_PARENT_MODEL); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/DefaultChildLabelEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/DefaultChildLabelEditPart.java deleted file mode 100644 index f444f354991..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/DefaultChildLabelEditPart.java +++ /dev/null @@ -1,35 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; - -/** - * Default implementation for child label node. - */ -public class DefaultChildLabelEditPart extends AbstractElementChildLabelEditPart { - - /** Constructor */ - public DefaultChildLabelEditPart(View view) { - super(view); - } - - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/NamedElementAffixedLabelNameEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/NamedElementAffixedLabelNameEditPart.java deleted file mode 100644 index be434b24f66..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/NamedElementAffixedLabelNameEditPart.java +++ /dev/null @@ -1,109 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; -import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.emf.appearance.helper.NameLabelIconHelper; -import org.eclipse.papyrus.sysml.diagram.common.Activator; -import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; -import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil; -import org.eclipse.swt.graphics.Image; -import org.eclipse.uml2.uml.NamedElement; - -/** - * Abstract non-diagram specific edit part for border node label representing {@link NamedElement}. - * This class is adapted from edit parts generated by GMF Tooling. - */ -public class NamedElementAffixedLabelNameEditPart extends AbstractElementLabelEditPart implements IBorderItemEditPart { - - /** Constructor */ - public NamedElementAffixedLabelNameEditPart(View view) { - super(view); - addSnapBackLocation(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - } - - @Override - public IBorderItemLocator getBorderItemLocator() { - IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { - Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - protected Image getLabelIcon() { - EObject parserElement = getParserElement(); - if (parserElement == null) { - return null; - } - - List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer()); - for (View view : views) { - if (NameLabelIconHelper.showLabelIcon(view)) { - return Activator.getInstance().getImage(parserElement.eClass()); - } - } - return null; - - } - - /** - * {@inheritDoc} - */ - @Override - protected IFigure createFigure() { - IFigure label = createFigurePrim(); - defaultText = getLabelTextHelper(label); - return label; - } - - protected IFigure createFigurePrim() { - return new PapyrusWrappingLabel(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getLabelRole() { - return "Name"; //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - public String getIconPathRole() { - return ""; //$NON-NLS-1$ - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/NamedElementLinkLabelNameEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/NamedElementLinkLabelNameEditPart.java deleted file mode 100644 index 9fd5a7198b0..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/NamedElementLinkLabelNameEditPart.java +++ /dev/null @@ -1,56 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; -import org.eclipse.uml2.uml.NamedElement; - -/** - * Edit Part for link label showing {@link NamedElement} name. - */ -public class NamedElementLinkLabelNameEditPart extends AbstractElementLabelEditPart { - - /** Constructor */ - public NamedElementLinkLabelNameEditPart(View view) { - super(view); - addSnapBackLocation(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusLinkLabelDragPolicy()); - } - - /** - * {@inheritDoc} - */ - @Override - public String getLabelRole() { - return "Name"; //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - public String getIconPathRole() { - return ""; //$NON-NLS-1$ - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/NamedElementNodeLabelNameEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/NamedElementNodeLabelNameEditPart.java deleted file mode 100644 index 321bb2fdca0..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/NamedElementNodeLabelNameEditPart.java +++ /dev/null @@ -1,52 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.uml2.uml.NamedElement; - -/** - * Abstract non-diagram specific edit part for node label representing {@link NamedElement}. - * This class is adapted from edit parts generated by GMF Tooling. - */ -public class NamedElementNodeLabelNameEditPart extends AbstractElementNodeLabelEditPart { - - public NamedElementNodeLabelNameEditPart(View view) { - super(view); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getLabelRole() { - return "Name"; //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - public String getIconPathRole() { - return ""; //$NON-NLS-1$ - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/PortAffixedLabelNameEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/PortAffixedLabelNameEditPart.java deleted file mode 100644 index 70d3db8ff42..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/PortAffixedLabelNameEditPart.java +++ /dev/null @@ -1,119 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; -import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper; -import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; -import org.eclipse.papyrus.sysml.diagram.common.Activator; -import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil; -import org.eclipse.swt.graphics.Image; -import org.eclipse.uml2.uml.Port; - -/** - * This class implements a {@link Port} affixed label edit part. - */ -public class PortAffixedLabelNameEditPart extends AbstractElementLabelEditPart implements IBorderItemEditPart { - - /** Constructor */ - public PortAffixedLabelNameEditPart(View view) { - super(view); - addSnapBackLocation(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - } - - /** - * @see org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart#getDefaultTextAlignment() - * - * @return - */ - @Override - protected int getDefaultTextAlignment() { - return PositionConstants.LEFT; - } - - @Override - public IBorderItemLocator getBorderItemLocator() { - IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { - Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return constraint instanceof IBorderItemLocator ? (IBorderItemLocator) constraint : null; - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - protected Image getLabelIcon() { - EObject parserElement = getParserElement(); - if (parserElement == null) { - return null; - } - - List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer()); - for (View view : views) { - if (AppearanceHelper.showElementIcon(view)) { - return Activator.getInstance().getLabelProvider().getImage(parserElement); - } - } - return null; - - } - - /** - * {@inheritDoc} - */ - @Override - protected IFigure createFigure() { - IFigure label = createFigurePrim(); - defaultText = getLabelTextHelper(label); - return label; - } - - protected IFigure createFigurePrim() { - return new PapyrusWrappingLabel(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getLabelRole() { - return "Label"; //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - public String getIconPathRole() { - return ""; //$NON-NLS-1$ - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/PropertyNodeLabelEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/PropertyNodeLabelEditPart.java deleted file mode 100644 index 05446ab6a64..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/PropertyNodeLabelEditPart.java +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.gmf.runtime.notation.View; - -/** - * Abstract non-diagram specific edit part for node label representing {@link Property}. - * This class is adapted from edit parts generated by GMF Tooling. - */ -public class PropertyNodeLabelEditPart extends AbstractElementNodeLabelEditPart { - - public PropertyNodeLabelEditPart(View view) { - super(view); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getLabelRole() { - return "Label"; //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - public String getIconPathRole() { - return ""; //$NON-NLS-1$ - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/SlotChildLabelEditPart.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/SlotChildLabelEditPart.java deleted file mode 100644 index fce649339b9..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/part/SlotChildLabelEditPart.java +++ /dev/null @@ -1,36 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.part; - -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.uml2.uml.Slot; - -/** - * Edit part for {@link Slot} used as Child label node. - */ -public class SlotChildLabelEditPart extends AbstractElementChildLabelEditPart { - - /** Constructor */ - public SlotChildLabelEditPart(View view) { - super(view); - } - - /** - * {@inheritDoc} - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/policy/EncapsulatedClassifierResizableShapeEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/policy/EncapsulatedClassifierResizableShapeEditPolicy.java deleted file mode 100644 index 683b933e63c..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/policy/EncapsulatedClassifierResizableShapeEditPolicy.java +++ /dev/null @@ -1,45 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.policy; - -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.commands.UnexecutableCommand; - -/** - * <pre> - * This class modifies EncapsulatedClassifier default resize command in order to move - * any Port IBorderItem possibly attached. - * See. bug. https://bugs.eclipse.org/bugs/show_bug.cgi?id=354814 - * Could not find a more general way to do this without making any assumption about - * the kind of attached IBorderItem and that would only rely on its IBorderItemLocator. - * </pre> - */ -public class EncapsulatedClassifierResizableShapeEditPolicy extends org.eclipse.papyrus.uml.diagram.composite.custom.edit.policies.EncapsulatedClassifierResizableShapeEditPolicy { - - /** - * <pre> - * {@inheritDoc} - * - * Forbid AutoSize for elements that can hold Port, it currently - * leads to Port (FlowPort) with incorrect location stored in notation, - * and possible incorrect visual representation (FlowPort). - * </pre> - */ - @Override - protected Command getAutoSizeCommand(Request request) { - return UnexecutableCommand.INSTANCE; - } - -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/policy/MaskManagedLabelEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/policy/MaskManagedLabelEditPolicy.java deleted file mode 100644 index b8c32595146..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/policy/MaskManagedLabelEditPolicy.java +++ /dev/null @@ -1,107 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.policy; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.gef.editpolicies.GraphicalEditPolicy; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.gmf.diagram.common.edit.part.ITextAwareEditPart; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.helper.MaskLabelHelper; -import org.eclipse.papyrus.uml.diagram.common.parser.IMaskManagedSemanticParser; - - -/** - * <pre> - * Generic mask manage edit policy for {@link ITextAwareEditPart}, managed masks are assumed to be given by the - * {@link ITextAwareEditPart} parser (must implement {@link IMaskManagedSemanticParser}). - * </pre> - */ -public class MaskManagedLabelEditPolicy extends GraphicalEditPolicy implements IMaskManagedLabelEditPolicy { - - /** - * {@inheritDoc} - */ - @Override - public Map<String, String> getMasks() { - Map<String, String> masks = new HashMap<String, String>(); - - IParser parser = getHostLabelEditPart().getParser(); - if (parser instanceof IMaskManagedSemanticParser) { - masks = ((IMaskManagedSemanticParser) parser).getMasks(); - } - - return masks; - } - - /** - * {@inheritDoc} - */ - @Override - public Collection<String> getCurrentDisplayValue() { - Collection<String> result = MaskLabelHelper.getMaskValues(getView()); - if (result == null) { - IParser parser = getHostLabelEditPart().getParser(); - if (parser instanceof IMaskManagedSemanticParser) { - result = ((IMaskManagedSemanticParser) parser).getDefaultValue(getHost()); - } - } - - if (result == null) { - return Collections.emptySet(); - } - - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public void updateDisplayValue(Collection<String> maskValues) { - MaskLabelHelper.setMaskValues(getView(), maskValues); - } - - /** - * {@inheritDoc} - */ - @Override - public void setDefaultDisplayValue() { - MaskLabelHelper.unsetMaskValues(getView()); - } - - // @unused. - @Override - public void refreshDisplay() { - // Not implemented. - } - - /** - * Get the host label edit part (has to implement {@link ITextAwareEditPart}). - * - * @return the host label edit part. - */ - private ITextAwareEditPart getHostLabelEditPart() { - return (ITextAwareEditPart) getHost(); - } - - private View getView() { - return (View) getHost().getModel(); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/policy/StructuredClassifierCreationEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/policy/StructuredClassifierCreationEditPolicy.java deleted file mode 100644 index 08a6de67b6d..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/edit/policy/StructuredClassifierCreationEditPolicy.java +++ /dev/null @@ -1,191 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.edit.policy; - -import java.util.Collections; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.SnapToHelper; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.commands.UnexecutableCommand; -import org.eclipse.gef.requests.ChangeBoundsRequest; -import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; -import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor; -import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.gmf.diagram.common.commands.CreateViewCommand; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.AspectUnspecifiedTypeCreationTool; -import org.eclipse.papyrus.infra.gmfdiag.common.snap.NodeSnapHelper; -import org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator; - -/** - * Replaces the {@link DefaultCreationEditPolicy} in order to manage Affixed Port position on creation or on drop. - */ -public class StructuredClassifierCreationEditPolicy extends CreationEditPolicy { - - /** - * {@inheritDoc} - */ - @Override - protected Command getReparentCommand(ChangeBoundsRequest request) { - // Forbid re-parent in this edit policy (to be used by compartment) - // in order to avoid node to be moved in compartments. - return UnexecutableCommand.INSTANCE; - } - - /** - * <pre> - * {@inheritDoc} - * - * The goal here is to create the view and to move it at the mouse location, - * respecting a given locator. It is assumed that only affixed Port can be created on - * edit part that have this edit policy, and the locator is a {@link PortPositionLocator}. - * - * @see DefaultCreationEditPolicy#getCreateCommand(). - * </pre> - */ - @Override - protected Command getCreateCommand(CreateViewRequest request) { - - // This overrides getCreateCommand in order to use a specific CreateViewCommand (instead of - // org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand. - - // The original CreateCommand#canExecute() implementation rely on ViewProvider#provides(CreateViewForKindOperation op) - // method to know if a view can be created. The problem is that this method is incorrectly generated by GMF Tooling and should be avoided. - - // CreateViewCommand replace the semantic adapter in its call to ViewService to know if a provider exists. - - TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); - CompositeTransactionalCommand cc = new CompositeTransactionalCommand(editingDomain, DiagramUIMessages.AddCommand_Label); - - Iterator<? extends ViewDescriptor> descriptors = request.getViewDescriptors().iterator(); - while (descriptors.hasNext()) { - - CreateViewRequest.ViewDescriptor descriptor = descriptors.next(); - ICommand createCommand = new CreateViewCommand(editingDomain, descriptor, (View) (getHost().getModel())); - - // Add SetBounds - createCommand = CompositeCommand.compose(createCommand, getSetBoundsCommand(request, descriptor)); - // - - cc.compose(createCommand); - - } - - return new ICommandProxy(cc.reduce()); - - } - - /** - * Get a SetBoundsCommand to move a new view at current mouse position. - * - * @param request - * The creation request. - * @param descriptor - * The descriptor of the new element. - * @return The set bounds command. - */ - private ICommand getSetBoundsCommand(CreateViewRequest request, CreateViewRequest.ViewDescriptor descriptor) { - ICommand setBoundsCommand = null; - TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); - - // Retrieve parent location - Point parentLoc = getHostFigure().getBounds().getLocation().getCopy(); - - - final Point realWantedLocation; - Map<?, ?> params = request.getExtendedData(); - Point realLocation = (Point) params.get(AspectUnspecifiedTypeCreationTool.INITIAL_MOUSE_LOCATION_FOR_CREATION); - if (realLocation != null) { - realWantedLocation = realLocation.getCopy(); - } else { - // we use this location to be able to create Port in the corners of the figure - realWantedLocation = request.getLocation().getCopy(); - } - - // Compute relative creation location - Point requestedLocation = realWantedLocation.getCopy(); - - - - getHostFigure().translateToRelative(requestedLocation); - - // Create proposed creation bounds and use the locator to find the expected position - PortPositionLocator locator = new PortPositionLocator(getHostFigure(), PositionConstants.NONE); - final Rectangle preferredBounds = locator.getPreferredLocation(new Rectangle(requestedLocation, new Dimension(20, 20))); - Rectangle retainedBounds = preferredBounds.getCopy(); - - // find the current side of the wanted position - final Rectangle parentBounds = getHostFigure().getBounds().getCopy(); - // break all!!! getHostFigure().translateToAbsolute(parentBounds); - locator.setConstraint(preferredBounds.getCopy().translate(parentBounds.getLocation().getNegated())); - int currentSide = locator.getCurrentSideOfParent(); - if (request.isSnapToEnabled() && currentSide != PositionConstants.NORTH_EAST && currentSide != PositionConstants.NORTH_WEST && currentSide != PositionConstants.SOUTH_EAST && currentSide != PositionConstants.SOUTH_WEST) { // request for snap port at the - // creation - // we find the best location with snap - Point wantedPoint = preferredBounds.getLocation(); - getHostFigure().translateToAbsolute(wantedPoint); - Rectangle portBounds = new Rectangle(wantedPoint, new Dimension(20, 20)); - NodeSnapHelper helper = new NodeSnapHelper((SnapToHelper) getHost().getAdapter(SnapToHelper.class), portBounds, false, false, true); - final ChangeBoundsRequest tmpRequest = new ChangeBoundsRequest("move"); //$NON-NLS-1$ - tmpRequest.setEditParts(Collections.emptyList()); - tmpRequest.setSnapToEnabled(true); - tmpRequest.setLocation(portBounds.getLocation()); - helper.snapPoint(tmpRequest); - preferredBounds.translate(tmpRequest.getMoveDelta()); - - switch (currentSide) { - case PositionConstants.NORTH: - case PositionConstants.SOUTH: - preferredBounds.y = retainedBounds.y; - break; - case PositionConstants.EAST: - case PositionConstants.WEST: - preferredBounds.x = retainedBounds.x; - break; - default: - break; - } - } - // Convert the calculated preferred bounds as relative to parent location - Rectangle creationBounds = preferredBounds.getTranslated(parentLoc.getNegated()); - setBoundsCommand = new SetBoundsCommand(editingDomain, DiagramUIMessages.SetLocationCommand_Label_Resize, descriptor, creationBounds); - return setBoundsCommand; - } - - /** - * Convenience method to return the host's Figure. - * - * @return The host GraphicalEditPart's Figure - */ - private IFigure getHostFigure() { - return ((GraphicalEditPart) getHost()).getFigure(); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/factory/AssociationLinkViewFactory.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/factory/AssociationLinkViewFactory.java deleted file mode 100644 index 8cedb0f8335..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/factory/AssociationLinkViewFactory.java +++ /dev/null @@ -1,100 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.factory; - -import java.util.List; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.notation.EObjectValueStyle; -import org.eclipse.gmf.runtime.notation.Edge; -import org.eclipse.gmf.runtime.notation.NotationFactory; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.gmf.diagram.common.factory.ConnectorViewFactory; -import org.eclipse.papyrus.uml.diagram.common.utils.AssociationViewUtils; -import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; -import org.eclipse.uml2.uml.Association; -import org.eclipse.uml2.uml.Property; - -/** - * View factory for Association. - */ -public class AssociationLinkViewFactory extends ConnectorViewFactory { - - /** - * <pre> - * {@inheritDoc} - * - * Add two EObjectValueStyle in order to store the Properties that are associated with - * the Graphical ends. - * </pre> - */ - @Override - protected List createStyles(View view) { - - EObjectValueStyle sourceStyle = NotationFactory.eINSTANCE.createEObjectValueStyle(); - sourceStyle.setName(AssociationViewUtils.SEMANTIC_SOURCE_END); - - EObjectValueStyle targetStyle = NotationFactory.eINSTANCE.createEObjectValueStyle(); - targetStyle.setName(AssociationViewUtils.SEMANTIC_TARGET_END); - - view.getStyles().add(sourceStyle); - view.getStyles().add(targetStyle); - - return super.createStyles(view); - } - - /** - * <pre> - * {@inheritDoc} - * - * Store {@link Association} semantic ends (Property) in dedicated styles. - * </pre> - */ - @Override - public View createView(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) { - Edge view = (Edge) super.createView(semanticAdapter, containerView, semanticHint, index, persisted, preferencesHint); - - if ((view != null) && (view.getElement() != null) && (view.getElement() instanceof Association)) { - Association association = (Association) view.getElement(); - - assert (association.getMemberEnds().size() == 2); - - Property propertySource = association.getMemberEnds().get(0); - Property propertyTarget = association.getMemberEnds().get(1); - - AssociationViewUtils.setSourceSemanticEnd(view, propertySource); - AssociationViewUtils.setTargetSemanticEnd(view, propertyTarget); - } - - return view; - } - - /** - * Creates Association view and add Label nodes - */ - @Override - protected void decorateView(View containerView, View view, IAdaptable element, String semanticHint, int index, boolean persisted) { - - getViewService().createNode(element, view, UMLGraphicalTypes.LINKLABEL_UML_APPLIEDSTEREOTYPE_ID, ViewUtil.APPEND, persisted, getPreferencesHint()); - getViewService().createNode(element, view, UMLGraphicalTypes.LINKLABEL_UML_NAMEDELEMENT_NAME_ID, ViewUtil.APPEND, persisted, getPreferencesHint()); - getViewService().createNode(element, view, UMLGraphicalTypes.LINKLABEL_UML_ASSOCIATION_SOURCE_ROLE_ID, ViewUtil.APPEND, persisted, getPreferencesHint()); - getViewService().createNode(element, view, UMLGraphicalTypes.LINKLABEL_UML_ASSOCIATION_SOURCE_MULTIPLICITY_ID, ViewUtil.APPEND, persisted, getPreferencesHint()); - getViewService().createNode(element, view, UMLGraphicalTypes.LINKLABEL_UML_ASSOCIATION_TARGET_ROLE_ID, ViewUtil.APPEND, persisted, getPreferencesHint()); - getViewService().createNode(element, view, UMLGraphicalTypes.LINKLABEL_UML_ASSOCIATION_TARGET_MULTIPLICITY_ID, ViewUtil.APPEND, persisted, getPreferencesHint()); - - super.decorateView(containerView, view, element, semanticHint, index, persisted); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/factory/ClassifierViewFactory.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/factory/ClassifierViewFactory.java deleted file mode 100644 index f52c3a73ce5..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/factory/ClassifierViewFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.factory; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.gmf.diagram.common.factory.ShapeViewFactory; -import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes; - -/** - * View factory for UML Classifier. - * - * FIXME : NestedClassifier compartment is not yet supported. - */ -public class ClassifierViewFactory extends ShapeViewFactory { - - /** - * Creates Classifier view and add Label and Compartment nodes - */ - @Override - protected void decorateView(View containerView, View view, IAdaptable element, String semanticHint, int index, boolean persisted) { - - getViewService().createNode(element, view, UMLGraphicalTypes.LABEL_UML_NAMEDELEMENT_NAME_ID, ViewUtil.APPEND, persisted, getPreferencesHint()); - getViewService().createNode(element, view, UMLGraphicalTypes.COMPARTMENT_UML_PROPERTY_AS_LIST_ID, ViewUtil.APPEND, persisted, getPreferencesHint()); - getViewService().createNode(element, view, UMLGraphicalTypes.COMPARTMENT_UML_OPERATION_AS_LIST_ID, ViewUtil.APPEND, persisted, getPreferencesHint()); - - // this action needs to be done after the compartments creation - super.decorateView(containerView, view, element, semanticHint, index, persisted); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/figure/ConnectorEdgeFigure.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/figure/ConnectorEdgeFigure.java deleted file mode 100644 index dd9cf5719ed..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/figure/ConnectorEdgeFigure.java +++ /dev/null @@ -1,85 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.figure; - -import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; -import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; - -/** - * Figure for UML {@link Connector} Edges. - */ -public class ConnectorEdgeFigure extends NamedElementEdgeFigure { - - /** The multiplicity source label. */ - private WrappingLabel fSourceMultiplicityLabel; - - /** The multiplicity target label. */ - private WrappingLabel fTargetMultiplicityLabel; - - /** - * Instantiates a new association figure. - */ - public ConnectorEdgeFigure() { - super(); - createContents(); - } - - /** - * Creates the contents. - */ - @Override - protected void createContents() { - super.createContents(); - - fSourceMultiplicityLabel = new PapyrusWrappingLabel(); - fSourceMultiplicityLabel.setText(""); - - this.add(fSourceMultiplicityLabel); - - fTargetMultiplicityLabel = new PapyrusWrappingLabel(); - fTargetMultiplicityLabel.setText(""); - - this.add(fTargetMultiplicityLabel); - - } - - /** - * Gets the applied stereotype association label. - * - * @return the applied stereotype association label - */ - @Override - public WrappingLabel getAppliedStereotypeLabel() { - return appliedStereotypeLabel; - } - - /** - * Gets the multiplicity source label. - * - * @return the multiplicity source label - */ - public WrappingLabel getSourceMultiplicityLabel() { - return fSourceMultiplicityLabel; - } - - /** - * Gets the multiplicity target label. - * - * @return the multiplicity target label - */ - public WrappingLabel getTargetMultiplicityLabel() { - return fTargetMultiplicityLabel; - } - -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/figure/EdgeDecorationType.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/figure/EdgeDecorationType.java deleted file mode 100644 index 7a644b7cf30..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/figure/EdgeDecorationType.java +++ /dev/null @@ -1,39 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.figure; - -import org.eclipse.gmf.runtime.notation.ArrowType; - -/** - * <pre> - * The class provides a list of predefined ids to create edge decorations. - * - * Also see : org.eclipse.papyrus.uml.diagram.common.edit.part.AbstractElementLinkEditPart#getArrowDecoration(). - * </pre> - */ -public final class EdgeDecorationType { - - public static final int NONE = ArrowType.NONE; // 0 - - public static final int OPEN_ARROW = ArrowType.OPEN_ARROW; // 1 - - public static final int SOLID_ARROW_FILLED = ArrowType.SOLID_ARROW; // 2 - - public static final int SOLID_ARROW_EMPTY = 3; - - public static final int SOLID_DIAMOND_FILLED = 4; - - public static final int SOLID_DIAMOND_EMPTY = 5; - -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/figure/GeneralizationFigure.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/figure/GeneralizationFigure.java deleted file mode 100644 index 51a89d59f97..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/figure/GeneralizationFigure.java +++ /dev/null @@ -1,26 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.figure; - -import org.eclipse.papyrus.uml.diagram.common.figure.edge.UMLEdgeFigure; - -/** - * Figure for UML Generalization Edges. - */ -public class GeneralizationFigure extends UMLEdgeFigure { - - public GeneralizationFigure() { - super(); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/figure/InterfaceRealizationFigure.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/figure/InterfaceRealizationFigure.java deleted file mode 100644 index 2511b00e612..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/figure/InterfaceRealizationFigure.java +++ /dev/null @@ -1,24 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.figure; - -/** - * Figure for UML InterfaceRealization Edges. - */ -public class InterfaceRealizationFigure extends NamedElementEdgeFigure { - - public InterfaceRealizationFigure() { - super(); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/figure/NamedElementEdgeFigure.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/figure/NamedElementEdgeFigure.java deleted file mode 100644 index 889906a6b2d..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/figure/NamedElementEdgeFigure.java +++ /dev/null @@ -1,64 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.figure; - -import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; -import org.eclipse.papyrus.uml.diagram.common.figure.edge.UMLEdgeFigure; -import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; - -/** - * <pre> - * This edge figure support stereotype application and name labels, - * and does not make any assumption on style, decorations, and width. - * These properties are managed by the edit part. - * - * This figure also provides its own custom dash pattern that can be use calling - * setLineType(Graphics.LINE_CUSTOM); - * </pre> - */ -public class NamedElementEdgeFigure extends UMLEdgeFigure { - - private WrappingLabel nameLabel; - - /** Dashes used to paint line. */ - private final int[] dashes = new int[10]; - - public NamedElementEdgeFigure() { - super(); - - // set dashes - for (int i = 0; i < 10; i++) { - dashes[i] = 5; - } - setLineDash(dashes); - - createContents(); - } - - public WrappingLabel getNameLabel() { - return nameLabel; - } - - /** - * @generated - */ - @Override - protected void createContents() { - super.createContents(); - nameLabel = new PapyrusWrappingLabel(); - nameLabel.setText(""); - - this.add(nameLabel); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/AssociationEndLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/AssociationEndLabelParser.java deleted file mode 100644 index 9cb1c33b8fd..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/AssociationEndLabelParser.java +++ /dev/null @@ -1,183 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.parser; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.emf.utils.EMFHelper; -import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; -import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLMultiplicityElementUtil; -import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; -import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; -import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil; -import org.eclipse.uml2.uml.Association; -import org.eclipse.uml2.uml.Property; -import org.eclipse.uml2.uml.ValueSpecification; -import org.eclipse.uml2.uml.VisibilityKind; - -/** - * Semantic Parser for {@link Property} used as {@link Association} end. - */ -public class AssociationEndLabelParser extends PropertyLabelParser { - - /** The String format for displaying a {@link Property} label with modifiers */ - protected static final String ALT_MODIFIER_FORMAT = "{%s}%s"; - - /** - * {@inheritDoc} - */ - @Override - public String getPrintString(IAdaptable element, int flags) { - Collection<String> maskValues = getMaskValues(element); - - if (maskValues.isEmpty()) { - return MaskedLabel; - } - - String result = ""; - EObject eObject = EMFHelper.getEObject(element); - - if ((eObject != null) && (eObject instanceof Property)) { - - Property property = (Property) eObject; - - // manage visibility - if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) { - String visibility; - switch (property.getVisibility().getValue()) { - case VisibilityKind.PACKAGE: - visibility = "~"; - break; - case VisibilityKind.PUBLIC: - visibility = "+"; - break; - case VisibilityKind.PROTECTED: - visibility = "#"; - break; - case VisibilityKind.PRIVATE: - visibility = "-"; - break; - default: - visibility = "+"; - break; - } - result = String.format(VISIBILITY_FORMAT, visibility, result); - } - - // manage derived modifier - if (maskValues.contains(ICustomAppearance.DISP_DERIVE) && property.isDerived()) { - result = String.format(DERIVED_FORMAT, result); - } - - // manage name - if (maskValues.contains(ICustomAppearance.DISP_NAME) && property.isSetName()) { - String name = UMLLabelInternationalization.getInstance().getLabel(property); - - // If property is owned by Association (non navigable) only show the name when explicitly asked. - - if (maskValues.contains(ILabelPreferenceConstants.DISP_NON_NAVIGABLE_ROLE) || !((property.getOwningAssociation() != null) && (property.getOwningAssociation().getOwnedEnds().contains(property)))) { - - result = String.format(NAME_FORMAT, result, name); - } - } - - // manage type - if (maskValues.contains(ICustomAppearance.DISP_TYPE)) { - String type = "<Undefined>"; - if (property.getType() != null) { - type = UMLLabelInternationalization.getInstance().getLabel(property.getType()); - } - - // If type is undefined only show "<Undefined>" when explicitly asked. - - if (maskValues.contains(ILabelPreferenceConstants.DISP_UNDEFINED_TYPE) || (!"<Undefined>".equals(type))) { - - result = String.format(TYPE_FORMAT, result, type); - } - } - - // manage multiplicity - if (maskValues.contains(ICustomAppearance.DISP_MULTIPLICITY)) { - - String multiplicity = SysMLMultiplicityElementUtil.formatMultiplicity(property, maskValues); - if (multiplicity != null && !multiplicity.isEmpty()) { - result += " " + multiplicity; - } - } - - // manage default value - if (maskValues.contains(ICustomAppearance.DISP_DEFAULT_VALUE) && property.getDefaultValue() != null) { - ValueSpecification valueSpecification = property.getDefaultValue(); - result = String.format(DEFAULT_VALUE_FORMAT, result, ValueSpecificationUtil.getSpecificationValue(valueSpecification, true)); - } - - // manage modifier - if (maskValues.contains(ICustomAppearance.DISP_MODIFIERS)) { - StringBuffer sb = new StringBuffer(); - if (property.isReadOnly()) { - sb.append(sb.length() == 0 ? "readOnly" : ", readOnly"); - } - if (property.isOrdered()) { - sb.append(sb.length() == 0 ? "ordered" : ", ordered"); - } - if (property.isUnique()) { - sb.append(sb.length() == 0 ? "unique" : ", unique"); - } - if (property.isDerivedUnion()) { - sb.append(sb.length() == 0 ? "union" : ", union"); - } - EList<Property> redefinedProperties = property.getRedefinedProperties(); - if (redefinedProperties != null && !redefinedProperties.isEmpty()) { - for (Property p : redefinedProperties) { - sb.append(sb.length() == 0 ? UMLLabelInternationalization.getInstance().getLabel(p) : ", redefines " + UMLLabelInternationalization.getInstance().getLabel(p)); - } - } - if (sb.length() != 0) { - result = String.format(ALT_MODIFIER_FORMAT, sb.toString(), result); - } - } - } - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public Map<String, String> getMasks() { - return super.getMasks(); - } - - @Override - public Collection<String> getDefaultValue(IAdaptable element) { - View view = (View) element.getAdapter(View.class); - if (view == null) { - return super.getDefaultValue(element); - } - - if (view.getType() != null && view.getType().contains("multiplicity")) { - return Arrays.asList(ICustomAppearance.DISP_MULTIPLICITY, ILabelPreferenceConstants.DISP_DEFAULT_MULTIPLICITY); - } else if (view.getType() != null && view.getType().contains("role")) { - return Arrays.asList(ICustomAppearance.DISP_NAME, ICustomAppearance.DISP_VISIBILITY, ICustomAppearance.DISP_DERIVE); - } - - return super.getDefaultValue(element); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ConnectorLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ConnectorLabelParser.java deleted file mode 100644 index dba310651f9..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ConnectorLabelParser.java +++ /dev/null @@ -1,134 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.parser; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.papyrus.infra.emf.utils.EMFHelper; -import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; -import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; -import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; -import org.eclipse.uml2.uml.Connector; -import org.eclipse.uml2.uml.UMLPackage; - -/** - * Semantic Parser for {@link Connector} - */ -public class ConnectorLabelParser extends NamedElementLabelParser { - - /** The String format for displaying a {@link Connector} label with its name */ - protected static final String NAME_FORMAT = "%s"; - - /** The String format for displaying a {@link Connector} label with its type */ - protected static final String TYPE_FORMAT = "%s: %s"; - - /** - * {@inheritDoc} - */ - @Override - public String getPrintString(IAdaptable element, int flags) { - - Collection<String> maskValues = getMaskValues(element); - - if (maskValues.isEmpty()) { - return MaskedLabel; - } - - String result = ""; - EObject eObject = EMFHelper.getEObject(element); - - if ((eObject != null) && (eObject instanceof Connector)) { - - Connector connector = (Connector) eObject; - - // manage name - if (maskValues.contains(ICustomAppearance.DISP_NAME) && (connector.isSetName())) { - String name = UMLLabelInternationalization.getInstance().getLabel(connector); - result = String.format(NAME_FORMAT, name); - } - - // manage type - if (maskValues.contains(ICustomAppearance.DISP_TYPE)) { - String type = "<Undefined>"; - if (connector.getType() != null) { - type = UMLLabelInternationalization.getInstance().getLabel(connector.getType()); - } - - // If type is undefined only show "<Undefined>" when explicitly asked. - if (maskValues.contains(ILabelPreferenceConstants.DISP_UNDEFINED_TYPE) || !"<Undefined>".equals(type)) { - result = String.format(TYPE_FORMAT, result, type); - } - } - - } - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isAffectingEvent(Object event, int flags) { - - if (event instanceof Notification) { - Object feature = ((Notification) event).getFeature(); - if (feature instanceof EStructuralFeature) { - return UMLPackage.eINSTANCE.getTypedElement_Type().equals(feature) || super.isAffectingEvent(event, flags); - } - } - - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public List<EObject> getSemanticElementsBeingParsed(EObject element) { - List<EObject> semanticElementsBeingParsed = new ArrayList<EObject>(); - - if ((element != null) && (element instanceof Connector)) { - Connector semElement = (Connector) element; - - semanticElementsBeingParsed.add(semElement); - if (semElement.getType() != null) { - semanticElementsBeingParsed.add(semElement.getType()); - } - } - return semanticElementsBeingParsed; - } - - @Override - public Map<String, String> getMasks() { - Map<String, String> masks = new HashMap<String, String>(); - masks.put(ICustomAppearance.DISP_NAME, "Name"); - masks.put(ICustomAppearance.DISP_TYPE, "Type"); - masks.put(ILabelPreferenceConstants.DISP_UNDEFINED_TYPE, "Show <Undefined> type"); - return masks; - } - - @Override - public Collection<String> getDefaultValue(IAdaptable element) { - return Arrays.asList(ICustomAppearance.DISP_NAME, ICustomAppearance.DISP_TYPE); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ConstraintLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ConstraintLabelParser.java deleted file mode 100644 index 72ad2e82762..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ConstraintLabelParser.java +++ /dev/null @@ -1,240 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.parser; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; -import org.eclipse.gmf.runtime.emf.type.core.IClientContext; -import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; -import org.eclipse.papyrus.infra.core.resource.ModelSet; -import org.eclipse.papyrus.infra.core.services.ServiceException; -import org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper; -import org.eclipse.papyrus.infra.emf.utils.EMFHelper; -import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; -import org.eclipse.papyrus.infra.services.edit.context.TypeContext; -import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; -import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; -import org.eclipse.papyrus.uml.diagram.common.Activator; -import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; -import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; -import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil; -import org.eclipse.uml2.uml.Constraint; -import org.eclipse.uml2.uml.UMLPackage; -import org.eclipse.uml2.uml.ValueSpecification; - -/** - * Semantic Parser for {@link Constraint}. - */ -public class ConstraintLabelParser extends NamedElementLabelParser { - - /** The String format for displaying a Property label with derived modifier */ - protected static final String NAME_FORMAT = "%s"; - - /** The String format for displaying a Property with visibility */ - protected static final String SPECIFICATION_FORMAT = "%s{%s}"; - - /** - * {@inheritDoc} - */ - @Override - public String getEditString(IAdaptable element, int flags) { - - Collection<String> maskValues = getMaskValues(element); - - if (maskValues.isEmpty()) { - return MaskedLabel; - } - - String editString = ""; - - EObject eObject = EMFHelper.getEObject(element); - if ((eObject != null) && (eObject instanceof Constraint)) { - Constraint semElement = (Constraint) eObject; - - // edit name - if ((maskValues.contains(ICustomAppearance.DISP_NAME))) { - if (semElement.isSetName()) { - editString = UMLLabelInternationalization.getInstance().getLabel(semElement); - } - - // (try to) edit constraint specification - } else if ((maskValues.contains(ILabelPreferenceConstants.DISP_SPECIFICATION))) { - if (semElement.getSpecification() != null) { - editString = ValueSpecificationUtil.getSpecificationValue(semElement.getSpecification()); - if (editString == null) { - editString = ""; - } - } - } - } - return editString; - } - - /** - * {@inheritDoc} - */ - @Override - public String getPrintString(IAdaptable element, int flags) { - Collection<String> maskValues = getMaskValues(element); - - if (maskValues.isEmpty()) { - return MaskedLabel; - } - - String result = ""; - EObject eObject = EMFHelper.getEObject(element); - - if ((eObject != null) && (eObject instanceof Constraint)) { - - Constraint semElement = (Constraint) eObject; - - // manage name - if ((maskValues.contains(ICustomAppearance.DISP_NAME)) && (semElement.isSetName())) { - String name = UMLLabelInternationalization.getInstance().getLabel(semElement); - result = String.format(NAME_FORMAT, name); - } - - // manage specification - if ((maskValues.contains(ILabelPreferenceConstants.DISP_SPECIFICATION))) { - String spec = "<Undefined>"; - if (semElement.getSpecification() != null) { - spec = ValueSpecificationUtil.getSpecificationValue(semElement.getSpecification(), true); - if (spec == null || "".equals(spec)) { - spec = "<Undefined>"; - } - } - result = String.format(SPECIFICATION_FORMAT, result, spec); - } - } - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public ICommand getParseCommand(IAdaptable element, String newString, int flags) { - - Collection<String> maskValues = getMaskValues(element); - - ICommand command = UnexecutableCommand.INSTANCE; - SetRequest updateRequest = null; - - Constraint constraint = (Constraint) EMFHelper.getEObject(element); - if (constraint == null) { - return UnexecutableCommand.INSTANCE; - } - - // prepare set name request - if ((maskValues.contains(ICustomAppearance.DISP_NAME))) { - if(InternationalizationPreferencesUtils.getInternationalizationPreference(constraint) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(constraint)){ - final ModelSet modelSet = (ModelSet)constraint.eResource().getResourceSet(); - command = new EMFtoGMFCommandWrapper(UMLLabelInternationalization.getInstance().getSetLabelCommand(modelSet.getTransactionalEditingDomain(), constraint, newString, null)); - }else{ - updateRequest = new SetRequest(constraint, UMLPackage.eINSTANCE.getNamedElement_Name(), newString); - updateRequest.setLabel("Update Constraint Label"); - } - - // prepare set specification request - } else if ((maskValues.contains(ILabelPreferenceConstants.DISP_SPECIFICATION))) { - ValueSpecification spec = constraint.getSpecification(); - if (spec == null) { - return UnexecutableCommand.INSTANCE; - } - - ValueSpecification specCopy = EcoreUtil.copy(spec); - ValueSpecificationUtil.restoreSpecificationValue(specCopy, newString); - - updateRequest = new SetRequest(constraint, UMLPackage.eINSTANCE.getConstraint_Specification(), specCopy); - updateRequest.setLabel("Update Constraint Label"); - } - - try { - if (updateRequest != null) { - IClientContext context = TypeContext.getContext(constraint); - command = ElementEditServiceUtils.getEditServiceProvider(context).getEditService(constraint).getEditCommand(updateRequest); - } - - } catch (ServiceException e) { - Activator.log.error(e); - } - - - return command; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isAffectingEvent(Object event, int flags) { - - if (event instanceof Notification) { - Object feature = ((Notification) event).getFeature(); - if (feature instanceof EStructuralFeature) { - return UMLPackage.eINSTANCE.getValueSpecification__BooleanValue().equals(feature) || UMLPackage.eINSTANCE.getValueSpecification__IntegerValue().equals(feature) || UMLPackage.eINSTANCE.getValueSpecification__StringValue().equals(feature) - || UMLPackage.eINSTANCE.getValueSpecification__UnlimitedValue().equals(feature) || UMLPackage.eINSTANCE.getOpaqueExpression_Body().equals(feature) || UMLPackage.eINSTANCE.getOpaqueExpression_Language().equals(feature) - || super.isAffectingEvent(event, flags); - } - } - - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public List<EObject> getSemanticElementsBeingParsed(EObject element) { - List<EObject> semanticElementsBeingParsed = new ArrayList<EObject>(); - - if ((element != null) && (element instanceof Constraint)) { - Constraint semElement = (Constraint) element; - - semanticElementsBeingParsed.add(semElement); - if (semElement.getSpecification() != null) { - semanticElementsBeingParsed.add(semElement.getSpecification()); - } - } - return semanticElementsBeingParsed; - } - - /** - * {@inheritDoc} - */ - @Override - public Map<String, String> getMasks() { - Map<String, String> masks = new HashMap<String, String>(2); - masks.put(ICustomAppearance.DISP_NAME, "Name"); - masks.put(ILabelPreferenceConstants.DISP_SPECIFICATION, "Specification"); - return masks; - } - - @Override - public Collection<String> getDefaultValue(IAdaptable element) { - return Arrays.asList(ILabelPreferenceConstants.DISP_SPECIFICATION); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/DefaultParserHintAdapter.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/DefaultParserHintAdapter.java deleted file mode 100644 index 1bfb39d67da..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/DefaultParserHintAdapter.java +++ /dev/null @@ -1,43 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.parser; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter; -import org.eclipse.gmf.runtime.notation.Diagram; - -public class DefaultParserHintAdapter extends ParserHintAdapter { - - private Diagram diagram = null; - - /** Constructor */ - public DefaultParserHintAdapter(Diagram diagram, EObject element, String parserHint) { - super(element, parserHint); - this.diagram = diagram; - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("rawtypes") - @Override - public Object getAdapter(Class adapter) { - - if (adapter.equals(Diagram.class)) { - return diagram; - } - - return super.getAdapter(adapter); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/MultiplicityElementLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/MultiplicityElementLabelParser.java deleted file mode 100644 index 1f0d3ceb89e..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/MultiplicityElementLabelParser.java +++ /dev/null @@ -1,188 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.parser; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; -import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.papyrus.infra.emf.utils.EMFHelper; -import org.eclipse.papyrus.infra.gmfdiag.common.helper.MaskLabelHelper; -import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; -import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLMultiplicityElementUtil; -import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; -import org.eclipse.uml2.uml.MultiplicityElement; -import org.eclipse.uml2.uml.Property; -import org.eclipse.uml2.uml.UMLPackage; - -/** - * Semantic Parser for {@link MultiplicityElement} - */ -public class MultiplicityElementLabelParser implements IMaskManagedSemanticParser { - - /** The String format for displaying a {@link Property} label with multiplicity */ - protected static final String MULTIPLICITY_FORMAT = "[%s..%s]"; - - /** The String format for displaying a {@link Property} label with multiplicity */ - protected static final String MULTIPLICITY_FORMAT_ALT = "[%s]"; - - /** - * {@inheritDoc} - */ - @Override - public String getEditString(IAdaptable element, int flags) { - return getPrintString(element, flags); - } - - /** - * {@inheritDoc} - */ - @Override - public IParserEditStatus isValidEditString(IAdaptable element, String editString) { - return ParserEditStatus.UNEDITABLE_STATUS; - } - - /** - * {@inheritDoc} - */ - @Override - public ICommand getParseCommand(IAdaptable element, String newString, int flags) { - return UnexecutableCommand.INSTANCE; - } - - /** - * {@inheritDoc} - */ - @Override - public String getPrintString(IAdaptable element, int flags) { - - Collection<String> maskValues = getMaskValues(element); - - if (maskValues.isEmpty()) { - return MaskedLabel; - } - - String result = ""; - EObject eObject = EMFHelper.getEObject(element); - - if ((eObject != null) && (eObject instanceof MultiplicityElement)) { - - MultiplicityElement multElt = (MultiplicityElement) eObject; - - // manage multiplicity - if ((maskValues.contains(ICustomAppearance.DISP_MULTIPLICITY))) { - - // TODO : add a case for default with multiplicity not set. - String multiplicity = SysMLMultiplicityElementUtil.formatMultiplicity(multElt, maskValues); - if (multiplicity != null && !multiplicity.isEmpty()) { - result += " " + multiplicity; - } - } - } - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isAffectingEvent(Object event, int flags) { - - if (event instanceof Notification) { - Object feature = ((Notification) event).getFeature(); - if (feature instanceof EStructuralFeature) { - return EcorePackage.eINSTANCE.getEAnnotation_Details().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_LowerValue().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_UpperValue().equals(feature); - } - } - - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public IContentAssistProcessor getCompletionProcessor(IAdaptable element) { - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public List<EObject> getSemanticElementsBeingParsed(EObject element) { - List<EObject> semanticElementsBeingParsed = new ArrayList<EObject>(); - - if ((element != null) && (element instanceof MultiplicityElement)) { - MultiplicityElement semElement = (MultiplicityElement) element; - - semanticElementsBeingParsed.add(semElement); - if (semElement.getLowerValue() != null) { - semanticElementsBeingParsed.add(semElement.getLowerValue()); - } - if (semElement.getUpperValue() != null) { - semanticElementsBeingParsed.add(semElement.getUpperValue()); - } - } - return semanticElementsBeingParsed; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean areSemanticElementsAffected(EObject listener, Object notification) { - return true; - } - - @Override - public Map<String, String> getMasks() { - Map<String, String> masks = new HashMap<String, String>(); - masks.put(ICustomAppearance.DISP_MULTIPLICITY, "Multiplicity"); - masks.put(ILabelPreferenceConstants.DISP_DEFAULT_MULTIPLICITY, "Show default multiplicity"); - return masks; - } - - protected Collection<String> getMaskValues(IAdaptable element) { - View view = (View) element.getAdapter(View.class); - if (view == null) { - return getDefaultValue(element); - } - - Collection<String> result = MaskLabelHelper.getMaskValues(view); - if (result == null) { - result = getDefaultValue(element); - } - return result; - } - - @Override - public Collection<String> getDefaultValue(IAdaptable element) { - return Arrays.asList(ICustomAppearance.DISP_MULTIPLICITY); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/NamedElementLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/NamedElementLabelParser.java deleted file mode 100644 index da7801a0797..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/NamedElementLabelParser.java +++ /dev/null @@ -1,189 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.parser; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; -import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; -import org.eclipse.gmf.runtime.emf.type.core.IClientContext; -import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.papyrus.infra.core.resource.ModelSet; -import org.eclipse.papyrus.infra.core.services.ServiceException; -import org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper; -import org.eclipse.papyrus.infra.emf.utils.EMFHelper; -import org.eclipse.papyrus.infra.gmfdiag.common.helper.MaskLabelHelper; -import org.eclipse.papyrus.infra.services.edit.context.TypeContext; -import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; -import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; -import org.eclipse.papyrus.uml.diagram.common.Activator; -import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; -import org.eclipse.uml2.uml.NamedElement; -import org.eclipse.uml2.uml.UMLPackage; - -/** - * Semantic Parser for {@link NamedElement} name. - */ -public class NamedElementLabelParser implements IMaskManagedSemanticParser { - - /** - * {@inheritDoc} - */ - @Override - public String getEditString(IAdaptable element, int flags) { - String editString = ""; - - EObject eObject = EMFHelper.getEObject(element); - if ((eObject != null) && (eObject instanceof NamedElement)) { - NamedElement semElement = (NamedElement) eObject; - if (semElement.isSetName()) { - editString = UMLLabelInternationalization.getInstance().getLabel(semElement); - } - } - return editString; - } - - /** - * {@inheritDoc} - */ - @Override - public IParserEditStatus isValidEditString(IAdaptable element, String editString) { - return ParserEditStatus.EDITABLE_STATUS; - } - - /** - * {@inheritDoc} - */ - @Override - public ICommand getParseCommand(IAdaptable element, String newString, int flags) { - - ICommand command = UnexecutableCommand.INSTANCE; - - EObject objectToEdit = EMFHelper.getEObject(element); - if (objectToEdit == null) { - return UnexecutableCommand.INSTANCE; - } - - try { - if(InternationalizationPreferencesUtils.getInternationalizationPreference(objectToEdit) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML((NamedElement)objectToEdit)){ - final ModelSet modelSet = (ModelSet)objectToEdit.eResource().getResourceSet(); - command = new EMFtoGMFCommandWrapper(UMLLabelInternationalization.getInstance().getSetLabelCommand(modelSet.getTransactionalEditingDomain(), (NamedElement)objectToEdit, newString, null)); - }else{ - IClientContext context = TypeContext.getContext(objectToEdit); - command = ElementEditServiceUtils.getEditServiceProvider(context).getEditService(objectToEdit).getEditCommand(new SetRequest(objectToEdit, UMLPackage.eINSTANCE.getNamedElement_Name(), newString)); - } - } catch (ServiceException e) { - Activator.log.error(e); - } - - return command; - } - - /** - * {@inheritDoc} - */ - @Override - public String getPrintString(IAdaptable element, int flags) { - String result = ""; - EObject eObject = EMFHelper.getEObject(element); - - if (eObject instanceof NamedElement) { - return UMLLabelInternationalization.getInstance().getLabel((NamedElement) eObject); - } - - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isAffectingEvent(Object event, int flags) { - - if (event instanceof Notification) { - Object feature = ((Notification) event).getFeature(); - if (feature instanceof EStructuralFeature) { - return EcorePackage.eINSTANCE.getEAnnotation_Details().equals(feature) || UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature); - } - } - - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public IContentAssistProcessor getCompletionProcessor(IAdaptable element) { - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public List<EObject> getSemanticElementsBeingParsed(EObject element) { - List<EObject> semanticElementsBeingParsed = new ArrayList<EObject>(); - semanticElementsBeingParsed.add(element); - - return semanticElementsBeingParsed; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean areSemanticElementsAffected(EObject listener, Object notification) { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public Map<String, String> getMasks() { - return Collections.emptyMap(); - } - - protected Collection<String> getMaskValues(IAdaptable element) { - View view = (View) element.getAdapter(View.class); - if (view == null) { - return getDefaultValue(element); - } - - Collection<String> result = MaskLabelHelper.getMaskValues(view); - if (result == null) { - result = getDefaultValue(element); - } - return result; - } - - @Override - public Collection<String> getDefaultValue(IAdaptable element) { - return Collections.emptySet(); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/OperationLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/OperationLabelParser.java deleted file mode 100644 index 81ef14ccf77..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/OperationLabelParser.java +++ /dev/null @@ -1,236 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.parser; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.papyrus.infra.emf.utils.EMFHelper; -import org.eclipse.papyrus.infra.tools.util.StringHelper; -import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; -import org.eclipse.papyrus.uml.diagram.common.utils.ParameterLabelUtil; -import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; -import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; -import org.eclipse.uml2.uml.Operation; -import org.eclipse.uml2.uml.Parameter; -import org.eclipse.uml2.uml.ParameterDirectionKind; -import org.eclipse.uml2.uml.UMLPackage; -import org.eclipse.uml2.uml.VisibilityKind; - -/** - * Semantic Parser for {@link Operation} - */ -public class OperationLabelParser extends NamedElementLabelParser { - - /** Parameter parser */ - protected IMaskManagedSemanticParser parameterParser = new ParameterLabelParser(); - - /** The String format for displaying {@link Operation} label with visibility */ - protected static final String VISIBILITY_FORMAT = "%s "; - - /** The String format for displaying a {@link Operation} label with its name */ - protected static final String NAME_FORMAT = "%s%s(%s)"; - - /** The String format for displaying a {@link Operation} label with its type */ - protected static final String TYPE_FORMAT = "%s: %s"; - - /** The String format for displaying a {@link Operation} label with modifiers */ - protected static final String MODIFIER_FORMAT = "%s{%s}"; - - /** - * {@inheritDoc} - */ - @Override - public String getPrintString(IAdaptable element, int flags) { - - Collection<String> maskValues = getMaskValues(element); - - if (maskValues.isEmpty()) { - return MaskedLabel; - } - - String result = ""; - EObject eObject = EMFHelper.getEObject(element); - - if ((eObject != null) && (eObject instanceof Operation)) { - - Operation operation = (Operation) eObject; - - // manage visibility - if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) { - String visibility; - switch (operation.getVisibility().getValue()) { - case VisibilityKind.PACKAGE: - visibility = "~"; - break; - case VisibilityKind.PUBLIC: - visibility = "+"; - break; - case VisibilityKind.PROTECTED: - visibility = "#"; - break; - case VisibilityKind.PRIVATE: - visibility = "-"; - break; - default: - visibility = "+"; - break; - } - result = String.format(VISIBILITY_FORMAT, visibility); - } - - // manage name and parameters - if ((maskValues.contains(ICustomAppearance.DISP_NAME)) && (operation.isSetName())) { - String name = UMLLabelInternationalization.getInstance().getLabel(operation); - - StringBuffer params = new StringBuffer(); - for (Parameter parameter : operation.getOwnedParameters()) { - if (parameter.getDirection() != ParameterDirectionKind.RETURN_LITERAL) { - String currentParamLabel = ParameterLabelUtil.getPrintString(parameter, extractParameterMaskValues(maskValues)); - params.append(params.length() == 0 ? currentParamLabel : ", " + currentParamLabel); - } - } - - result = String.format(NAME_FORMAT, result, name, params); - } - - // manage type - if ((maskValues.contains(ICustomAppearance.DISP_TYPE))) { - String type = "<Undefined>"; - if (operation.getType() != null) { - type = UMLLabelInternationalization.getInstance().getLabel(operation.getType()); - } - - // If type is undefined only show "<Undefined>" when explicitly asked. - if ((maskValues.contains(ILabelPreferenceConstants.DISP_UNDEFINED_TYPE)) || (!"<Undefined>".equals(type))) { - result = String.format(TYPE_FORMAT, result, type); - } - } - - // manage modifier - if (maskValues.contains(ICustomAppearance.DISP_MODIFIERS)) { - StringBuffer sb = new StringBuffer(); - if (operation.isAbstract()) { - sb.append(sb.length() == 0 ? "abstract" : ", abstract"); - } - if (operation.isStatic()) { - sb.append(sb.length() == 0 ? "static" : ", static"); - } - if (operation.isUnique()) { - sb.append(sb.length() == 0 ? "unique" : ", unique"); - } - if (operation.isQuery()) { - sb.append(sb.length() == 0 ? "query" : ", query"); - } - if (operation.isLeaf()) { - sb.append(sb.length() == 0 ? "leaf" : ", leaf"); - } - - if (sb.length() != 0) { - result = String.format(MODIFIER_FORMAT, result, sb.toString()); - } - } - } - return result; - } - - private static Collection<String> extractParameterMaskValues(Collection<String> operationMaskValues) { - Set<String> result = new HashSet<String>(); - - for (String maskValue : operationMaskValues) { - if (maskValue.startsWith(ICustomAppearance.PARAMETERS_PREFIX)) { - String newValue = StringHelper.firstToLower(maskValue.replace(ICustomAppearance.PARAMETERS_PREFIX, "")); - result.add(newValue); - } - } - - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isAffectingEvent(Object event, int flags) { - - if (event instanceof Notification) { - Object feature = ((Notification) event).getFeature(); - if (feature instanceof EStructuralFeature) { - return UMLPackage.eINSTANCE.getNamedElement_Visibility().equals(feature) || UMLPackage.eINSTANCE.getTypedElement_Type().equals(feature) || UMLPackage.eINSTANCE.getBehavioralFeature_IsAbstract().equals(feature) - || UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature) || UMLPackage.eINSTANCE.getOperation_IsUnique().equals(feature) || UMLPackage.eINSTANCE.getOperation_IsQuery().equals(feature) - || UMLPackage.eINSTANCE.getRedefinableElement_IsLeaf().equals(feature) || parameterParser.isAffectingEvent(event, flags) || super.isAffectingEvent(event, flags); - } - } - - return false; - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - @Override - public List<EObject> getSemanticElementsBeingParsed(EObject element) { - List<EObject> semanticElementsBeingParsed = new ArrayList<EObject>(); - - if ((element != null) && (element instanceof Operation)) { - Operation semElement = (Operation) element; - - semanticElementsBeingParsed.add(semElement); - if (semElement.getType() != null) { - semanticElementsBeingParsed.add(semElement.getType()); - } - for (Parameter parameter : semElement.getOwnedParameters()) { - semanticElementsBeingParsed.addAll(parameterParser.getSemanticElementsBeingParsed(parameter)); - } - } - return semanticElementsBeingParsed; - } - - /** - * {@inheritDoc} - */ - @Override - public Map<String, String> getMasks() { - Map<String, String> masks = new HashMap<String, String>(5); - masks.put(ICustomAppearance.DISP_VISIBILITY, "Visibility"); - masks.put(ICustomAppearance.DISP_NAME, "Name"); - masks.put(ICustomAppearance.DISP_TYPE, "Type"); - masks.put(ILabelPreferenceConstants.DISP_UNDEFINED_TYPE, "Show <Undefined> type"); - masks.put(ICustomAppearance.DISP_MODIFIERS, "Modifiers"); - - masks.put(ICustomAppearance.DISP_PARAMETER_DIRECTION, "Parameter direction"); - masks.put(ICustomAppearance.DISP_PARAMETER_NAME, "Parameter name"); - masks.put(ICustomAppearance.DISP_PARAMETER_TYPE, "Parameter type"); - masks.put(ICustomAppearance.DISP_PARAMETER_MULTIPLICITY, "Parameter multiplicity"); - masks.put(ICustomAppearance.DISP_PARAMETER_DEFAULT, "Parameter default value"); - masks.put(ICustomAppearance.DISP_PARAMETER_MODIFIERS, "Parameter modifiers"); - return masks; - } - - @Override - public Collection<String> getDefaultValue(IAdaptable element) { - return Arrays.asList(ICustomAppearance.DISP_NAME, ICustomAppearance.DISP_TYPE, ICustomAppearance.DISP_PARAMETER_DIRECTION, ICustomAppearance.DISP_PARAMETER_NAME, ICustomAppearance.DISP_PARAMETER_TYPE); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ParameterLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ParameterLabelParser.java deleted file mode 100644 index 0c37c6078ba..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ParameterLabelParser.java +++ /dev/null @@ -1,143 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.parser; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.papyrus.infra.emf.utils.EMFHelper; -import org.eclipse.papyrus.uml.diagram.common.utils.ParameterLabelUtil; -import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; -import org.eclipse.uml2.uml.Parameter; -import org.eclipse.uml2.uml.UMLPackage; - -/** - * Semantic Parser for {@link Parameter} - */ -public class ParameterLabelParser extends NamedElementLabelParser { - - /** The String format for displaying a {@link Parameter} with direction */ - protected static final String DIRECTION_FORMAT = "%s %s"; - - /** The String format for displaying a {@link Parameter} label with its name */ - protected static final String NAME_FORMAT = "%s%s"; - - /** The String format for displaying a {@link Parameter} label with its type */ - protected static final String TYPE_FORMAT = "%s: %s"; - - /** The String format for displaying a {@link Parameter} label with its multiplicity */ - protected static final String MULTIPLICITY_FORMAT = "%s [%s..%s]"; - - /** The String format for displaying a {@link Parameter} label with its default value */ - protected static final String DEFAULT_VALUE_FORMAT = "%s= %s"; - - /** The String format for displaying a {@link Parameter} label with its modifiers */ - protected static final String MODIFIER_FORMAT = "%s{%s}"; - - /** - * {@inheritDoc} - */ - @Override - public String getPrintString(IAdaptable element, int flags) { - - Collection<String> maskValues = getMaskValues(element); - - if (maskValues.isEmpty()) { - return MaskedLabel; - } - - EObject eObject = EMFHelper.getEObject(element); - - if (eObject != null && eObject instanceof Parameter) { - Parameter parameter = (Parameter) eObject; - return ParameterLabelUtil.getPrintString(parameter, maskValues); - } - - return ""; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isAffectingEvent(Object event, int flags) { - - if (event instanceof Notification) { - Object feature = ((Notification) event).getFeature(); - if (feature instanceof EStructuralFeature) { - return UMLPackage.eINSTANCE.getTypedElement_Type().equals(feature) || UMLPackage.eINSTANCE.getParameter_Direction().equals(feature) || UMLPackage.eINSTANCE.getParameter_DefaultValue().equals(feature) - || UMLPackage.eINSTANCE.getParameter_IsStream().equals(feature) || UMLPackage.eINSTANCE.getParameter_IsException().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_IsOrdered().equals(feature) - || UMLPackage.eINSTANCE.getMultiplicityElement_IsUnique().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_LowerValue().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_UpperValue().equals(feature) - || super.isAffectingEvent(event, flags); - } - } - - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public List<EObject> getSemanticElementsBeingParsed(EObject element) { - List<EObject> semanticElementsBeingParsed = new ArrayList<EObject>(); - - if ((element != null) && (element instanceof Parameter)) { - Parameter semElement = (Parameter) element; - - semanticElementsBeingParsed.add(semElement); - if (semElement.getType() != null) { - semanticElementsBeingParsed.add(semElement.getType()); - } - if (semElement.getDefaultValue() != null) { - semanticElementsBeingParsed.add(semElement.getDefaultValue()); - } - if (semElement.getLowerValue() != null) { - semanticElementsBeingParsed.add(semElement.getLowerValue()); - } - if (semElement.getUpperValue() != null) { - semanticElementsBeingParsed.add(semElement.getUpperValue()); - } - } - return semanticElementsBeingParsed; - } - - /** - * {@inheritDoc} - */ - @Override - public Map<String, String> getMasks() { - Map<String, String> masks = new HashMap<String, String>(); - masks.put(ICustomAppearance.DISP_DIRECTION, "Direction"); - masks.put(ICustomAppearance.DISP_NAME, "Name"); - masks.put(ICustomAppearance.DISP_TYPE, "Type"); - masks.put(ICustomAppearance.DISP_MULTIPLICITY, "Multiplicity"); - masks.put(ICustomAppearance.DISP_DEFAULT_VALUE, "Default value"); - masks.put(ICustomAppearance.DISP_MODIFIERS, "Modifiers"); - return masks; - } - - @Override - public Collection<String> getDefaultValue(IAdaptable element) { - return Arrays.asList(ICustomAppearance.DISP_NAME); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/PropertyLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/PropertyLabelParser.java deleted file mode 100644 index 89ea3a8e1d7..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/PropertyLabelParser.java +++ /dev/null @@ -1,248 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.parser; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.papyrus.infra.emf.utils.EMFHelper; -import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; -import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLMultiplicityElementUtil; -import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; -import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; -import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil; -import org.eclipse.uml2.uml.Property; -import org.eclipse.uml2.uml.UMLPackage; -import org.eclipse.uml2.uml.ValueSpecification; -import org.eclipse.uml2.uml.VisibilityKind; - -/** - * Semantic Parser for {@link Property} - */ -public class PropertyLabelParser extends NamedElementLabelParser { - - /** The String format for displaying a {@link Property} with visibility */ - protected static final String VISIBILITY_FORMAT = "%s %s"; - - /** The String format for displaying a {@link Property} label with derived modifier */ - protected static final String DERIVED_FORMAT = "%s/"; - - /** The String format for displaying a {@link Property} label with its name */ - protected static final String NAME_FORMAT = "%s%s"; - - /** The String format for displaying a {@link Property} label with its type */ - protected static final String TYPE_FORMAT = "%s: %s"; - - /** The String format for displaying a {@link Property} label with multiplicity */ - protected static final String MULTIPLICITY_FORMAT = "%s [%s..%s]"; - - /** The String format for displaying a {@link Property} label with multiplicity */ - protected static final String MULTIPLICITY_FORMAT_ALT = "%s [%s]"; - - /** The String format for displaying a {@link Property} label with default value */ - protected static final String DEFAULT_VALUE_FORMAT = "%s= %s"; - - /** The String format for displaying a {@link Property} label with modifiers */ - protected static final String MODIFIER_FORMAT = "%s{%s}"; - - /** - * {@inheritDoc} - */ - @Override - public String getPrintString(IAdaptable element, int flags) { - - Collection<String> maskValues = getMaskValues(element); - - if (maskValues.isEmpty()) { - return MaskedLabel; - } - - String result = ""; - EObject eObject = EMFHelper.getEObject(element); - - if ((eObject != null) && (eObject instanceof Property)) { - - Property property = (Property) eObject; - - // manage visibility - if (maskValues.contains(ICustomAppearance.DISP_VISIBILITY)) { - String visibility; - switch (property.getVisibility().getValue()) { - case VisibilityKind.PACKAGE: - visibility = "~"; - break; - case VisibilityKind.PUBLIC: - visibility = "+"; - break; - case VisibilityKind.PROTECTED: - visibility = "#"; - break; - case VisibilityKind.PRIVATE: - visibility = "-"; - break; - default: - visibility = "+"; - break; - } - result = String.format(VISIBILITY_FORMAT, visibility, result); - } - - // manage derived modifier - if (maskValues.contains(ICustomAppearance.DISP_DERIVE) && (property.isDerived())) { - result = String.format(DERIVED_FORMAT, result); - } - - // manage name - if (maskValues.contains(ICustomAppearance.DISP_NAME) && (property.isSetName())) { - String name = UMLLabelInternationalization.getInstance().getLabel(property); - result = String.format(NAME_FORMAT, result, name); - } - - // manage type - if (maskValues.contains(ICustomAppearance.DISP_TYPE)) { - String type = "<Undefined>"; - if (property.getType() != null) { - type = UMLLabelInternationalization.getInstance().getLabel(property.getType()); - } - - // If type is undefined only show "<Undefined>" when explicitly asked. - if (maskValues.contains(ILabelPreferenceConstants.DISP_UNDEFINED_TYPE) || (!"<Undefined>".equals(type))) { - result = String.format(TYPE_FORMAT, result, type); - } - } - - // manage multiplicity - if (maskValues.contains(ICustomAppearance.DISP_MULTIPLICITY)) { - - // TODO : add a case for default with multiplicity not set. - String multiplicity = SysMLMultiplicityElementUtil.formatMultiplicity(property, maskValues); - if (multiplicity != null && !multiplicity.isEmpty()) { - result += " " + multiplicity; - } - } - - // manage default value - if (maskValues.contains(ICustomAppearance.DISP_DEFAULT_VALUE) && property.getDefaultValue() != null) { - ValueSpecification valueSpecification = property.getDefaultValue(); - result = String.format(DEFAULT_VALUE_FORMAT, result, ValueSpecificationUtil.getSpecificationValue(valueSpecification, true)); - } - - // manage modifier - if (maskValues.contains(ICustomAppearance.DISP_MODIFIERS)) { - StringBuffer sb = new StringBuffer(); - if (property.isReadOnly()) { - sb.append(sb.length() == 0 ? "readOnly" : ", readOnly"); - } - if (property.isOrdered()) { - sb.append(sb.length() == 0 ? "ordered" : ", ordered"); - } - if (property.isUnique()) { - sb.append(sb.length() == 0 ? "unique" : ", unique"); - } - if (property.isDerivedUnion()) { - sb.append(sb.length() == 0 ? "union" : ", union"); - } - EList<Property> redefinedProperties = property.getRedefinedProperties(); - if (redefinedProperties != null && !redefinedProperties.isEmpty()) { - for (Property p : redefinedProperties) { - sb.append(sb.length() == 0 ? UMLLabelInternationalization.getInstance().getLabel(p) : ", redefines " + UMLLabelInternationalization.getInstance().getLabel(p)); - } - } - if (sb.length() != 0) { - result = String.format(MODIFIER_FORMAT, result, sb.toString()); - } - } - } - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isAffectingEvent(Object event, int flags) { - - if (event instanceof Notification) { - Object feature = ((Notification) event).getFeature(); - - if (feature instanceof EStructuralFeature) { // UMLPackage.eINSTANCE.getLiteralString_Value().equals(feature) || - return UMLPackage.eINSTANCE.getTypedElement_Type().equals(feature) || UMLPackage.eINSTANCE.getInstanceValue_Instance().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_IsOrdered().equals(feature) - || UMLPackage.eINSTANCE.getMultiplicityElement_IsUnique().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_LowerValue().equals(feature) || UMLPackage.eINSTANCE.getMultiplicityElement_UpperValue().equals(feature) - || UMLPackage.eINSTANCE.getStructuralFeature_IsReadOnly().equals(feature) || UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature) || UMLPackage.eINSTANCE.getProperty_IsDerived().equals(feature) - || UMLPackage.eINSTANCE.getProperty_IsDerivedUnion().equals(feature) || UMLPackage.eINSTANCE.getProperty_RedefinedProperty().equals(feature) || super.isAffectingEvent(event, flags); - } - } - - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public List<EObject> getSemanticElementsBeingParsed(EObject element) { - List<EObject> semanticElementsBeingParsed = new ArrayList<EObject>(); - - if ((element != null) && (element instanceof Property)) { - Property semElement = (Property) element; - - semanticElementsBeingParsed.add(semElement); - if (semElement.getType() != null) { - semanticElementsBeingParsed.add(semElement.getType()); - } - if (semElement.getLowerValue() != null) { - semanticElementsBeingParsed.add(semElement.getLowerValue()); - } - if (semElement.getUpperValue() != null) { - semanticElementsBeingParsed.add(semElement.getUpperValue()); - } - if (semElement.getDefaultValue() != null) { - semanticElementsBeingParsed.add(semElement.getDefaultValue()); - } - } - return semanticElementsBeingParsed; - } - - /** - * {@inheritDoc} - */ - @Override - public Map<String, String> getMasks() { - Map<String, String> masks = new HashMap<String, String>(); - masks.put(ICustomAppearance.DISP_VISIBILITY, "Visibility"); - masks.put(ICustomAppearance.DISP_DERIVE, "Is Derived"); - masks.put(ICustomAppearance.DISP_NAME, "Name"); - masks.put(ICustomAppearance.DISP_TYPE, "Type"); - masks.put(ILabelPreferenceConstants.DISP_UNDEFINED_TYPE, "Show <Undefined> type"); - masks.put(ICustomAppearance.DISP_MULTIPLICITY, "Multiplicity"); - masks.put(ILabelPreferenceConstants.DISP_DEFAULT_MULTIPLICITY, "Show default multiplicity"); - masks.put(ICustomAppearance.DISP_DEFAULT_VALUE, "Default Value"); - masks.put(ICustomAppearance.DISP_MODIFIERS, "Modifiers"); - return masks; - } - - @Override - public Collection<String> getDefaultValue(IAdaptable element) { - return Arrays.asList(ICustomAppearance.DISP_NAME, ICustomAppearance.DISP_TYPE, ICustomAppearance.DISP_MULTIPLICITY, ILabelPreferenceConstants.DISP_UNDEFINED_TYPE); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ReceptionLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ReceptionLabelParser.java deleted file mode 100644 index a5fbfaef55c..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/ReceptionLabelParser.java +++ /dev/null @@ -1,135 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.parser; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.papyrus.infra.emf.utils.EMFHelper; -import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; -import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; -import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; -import org.eclipse.uml2.uml.Reception; -import org.eclipse.uml2.uml.UMLPackage; - -/** - * Semantic Parser for {@link Reception} - */ -public class ReceptionLabelParser extends NamedElementLabelParser implements IMaskManagedSemanticParser { - - /** The String format for displaying a Property with visibility */ - protected static final String PREFIX = "\u00ABsignal\u00BB "; - - /** The String format for displaying a Property label with its name */ - protected static final String NAME_FORMAT = "%s%s"; - - /** The String format for displaying a Property label with its type */ - protected static final String TYPE_FORMAT = "%s: %s"; - - /** - * {@inheritDoc} - */ - @Override - public String getPrintString(IAdaptable element, int flags) { - - Collection<String> maskValues = getMaskValues(element); - - if (maskValues.isEmpty()) { - return MaskedLabel; - } - - String result = PREFIX; - EObject eObject = EMFHelper.getEObject(element); - - if ((eObject != null) && (eObject instanceof Reception)) { - - Reception reception = (Reception) eObject; - - // manage name - if (maskValues.contains(ICustomAppearance.DISP_NAME) && reception.isSetName()) { - String name = UMLLabelInternationalization.getInstance().getLabel(reception); - result = String.format(NAME_FORMAT, result, name); - } - - // manage signal - if (maskValues.contains(ILabelPreferenceConstants.DISP_SIGNAL)) { - String type = "<Undefined>"; - if (reception.getSignal() != null) { - type = UMLLabelInternationalization.getInstance().getLabel(reception.getSignal()); - } - result = String.format(TYPE_FORMAT, result, type); - } - } - - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isAffectingEvent(Object event, int flags) { - - if (event instanceof Notification) { - Object feature = ((Notification) event).getFeature(); - if (feature instanceof EStructuralFeature) { - return UMLPackage.eINSTANCE.getReception_Signal().equals(feature) || super.isAffectingEvent(event, flags); - } - } - - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public List<EObject> getSemanticElementsBeingParsed(EObject element) { - List<EObject> semanticElementsBeingParsed = new ArrayList<EObject>(); - - if ((element != null) && (element instanceof Reception)) { - Reception semElement = (Reception) element; - - semanticElementsBeingParsed.add(semElement); - if (semElement.getSignal() != null) { - semanticElementsBeingParsed.add(semElement.getSignal()); - } - } - return semanticElementsBeingParsed; - } - - /** - * {@inheritDoc} - */ - @Override - public Map<String, String> getMasks() { - Map<String, String> masks = new HashMap<String, String>(); - masks.put(ICustomAppearance.DISP_NAME, "Name"); - masks.put(ILabelPreferenceConstants.DISP_SIGNAL, "Signal"); - return masks; - } - - @Override - public Collection<String> getDefaultValue(IAdaptable element) { - return Arrays.asList(ICustomAppearance.DISP_NAME, ILabelPreferenceConstants.DISP_SIGNAL); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/SlotLabelParser.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/SlotLabelParser.java deleted file mode 100644 index f1b973ad083..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/parser/SlotLabelParser.java +++ /dev/null @@ -1,151 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.parser; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; -import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; -import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.papyrus.infra.emf.utils.EMFHelper; -import org.eclipse.uml2.uml.InstanceValue; -import org.eclipse.uml2.uml.Slot; -import org.eclipse.uml2.uml.UMLPackage; -import org.eclipse.uml2.uml.ValueSpecification; - -/** - * Semantic Parser for {@link Slot} - */ -public class SlotLabelParser implements ISemanticParser { - - /** - * {@inheritDoc} - */ - @Override - public String getEditString(IAdaptable element, int flags) { - return getPrintString(element, flags); - } - - /** - * {@inheritDoc} - */ - @Override - public IParserEditStatus isValidEditString(IAdaptable element, String editString) { - return ParserEditStatus.UNEDITABLE_STATUS; - } - - /** - * {@inheritDoc} - */ - @Override - public ICommand getParseCommand(IAdaptable element, String newString, int flags) { - return UnexecutableCommand.INSTANCE; - } - - /** - * {@inheritDoc} - */ - @Override - public String getPrintString(IAdaptable element, int flags) { - String result = ""; - EObject eObject = EMFHelper.getEObject(element); - - if (eObject instanceof Slot) { - Slot slot = (Slot) eObject; - result = "<UNDEFINED>"; - - if (slot.getDefiningFeature() != null) { - - // Add defining feature - result = slot.getDefiningFeature().getName(); - - // Add values - if (!slot.getValues().isEmpty()) { - - String values = ""; - Iterator<ValueSpecification> iter = slot.getValues().iterator(); - while (iter.hasNext()) { - ValueSpecification currentSpecification = iter.next(); - - String currentValue = currentSpecification.stringValue(); - if ((currentSpecification instanceof InstanceValue) && ((InstanceValue) currentSpecification).getInstance() != null) { - currentValue = ((InstanceValue) currentSpecification).getInstance().getName(); - } - - values = values + currentValue; - if (iter.hasNext()) { - result = result + ", "; - } - } - - result = result + ": " + values; - } - } - } - - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isAffectingEvent(Object event, int flags) { - if (event instanceof Notification) { - Object feature = ((Notification) event).getFeature(); - if (feature instanceof EStructuralFeature) { - return UMLPackage.eINSTANCE.getSlot_DefiningFeature().equals(feature); - } - } - - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public IContentAssistProcessor getCompletionProcessor(IAdaptable element) { - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public List<EObject> getSemanticElementsBeingParsed(EObject element) { - List<EObject> semanticElementsBeingParsed = new ArrayList<EObject>(); - semanticElementsBeingParsed.add(element); - - return semanticElementsBeingParsed; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean areSemanticElementsAffected(EObject listener, Object notification) { - return true; - } - -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/utils/AssociationViewUtils.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/utils/AssociationViewUtils.java deleted file mode 100644 index a9be2ba4980..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/utils/AssociationViewUtils.java +++ /dev/null @@ -1,81 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.utils; - -import org.eclipse.gmf.runtime.notation.EObjectValueStyle; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.uml2.uml.Property; - -/** - * Utility class for Association graphical end - property mapping. - */ -public class AssociationViewUtils { - - /** ID for the source end - property mapping of an association */ - public static final String SEMANTIC_SOURCE_END = "semantic_source_end"; - - /** ID for the target end - property mapping of an association */ - public static final String SEMANTIC_TARGET_END = "semantic_target_end"; - - /** - * Get the semantic end from the source of an edge representing an Association. - * - * @param view - * the Association view. - * @return the Property corresponding to the source of the graphical end. - */ - public static Property getSourceSemanticEnd(View view) { - EObjectValueStyle semanticStyle = (EObjectValueStyle) view.getNamedStyle(NotationPackage.eINSTANCE.getEObjectValueStyle(), SEMANTIC_SOURCE_END); - return semanticStyle == null ? null : (Property) semanticStyle.getEObjectValue(); - } - - /** - * Get the semantic end from the target of an edge representing an Association. - * - * @param view - * the Association view. - * @return the Property corresponding to the target of the graphical end. - */ - public static Property getTargetSemanticEnd(View view) { - EObjectValueStyle semanticStyle = (EObjectValueStyle) view.getNamedStyle(NotationPackage.eINSTANCE.getEObjectValueStyle(), SEMANTIC_TARGET_END); - return semanticStyle == null ? null : (Property) semanticStyle.getEObjectValue(); - } - - /** - * Set the semantic end for the source of an edge representing an Association. - * - * @param view - * the Association view. - * @param end - * the Property corresponding to the source of the graphical end. - */ - public static void setSourceSemanticEnd(View view, Property end) { - EObjectValueStyle semanticStyle = (EObjectValueStyle) view.getNamedStyle(NotationPackage.eINSTANCE.getEObjectValueStyle(), SEMANTIC_SOURCE_END); - semanticStyle.setEObjectValue(end); - } - - /** - * Set the semantic end for the target of an edge representing an Association. - * - * @param view - * the Association view. - * @param end - * the Property corresponding to the target of the graphical end. - */ - public static void setTargetSemanticEnd(View view, Property end) { - EObjectValueStyle semanticStyle = (EObjectValueStyle) view.getNamedStyle(NotationPackage.eINSTANCE.getEObjectValueStyle(), SEMANTIC_TARGET_END); - semanticStyle.setEObjectValue(end); - } -} diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/utils/ParameterLabelUtil.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/utils/ParameterLabelUtil.java deleted file mode 100644 index edb3268fffb..00000000000 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-uml/org/eclipse/papyrus/uml/diagram/common/utils/ParameterLabelUtil.java +++ /dev/null @@ -1,136 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.utils; - -import java.util.Collection; - -import org.eclipse.papyrus.sysml.diagram.common.preferences.ILabelPreferenceConstants; -import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLMultiplicityElementUtil; -import org.eclipse.papyrus.uml.diagram.common.parser.IMaskManagedSemanticParser; -import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization; -import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; -import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil; -import org.eclipse.uml2.uml.Parameter; -import org.eclipse.uml2.uml.ParameterDirectionKind; -import org.eclipse.uml2.uml.ValueSpecification; - - -public class ParameterLabelUtil { - - /** The String format for displaying a {@link Parameter} with direction */ - protected static final String DIRECTION_FORMAT = "%s %s"; - - /** The String format for displaying a {@link Parameter} label with its name */ - protected static final String NAME_FORMAT = "%s%s"; - - /** The String format for displaying a {@link Parameter} label with its type */ - protected static final String TYPE_FORMAT = "%s: %s"; - - /** The String format for displaying a {@link Parameter} label with its multiplicity */ - protected static final String MULTIPLICITY_FORMAT = "%s [%s..%s]"; - - /** The String format for displaying a {@link Parameter} label with its default value */ - protected static final String DEFAULT_VALUE_FORMAT = "%s= %s"; - - /** The String format for displaying a {@link Parameter} label with its modifiers */ - protected static final String MODIFIER_FORMAT = "%s{%s}"; - - public static String getPrintString(Parameter parameter, Collection<String> displayValue) { - if (displayValue.isEmpty()) { - return IMaskManagedSemanticParser.MaskedLabel; - } - - String result = ""; - - if (parameter != null) { - - // manage direction - if (displayValue.contains(ICustomAppearance.DISP_DIRECTION) || displayValue.contains(ICustomAppearance.DISP_PARAMETER_DIRECTION)) { - String direction; - switch (parameter.getDirection().getValue()) { - case ParameterDirectionKind.IN: - direction = "in"; - break; - case ParameterDirectionKind.OUT: - direction = "out"; - break; - case ParameterDirectionKind.INOUT: - direction = "inout"; - break; - case ParameterDirectionKind.RETURN: - direction = "return"; - break; - default: - direction = "in"; - break; - } - result = String.format(DIRECTION_FORMAT, direction, result); - } - - // manage name - if ((displayValue.contains(ICustomAppearance.DISP_NAME) || displayValue.contains(ICustomAppearance.DISP_PARAMETER_NAME)) && (parameter.isSetName())) { - String name = UMLLabelInternationalization.getInstance().getLabel(parameter); - result = String.format(NAME_FORMAT, result, name); - } - - // manage type - if (displayValue.contains(ICustomAppearance.DISP_TYPE) || displayValue.contains(ICustomAppearance.DISP_PARAMETER_TYPE)) { - String type = "<Undefined>"; - if (parameter.getType() != null) { - type = UMLLabelInternationalization.getInstance().getLabel(parameter.getType()); - } - - // If type is undefined only show "<Undefined>" when explicitly asked. - if (displayValue.contains(ILabelPreferenceConstants.DISP_UNDEFINED_TYPE) || (!"<Undefined>".equals(type))) { - result = String.format(TYPE_FORMAT, result, type); - } - } - - // manage multiplicity - String multiplicity = SysMLMultiplicityElementUtil.formatMultiplicity(parameter, displayValue); - if (multiplicity != null && !multiplicity.isEmpty()) { - result += " " + multiplicity; - } - - // manage default value - if ((displayValue.contains(ICustomAppearance.DISP_PARAMETER_DEFAULT) || displayValue.contains(ICustomAppearance.DISP_DEFAULT_VALUE)) && ((parameter.getDefaultValue() != null))) { - ValueSpecification valueSpecification = parameter.getDefaultValue(); - result = String.format(DEFAULT_VALUE_FORMAT, result, ValueSpecificationUtil.getSpecificationValue(valueSpecification, true)); - } - - // manage modifier - if (displayValue.contains(ICustomAppearance.DISP_PARAMETER_MODIFIERS) || displayValue.contains(ICustomAppearance.DISP_MODIFIERS)) { - StringBuffer sb = new StringBuffer(); - if (parameter.isOrdered()) { - sb.append(sb.length() == 0 ? "ordered" : ", ordered"); - } - if (parameter.isUnique()) { - sb.append(sb.length() == 0 ? "unique" : ", unique"); - } - if (parameter.isStream()) { - sb.append(sb.length() == 0 ? "stream" : ", stream"); - } - if (parameter.isException()) { - sb.append(sb.length() == 0 ? "exception" : ", exception"); - } - if (sb.length() != 0) { - result = String.format(MODIFIER_FORMAT, result, sb.toString()); - } - } - - } - return result; - } - -} |