diff options
author | Quentin Le Menez | 2018-01-09 10:09:46 +0000 |
---|---|---|
committer | Quentin Le Menez | 2018-01-09 13:18:15 +0000 |
commit | d98116b5b376f18b6cf626ba4158a35fe9a4a64e (patch) | |
tree | 4458c9c5ada0a216b385813a56ea9a9b8c7b6509 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common | |
parent | 453e99bc2dcbd5fabad100f9d0d5f682013c3b19 (diff) | |
download | org.eclipse.papyrus-d98116b5b376f18b6cf626ba4158a35fe9a4a64e.tar.gz org.eclipse.papyrus-d98116b5b376f18b6cf626ba4158a35fe9a4a64e.tar.xz org.eclipse.papyrus-d98116b5b376f18b6cf626ba4158a35fe9a4a64e.zip |
Bug 515367 - [releng] Uniformization of the end of lines to Unix standard
- Format the EOL of all the files matched by: grep -rIUs . | xargs -Ifile dos2unix -k 'file'
Change-Id: I5c41d540a9a67b50de9b912ab35e16cc9a912961
Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common')
58 files changed, 6918 insertions, 6918 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF index b23b68ae74e..e1a4c206ec3 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF @@ -1,95 +1,95 @@ -Manifest-Version: 1.0
-Export-Package: org.eclipse.papyrus.uml.diagram.common,
- org.eclipse.papyrus.uml.diagram.common.actions,
- org.eclipse.papyrus.uml.diagram.common.actions.handlers,
- org.eclipse.papyrus.uml.diagram.common.canonical,
- org.eclipse.papyrus.uml.diagram.common.commands,
- org.eclipse.papyrus.uml.diagram.common.dialogs,
- org.eclipse.papyrus.uml.diagram.common.directedit,
- org.eclipse.papyrus.uml.diagram.common.dragtracker,
- org.eclipse.papyrus.uml.diagram.common.draw2d,
- org.eclipse.papyrus.uml.diagram.common.draw2d.anchors,
- org.eclipse.papyrus.uml.diagram.common.editparts,
- org.eclipse.papyrus.uml.diagram.common.editpolicies,
- org.eclipse.papyrus.uml.diagram.common.figure.edge,
- org.eclipse.papyrus.uml.diagram.common.figure.layout,
- org.eclipse.papyrus.uml.diagram.common.figure.node,
- org.eclipse.papyrus.uml.diagram.common.handlers,
- org.eclipse.papyrus.uml.diagram.common.helper,
- org.eclipse.papyrus.uml.diagram.common.keyword,
- org.eclipse.papyrus.uml.diagram.common.layout,
- org.eclipse.papyrus.uml.diagram.common.listeners,
- org.eclipse.papyrus.uml.diagram.common.locator,
- org.eclipse.papyrus.uml.diagram.common.parser,
- org.eclipse.papyrus.uml.diagram.common.parser.assist,
- org.eclipse.papyrus.uml.diagram.common.parser.custom,
- org.eclipse.papyrus.uml.diagram.common.parser.lookup,
- org.eclipse.papyrus.uml.diagram.common.parser.packageimport,
- org.eclipse.papyrus.uml.diagram.common.parser.stereotype,
- org.eclipse.papyrus.uml.diagram.common.parser.structural,
- org.eclipse.papyrus.uml.diagram.common.part,
- org.eclipse.papyrus.uml.diagram.common.preferences,
- org.eclipse.papyrus.uml.diagram.common.providers,
- org.eclipse.papyrus.uml.diagram.common.providers.assistant,
- org.eclipse.papyrus.uml.diagram.common.resourceupdate,
- org.eclipse.papyrus.uml.diagram.common.service,
- org.eclipse.papyrus.uml.diagram.common.service.palette,
- org.eclipse.papyrus.uml.diagram.common.sheet,
- org.eclipse.papyrus.uml.diagram.common.stereotype,
- org.eclipse.papyrus.uml.diagram.common.stereotype.display.command,
- org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper,
- org.eclipse.papyrus.uml.diagram.common.stereotype.migration,
- org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies,
- org.eclipse.papyrus.uml.diagram.common.strategy.paste,
- org.eclipse.papyrus.uml.diagram.common.ui.dialogs,
- org.eclipse.papyrus.uml.diagram.common.ui.helper,
- org.eclipse.papyrus.uml.diagram.common.util,
- org.eclipse.papyrus.uml.diagram.common.util.functions,
- org.eclipse.papyrus.uml.diagram.common.util.predicates,
- org.eclipse.papyrus.uml.diagram.internal.common.services;x-internal:=true
-Bundle-ActivationPolicy: lazy
-Bundle-ClassPath: .
-Bundle-Name: %pluginName
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Require-Bundle: org.eclipse.papyrus.extensionpoints.editors;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
- org.eclipse.papyrus.uml.tools.utils;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
- org.eclipse.gmf.runtime.diagram.ui.properties;bundle-version="[1.7.0,2.0.0)";visibility:=reexport,
- org.eclipse.papyrus.uml.diagram.wizards;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.papyrus.editor;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.gmf.runtime.diagram.ui.render;bundle-version="[1.7.0,2.0.0)",
- org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.gmf.runtime.diagram.ui.actions;bundle-version="[1.7.0,2.0.0)",
- org.eclipse.papyrus.infra.gmfdiag.dnd;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.papyrus.uml.diagram.navigation;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.gmf.runtime.diagram.ui.printing;bundle-version="[1.7.0,2.0.0)",
- org.eclipse.gmf.runtime.diagram.ui.providers.ide;bundle-version="[1.7.0,2.0.0)",
- org.eclipse.papyrus.infra.services.resourceloading;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.papyrus.uml.profile;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.papyrus.infra.emf.appearance;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.emf.readonly;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.papyrus.infra.services.localizer;bundle-version="[2.0.0,3.0.0)",
+Manifest-Version: 1.0 +Export-Package: org.eclipse.papyrus.uml.diagram.common, + org.eclipse.papyrus.uml.diagram.common.actions, + org.eclipse.papyrus.uml.diagram.common.actions.handlers, + org.eclipse.papyrus.uml.diagram.common.canonical, + org.eclipse.papyrus.uml.diagram.common.commands, + org.eclipse.papyrus.uml.diagram.common.dialogs, + org.eclipse.papyrus.uml.diagram.common.directedit, + org.eclipse.papyrus.uml.diagram.common.dragtracker, + org.eclipse.papyrus.uml.diagram.common.draw2d, + org.eclipse.papyrus.uml.diagram.common.draw2d.anchors, + org.eclipse.papyrus.uml.diagram.common.editparts, + org.eclipse.papyrus.uml.diagram.common.editpolicies, + org.eclipse.papyrus.uml.diagram.common.figure.edge, + org.eclipse.papyrus.uml.diagram.common.figure.layout, + org.eclipse.papyrus.uml.diagram.common.figure.node, + org.eclipse.papyrus.uml.diagram.common.handlers, + org.eclipse.papyrus.uml.diagram.common.helper, + org.eclipse.papyrus.uml.diagram.common.keyword, + org.eclipse.papyrus.uml.diagram.common.layout, + org.eclipse.papyrus.uml.diagram.common.listeners, + org.eclipse.papyrus.uml.diagram.common.locator, + org.eclipse.papyrus.uml.diagram.common.parser, + org.eclipse.papyrus.uml.diagram.common.parser.assist, + org.eclipse.papyrus.uml.diagram.common.parser.custom, + org.eclipse.papyrus.uml.diagram.common.parser.lookup, + org.eclipse.papyrus.uml.diagram.common.parser.packageimport, + org.eclipse.papyrus.uml.diagram.common.parser.stereotype, + org.eclipse.papyrus.uml.diagram.common.parser.structural, + org.eclipse.papyrus.uml.diagram.common.part, + org.eclipse.papyrus.uml.diagram.common.preferences, + org.eclipse.papyrus.uml.diagram.common.providers, + org.eclipse.papyrus.uml.diagram.common.providers.assistant, + org.eclipse.papyrus.uml.diagram.common.resourceupdate, + org.eclipse.papyrus.uml.diagram.common.service, + org.eclipse.papyrus.uml.diagram.common.service.palette, + org.eclipse.papyrus.uml.diagram.common.sheet, + org.eclipse.papyrus.uml.diagram.common.stereotype, + org.eclipse.papyrus.uml.diagram.common.stereotype.display.command, + org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper, + org.eclipse.papyrus.uml.diagram.common.stereotype.migration, + org.eclipse.papyrus.uml.diagram.common.stereotype.migration.editpolicies, + org.eclipse.papyrus.uml.diagram.common.strategy.paste, + org.eclipse.papyrus.uml.diagram.common.ui.dialogs, + org.eclipse.papyrus.uml.diagram.common.ui.helper, + org.eclipse.papyrus.uml.diagram.common.util, + org.eclipse.papyrus.uml.diagram.common.util.functions, + org.eclipse.papyrus.uml.diagram.common.util.predicates, + org.eclipse.papyrus.uml.diagram.internal.common.services;x-internal:=true +Bundle-ActivationPolicy: lazy +Bundle-ClassPath: . +Bundle-Name: %pluginName +Bundle-Localization: plugin +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.papyrus.extensionpoints.editors;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, + org.eclipse.papyrus.uml.tools.utils;bundle-version="[3.0.0,4.0.0)";visibility:=reexport, + org.eclipse.gmf.runtime.diagram.ui.properties;bundle-version="[1.7.0,2.0.0)";visibility:=reexport, + org.eclipse.papyrus.uml.diagram.wizards;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.editor;bundle-version="[2.0.0,3.0.0)", + org.eclipse.gmf.runtime.diagram.ui.render;bundle-version="[1.7.0,2.0.0)", + org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="[3.0.0,4.0.0)", + org.eclipse.gmf.runtime.diagram.ui.actions;bundle-version="[1.7.0,2.0.0)", + org.eclipse.papyrus.infra.gmfdiag.dnd;bundle-version="[1.2.0,2.0.0)", + org.eclipse.papyrus.uml.diagram.navigation;bundle-version="[2.0.0,3.0.0)", + org.eclipse.gmf.runtime.diagram.ui.printing;bundle-version="[1.7.0,2.0.0)", + org.eclipse.gmf.runtime.diagram.ui.providers.ide;bundle-version="[1.7.0,2.0.0)", + org.eclipse.papyrus.infra.services.resourceloading;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.uml.profile;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.emf.appearance;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, + org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="[2.0.0,3.0.0)", + org.eclipse.papyrus.infra.emf.readonly;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.services.localizer;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration;bundle-version="[3.0.0,4.0.0)";visibility:=reexport, - org.eclipse.papyrus.uml.modelrepair;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.gmfdiag.menu;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
- org.eclipse.e4.ui.css.core;bundle-version="[0.11.0,1.0.0)",
- org.eclipse.papyrus.infra.gmfdiag.canonical;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.gmfdiag.expansion;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.uml.appearance;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.hyperlink;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.nebula.widgets.richtext;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.papyrus.uml.internationalization.edit;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.papyrus.uml.internationalization.utils;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.papyrus.uml.modelrepair;bundle-version="[2.0.0,3.0.0)", + org.eclipse.papyrus.infra.gmfdiag.menu;bundle-version="[1.2.0,2.0.0)";visibility:=reexport, + org.eclipse.e4.ui.css.core;bundle-version="[0.11.0,1.0.0)", + org.eclipse.papyrus.infra.gmfdiag.canonical;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, + org.eclipse.papyrus.infra.gmfdiag.expansion;bundle-version="[2.0.0,3.0.0)", + org.eclipse.papyrus.uml.appearance;bundle-version="[2.0.0,3.0.0)", + org.eclipse.papyrus.infra.hyperlink;bundle-version="[3.0.0,4.0.0)", + org.eclipse.nebula.widgets.richtext;bundle-version="[1.0.0,2.0.0)", + org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)", + org.eclipse.papyrus.uml.internationalization.edit;bundle-version="[1.0.0,2.0.0)", + org.eclipse.papyrus.uml.internationalization.utils;bundle-version="[1.0.0,2.0.0)", + org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)", org.eclipse.papyrus.infra.internationalization.common;bundle-version="[1.0.0,2.0.0)";visibility:=reexport, org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[3.0.0,4.0.0)" -Bundle-Vendor: %providerName
-Bundle-Version: 3.1.0.qualifier
-Eclipse-BuddyPolicy: dependent
-Bundle-Activator: org.eclipse.papyrus.uml.diagram.common.Activator
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.uml.diagram.common;singleton:=true
+Bundle-Vendor: %providerName +Bundle-Version: 3.1.0.qualifier +Eclipse-BuddyPolicy: dependent +Bundle-Activator: org.eclipse.papyrus.uml.diagram.common.Activator +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: org.eclipse.papyrus.uml.diagram.common;singleton:=true Import-Package: com.google.common.base;version="21.0.0", com.google.common.collect;version="21.0.0" diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/model/UMLRepresentationKind.xmi b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/model/UMLRepresentationKind.xmi index 09578dd05c6..eaf69d4a4d0 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/model/UMLRepresentationKind.xmi +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/model/UMLRepresentationKind.xmi @@ -1,42 +1,42 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<expansionmodel:DiagramExpansion
- xmi:version="2.0"
- xmlns:xmi="http://www.omg.org/XMI"
- xmlns:expansionmodel="http:///expansionmodel.ecore"
- xmi:id="_Ah6igN0DEeSiOexlyH3Ifw"
- ID="UMLRepresentationKind">
- <libraries
- xmi:id="_B-yJIN0DEeSiOexlyH3Ifw"
- name="RepresentationKind">
- <representationkinds
- xmi:id="_EoAOIN0DEeSiOexlyH3Ifw"
- editPartQualifiedName="org.eclipse.papyrus.uml.diagram.common.editparts.AroundBorderItemEditPart"
- name="AroundBorderItem"
- viewFactory="org.eclipse.gmf.runtime.diagram.ui.view.factories.optimal.ShapeViewFactory"/>
- <representationkinds
- xmi:id="_vbTKYN0DEeS-X4lB2Ut-YA"
- editPartQualifiedName="org.eclipse.papyrus.uml.diagram.common.editparts.ListCompartmentEditPart"
- name="List Compartment"
- viewFactory="org.eclipse.gmf.runtime.diagram.ui.view.factories.optimal.CompartmentViewFactory"/>
- <representationkinds
- xmi:id="_1uXq8N0DEeS-X4lB2Ut-YA"
- editPartQualifiedName="org.eclipse.papyrus.uml.diagram.common.editparts.XYCompartmentEditPart"
- name="XY Compartment"
- viewFactory="org.eclipse.gmf.runtime.diagram.ui.view.factories.optimal.CompartmentViewFactory"/>
- <representationkinds
- xmi:id="_dG-hoN0HEeSfTfTnKh2G1Q"
- editPartQualifiedName="org.eclipse.papyrus.uml.diagram.common.editparts.BorderItemNameEditPart"
- name="NameLabel for BorderItem"
- viewFactory="org.eclipse.gmf.runtime.diagram.ui.view.factories.optimal.ShapeViewFactory"/>
- <representationkinds
- xmi:id="_dG-hoN0HEeSfTfTnKh2G1P"
- editPartQualifiedName="org.eclipse.papyrus.uml.diagram.common.editparts.ContainerNodeEditPart"
- name="Container as a Node"
- viewFactory="org.eclipse.papyrus.gmf.diagram.common.factory.ShapeViewFactory"/>
- <representationkinds
- xmi:id="_dG-hoN0HEeSfTfTnKh2G1L"
- editPartQualifiedName="org.eclipse.papyrus.uml.diagram.common.editparts.EditableLabelForNodeEditPart"
- name="Editable Label representing the name of a Node"
- viewFactory="org.eclipse.papyrus.gmf.diagram.common.factory.ShapeViewFactory"/>
- </libraries>
-</expansionmodel:DiagramExpansion>
+<?xml version="1.0" encoding="UTF-8"?> +<expansionmodel:DiagramExpansion + xmi:version="2.0" + xmlns:xmi="http://www.omg.org/XMI" + xmlns:expansionmodel="http:///expansionmodel.ecore" + xmi:id="_Ah6igN0DEeSiOexlyH3Ifw" + ID="UMLRepresentationKind"> + <libraries + xmi:id="_B-yJIN0DEeSiOexlyH3Ifw" + name="RepresentationKind"> + <representationkinds + xmi:id="_EoAOIN0DEeSiOexlyH3Ifw" + editPartQualifiedName="org.eclipse.papyrus.uml.diagram.common.editparts.AroundBorderItemEditPart" + name="AroundBorderItem" + viewFactory="org.eclipse.gmf.runtime.diagram.ui.view.factories.optimal.ShapeViewFactory"/> + <representationkinds + xmi:id="_vbTKYN0DEeS-X4lB2Ut-YA" + editPartQualifiedName="org.eclipse.papyrus.uml.diagram.common.editparts.ListCompartmentEditPart" + name="List Compartment" + viewFactory="org.eclipse.gmf.runtime.diagram.ui.view.factories.optimal.CompartmentViewFactory"/> + <representationkinds + xmi:id="_1uXq8N0DEeS-X4lB2Ut-YA" + editPartQualifiedName="org.eclipse.papyrus.uml.diagram.common.editparts.XYCompartmentEditPart" + name="XY Compartment" + viewFactory="org.eclipse.gmf.runtime.diagram.ui.view.factories.optimal.CompartmentViewFactory"/> + <representationkinds + xmi:id="_dG-hoN0HEeSfTfTnKh2G1Q" + editPartQualifiedName="org.eclipse.papyrus.uml.diagram.common.editparts.BorderItemNameEditPart" + name="NameLabel for BorderItem" + viewFactory="org.eclipse.gmf.runtime.diagram.ui.view.factories.optimal.ShapeViewFactory"/> + <representationkinds + xmi:id="_dG-hoN0HEeSfTfTnKh2G1P" + editPartQualifiedName="org.eclipse.papyrus.uml.diagram.common.editparts.ContainerNodeEditPart" + name="Container as a Node" + viewFactory="org.eclipse.papyrus.gmf.diagram.common.factory.ShapeViewFactory"/> + <representationkinds + xmi:id="_dG-hoN0HEeSfTfTnKh2G1L" + editPartQualifiedName="org.eclipse.papyrus.uml.diagram.common.editparts.EditableLabelForNodeEditPart" + name="Editable Label representing the name of a Node" + viewFactory="org.eclipse.papyrus.gmf.diagram.common.factory.ShapeViewFactory"/> + </libraries> +</expansionmodel:DiagramExpansion> diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/pom.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/pom.xml index 98b279c0b90..d6c1abcad3b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/pom.xml +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/pom.xml @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> -<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.eclipse.papyrus</groupId>
- <artifactId>org.eclipse.papyrus.uml-diagrams</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>org.eclipse.papyrus.uml.diagram.common</artifactId>
- <version>3.1.0-SNAPSHOT</version>
- <packaging>eclipse-plugin</packaging>
+<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.eclipse.papyrus</groupId> + <artifactId>org.eclipse.papyrus.uml-diagrams</artifactId> + <version>0.0.1-SNAPSHOT</version> + </parent> + <artifactId>org.eclipse.papyrus.uml.diagram.common</artifactId> + <version>3.1.0-SNAPSHOT</version> + <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/AbstractCommonTransactionalCommmand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/AbstractCommonTransactionalCommmand.java index 4ca81edd57a..1b6b6a1ed1a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/AbstractCommonTransactionalCommmand.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/AbstractCommonTransactionalCommmand.java @@ -1,71 +1,71 @@ -/*******************************************************************************
- * Copyright (c) 2008 Conselleria de Infraestructuras y Transporte,
- * Generalitat de la Comunitat Valenciana .
- * 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: Francisco Javier Cano Muñoz (Prodevelop) - initial API implementation
- *
- ******************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.commands;
-
-import java.util.List;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
-
-/**
- * An <AbstractTransactionalCommand> that can give proxies for EMF and GEF.
- *
- * @author <a href="mailto:fjcano@prodevelop.es">Francisco Javier Cano Muñoz</a>
- *
- */
-public abstract class AbstractCommonTransactionalCommmand extends AbstractTransactionalCommand {
-
- /**
- * Default constructor.
- *
- * @param domain
- * @param label
- * @param affectedFiles
- */
- public AbstractCommonTransactionalCommmand(TransactionalEditingDomain domain, String label, List affectedFiles) {
- super(domain, label, affectedFiles);
- }
-
- /**
- * To EMF proxy.
- *
- * @return
- */
- public Command toEMFCommand() {
- return new GMFtoEMFCommandWrapper(this);
- }
-
- /**
- * To GEF proxy.
- *
- * @return
- */
- // @unused
- public org.eclipse.gef.commands.Command toGEFCommand() {
- return new ICommandProxy(this);
- }
-
- /**
- * Execute this command in the <EditingDomain>'s <CommandStack> as a
- * transaction.
- */
- // @unused
- public void executeInTransaction() {
- if (getEditingDomain() != null) {
- getEditingDomain().getCommandStack().execute(toEMFCommand());
- }
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2008 Conselleria de Infraestructuras y Transporte, + * Generalitat de la Comunitat Valenciana . + * 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: Francisco Javier Cano Muñoz (Prodevelop) - initial API implementation + * + ******************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.commands; + +import java.util.List; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; + +/** + * An <AbstractTransactionalCommand> that can give proxies for EMF and GEF. + * + * @author <a href="mailto:fjcano@prodevelop.es">Francisco Javier Cano Muñoz</a> + * + */ +public abstract class AbstractCommonTransactionalCommmand extends AbstractTransactionalCommand { + + /** + * Default constructor. + * + * @param domain + * @param label + * @param affectedFiles + */ + public AbstractCommonTransactionalCommmand(TransactionalEditingDomain domain, String label, List affectedFiles) { + super(domain, label, affectedFiles); + } + + /** + * To EMF proxy. + * + * @return + */ + public Command toEMFCommand() { + return new GMFtoEMFCommandWrapper(this); + } + + /** + * To GEF proxy. + * + * @return + */ + // @unused + public org.eclipse.gef.commands.Command toGEFCommand() { + return new ICommandProxy(this); + } + + /** + * Execute this command in the <EditingDomain>'s <CommandStack> as a + * transaction. + */ + // @unused + public void executeInTransaction() { + if (getEditingDomain() != null) { + getEditingDomain().getCommandStack().execute(toEMFCommand()); + } + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/SupplementCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/SupplementCommand.java index e10b54d7dca..2bca65feabd 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/SupplementCommand.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/SupplementCommand.java @@ -1,118 +1,118 @@ -/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.commands;
-
-import org.eclipse.core.commands.operations.IUndoableOperation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
-import org.eclipse.gmf.runtime.notation.Diagram;
-
-/**
- * This class is used to supplement a gmf connection command.
- *
- * @author Patrick Tessier
- */
-public abstract class SupplementCommand {
-
- private EObject container;
-
- private final EObject source;
-
- private final EObject target;
-
- protected final Diagram diagram;
-
- /**
- * the supplement command has the same parameter as connection create
- * command of gmf command
- *
- * @param container
- * the container of the link
- * @param source
- * the source of the link
- *
- * @param target
- * the target of the link
- */
- public SupplementCommand(EObject container, EObject source, EObject target, Diagram diagram) {
- super();
- this.container = container;
- this.source = source;
- this.target = target;
- this.diagram = diagram;
- }
-
- /**
- * this is the same fucntionnality as {@link IUndoableOperation}
- *
- * @return true if the command ca be executed
- */
- // @unused
- public abstract boolean canExecute();
-
- /**
- * Creates the request to configure the new element.
- *
- * @see EditElementCommand
- * @return the request
- */
- // @unused
- protected abstract ConfigureRequest createConfigureRequest(ConfigureRequest request);
-
- /**
- * this is the method tat realize the execution of the command
- *
- * @param newElement
- * the new element ro configure
- * @return the new element
- */
- public abstract EObject doDefaultElementCreation(TransactionalEditingDomain domain, EObject newElement);
-
- /**
- * use to obtain the container of the link
- *
- * @return the container of the link
- */
- public EObject getContainer() {
- return container;
- }
-
- /**
- * use to obtain the source of the link
- *
- * @return the source of the link
- */
- public EObject getSource() {
- return source;
- }
-
- /**
- * use to obtain the target of the link
- *
- * @return the target of the link
- */
- public EObject getTarget() {
- return target;
- }
-
- /**
- * use to set the container of the link
- */
- // @unused
- public void setContainer(EObject container) {
- this.container = container;
- }
-}
+/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.commands; + +import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand; +import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; +import org.eclipse.gmf.runtime.notation.Diagram; + +/** + * This class is used to supplement a gmf connection command. + * + * @author Patrick Tessier + */ +public abstract class SupplementCommand { + + private EObject container; + + private final EObject source; + + private final EObject target; + + protected final Diagram diagram; + + /** + * the supplement command has the same parameter as connection create + * command of gmf command + * + * @param container + * the container of the link + * @param source + * the source of the link + * + * @param target + * the target of the link + */ + public SupplementCommand(EObject container, EObject source, EObject target, Diagram diagram) { + super(); + this.container = container; + this.source = source; + this.target = target; + this.diagram = diagram; + } + + /** + * this is the same fucntionnality as {@link IUndoableOperation} + * + * @return true if the command ca be executed + */ + // @unused + public abstract boolean canExecute(); + + /** + * Creates the request to configure the new element. + * + * @see EditElementCommand + * @return the request + */ + // @unused + protected abstract ConfigureRequest createConfigureRequest(ConfigureRequest request); + + /** + * this is the method tat realize the execution of the command + * + * @param newElement + * the new element ro configure + * @return the new element + */ + public abstract EObject doDefaultElementCreation(TransactionalEditingDomain domain, EObject newElement); + + /** + * use to obtain the container of the link + * + * @return the container of the link + */ + public EObject getContainer() { + return container; + } + + /** + * use to obtain the source of the link + * + * @return the source of the link + */ + public EObject getSource() { + return source; + } + + /** + * use to obtain the target of the link + * + * @return the target of the link + */ + public EObject getTarget() { + return target; + } + + /** + * use to set the container of the link + */ + // @unused + public void setContainer(EObject container) { + this.container = container; + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractInteractionEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractInteractionEditPart.java index 53b57c7f92f..78ddd814458 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractInteractionEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AbstractInteractionEditPart.java @@ -1,56 +1,56 @@ -/*****************************************************************************
- * Copyright (c) 2014 CEA LIST and others.
- *
- * 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.editparts;
-
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * @author Mickael ADAM
- *Deprecated: use of css instead of hard code to set header and position.
- */
-@Deprecated
-public abstract class AbstractInteractionEditPart extends RoundedCompartmentEditPart {
-
- /**
- * Constructor.
- *
- * @param view
- */
- public AbstractInteractionEditPart(View view) {
- super(view);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.papyrus.uml.diagram.common.editparts.RoundedCompartmentEditPart#getDefaultHasHeader()
- */
- @Override
- protected boolean getDefaultHasHeader() {
- return true;
- }
-
- /**
- *
- * deprecated, use css instead
- *
- * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#getDefaultNamePosition()
- */
- @Override
- protected int getDefaultNamePosition() {
- return PositionConstants.LEFT;
- }
-
+/***************************************************************************** + * Copyright (c) 2014 CEA LIST and others. + * + * 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.editparts; + +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.gmf.runtime.notation.View; + +/** + * @author Mickael ADAM + *Deprecated: use of css instead of hard code to set header and position. + */ +@Deprecated +public abstract class AbstractInteractionEditPart extends RoundedCompartmentEditPart { + + /** + * Constructor. + * + * @param view + */ + public AbstractInteractionEditPart(View view) { + super(view); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.diagram.common.editparts.RoundedCompartmentEditPart#getDefaultHasHeader() + */ + @Override + protected boolean getDefaultHasHeader() { + return true; + } + + /** + * + * deprecated, use css instead + * + * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#getDefaultNamePosition() + */ + @Override + protected int getDefaultNamePosition() { + return PositionConstants.LEFT; + } + }
\ No newline at end of file diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AroundBorderItemEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AroundBorderItemEditPart.java index 4eff2527c6f..dc93d2ffee4 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AroundBorderItemEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/AroundBorderItemEditPart.java @@ -1,218 +1,218 @@ -/**
- * Copyright (c) 2015 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.editparts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.LayoutListener;
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.StackLayout;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.editpolicies.LayoutEditPolicy;
-import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
-import org.eclipse.gef.handles.MoveHandle;
-import org.eclipse.gef.requests.CreateRequest;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator;
-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.papyrus.infra.gmfdiag.common.editpart.IBorderItemWithLocator;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimaryDragRoleEditPolicy;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.GetChildLayoutEditPolicy;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.MaskManagedNodeEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideLabelEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.AffixedNamedElementFigure;
-import org.eclipse.papyrus.uml.diagram.common.locator.ExternalLabelPositionLocator;
-import org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator;
-
-public class AroundBorderItemEditPart extends RoundedBorderNamedElementEditPart implements IBorderItemWithLocator{
-
-
- private LayoutListener.Stub layoutInitializationListener;
-
- private IFigure contentPane=null;
-
- private AffixedNamedElementFigure primaryShape;
-
- public AroundBorderItemEditPart(View view) {
- super(view);
- }
-
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- installEditPolicy(ShowHideLabelEditPolicy.SHOW_HIDE_LABEL_ROLE, new ShowHideLabelEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new BorderItemResizableEditPolicy());
- installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new MaskManagedNodeEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy());
- }
-
- protected LayoutEditPolicy createLayoutEditPolicy() {
- org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() {
-
- @Override
- protected EditPolicy createChildEditPolicy(EditPart child) {
- if (child instanceof IBorderItemEditPart) { // External labels
- return new ExternalLabelPrimaryDragRoleEditPolicy() {
-
- @Override
- @SuppressWarnings("rawtypes")
- protected List createSelectionHandles() {
- MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost());
- mh.setBorder(null);
- return Collections.singletonList(mh);
- }
- };
- }
-
- EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (result == null) {
- result = new NonResizableEditPolicy();
- }
- return result;
- }
-
- @Override
- protected Command getMoveChildrenCommand(Request request) {
- return null;
- }
-
- @Override
- protected Command getCreateCommand(CreateRequest request) {
- return null;
- }
- };
- return lep;
- }
-
- @Override
- protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
- IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure());
- borderItemContainer.add(borderItemEditPart.getFigure(), locator);
- return;
- }
-
-
-
- /**
- * <pre>
- * Calls the figure refresh when a change event is detected on
- * UMLPackage.eINSTANCE.getProperty_Aggregation().
- *
- * {@inheritDoc}
- * </pre>
- */
- @Override
- protected void handleNotificationEvent(Notification event) {
-
- // When the flow port position changes, its position on parent side may change and requires a visual refresh.
- Object feature = event.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)) {
- refreshVisuals();
- }
-
-
- super.handleNotificationEvent(event);
- }
-
-
-
- /**
- * <pre>
- * A post layout listener is added during activate and remove the first time the layout occurs.
- * This is required in order to be able to find the side of this border item on its parent when opening the model.
- * Without this, the locator is unable to guess the parent side because the parent constraint is not set yet.
- *
- * Once the initialization is done, the listener become useless and can be removed.
- *
- * {@inheritDoc}
- * </pre>
- */
- @Override
- public void activate() {
-
- layoutInitializationListener = new LayoutListener.Stub() {
-
- @Override
- public void postLayout(IFigure container) {
- refreshVisuals();
- // getBorderedFigure().getBorderItemContainer().removeLayoutListener(layoutInitializationListener);
- layoutInitializationListener = null;
- }
- };
- getBorderedFigure().getBorderItemContainer().addLayoutListener(layoutInitializationListener);
-
- super.activate();
- }
-
- protected NodeFigure createNodePlate() {
- RoundedRectangleNodePlateFigure result = new RoundedRectangleNodePlateFigure(20, 20);
- return result;
- }
-
- /**
- * Default implementation treats passed figure as content pane.
- * Respects layout one may have set for generated figure.
- * @param nodeShape instance of generated figure class
- * @generated
- */
- protected IFigure setupContentPane(IFigure nodeShape) {
- return nodeShape; // use nodeShape itself as contentPane
- }
- /**
- * Creates figure for this edit part.
- *
- * Body of this method does not depend on settings in generation model
- * so you may safely remove <i>generated</i> tag and modify it.
- *
- * @generated
- */
- protected NodeFigure createMainFigure() {
- NodeFigure figure = createNodePlate();
- figure.setLayoutManager(new StackLayout());
- IFigure shape = createNodeShape();
- figure.add(shape);
- contentPane = setupContentPane(shape);
- return figure;
- }
-
- /**
- * @generated
- */
- protected IFigure createNodeShape() {
- return primaryShape = new AffixedNamedElementFigure();
- }
-
- /**
- * org.eclipse.papyrus.uml.diagram.composite.custom.figures.PortFigure
- * @generated
- */
- public AffixedNamedElementFigure getPrimaryShape() {
- return (AffixedNamedElementFigure)primaryShape;
- }
-
- @Override
- public IBorderItemLocator getNewBorderItemLocator(IFigure mainFigure) {
- return new PortPositionLocator(mainFigure, PositionConstants.NONE);
- }
-}
+/** + * Copyright (c) 2015 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.editparts; + +import java.util.Collections; +import java.util.List; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.LayoutListener; +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.draw2d.StackLayout; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.editpolicies.LayoutEditPolicy; +import org.eclipse.gef.editpolicies.NonResizableEditPolicy; +import org.eclipse.gef.handles.MoveHandle; +import org.eclipse.gef.requests.CreateRequest; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; +import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; +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.papyrus.infra.gmfdiag.common.editpart.IBorderItemWithLocator; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimaryDragRoleEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.GetChildLayoutEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.MaskManagedNodeEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideLabelEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.figure.node.AffixedNamedElementFigure; +import org.eclipse.papyrus.uml.diagram.common.locator.ExternalLabelPositionLocator; +import org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator; + +public class AroundBorderItemEditPart extends RoundedBorderNamedElementEditPart implements IBorderItemWithLocator{ + + + private LayoutListener.Stub layoutInitializationListener; + + private IFigure contentPane=null; + + private AffixedNamedElementFigure primaryShape; + + public AroundBorderItemEditPart(View view) { + super(view); + } + + @Override + protected void createDefaultEditPolicies() { + super.createDefaultEditPolicies(); + installEditPolicy(ShowHideLabelEditPolicy.SHOW_HIDE_LABEL_ROLE, new ShowHideLabelEditPolicy()); + installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new BorderItemResizableEditPolicy()); + installEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY, new MaskManagedNodeEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); + } + + protected LayoutEditPolicy createLayoutEditPolicy() { + org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() { + + @Override + protected EditPolicy createChildEditPolicy(EditPart child) { + if (child instanceof IBorderItemEditPart) { // External labels + return new ExternalLabelPrimaryDragRoleEditPolicy() { + + @Override + @SuppressWarnings("rawtypes") + protected List createSelectionHandles() { + MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); + mh.setBorder(null); + return Collections.singletonList(mh); + } + }; + } + + EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); + if (result == null) { + result = new NonResizableEditPolicy(); + } + return result; + } + + @Override + protected Command getMoveChildrenCommand(Request request) { + return null; + } + + @Override + protected Command getCreateCommand(CreateRequest request) { + return null; + } + }; + return lep; + } + + @Override + protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { + IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); + borderItemContainer.add(borderItemEditPart.getFigure(), locator); + return; + } + + + + /** + * <pre> + * Calls the figure refresh when a change event is detected on + * UMLPackage.eINSTANCE.getProperty_Aggregation(). + * + * {@inheritDoc} + * </pre> + */ + @Override + protected void handleNotificationEvent(Notification event) { + + // When the flow port position changes, its position on parent side may change and requires a visual refresh. + Object feature = event.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)) { + refreshVisuals(); + } + + + super.handleNotificationEvent(event); + } + + + + /** + * <pre> + * A post layout listener is added during activate and remove the first time the layout occurs. + * This is required in order to be able to find the side of this border item on its parent when opening the model. + * Without this, the locator is unable to guess the parent side because the parent constraint is not set yet. + * + * Once the initialization is done, the listener become useless and can be removed. + * + * {@inheritDoc} + * </pre> + */ + @Override + public void activate() { + + layoutInitializationListener = new LayoutListener.Stub() { + + @Override + public void postLayout(IFigure container) { + refreshVisuals(); + // getBorderedFigure().getBorderItemContainer().removeLayoutListener(layoutInitializationListener); + layoutInitializationListener = null; + } + }; + getBorderedFigure().getBorderItemContainer().addLayoutListener(layoutInitializationListener); + + super.activate(); + } + + protected NodeFigure createNodePlate() { + RoundedRectangleNodePlateFigure result = new RoundedRectangleNodePlateFigure(20, 20); + return result; + } + + /** + * Default implementation treats passed figure as content pane. + * Respects layout one may have set for generated figure. + * @param nodeShape instance of generated figure class + * @generated + */ + protected IFigure setupContentPane(IFigure nodeShape) { + return nodeShape; // use nodeShape itself as contentPane + } + /** + * Creates figure for this edit part. + * + * Body of this method does not depend on settings in generation model + * so you may safely remove <i>generated</i> tag and modify it. + * + * @generated + */ + protected NodeFigure createMainFigure() { + NodeFigure figure = createNodePlate(); + figure.setLayoutManager(new StackLayout()); + IFigure shape = createNodeShape(); + figure.add(shape); + contentPane = setupContentPane(shape); + return figure; + } + + /** + * @generated + */ + protected IFigure createNodeShape() { + return primaryShape = new AffixedNamedElementFigure(); + } + + /** + * org.eclipse.papyrus.uml.diagram.composite.custom.figures.PortFigure + * @generated + */ + public AffixedNamedElementFigure getPrimaryShape() { + return (AffixedNamedElementFigure)primaryShape; + } + + @Override + public IBorderItemLocator getNewBorderItemLocator(IFigure mainFigure) { + return new PortPositionLocator(mainFigure, PositionConstants.NONE); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/ContainerNodeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/ContainerNodeEditPart.java index f5ad89a6e5c..6f480398480 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/ContainerNodeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/ContainerNodeEditPart.java @@ -1,165 +1,165 @@ -/**
- * Copyright (c) 2014 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.editparts;
-
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
-import org.eclipse.gmf.runtime.notation.BasicCompartment;
-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.common.editpolicies.DefaultCreationEditPolicy;
-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.editpolicies.GetChildLayoutEditPolicy;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideClassifierContentsEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.RoundedCompartmentFigure;
-import org.eclipse.swt.graphics.Color;
-
-public class ContainerNodeEditPart extends RoundedCompartmentEditPart {
-
-
- protected IFigure contentPane;
-
- protected IFigure primaryShape;
-
- public ContainerNodeEditPart(View view) {
- super(view);
- }
-
- @Override
- protected void createDefaultEditPolicies() {
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy());
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy());
-
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy());
-
- installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy());
- installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy());
- installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy());
- installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy());
- // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
- }
-
-
- @Override
- protected void handleNotificationEvent(Notification event) {
- /*
- * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart
- * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)!
- */
- if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) {
- Object notifier = event.getNotifier();
- List<?> modelChildren = ((View) getModel()).getChildren();
- if (false == notifier instanceof Edge
- && false == notifier instanceof BasicCompartment) {
- if (modelChildren.contains(event.getNotifier())) {
- return;
- }
- }
- }
- super.handleNotificationEvent(event);
-
- }
-
- @Override
- protected IFigure createNodeShape() {
- return primaryShape = new RoundedCompartmentFigure();
- }
-
- @Override
- public RoundedCompartmentFigure getPrimaryShape() {
- return (RoundedCompartmentFigure) primaryShape;
- }
-
-
-
- @Override
- protected NodeFigure createNodePlate() {
- RoundedRectangleNodePlateFigure result = new RoundedRectangleNodePlateFigure(100, 100);
- return result;
- }
-
- @Override
- protected NodeFigure createMainFigure() {
- return new SelectableBorderedNodeFigure(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();
- }
-
- /**
- * @generated
- */
- @Override
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
- if (editPart instanceof IBorderItemEditPart) {
- return getBorderedFigure().getBorderItemContainer();
- }
-
- return getContentPane();
- }
-
- @Override
- protected void setForegroundColor(Color color) {
- if (primaryShape != null) {
- primaryShape.setForegroundColor(color);
- }
- }
- @Override
- protected void setLineWidth(int width) {
- super.setLineWidth(width);
- }
-
- @Override
- protected void setLineType(int style) {
- if (primaryShape instanceof IPapyrusNodeFigure) {
- ((IPapyrusNodeFigure) primaryShape).setLineStyle(style);
- }
- }
-
-
-}
+/** + * Copyright (c) 2014 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.editparts; + +import java.util.List; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout; +import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; +import org.eclipse.gmf.runtime.notation.BasicCompartment; +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.common.editpolicies.DefaultCreationEditPolicy; +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.editpolicies.GetChildLayoutEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideClassifierContentsEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.figure.node.RoundedCompartmentFigure; +import org.eclipse.swt.graphics.Color; + +public class ContainerNodeEditPart extends RoundedCompartmentEditPart { + + + protected IFigure contentPane; + + protected IFigure primaryShape; + + public ContainerNodeEditPart(View view) { + super(view); + } + + @Override + protected void createDefaultEditPolicies() { + installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy()); + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideClassifierContentsEditPolicy.SHOW_HIDE_CLASSIFIER_CONTENTS_POLICY, new ShowHideClassifierContentsEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); + // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies + // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); + } + + + @Override + protected void handleNotificationEvent(Notification event) { + /* + * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart + * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! + */ + if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + Object notifier = event.getNotifier(); + List<?> modelChildren = ((View) getModel()).getChildren(); + if (false == notifier instanceof Edge + && false == notifier instanceof BasicCompartment) { + if (modelChildren.contains(event.getNotifier())) { + return; + } + } + } + super.handleNotificationEvent(event); + + } + + @Override + protected IFigure createNodeShape() { + return primaryShape = new RoundedCompartmentFigure(); + } + + @Override + public RoundedCompartmentFigure getPrimaryShape() { + return (RoundedCompartmentFigure) primaryShape; + } + + + + @Override + protected NodeFigure createNodePlate() { + RoundedRectangleNodePlateFigure result = new RoundedRectangleNodePlateFigure(100, 100); + return result; + } + + @Override + protected NodeFigure createMainFigure() { + return new SelectableBorderedNodeFigure(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(); + } + + /** + * @generated + */ + @Override + protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { + if (editPart instanceof IBorderItemEditPart) { + return getBorderedFigure().getBorderItemContainer(); + } + + return getContentPane(); + } + + @Override + protected void setForegroundColor(Color color) { + if (primaryShape != null) { + primaryShape.setForegroundColor(color); + } + } + @Override + protected void setLineWidth(int width) { + super.setLineWidth(width); + } + + @Override + protected void setLineType(int style) { + if (primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + } + } + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/PackageEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/PackageEditPart.java index c00b6c61f7d..b7cfb151055 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/PackageEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/PackageEditPart.java @@ -1,94 +1,94 @@ -/*****************************************************************************
- * Copyright (c) 2014 CEA LIST and others.
- *
- * 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.editparts;
-
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * @author Mickael ADAM
- *
- */
-public abstract class PackageEditPart extends RoundedCompartmentEditPart {
-
- /**
- * Constructor.
- *
- * @param view
- */
- public PackageEditPart(View view) {
- super(view);
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#getDefaultNamePosition()
- *
- * @return
- */
- @Override
- protected int getDefaultNamePosition() {
- return PositionConstants.LEFT;
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editparts.RoundedCompartmentEditPart#getDefaultIsPackage()
- *
- * @return
- */
- @Override
- protected boolean getDefaultIsPackage() {
- return true;
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#getDefaultBottomNameMargin()
- *
- * @return
- */
- @Override
- protected int getDefaultBottomNameMargin() {
- return 2;
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#getDefaultBottomNameMargin()
- *
- * @return
- */
- @Override
- protected int getDefaultTopNameMargin() {
- return 0;
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#getDefaultBottomNameMargin()
- *
- * @return
- */
- @Override
- protected int getDefaultLeftNameMargin() {
- return 5;
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#getDefaultBottomNameMargin()
- *
- * @return
- */
- @Override
- protected int getDefaultRightNameMargin() {
- return 5;
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2014 CEA LIST and others. + * + * 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.editparts; + +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.gmf.runtime.notation.View; + +/** + * @author Mickael ADAM + * + */ +public abstract class PackageEditPart extends RoundedCompartmentEditPart { + + /** + * Constructor. + * + * @param view + */ + public PackageEditPart(View view) { + super(view); + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#getDefaultNamePosition() + * + * @return + */ + @Override + protected int getDefaultNamePosition() { + return PositionConstants.LEFT; + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.editparts.RoundedCompartmentEditPart#getDefaultIsPackage() + * + * @return + */ + @Override + protected boolean getDefaultIsPackage() { + return true; + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#getDefaultBottomNameMargin() + * + * @return + */ + @Override + protected int getDefaultBottomNameMargin() { + return 2; + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#getDefaultBottomNameMargin() + * + * @return + */ + @Override + protected int getDefaultTopNameMargin() { + return 0; + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#getDefaultBottomNameMargin() + * + * @return + */ + @Override + protected int getDefaultLeftNameMargin() { + return 5; + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.editparts.NamedElementEditPart#getDefaultBottomNameMargin() + * + * @return + */ + @Override + protected int getDefaultRightNameMargin() { + return 5; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ContextLinkSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ContextLinkSemanticEditPolicy.java index 3efbaecff07..bfa0f92886a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ContextLinkSemanticEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ContextLinkSemanticEditPolicy.java @@ -1,84 +1,84 @@ -/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
- * 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 - bug 493317 (deprecated)
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RootEditPart;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
-import org.eclipse.gmf.runtime.notation.Connector;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy;
-import org.eclipse.uml2.uml.Constraint;
-
-/**
- * Custom context link semantic edit policy that provides removing a context from constrained element
- * during delete/hide context link command
- *
- * @deprecated since 2.0, the work is now done by an advice helper in the oep.uml.service.types
- */
-public class ContextLinkSemanticEditPolicy extends DefaultSemanticEditPolicy {
-
- @Override
- public Command getCommand(Request request) {
- if (isContextLinkHideRequest(request)) {
- EObject context = ViewUtil.resolveSemanticElement(((Edge) getHost().getModel()).getSource());
- EObject referenceObject = resolveSemanticElement(getHost().getParent());
- DestroyReferenceRequest req = new DestroyReferenceRequest(((IGraphicalEditPart) getHost()).getEditingDomain(), context, null, referenceObject, false);
- return getSemanticCommand(req);
- }
- return super.getCommand(request);
- }
-
- @Override
- protected Command getDestroyReferenceCommand(DestroyReferenceRequest req) {
- EObject context = req.getContainer();
- return super.getDestroyReferenceCommand(req, context);
- }
-
- @Override
- protected IEditCommandRequest completeRequest(IEditCommandRequest request) {
- return request;
- }
-
- private boolean isContextLinkHideRequest(Request request) {
- if (!REQ_DELETE.equals(request.getType())) {
- return false;
- }
- View hostView = ((IGraphicalEditPart) getHost()).getNotationView();
- if (false == hostView instanceof Connector) {
- return false;
- }
- EObject hostElement = ((IGraphicalEditPart) getHost()).resolveSemanticElement();
- EObject sourceElement = ((Connector) hostView).getSource().getElement();
- return hostElement == null && sourceElement instanceof Constraint;
- }
-
- private EObject resolveSemanticElement(EditPart editPart) {
- if (editPart == null) {
- return null;
- }
- if (editPart instanceof RootEditPart) {
- return ViewUtil.resolveSemanticElement((View) ((RootEditPart) editPart).getContents().getModel());
- }
- return ((IGraphicalEditPart) editPart).resolveSemanticElement();
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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 - bug 493317 (deprecated) + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.common.editpolicies; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.RootEditPart; +import org.eclipse.gef.commands.Command; +import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; +import org.eclipse.gmf.runtime.notation.Connector; +import org.eclipse.gmf.runtime.notation.Edge; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; +import org.eclipse.uml2.uml.Constraint; + +/** + * Custom context link semantic edit policy that provides removing a context from constrained element + * during delete/hide context link command + * + * @deprecated since 2.0, the work is now done by an advice helper in the oep.uml.service.types + */ +public class ContextLinkSemanticEditPolicy extends DefaultSemanticEditPolicy { + + @Override + public Command getCommand(Request request) { + if (isContextLinkHideRequest(request)) { + EObject context = ViewUtil.resolveSemanticElement(((Edge) getHost().getModel()).getSource()); + EObject referenceObject = resolveSemanticElement(getHost().getParent()); + DestroyReferenceRequest req = new DestroyReferenceRequest(((IGraphicalEditPart) getHost()).getEditingDomain(), context, null, referenceObject, false); + return getSemanticCommand(req); + } + return super.getCommand(request); + } + + @Override + protected Command getDestroyReferenceCommand(DestroyReferenceRequest req) { + EObject context = req.getContainer(); + return super.getDestroyReferenceCommand(req, context); + } + + @Override + protected IEditCommandRequest completeRequest(IEditCommandRequest request) { + return request; + } + + private boolean isContextLinkHideRequest(Request request) { + if (!REQ_DELETE.equals(request.getType())) { + return false; + } + View hostView = ((IGraphicalEditPart) getHost()).getNotationView(); + if (false == hostView instanceof Connector) { + return false; + } + EObject hostElement = ((IGraphicalEditPart) getHost()).resolveSemanticElement(); + EObject sourceElement = ((Connector) hostView).getSource().getElement(); + return hostElement == null && sourceElement instanceof Constraint; + } + + private EObject resolveSemanticElement(EditPart editPart) { + if (editPart == null) { + return null; + } + if (editPart instanceof RootEditPart) { + return ViewUtil.resolveSemanticElement((View) ((RootEditPart) editPart).getContents().getModel()); + } + return ((IGraphicalEditPart) editPart).resolveSemanticElement(); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy.java index 1d016313226..44adfee0637 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy.java @@ -1,57 +1,57 @@ -/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boutheina Bannour (CEA LIST) boutheina.bannour@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusUMLElementFigure;
-
-/**
- * Edit Policy for Applied Stereotype Label for {@link ContextLink}.
- */
-public class CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy extends AppliedStereotypeLinkLabelDisplayEditPolicy {
-
- public static final String APPLIED_STEREOTYPE_LABEL = "context"; //$NON-NLS-1$
-
- /**
- * Creates the EditPolicy, with the correct tag.
- */
- public CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy() {
- super(APPLIED_STEREOTYPE_LABEL); //$NON-NLS-1$
- }
-
- @Override
- public void activate() {
- // retrieve the view
- View view = getView();
- if (view == null) {
- return;
- }
- // call the refresh overridden in this class
- refreshDisplay();
- }
-
- /**
- * Refreshes the tag display
- */
- @Override
- protected void refreshStereotypeDisplay() {
- IFigure figure = ((GraphicalEditPart) getHost()).getFigure();
- // the tag displayed here is <code>« context »</code> see the class constructor
- if (figure instanceof IPapyrusUMLElementFigure) {
- ((IPapyrusUMLElementFigure) figure).setStereotypeDisplay(tag, null);
- }
- }
-}
+/***************************************************************************** + * Copyright (c) 2013 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boutheina Bannour (CEA LIST) boutheina.bannour@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.editpolicies; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusUMLElementFigure; + +/** + * Edit Policy for Applied Stereotype Label for {@link ContextLink}. + */ +public class CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy extends AppliedStereotypeLinkLabelDisplayEditPolicy { + + public static final String APPLIED_STEREOTYPE_LABEL = "context"; //$NON-NLS-1$ + + /** + * Creates the EditPolicy, with the correct tag. + */ + public CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy() { + super(APPLIED_STEREOTYPE_LABEL); //$NON-NLS-1$ + } + + @Override + public void activate() { + // retrieve the view + View view = getView(); + if (view == null) { + return; + } + // call the refresh overridden in this class + refreshDisplay(); + } + + /** + * Refreshes the tag display + */ + @Override + protected void refreshStereotypeDisplay() { + IFigure figure = ((GraphicalEditPart) getHost()).getFigure(); + // the tag displayed here is <code>« context »</code> see the class constructor + if (figure instanceof IPapyrusUMLElementFigure) { + ((IPapyrusUMLElementFigure) figure).setStereotypeDisplay(tag, null); + } + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationBranchEndEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationBranchEndEditPolicy.java index 1c7ae487c37..ca619ea8e83 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationBranchEndEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationBranchEndEditPolicy.java @@ -1,49 +1,49 @@ -/*****************************************************************************
- * Copyright (c) 2009 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-
-import org.eclipse.papyrus.uml.diagram.common.helper.AssociationBranchEndLabelHelper;
-import org.eclipse.papyrus.uml.diagram.common.helper.PropertyLabelHelper;
-
-/**
- * Mask Managed label edit policy for association ends (target role)
- */
-public class DisplayAssociationBranchEndEditPolicy extends DisplayAssociationEndEditPolicy {
-
- @Override
- public void addAdditionalListeners() {
- super.addAdditionalListeners();
- // adds a listener to the element itself, and to linked elements, like Type
- if (getView().eContainer() != null) {
- getDiagramEventBroker().addNotificationListener(getView().eContainer(), this);
- }
- }
-
- /**
- * Instantiates a new display association end target edit policy.
- */
- public DisplayAssociationBranchEndEditPolicy() {
- super();
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndEditPolicy#createPropertyLabelHelper()
- *
- * @return
- */
- @Override
- protected PropertyLabelHelper createPropertyLabelHelper() {
- return AssociationBranchEndLabelHelper.getInstance();
- }
-}
+/***************************************************************************** + * Copyright (c) 2009 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.editpolicies; + +import org.eclipse.papyrus.uml.diagram.common.helper.AssociationBranchEndLabelHelper; +import org.eclipse.papyrus.uml.diagram.common.helper.PropertyLabelHelper; + +/** + * Mask Managed label edit policy for association ends (target role) + */ +public class DisplayAssociationBranchEndEditPolicy extends DisplayAssociationEndEditPolicy { + + @Override + public void addAdditionalListeners() { + super.addAdditionalListeners(); + // adds a listener to the element itself, and to linked elements, like Type + if (getView().eContainer() != null) { + getDiagramEventBroker().addNotificationListener(getView().eContainer(), this); + } + } + + /** + * Instantiates a new display association end target edit policy. + */ + public DisplayAssociationBranchEndEditPolicy() { + super(); + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndEditPolicy#createPropertyLabelHelper() + * + * @return + */ + @Override + protected PropertyLabelHelper createPropertyLabelHelper() { + return AssociationBranchEndLabelHelper.getInstance(); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationBranchEndMultiplicityEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationBranchEndMultiplicityEditPolicy.java index 8db0d876a58..15e1ff3352f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationBranchEndMultiplicityEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationBranchEndMultiplicityEditPolicy.java @@ -1,36 +1,36 @@ -/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance;
-
-/**
- * this class enables to refresh the multiplicity label of the association end (target)
- *
- */
-public class DisplayAssociationBranchEndMultiplicityEditPolicy extends DisplayAssociationBranchEndEditPolicy {
-
- /**
- *
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndEditPolicy#getDefaultDisplayValue()
- *
- */
- @Override
- protected Collection<String> getDefaultDisplayValue() {
- return Collections.singleton(ICustomAppearance.DISP_MULTIPLICITY);
- }
-}
+/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.editpolicies; + +import java.util.Collection; +import java.util.Collections; + +import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; + +/** + * this class enables to refresh the multiplicity label of the association end (target) + * + */ +public class DisplayAssociationBranchEndMultiplicityEditPolicy extends DisplayAssociationBranchEndEditPolicy { + + /** + * + * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndEditPolicy#getDefaultDisplayValue() + * + */ + @Override + protected Collection<String> getDefaultDisplayValue() { + return Collections.singleton(ICustomAppearance.DISP_MULTIPLICITY); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationEndSourceEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationEndSourceEditPolicy.java index 9b4dc1e0b52..37f78b9874c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationEndSourceEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationEndSourceEditPolicy.java @@ -1,49 +1,49 @@ -/*****************************************************************************
- * Copyright (c) 2009 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-
-import org.eclipse.papyrus.uml.diagram.common.helper.AssociationEndSourceLabelHelper;
-import org.eclipse.papyrus.uml.diagram.common.helper.PropertyLabelHelper;
-
-/**
- * Mask Managed label edit policy for association ends (source role)
- */
-public class DisplayAssociationEndSourceEditPolicy extends DisplayAssociationEndEditPolicy {
-
- @Override
- public void addAdditionalListeners() {
- super.addAdditionalListeners();
- // adds a listener to the element itself, and to linked elements, like Type
- if (getView().eContainer() != null) {
- getDiagramEventBroker().addNotificationListener(getView().eContainer(), this);
- }
- }
-
- /**
- * Instantiates a new display association end source edit policy.
- */
- public DisplayAssociationEndSourceEditPolicy() {
- super();
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndEditPolicy#createPropertyLabelHelper()
- *
- * @return
- */
- @Override
- protected PropertyLabelHelper createPropertyLabelHelper() {
- return AssociationEndSourceLabelHelper.getInstance();
- }
-}
+/***************************************************************************** + * Copyright (c) 2009 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.editpolicies; + +import org.eclipse.papyrus.uml.diagram.common.helper.AssociationEndSourceLabelHelper; +import org.eclipse.papyrus.uml.diagram.common.helper.PropertyLabelHelper; + +/** + * Mask Managed label edit policy for association ends (source role) + */ +public class DisplayAssociationEndSourceEditPolicy extends DisplayAssociationEndEditPolicy { + + @Override + public void addAdditionalListeners() { + super.addAdditionalListeners(); + // adds a listener to the element itself, and to linked elements, like Type + if (getView().eContainer() != null) { + getDiagramEventBroker().addNotificationListener(getView().eContainer(), this); + } + } + + /** + * Instantiates a new display association end source edit policy. + */ + public DisplayAssociationEndSourceEditPolicy() { + super(); + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndEditPolicy#createPropertyLabelHelper() + * + * @return + */ + @Override + protected PropertyLabelHelper createPropertyLabelHelper() { + return AssociationEndSourceLabelHelper.getInstance(); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationEndTargetEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationEndTargetEditPolicy.java index d31b81588dd..405fc046096 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationEndTargetEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/DisplayAssociationEndTargetEditPolicy.java @@ -1,49 +1,49 @@ -/*****************************************************************************
- * Copyright (c) 2009 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-
-import org.eclipse.papyrus.uml.diagram.common.helper.AssociationEndTargetLabelHelper;
-import org.eclipse.papyrus.uml.diagram.common.helper.PropertyLabelHelper;
-
-/**
- * Mask Managed label edit policy for association ends (target role)
- */
-public class DisplayAssociationEndTargetEditPolicy extends DisplayAssociationEndEditPolicy {
-
- @Override
- public void addAdditionalListeners() {
- super.addAdditionalListeners();
- // adds a listener to the element itself, and to linked elements, like Type
- if (getView().eContainer() != null) {
- getDiagramEventBroker().addNotificationListener(getView().eContainer(), this);
- }
- }
-
- /**
- * Instantiates a new display association end target edit policy.
- */
- public DisplayAssociationEndTargetEditPolicy() {
- super();
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndEditPolicy#createPropertyLabelHelper()
- *
- * @return
- */
- @Override
- protected PropertyLabelHelper createPropertyLabelHelper() {
- return AssociationEndTargetLabelHelper.getInstance();
- }
-}
+/***************************************************************************** + * Copyright (c) 2009 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.editpolicies; + +import org.eclipse.papyrus.uml.diagram.common.helper.AssociationEndTargetLabelHelper; +import org.eclipse.papyrus.uml.diagram.common.helper.PropertyLabelHelper; + +/** + * Mask Managed label edit policy for association ends (target role) + */ +public class DisplayAssociationEndTargetEditPolicy extends DisplayAssociationEndEditPolicy { + + @Override + public void addAdditionalListeners() { + super.addAdditionalListeners(); + // adds a listener to the element itself, and to linked elements, like Type + if (getView().eContainer() != null) { + getDiagramEventBroker().addNotificationListener(getView().eContainer(), this); + } + } + + /** + * Instantiates a new display association end target edit policy. + */ + public DisplayAssociationEndTargetEditPolicy() { + super(); + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.DisplayAssociationEndEditPolicy#createPropertyLabelHelper() + * + * @return + */ + @Override + protected PropertyLabelHelper createPropertyLabelHelper() { + return AssociationEndTargetLabelHelper.getInstance(); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/EnumerationLiteralLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/EnumerationLiteralLabelEditPolicy.java index 6e7098e92ef..5ec6e57481e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/EnumerationLiteralLabelEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/EnumerationLiteralLabelEditPolicy.java @@ -1,59 +1,59 @@ -/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
- * 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:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 472034
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.papyrus.uml.diagram.common.helper.EnumerationLiteralLabelHelper;
-
-/**
- * @author Céline JANSSENS
- *
- */
-public class EnumerationLiteralLabelEditPolicy extends AbstractMaskManagedEditPolicy {
-
- /**
- * @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy#getMasks()
- *
- * @return
- */
- @Override
- public Map<String, String> getMasks() {
- return Collections.emptyMap();
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy#refreshDisplay()
- *
- */
- @Override
- public void refreshDisplay() {
- EnumerationLiteralLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost());
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy#getDefaultDisplayValue()
- *
- * @return
- */
- @Override
- protected Collection<String> getDefaultDisplayValue() {
- return Collections.emptyList();
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 472034 + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.common.editpolicies; + +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.papyrus.uml.diagram.common.helper.EnumerationLiteralLabelHelper; + +/** + * @author Céline JANSSENS + * + */ +public class EnumerationLiteralLabelEditPolicy extends AbstractMaskManagedEditPolicy { + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy#getMasks() + * + * @return + */ + @Override + public Map<String, String> getMasks() { + return Collections.emptyMap(); + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy#refreshDisplay() + * + */ + @Override + public void refreshDisplay() { + EnumerationLiteralLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost()); + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy#getDefaultDisplayValue() + * + * @return + */ + @Override + protected Collection<String> getDefaultDisplayValue() { + return Collections.emptyList(); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ImportedElementEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ImportedElementEditPolicy.java index 7285d9199e3..7429f7f81d6 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ImportedElementEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ImportedElementEditPolicy.java @@ -1,138 +1,138 @@ -/*****************************************************************************
- * Copyright (c) 2014,2017 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- * Benoit Maggi (CEA LIST) - Bug 518313
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalReferenceEditPolicy;
-import org.eclipse.papyrus.infra.gmfdiag.common.helper.SemanticElementHelper;
-import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.ExternalReferenceGroup;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
-import org.eclipse.uml2.uml.Classifier;
-import org.eclipse.uml2.uml.Comment;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Property;
-
-/**
- * UML-specific implementation of the {@link ExternalReferenceEditPolicy}
- *
- * It displays a decorator for elements which are located in another Package, and
- * for inherited properties (displayed in a Classifier Representation which is not
- * the defining classifier)
- *
- * @author Camille Letavernier
- */
-public class ImportedElementEditPolicy extends ExternalReferenceEditPolicy {
-
- @Override
- protected boolean isExternalRef(View diagramElement) {
- if (!super.isExternalRef(diagramElement)) {
- return false;
- }
-
- if (diagramElement == null) {
- return false;
- }
-
- View primaryView = SemanticElementHelper.findTopView(diagramElement);
- if (primaryView == null) {
- return false;
- }
-
- EObject semanticElement = primaryView.getElement();
-
- if (!(semanticElement instanceof Element)) {
- return false;
- }
-
- // Special case for properties
- if (semanticElement instanceof Property) {
- return isInheritedProperty(diagramElement);
- }
-
- // Don't display decorators on Constraints and Comments. Their graphical containment is not meant
- // to match their semantic containment (The relationship is often represented with a link)
- if (semanticElement instanceof Constraint || semanticElement instanceof Comment) {
- return false;
- }
-
- EObject parentView = primaryView.eContainer();
- if (!(parentView instanceof View)) {
- return false;
- }
-
- EObject parentSemanticElement = ((View) parentView).getElement();
- if (!(parentSemanticElement instanceof Element)) {
- return false;
- }
-
-
- if (StereotypeDisplayUtil.getInstance().isStereotypeView(getView())) {
- return false;
- }
-
- // Generic case: graphical containment doesn't match the semantic containment (We only check Package containment)
- Element semanticUMLElement = (Element) semanticElement;
- Element parentUMLElement = (Element) parentSemanticElement;
-
- String papyrusEditorConstant = PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.EXTERNAL_REFERENCE_STRATEGY);
- String externalReferencePreference = org.eclipse.papyrus.infra.gmfdiag.preferences.Activator.getDefault().getPreferenceStore().getString(papyrusEditorConstant);
- switch (externalReferencePreference) {
- case ExternalReferenceGroup.EXTERNAL_REFERENCE_NONE: return false;
- case ExternalReferenceGroup.EXTERNAL_REFERENCE_OWNER: return semanticUMLElement.getOwner() != parentUMLElement;
- case ExternalReferenceGroup.EXTERNAL_REFERENCE_CONTAINER:
- default:
- if (parentUMLElement instanceof Package) {
- return semanticUMLElement.getNearestPackage() != parentUMLElement;
- }
- return semanticUMLElement.getNearestPackage() != parentUMLElement.getNearestPackage();
- }
- }
-
- // Display a decorator on inherited properties, when they are displayed in a Classifier
- // Don't display a decorator for properties displayed as white box parts/references (Part with port, Part with structure, ...)
- protected boolean isInheritedProperty(View diagramElement) {
- View primaryView = SemanticElementHelper.findTopView(diagramElement);
- if (primaryView == null) {
- return false;
- }
-
- View parentView = (View) primaryView.eContainer();
- if (parentView == null) {
- return false;
- }
-
- EObject semanticElement = SemanticElementHelper.findSemanticElement(diagramElement);
- if (!(semanticElement instanceof Property)) {
- return false;
- }
-
- Property property = (Property) semanticElement;
-
- EObject semanticParent = SemanticElementHelper.findSemanticElement(parentView);
-
- if (semanticParent instanceof Property) { // For parts/ref/ports, never display the decorator
- // semanticParent = ((Property)semanticParent).getType(); //Check the inheritance from the type
- return false;
- }
-
- if (semanticParent instanceof Classifier) {
- return property.eContainer() != semanticParent;
- } else {
- return true;
- }
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2014,2017 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + * Benoit Maggi (CEA LIST) - Bug 518313 + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.editpolicies; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalReferenceEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.helper.SemanticElementHelper; +import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper; +import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.ExternalReferenceGroup; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.Comment; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Property; + +/** + * UML-specific implementation of the {@link ExternalReferenceEditPolicy} + * + * It displays a decorator for elements which are located in another Package, and + * for inherited properties (displayed in a Classifier Representation which is not + * the defining classifier) + * + * @author Camille Letavernier + */ +public class ImportedElementEditPolicy extends ExternalReferenceEditPolicy { + + @Override + protected boolean isExternalRef(View diagramElement) { + if (!super.isExternalRef(diagramElement)) { + return false; + } + + if (diagramElement == null) { + return false; + } + + View primaryView = SemanticElementHelper.findTopView(diagramElement); + if (primaryView == null) { + return false; + } + + EObject semanticElement = primaryView.getElement(); + + if (!(semanticElement instanceof Element)) { + return false; + } + + // Special case for properties + if (semanticElement instanceof Property) { + return isInheritedProperty(diagramElement); + } + + // Don't display decorators on Constraints and Comments. Their graphical containment is not meant + // to match their semantic containment (The relationship is often represented with a link) + if (semanticElement instanceof Constraint || semanticElement instanceof Comment) { + return false; + } + + EObject parentView = primaryView.eContainer(); + if (!(parentView instanceof View)) { + return false; + } + + EObject parentSemanticElement = ((View) parentView).getElement(); + if (!(parentSemanticElement instanceof Element)) { + return false; + } + + + if (StereotypeDisplayUtil.getInstance().isStereotypeView(getView())) { + return false; + } + + // Generic case: graphical containment doesn't match the semantic containment (We only check Package containment) + Element semanticUMLElement = (Element) semanticElement; + Element parentUMLElement = (Element) parentSemanticElement; + + String papyrusEditorConstant = PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.EXTERNAL_REFERENCE_STRATEGY); + String externalReferencePreference = org.eclipse.papyrus.infra.gmfdiag.preferences.Activator.getDefault().getPreferenceStore().getString(papyrusEditorConstant); + switch (externalReferencePreference) { + case ExternalReferenceGroup.EXTERNAL_REFERENCE_NONE: return false; + case ExternalReferenceGroup.EXTERNAL_REFERENCE_OWNER: return semanticUMLElement.getOwner() != parentUMLElement; + case ExternalReferenceGroup.EXTERNAL_REFERENCE_CONTAINER: + default: + if (parentUMLElement instanceof Package) { + return semanticUMLElement.getNearestPackage() != parentUMLElement; + } + return semanticUMLElement.getNearestPackage() != parentUMLElement.getNearestPackage(); + } + } + + // Display a decorator on inherited properties, when they are displayed in a Classifier + // Don't display a decorator for properties displayed as white box parts/references (Part with port, Part with structure, ...) + protected boolean isInheritedProperty(View diagramElement) { + View primaryView = SemanticElementHelper.findTopView(diagramElement); + if (primaryView == null) { + return false; + } + + View parentView = (View) primaryView.eContainer(); + if (parentView == null) { + return false; + } + + EObject semanticElement = SemanticElementHelper.findSemanticElement(diagramElement); + if (!(semanticElement instanceof Property)) { + return false; + } + + Property property = (Property) semanticElement; + + EObject semanticParent = SemanticElementHelper.findSemanticElement(parentView); + + if (semanticParent instanceof Property) { // For parts/ref/ports, never display the decorator + // semanticParent = ((Property)semanticParent).getType(); //Check the inheritance from the type + return false; + } + + if (semanticParent instanceof Classifier) { + return property.eContainer() != semanticParent; + } else { + return true; + } + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/IndirectPortLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/IndirectPortLabelEditPolicy.java index aaa5f2a5b88..50c0f0e0572 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/IndirectPortLabelEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/IndirectPortLabelEditPolicy.java @@ -1,49 +1,49 @@ -/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
-
-/**
- * this edit policy is used to update the label of the port from the primary shape not directly from the label
- *
- */
-public class IndirectPortLabelEditPolicy extends PortLabelEditPolicy implements IndirectMaskLabelEditPolicy {
-
-
- /**
- * Returns the view controlled by the host edit part
- *
- * @return the view controlled by the host edit part
- */
- @Override
- protected View getView() {
- EditPart host = getHost();
- if (host == null) {
- return null;
- }
-
- Object hostView = host.getModel();
- if (hostView instanceof View) {
- Object parentView = ((View) hostView).eContainer();
- if (parentView instanceof View) {
- return (View) parentView;
- }
- return null;
- }
- return null;
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2014 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.editpolicies; + +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; + +/** + * this edit policy is used to update the label of the port from the primary shape not directly from the label + * + */ +public class IndirectPortLabelEditPolicy extends PortLabelEditPolicy implements IndirectMaskLabelEditPolicy { + + + /** + * Returns the view controlled by the host edit part + * + * @return the view controlled by the host edit part + */ + @Override + protected View getView() { + EditPart host = getHost(); + if (host == null) { + return null; + } + + Object hostView = host.getModel(); + if (hostView instanceof View) { + Object parentView = ((View) hostView).eContainer(); + if (parentView instanceof View) { + return (View) parentView; + } + return null; + } + return null; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/IndirectPropertyLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/IndirectPropertyLabelEditPolicy.java index c6097d4a9c8..867fffa076c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/IndirectPropertyLabelEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/IndirectPropertyLabelEditPolicy.java @@ -1,49 +1,49 @@ -/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy;
-
-/**
- * this edit policy is used to update the label of the property from the primary shape not directly from the label
- *
- */
-public class IndirectPropertyLabelEditPolicy extends PropertyLabelEditPolicy implements IndirectMaskLabelEditPolicy {
-
-
- /**
- * Returns the view controlled by the host edit part
- *
- * @return the view controlled by the host edit part
- */
- @Override
- protected View getView() {
- EditPart host = getHost();
- if (host == null) {
- return null;
- }
-
- Object hostView = host.getModel();
- if (hostView instanceof View) {
- Object parentView = ((View) hostView).eContainer();
- if (parentView instanceof View) {
- return (View) parentView;
- }
- return null;
- }
- return null;
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2014 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.editpolicies; + +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; + +/** + * this edit policy is used to update the label of the property from the primary shape not directly from the label + * + */ +public class IndirectPropertyLabelEditPolicy extends PropertyLabelEditPolicy implements IndirectMaskLabelEditPolicy { + + + /** + * Returns the view controlled by the host edit part + * + * @return the view controlled by the host edit part + */ + @Override + protected View getView() { + EditPart host = getHost(); + if (host == null) { + return null; + } + + Object hostView = host.getModel(); + if (hostView instanceof View) { + Object parentView = ((View) hostView).eContainer(); + if (parentView instanceof View) { + return (View) parentView; + } + return null; + } + return null; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ListenerEventEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ListenerEventEditPolicy.java index 80dd70e2bbc..f7c10dec356 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ListenerEventEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ListenerEventEditPolicy.java @@ -1,244 +1,244 @@ -/*****************************************************************************
- * Copyright (c) 2011 Atos.
- *
- *
- * 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:
- * Atos - Initial API and implementation
- * Arthur Daussy (Atos) arthur.daussy@atos.net - Bug 249786: [General] drag'n'drop does not work for elements stored in nested classifier compartment
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-
-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.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.editpolicies.AbstractEditPolicy;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
-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.CanonicalEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
-
-import com.google.common.collect.ImmutableSet;
-
-public abstract class ListenerEventEditPolicy extends AbstractEditPolicy implements IStructuralFeatureListener {
-
- /** Adds <code>String.class</tt> adaptablity to return a factory hint. Copied from {@link CanonicalEditPolicy} */
- protected static final class ElementListenerAdapter extends EObjectAdapter {
-
- private String _hint;
-
- /**
- * constructor
- *
- * @param element
- * @param hint
- */
- public ElementListenerAdapter(EObject element, String hint) {
- super(element);
- _hint = hint;
- }
-
- /** Adds <code>String.class</tt> adaptablity. */
- @Override
- public Object getAdapter(Class adapter) {
- if (adapter.equals(String.class)) {
- return _hint;
- }
- return super.getAdapter(adapter);
- }
- }
-
- public ListenerEventEditPolicy() {
- super();
- }
-
- /**
- * This method tries to locate the position that the view will be
- * inserted into it's parent. The position is determined by the position
- * of the semantic element. If the semantic element is not found the view
- * will be appended to it's parent.
- *
- * @param semanticChild
- * @return position where the view should be inserted
- */
- protected int getViewIndexFor(EObject semanticChild) {
- // The default implementation returns APPEND
- return ViewUtil.APPEND;
- }
-
- /**
- * Returns the default factory hint.
- *
- * @return <code>host().getView().getSemanticType()</code>
- */
- protected String getDefaultFactoryHint() {
- return ((View) host().getModel()).getType();
- }
-
-
- /**
- * Return a view descriptor.
- *
- * @param elementAdapter
- * semantic element
- * @param viewKind
- * type of view to create
- * @param hint
- * factory hint
- * @param index
- * index
- * @return a create <i>non-persisted</i> view descriptor
- */
- protected CreateViewRequest.ViewDescriptor getViewDescriptor(IAdaptable elementAdapter, Class viewKind, String hint, int index) {
- return new CreateViewRequest.ViewDescriptor(elementAdapter, viewKind, hint, index, false, host().getDiagramPreferencesHint());
- }
-
-
-
- /**
- * Gets the diagram event broker from the editing domain.
- *
- * @return the diagram event broker
- */
- private DiagramEventBroker getDiagramEventBroker() {
- TransactionalEditingDomain theEditingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
- if (theEditingDomain != null) {
- return DiagramEventBroker.getInstance(theEditingDomain);
- }
- throw new IllegalStateException("EditPolicy unable to retrive the DiagramEventBroker");//
- }
-
- /**
- * Return the {@link IGraphicalEditPart} host (never null)
- *
- * @return
- */
- protected IGraphicalEditPart host() {
- EditPart host = getHost();
- if (host instanceof IGraphicalEditPart) {
- return ((IGraphicalEditPart) host);
- }
- throw new IllegalStateException("The host of this EditPolicy is not an instance of IGraphicalEditPart");//
- }
-
- /**
- *
- * @return {@link EObject} of the host of this edit Policy or null if error
- */
- protected EObject getSemanticHost() {
- IGraphicalEditPart host = host();
- if (host != null) {
- return host.resolveSemanticElement();
- }
- return null;
- }
-
- /**
- * Add the listeners corresponding to to the structural feature
- *
- * @see org.eclipse.gef.editpolicies.AbstractEditPolicy#activate()
- */
- @Override
- public void activate() {
- for (EStructuralFeature feature : getEStructuralFeaturesToListen()) {
- getDiagramEventBroker().addNotificationListener(getSemanticHost(), feature, this);
- }
- super.activate();
- }
-
- /**
- * Add the listeners corresponding to to the structural feature
- *
- * @see org.eclipse.gef.editpolicies.AbstractEditPolicy#activate()
- */
- @Override
- public void deactivate() {
- for (EStructuralFeature feature : getEStructuralFeaturesToListen()) {
- getDiagramEventBroker().removeNotificationListener(getSemanticHost(), feature, this);
- }
- super.deactivate();
- }
-
- /**
- *
- * @see org.eclipse.gmf.runtime.diagram.core.listener.NotificationPreCommitListener#transactionAboutToCommit(org.eclipse.emf.common.notify.Notification)
- *
- * @param notification
- * @return
- */
- @Override
- public org.eclipse.emf.common.command.Command transactionAboutToCommit(Notification notification) {
- ICommand result = null;
- if (getEStructuralFeaturesToListen().contains(notification.getFeature()) && handleNotificationType(notification.getEventType())) {
- Object newObject = notification.getNewValue();
- Object oldObject = notification.getOldValue();
- Object feature = notification.getFeature();
- int eventType = notification.getEventType();
- Object notifier = notification.getNotifier();
- if (isInstaceofOrNull(newObject, EObject.class) && isInstaceofOrNull(oldObject, EObject.class) && feature instanceof EStructuralFeature && isInstaceofOrNull(notifier, EObject.class)) {
- result = getCommand((EObject) newObject, (EObject) oldObject, (EStructuralFeature) feature, eventType, (EObject) notifier);
- } else {
- result = getSpecialCommandCommand(notification);
- }
- }
- return (result != null) ? new GMFtoEMFCommandWrapper(result) : null;
- }
-
- /**
- * Similar to instance but return true if the objet is null
- *
- * @param o
- * @param clazz
- * @return
- */
- private boolean isInstaceofOrNull(Object o, Class clazz) {
- return o == null || clazz.isInstance(o);
- }
-
- /**
- * This method could be override by extended class to handle specific notification
- *
- * @param notification
- * @return
- */
- protected ICommand getSpecialCommandCommand(Notification notification) {
- return null;
- }
-
- protected abstract ICommand getCommand(EObject newObject, EObject oldObject, EStructuralFeature feature, int eventType, EObject notifier);
-
- /**
- * {@inheritDoc IStructuralFeatureListener}
- *
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IStructuralFeatureListener#handleNotificationType(int)
- *
- * @param type
- * @return
- */
- @Override
- public abstract boolean handleNotificationType(int type);
-
- /**
- * {@inheritDoc IStructuralFeatureListener}
- *
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IStructuralFeatureListener#getEStructuralFeaturesToListen()
- *
- * @param type
- * @return
- */
- @Override
- public abstract ImmutableSet<EStructuralFeature> getEStructuralFeaturesToListen();
-}
+/***************************************************************************** + * Copyright (c) 2011 Atos. + * + * + * 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: + * Atos - Initial API and implementation + * Arthur Daussy (Atos) arthur.daussy@atos.net - Bug 249786: [General] drag'n'drop does not work for elements stored in nested classifier compartment + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.editpolicies; + +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.transaction.TransactionalEditingDomain; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.editpolicies.AbstractEditPolicy; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker; +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.CanonicalEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; +import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; + +import com.google.common.collect.ImmutableSet; + +public abstract class ListenerEventEditPolicy extends AbstractEditPolicy implements IStructuralFeatureListener { + + /** Adds <code>String.class</tt> adaptablity to return a factory hint. Copied from {@link CanonicalEditPolicy} */ + protected static final class ElementListenerAdapter extends EObjectAdapter { + + private String _hint; + + /** + * constructor + * + * @param element + * @param hint + */ + public ElementListenerAdapter(EObject element, String hint) { + super(element); + _hint = hint; + } + + /** Adds <code>String.class</tt> adaptablity. */ + @Override + public Object getAdapter(Class adapter) { + if (adapter.equals(String.class)) { + return _hint; + } + return super.getAdapter(adapter); + } + } + + public ListenerEventEditPolicy() { + super(); + } + + /** + * This method tries to locate the position that the view will be + * inserted into it's parent. The position is determined by the position + * of the semantic element. If the semantic element is not found the view + * will be appended to it's parent. + * + * @param semanticChild + * @return position where the view should be inserted + */ + protected int getViewIndexFor(EObject semanticChild) { + // The default implementation returns APPEND + return ViewUtil.APPEND; + } + + /** + * Returns the default factory hint. + * + * @return <code>host().getView().getSemanticType()</code> + */ + protected String getDefaultFactoryHint() { + return ((View) host().getModel()).getType(); + } + + + /** + * Return a view descriptor. + * + * @param elementAdapter + * semantic element + * @param viewKind + * type of view to create + * @param hint + * factory hint + * @param index + * index + * @return a create <i>non-persisted</i> view descriptor + */ + protected CreateViewRequest.ViewDescriptor getViewDescriptor(IAdaptable elementAdapter, Class viewKind, String hint, int index) { + return new CreateViewRequest.ViewDescriptor(elementAdapter, viewKind, hint, index, false, host().getDiagramPreferencesHint()); + } + + + + /** + * Gets the diagram event broker from the editing domain. + * + * @return the diagram event broker + */ + private DiagramEventBroker getDiagramEventBroker() { + TransactionalEditingDomain theEditingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); + if (theEditingDomain != null) { + return DiagramEventBroker.getInstance(theEditingDomain); + } + throw new IllegalStateException("EditPolicy unable to retrive the DiagramEventBroker");// + } + + /** + * Return the {@link IGraphicalEditPart} host (never null) + * + * @return + */ + protected IGraphicalEditPart host() { + EditPart host = getHost(); + if (host instanceof IGraphicalEditPart) { + return ((IGraphicalEditPart) host); + } + throw new IllegalStateException("The host of this EditPolicy is not an instance of IGraphicalEditPart");// + } + + /** + * + * @return {@link EObject} of the host of this edit Policy or null if error + */ + protected EObject getSemanticHost() { + IGraphicalEditPart host = host(); + if (host != null) { + return host.resolveSemanticElement(); + } + return null; + } + + /** + * Add the listeners corresponding to to the structural feature + * + * @see org.eclipse.gef.editpolicies.AbstractEditPolicy#activate() + */ + @Override + public void activate() { + for (EStructuralFeature feature : getEStructuralFeaturesToListen()) { + getDiagramEventBroker().addNotificationListener(getSemanticHost(), feature, this); + } + super.activate(); + } + + /** + * Add the listeners corresponding to to the structural feature + * + * @see org.eclipse.gef.editpolicies.AbstractEditPolicy#activate() + */ + @Override + public void deactivate() { + for (EStructuralFeature feature : getEStructuralFeaturesToListen()) { + getDiagramEventBroker().removeNotificationListener(getSemanticHost(), feature, this); + } + super.deactivate(); + } + + /** + * + * @see org.eclipse.gmf.runtime.diagram.core.listener.NotificationPreCommitListener#transactionAboutToCommit(org.eclipse.emf.common.notify.Notification) + * + * @param notification + * @return + */ + @Override + public org.eclipse.emf.common.command.Command transactionAboutToCommit(Notification notification) { + ICommand result = null; + if (getEStructuralFeaturesToListen().contains(notification.getFeature()) && handleNotificationType(notification.getEventType())) { + Object newObject = notification.getNewValue(); + Object oldObject = notification.getOldValue(); + Object feature = notification.getFeature(); + int eventType = notification.getEventType(); + Object notifier = notification.getNotifier(); + if (isInstaceofOrNull(newObject, EObject.class) && isInstaceofOrNull(oldObject, EObject.class) && feature instanceof EStructuralFeature && isInstaceofOrNull(notifier, EObject.class)) { + result = getCommand((EObject) newObject, (EObject) oldObject, (EStructuralFeature) feature, eventType, (EObject) notifier); + } else { + result = getSpecialCommandCommand(notification); + } + } + return (result != null) ? new GMFtoEMFCommandWrapper(result) : null; + } + + /** + * Similar to instance but return true if the objet is null + * + * @param o + * @param clazz + * @return + */ + private boolean isInstaceofOrNull(Object o, Class clazz) { + return o == null || clazz.isInstance(o); + } + + /** + * This method could be override by extended class to handle specific notification + * + * @param notification + * @return + */ + protected ICommand getSpecialCommandCommand(Notification notification) { + return null; + } + + protected abstract ICommand getCommand(EObject newObject, EObject oldObject, EStructuralFeature feature, int eventType, EObject notifier); + + /** + * {@inheritDoc IStructuralFeatureListener} + * + * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IStructuralFeatureListener#handleNotificationType(int) + * + * @param type + * @return + */ + @Override + public abstract boolean handleNotificationType(int type); + + /** + * {@inheritDoc IStructuralFeatureListener} + * + * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IStructuralFeatureListener#getEStructuralFeaturesToListen() + * + * @param type + * @return + */ + @Override + public abstract ImmutableSet<EStructuralFeature> getEStructuralFeaturesToListen(); +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedNodeEditPolicy.java index e4ba72575af..c3fa622f3d1 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedNodeEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/MaskManagedNodeEditPolicy.java @@ -1,89 +1,89 @@ -/*****************************************************************************
- * Copyright (c) 2009 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:
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
- * Nizar GUEDIDI (CEA LIST) - Update getUMLElement()
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-
-import java.util.Collection;
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.uml.diagram.common.helper.PortLabelHelper;
-import org.eclipse.papyrus.uml.diagram.common.helper.PropertyLabelHelper;
-import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance;
-import org.eclipse.uml2.uml.Port;
-import org.eclipse.uml2.uml.Property;
-
-/**
- * Specific edit policy for to allow nodes to have mash managed that can be consulted by delegated mask managed.
- */
-public class MaskManagedNodeEditPolicy extends AbstractMaskManagedEditPolicy {
-
- /**
- * Creates a new PropertyLabelEditPolicy
- */
- public MaskManagedNodeEditPolicy() {
- super();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addAdditionalListeners() {
- super.addAdditionalListeners();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Collection<String> getDefaultDisplayValue() {
- if (getUMLElement() instanceof Port) {
- return ICustomAppearance.DEFAULT_UML_PORT;
- }
- return ICustomAppearance.DEFAULT_UML_PROPERTY;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Map<String, String> getMasks() {
- if (getUMLElement() instanceof Port) {
- return PortLabelHelper.getInstance().getMasks();
- }
-
- return PropertyLabelHelper.getInstance().getMasks();
- }
-
- /**
- * {@inheritedDoc}
- */
- @Override
- public Property getUMLElement() {
- EObject element = super.getUMLElement();
- if (element instanceof Property) {
- return (Property) element;
- }
- return null;
- }
-
- @Override
- public void refreshDisplay() {
- // do nothing
- // there are label that are will be refreshed
-
- }
-
-
-}
+/***************************************************************************** + * Copyright (c) 2009 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * Nizar GUEDIDI (CEA LIST) - Update getUMLElement() + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.editpolicies; + +import java.util.Collection; +import java.util.Map; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.uml.diagram.common.helper.PortLabelHelper; +import org.eclipse.papyrus.uml.diagram.common.helper.PropertyLabelHelper; +import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; +import org.eclipse.uml2.uml.Port; +import org.eclipse.uml2.uml.Property; + +/** + * Specific edit policy for to allow nodes to have mash managed that can be consulted by delegated mask managed. + */ +public class MaskManagedNodeEditPolicy extends AbstractMaskManagedEditPolicy { + + /** + * Creates a new PropertyLabelEditPolicy + */ + public MaskManagedNodeEditPolicy() { + super(); + } + + /** + * {@inheritDoc} + */ + @Override + public void addAdditionalListeners() { + super.addAdditionalListeners(); + } + + /** + * {@inheritDoc} + */ + @Override + public Collection<String> getDefaultDisplayValue() { + if (getUMLElement() instanceof Port) { + return ICustomAppearance.DEFAULT_UML_PORT; + } + return ICustomAppearance.DEFAULT_UML_PROPERTY; + } + + /** + * {@inheritDoc} + */ + @Override + public Map<String, String> getMasks() { + if (getUMLElement() instanceof Port) { + return PortLabelHelper.getInstance().getMasks(); + } + + return PropertyLabelHelper.getInstance().getMasks(); + } + + /** + * {@inheritedDoc} + */ + @Override + public Property getUMLElement() { + EObject element = super.getUMLElement(); + if (element instanceof Property) { + return (Property) element; + } + return null; + } + + @Override + public void refreshDisplay() { + // do nothing + // there are label that are will be refreshed + + } + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/OperationLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/OperationLabelEditPolicy.java index e1e6a702f57..8a533c406fb 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/OperationLabelEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/OperationLabelEditPolicy.java @@ -1,355 +1,355 @@ -/*****************************************************************************
- * Copyright (c) 2009 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:
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
- * Nizar GUEDIDI (CEA LIST) - Update getUMLElement()
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.papyrus.uml.diagram.common.helper.OperationLabelHelper;
-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.Type;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * Specific edit policy for label displaying stereotypes and their properties for edges representing
- * UML elements.
- */
-public class OperationLabelEditPolicy extends AbstractMaskManagedEditPolicy {
-
- /**
- * Creates a new PropertyLabelEditPolicy
- */
- public OperationLabelEditPolicy() {
- super();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addAdditionalListeners() {
- super.addAdditionalListeners();
- Operation operation = getUMLElement();
- // check host semantic element is not null
- if (operation == null) {
- return;
- }
- // adds a listener to the element itself, and to linked elements, like Type
- for (Parameter parameter : operation.getOwnedParameters()) {
- getDiagramEventBroker().addNotificationListener(parameter, this);
- // should also add this element as a listener of parameter type
- if (parameter.getType() != null) {
- getDiagramEventBroker().addNotificationListener(parameter.getType(), this);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Collection<String> getDefaultDisplayValue() {
- return ICustomAppearance.DEFAULT_UML_OPERATION;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Map<String, String> getMasks() {
- return OperationLabelHelper.getInstance().getMasks();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Operation getUMLElement() {
- if (hostSemanticElement instanceof Operation) {
- return (Operation) hostSemanticElement;
- }
- return null;
- }
-
- /**
- * {@inheritedDoc}
- */
- @Override
- public void notifyChanged(Notification notification) {
- super.notifyChanged(notification);
- // change the label of the figure managed by the host edit part (managed by the parent edit
- // part in general...)
- // it must be changed only if:
- // - the annotation corresponding to the display of the stereotype changes
- // - the stereotype application list has changed
- Object object = notification.getNotifier();
- Operation operation = getUMLElement();
- if (object == null) {
- return;
- }
- if (object.equals(operation)) {
- notifyOperationChanged(operation, notification);
- } else if (isParameter(object)) {
- notifyParameterChanged(notification);
- } else if (isParameterType(object)) {
- notifyParameterTypeChanged(notification);
- }
- if (isMaskManagedAnnotation(object)) {
- refreshDisplay();
- }
- if (isRemovedMaskManagedLabelAnnotation(object, notification)) {
- refreshDisplay();
- }
- }
-
- /**
- * Checks if the given object is one of the parameter type of the operation
- *
- * @param object
- * the object to test
- * @return <code>true</code> if the object corresponds to the type of a parameter of the
- * operation
- */
- protected boolean isParameterType(Object object) {
- if (!(object instanceof Type)) {
- return false;
- }
- for (Parameter parameter : getUMLElement().getOwnedParameters()) {
- if (object.equals(parameter.getType())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Checks if the given object is one of the parameter of the operation
- *
- * @param object
- * the object to test
- * @return <code>true</code> if the object is a parameter of the operation
- */
- protected boolean isParameter(Object object) {
- if (!(object instanceof Parameter)) {
- return false;
- }
- return getUMLElement().getOwnedParameters().contains(object);
- }
-
- /**
- * notifies that a parameter of the operation has changed.
- *
- * @param parameter
- * the {@link Parameter} that has changed
- * @param notification
- * the notification send when the element has been changed
- */
- protected void notifyParameterChanged(Notification notification) {
- switch (notification.getFeatureID(Parameter.class)) {
- case UMLPackage.PARAMETER__NAME:
- case UMLPackage.PARAMETER__DEFAULT_VALUE:
- case UMLPackage.PARAMETER__DIRECTION:
- case UMLPackage.PARAMETER__IS_STREAM:
- case UMLPackage.PARAMETER__IS_ORDERED:
- case UMLPackage.PARAMETER__LOWER:
- case UMLPackage.PARAMETER__UPPER:
- case UMLPackage.PARAMETER__LOWER_VALUE:
- case UMLPackage.PARAMETER__UPPER_VALUE:
- refreshDisplay();
- break;
- case UMLPackage.PARAMETER__TYPE:
- switch (notification.getEventType()) {
- // if it is added => adds listener to the type element
- case Notification.ADD:
- getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this);
- refreshDisplay();
- // if it is removed => removes listener from the type element
- break;
- case Notification.ADD_MANY: // should never happen
- if (notification.getNewValue() instanceof List<?>) {
- List<?> addedElements = (List<?>) notification.getNewValue();
- for (Object addedElement : addedElements) {
- if (addedElement instanceof EObject) {
- getDiagramEventBroker().addNotificationListener((EObject) addedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- case Notification.REMOVE:
- getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this);
- refreshDisplay();
- break;
- case Notification.REMOVE_MANY: // should never happen
- if (notification.getOldValue() instanceof List<?>) {
- List<?> removedElements = (List<?>) notification.getOldValue();
- for (Object removedElement : removedElements) {
- if (removedElement instanceof EObject) {
- getDiagramEventBroker().removeNotificationListener((EObject) removedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- // if it is set, remove the old one and adds the new one. this is the method use when
- // the type is set or removed...
- case Notification.SET:
- if (notification.getNewValue() != null) {
- getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this);
- }
- if (notification.getOldValue() != null) {
- getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this);
- }
- refreshDisplay();
- default:
- break;
- }
- break;
- default:
- // does nothing in other cases
- break;
- }
- }
-
- /**
- * notifies that a parameter of the operation has changed.
- *
- * @param parameter
- * the {@link Parameter} that has changed
- * @param notification
- * the notification send when the element has been changed
- */
- protected void notifyParameterTypeChanged(Notification notification) {
- // should be type.class, but seems to be a bug if this is put instead.
- switch (notification.getFeatureID(notification.getNotifier().getClass())) {
- case UMLPackage.TYPE__NAME:
- case UMLPackage.TYPE__TEMPLATE_PARAMETER:
- case UMLPackage.TYPE__VISIBILITY:
- refreshDisplay();
- break;
- default:
- // does nothing in other cases
- break;
- }
- }
-
- /**
- * notifies that the the property has changed.
- *
- * @param operation
- * the operation that has changed
- * @param notification
- * the notification send when the element has been changed
- */
- protected void notifyOperationChanged(Operation operation, Notification notification) {
- switch (notification.getFeatureID(Operation.class)) {
- case UMLPackage.OPERATION__NAME:
- case UMLPackage.OPERATION__VISIBILITY:
- case UMLPackage.OPERATION__IS_UNIQUE:
- case UMLPackage.OPERATION__REDEFINED_OPERATION:
- case UMLPackage.OPERATION__IS_ORDERED:
- case UMLPackage.OPERATION__LOWER:
- case UMLPackage.OPERATION__UPPER:
- case UMLPackage.OPERATION__IS_STATIC:
- refreshDisplay();
- break;
- case UMLPackage.OPERATION__OWNED_PARAMETER:
- switch (notification.getEventType()) {
- // if it is added => adds listener to the type element
- case Notification.ADD:
- getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this);
- refreshDisplay();
- // if it is removed => removes listener from the type element
- break;
- case Notification.ADD_MANY: // should never happen
- if (notification.getNewValue() instanceof List<?>) {
- List<?> addedElements = (List<?>) notification.getNewValue();
- for (Object addedElement : addedElements) {
- if (addedElement instanceof EObject) {
- getDiagramEventBroker().addNotificationListener((EObject) addedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- case Notification.REMOVE:
- getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this);
- refreshDisplay();
- break;
- case Notification.REMOVE_MANY: // should never happen
- if (notification.getOldValue() instanceof List<?>) {
- List<?> removedElements = (List<?>) notification.getOldValue();
- for (Object removedElement : removedElements) {
- if (removedElement instanceof EObject) {
- getDiagramEventBroker().removeNotificationListener((EObject) removedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- // if it is set, remove the old one and adds the new one. this is the method use when
- // the type is set or removed...
- case Notification.SET:
- if (notification.getNewValue() != null) {
- getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this);
- }
- if (notification.getOldValue() != null) {
- getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this);
- }
- refreshDisplay();
- default:
- break;
- }
- break;
- default:
- // does nothing in other cases
- break;
- }
- }
-
- /**
- * Refreshes the display of the edit part
- */
- @Override
- public void refreshDisplay() {
- // calls the helper for this edit Part
- OperationLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void removeAdditionalListeners() {
- super.removeAdditionalListeners();
- Operation operation = getUMLElement();
- // check host semantic element is not null
- if (operation == null) {
- return;
- }
- for (Parameter parameter : operation.getOwnedParameters()) {
- getDiagramEventBroker().removeNotificationListener(parameter, this);
- // remove parameter type listener
- if (parameter.getType() != null) {
- getDiagramEventBroker().removeNotificationListener(parameter.getType(), this);
- }
- }
- }
-}
+/***************************************************************************** + * Copyright (c) 2009 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * Nizar GUEDIDI (CEA LIST) - Update getUMLElement() + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.editpolicies; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.papyrus.uml.diagram.common.helper.OperationLabelHelper; +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.Type; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Specific edit policy for label displaying stereotypes and their properties for edges representing + * UML elements. + */ +public class OperationLabelEditPolicy extends AbstractMaskManagedEditPolicy { + + /** + * Creates a new PropertyLabelEditPolicy + */ + public OperationLabelEditPolicy() { + super(); + } + + /** + * {@inheritDoc} + */ + @Override + public void addAdditionalListeners() { + super.addAdditionalListeners(); + Operation operation = getUMLElement(); + // check host semantic element is not null + if (operation == null) { + return; + } + // adds a listener to the element itself, and to linked elements, like Type + for (Parameter parameter : operation.getOwnedParameters()) { + getDiagramEventBroker().addNotificationListener(parameter, this); + // should also add this element as a listener of parameter type + if (parameter.getType() != null) { + getDiagramEventBroker().addNotificationListener(parameter.getType(), this); + } + } + } + + /** + * {@inheritDoc} + */ + @Override + public Collection<String> getDefaultDisplayValue() { + return ICustomAppearance.DEFAULT_UML_OPERATION; + } + + /** + * {@inheritDoc} + */ + @Override + public Map<String, String> getMasks() { + return OperationLabelHelper.getInstance().getMasks(); + } + + /** + * {@inheritDoc} + */ + @Override + public Operation getUMLElement() { + if (hostSemanticElement instanceof Operation) { + return (Operation) hostSemanticElement; + } + return null; + } + + /** + * {@inheritedDoc} + */ + @Override + public void notifyChanged(Notification notification) { + super.notifyChanged(notification); + // change the label of the figure managed by the host edit part (managed by the parent edit + // part in general...) + // it must be changed only if: + // - the annotation corresponding to the display of the stereotype changes + // - the stereotype application list has changed + Object object = notification.getNotifier(); + Operation operation = getUMLElement(); + if (object == null) { + return; + } + if (object.equals(operation)) { + notifyOperationChanged(operation, notification); + } else if (isParameter(object)) { + notifyParameterChanged(notification); + } else if (isParameterType(object)) { + notifyParameterTypeChanged(notification); + } + if (isMaskManagedAnnotation(object)) { + refreshDisplay(); + } + if (isRemovedMaskManagedLabelAnnotation(object, notification)) { + refreshDisplay(); + } + } + + /** + * Checks if the given object is one of the parameter type of the operation + * + * @param object + * the object to test + * @return <code>true</code> if the object corresponds to the type of a parameter of the + * operation + */ + protected boolean isParameterType(Object object) { + if (!(object instanceof Type)) { + return false; + } + for (Parameter parameter : getUMLElement().getOwnedParameters()) { + if (object.equals(parameter.getType())) { + return true; + } + } + return false; + } + + /** + * Checks if the given object is one of the parameter of the operation + * + * @param object + * the object to test + * @return <code>true</code> if the object is a parameter of the operation + */ + protected boolean isParameter(Object object) { + if (!(object instanceof Parameter)) { + return false; + } + return getUMLElement().getOwnedParameters().contains(object); + } + + /** + * notifies that a parameter of the operation has changed. + * + * @param parameter + * the {@link Parameter} that has changed + * @param notification + * the notification send when the element has been changed + */ + protected void notifyParameterChanged(Notification notification) { + switch (notification.getFeatureID(Parameter.class)) { + case UMLPackage.PARAMETER__NAME: + case UMLPackage.PARAMETER__DEFAULT_VALUE: + case UMLPackage.PARAMETER__DIRECTION: + case UMLPackage.PARAMETER__IS_STREAM: + case UMLPackage.PARAMETER__IS_ORDERED: + case UMLPackage.PARAMETER__LOWER: + case UMLPackage.PARAMETER__UPPER: + case UMLPackage.PARAMETER__LOWER_VALUE: + case UMLPackage.PARAMETER__UPPER_VALUE: + refreshDisplay(); + break; + case UMLPackage.PARAMETER__TYPE: + switch (notification.getEventType()) { + // if it is added => adds listener to the type element + case Notification.ADD: + getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this); + refreshDisplay(); + // if it is removed => removes listener from the type element + break; + case Notification.ADD_MANY: // should never happen + if (notification.getNewValue() instanceof List<?>) { + List<?> addedElements = (List<?>) notification.getNewValue(); + for (Object addedElement : addedElements) { + if (addedElement instanceof EObject) { + getDiagramEventBroker().addNotificationListener((EObject) addedElement, this); + } + } + } + refreshDisplay(); + break; + case Notification.REMOVE: + getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this); + refreshDisplay(); + break; + case Notification.REMOVE_MANY: // should never happen + if (notification.getOldValue() instanceof List<?>) { + List<?> removedElements = (List<?>) notification.getOldValue(); + for (Object removedElement : removedElements) { + if (removedElement instanceof EObject) { + getDiagramEventBroker().removeNotificationListener((EObject) removedElement, this); + } + } + } + refreshDisplay(); + break; + // if it is set, remove the old one and adds the new one. this is the method use when + // the type is set or removed... + case Notification.SET: + if (notification.getNewValue() != null) { + getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this); + } + if (notification.getOldValue() != null) { + getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this); + } + refreshDisplay(); + default: + break; + } + break; + default: + // does nothing in other cases + break; + } + } + + /** + * notifies that a parameter of the operation has changed. + * + * @param parameter + * the {@link Parameter} that has changed + * @param notification + * the notification send when the element has been changed + */ + protected void notifyParameterTypeChanged(Notification notification) { + // should be type.class, but seems to be a bug if this is put instead. + switch (notification.getFeatureID(notification.getNotifier().getClass())) { + case UMLPackage.TYPE__NAME: + case UMLPackage.TYPE__TEMPLATE_PARAMETER: + case UMLPackage.TYPE__VISIBILITY: + refreshDisplay(); + break; + default: + // does nothing in other cases + break; + } + } + + /** + * notifies that the the property has changed. + * + * @param operation + * the operation that has changed + * @param notification + * the notification send when the element has been changed + */ + protected void notifyOperationChanged(Operation operation, Notification notification) { + switch (notification.getFeatureID(Operation.class)) { + case UMLPackage.OPERATION__NAME: + case UMLPackage.OPERATION__VISIBILITY: + case UMLPackage.OPERATION__IS_UNIQUE: + case UMLPackage.OPERATION__REDEFINED_OPERATION: + case UMLPackage.OPERATION__IS_ORDERED: + case UMLPackage.OPERATION__LOWER: + case UMLPackage.OPERATION__UPPER: + case UMLPackage.OPERATION__IS_STATIC: + refreshDisplay(); + break; + case UMLPackage.OPERATION__OWNED_PARAMETER: + switch (notification.getEventType()) { + // if it is added => adds listener to the type element + case Notification.ADD: + getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this); + refreshDisplay(); + // if it is removed => removes listener from the type element + break; + case Notification.ADD_MANY: // should never happen + if (notification.getNewValue() instanceof List<?>) { + List<?> addedElements = (List<?>) notification.getNewValue(); + for (Object addedElement : addedElements) { + if (addedElement instanceof EObject) { + getDiagramEventBroker().addNotificationListener((EObject) addedElement, this); + } + } + } + refreshDisplay(); + break; + case Notification.REMOVE: + getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this); + refreshDisplay(); + break; + case Notification.REMOVE_MANY: // should never happen + if (notification.getOldValue() instanceof List<?>) { + List<?> removedElements = (List<?>) notification.getOldValue(); + for (Object removedElement : removedElements) { + if (removedElement instanceof EObject) { + getDiagramEventBroker().removeNotificationListener((EObject) removedElement, this); + } + } + } + refreshDisplay(); + break; + // if it is set, remove the old one and adds the new one. this is the method use when + // the type is set or removed... + case Notification.SET: + if (notification.getNewValue() != null) { + getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this); + } + if (notification.getOldValue() != null) { + getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this); + } + refreshDisplay(); + default: + break; + } + break; + default: + // does nothing in other cases + break; + } + } + + /** + * Refreshes the display of the edit part + */ + @Override + public void refreshDisplay() { + // calls the helper for this edit Part + OperationLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost()); + } + + /** + * {@inheritDoc} + */ + @Override + protected void removeAdditionalListeners() { + super.removeAdditionalListeners(); + Operation operation = getUMLElement(); + // check host semantic element is not null + if (operation == null) { + return; + } + for (Parameter parameter : operation.getOwnedParameters()) { + getDiagramEventBroker().removeNotificationListener(parameter, this); + // remove parameter type listener + if (parameter.getType() != null) { + getDiagramEventBroker().removeNotificationListener(parameter.getType(), this); + } + } + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/PortLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/PortLabelEditPolicy.java index 29e9365f2d5..28ee060b28e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/PortLabelEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/PortLabelEditPolicy.java @@ -1,140 +1,140 @@ -/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) - Initial API and implementation
- /*****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.papyrus.uml.diagram.common.helper.PortLabelHelper;
-import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.UMLPackage;
-
-
-public class PortLabelEditPolicy extends PropertyLabelEditPolicy {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Collection<String> getDefaultDisplayValue() {
- return ICustomAppearance.DEFAULT_UML_PORT;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Map<String, String> getMasks() {
- return PortLabelHelper.getInstance().getMasks();
- }
-
- /**
- * notifies that the the property has changed.
- *
- * @param property
- * the property that has changed
- * @param notification
- * the notification send when the element has been changed
- */
- @Override
- protected void notifyPropertyChanged(Property property, Notification notification) {
- switch (notification.getFeatureID(Property.class)) {
- case UMLPackage.PROPERTY__NAME:
- case UMLPackage.PORT__IS_CONJUGATED:
- case UMLPackage.PROPERTY__VISIBILITY:
- case UMLPackage.PROPERTY__IS_DERIVED:
- case UMLPackage.PROPERTY__DEFAULT_VALUE:
- case UMLPackage.PROPERTY__SUBSETTED_PROPERTY:
- case UMLPackage.PROPERTY__REDEFINED_PROPERTY:
- case UMLPackage.PROPERTY__IS_ORDERED:
- case UMLPackage.PROPERTY__IS_UNIQUE:
- case UMLPackage.PROPERTY__IS_READ_ONLY:
- refreshDisplay();
- break;
- case UMLPackage.PROPERTY__TYPE:
- case UMLPackage.PROPERTY__LOWER:
- case UMLPackage.PROPERTY__LOWER_VALUE:
- case UMLPackage.PROPERTY__UPPER:
- case UMLPackage.PROPERTY__UPPER_VALUE:
-
- switch (notification.getEventType()) {
- // if it is added => adds listener to the type element
- case Notification.ADD:
- getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this);
- refreshDisplay();
- // if it is removed => removes listener from the type element
- break;
- case Notification.ADD_MANY: // should never happen
- if (notification.getNewValue() instanceof List<?>) {
- List<?> addedElements = (List<?>) notification.getNewValue();
- for (Object addedElement : addedElements) {
- if (addedElement instanceof EObject) {
- getDiagramEventBroker().addNotificationListener((EObject) addedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- case Notification.REMOVE:
- getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this);
- refreshDisplay();
- break;
- case Notification.REMOVE_MANY: // should never happen
- if (notification.getOldValue() instanceof List<?>) {
- List<?> removedElements = (List<?>) notification.getOldValue();
- for (Object removedElement : removedElements) {
- if (removedElement instanceof EObject) {
- getDiagramEventBroker().removeNotificationListener((EObject) removedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- // if it is set, remove the old one and adds the new one. this is the method use when
- // the type is set or removed...
- case Notification.SET:
- if (notification.getOldValue() != null) {
- getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this);
- }
- if (notification.getNewValue() != null) {
- getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this);
- }
- refreshDisplay();
-
- default:
- break;
-
- }
-
- break;
- default:
- // does nothing in other cases
- break;
- }
- }
-
- /**
- * Refreshes the display of the edit part
- */
- @Override
- public void refreshDisplay() {
- // calls the helper for this edit Part
- PortLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost());
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2014 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) - Initial API and implementation + /*****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.editpolicies; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.papyrus.uml.diagram.common.helper.PortLabelHelper; +import org.eclipse.papyrus.uml.tools.utils.ICustomAppearance; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; + + +public class PortLabelEditPolicy extends PropertyLabelEditPolicy { + + /** + * {@inheritDoc} + */ + @Override + public Collection<String> getDefaultDisplayValue() { + return ICustomAppearance.DEFAULT_UML_PORT; + } + + /** + * {@inheritDoc} + */ + @Override + public Map<String, String> getMasks() { + return PortLabelHelper.getInstance().getMasks(); + } + + /** + * notifies that the the property has changed. + * + * @param property + * the property that has changed + * @param notification + * the notification send when the element has been changed + */ + @Override + protected void notifyPropertyChanged(Property property, Notification notification) { + switch (notification.getFeatureID(Property.class)) { + case UMLPackage.PROPERTY__NAME: + case UMLPackage.PORT__IS_CONJUGATED: + case UMLPackage.PROPERTY__VISIBILITY: + case UMLPackage.PROPERTY__IS_DERIVED: + case UMLPackage.PROPERTY__DEFAULT_VALUE: + case UMLPackage.PROPERTY__SUBSETTED_PROPERTY: + case UMLPackage.PROPERTY__REDEFINED_PROPERTY: + case UMLPackage.PROPERTY__IS_ORDERED: + case UMLPackage.PROPERTY__IS_UNIQUE: + case UMLPackage.PROPERTY__IS_READ_ONLY: + refreshDisplay(); + break; + case UMLPackage.PROPERTY__TYPE: + case UMLPackage.PROPERTY__LOWER: + case UMLPackage.PROPERTY__LOWER_VALUE: + case UMLPackage.PROPERTY__UPPER: + case UMLPackage.PROPERTY__UPPER_VALUE: + + switch (notification.getEventType()) { + // if it is added => adds listener to the type element + case Notification.ADD: + getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this); + refreshDisplay(); + // if it is removed => removes listener from the type element + break; + case Notification.ADD_MANY: // should never happen + if (notification.getNewValue() instanceof List<?>) { + List<?> addedElements = (List<?>) notification.getNewValue(); + for (Object addedElement : addedElements) { + if (addedElement instanceof EObject) { + getDiagramEventBroker().addNotificationListener((EObject) addedElement, this); + } + } + } + refreshDisplay(); + break; + case Notification.REMOVE: + getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this); + refreshDisplay(); + break; + case Notification.REMOVE_MANY: // should never happen + if (notification.getOldValue() instanceof List<?>) { + List<?> removedElements = (List<?>) notification.getOldValue(); + for (Object removedElement : removedElements) { + if (removedElement instanceof EObject) { + getDiagramEventBroker().removeNotificationListener((EObject) removedElement, this); + } + } + } + refreshDisplay(); + break; + // if it is set, remove the old one and adds the new one. this is the method use when + // the type is set or removed... + case Notification.SET: + if (notification.getOldValue() != null) { + getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this); + } + if (notification.getNewValue() != null) { + getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this); + } + refreshDisplay(); + + default: + break; + + } + + break; + default: + // does nothing in other cases + break; + } + } + + /** + * Refreshes the display of the edit part + */ + @Override + public void refreshDisplay() { + // calls the helper for this edit Part + PortLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost()); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/SideAffixedNodesCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/SideAffixedNodesCreationEditPolicy.java index 569550b745e..5c1c5cbe81c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/SideAffixedNodesCreationEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/SideAffixedNodesCreationEditPolicy.java @@ -1,117 +1,117 @@ -/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
- * 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.editpolicies;
-
-import java.util.Collections;
-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.requests.ChangeBoundsRequest;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-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.l10n.DiagramUIMessages;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
-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.ISideAffixedNodeBorderItemLocator;
-import org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator;
-
-
-public class SideAffixedNodesCreationEditPolicy extends DefaultCreationEditPolicy {
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected 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
- ISideAffixedNodeBorderItemLocator locator = getPositionLocator();
- if (locator == null) {
- return null;
- }
- final Rectangle preferredBounds = locator.getPreferredLocation(new Rectangle(requestedLocation, new Dimension(-1, -1)));
- 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(-1, -1));
- NodeSnapHelper helper = new NodeSnapHelper(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;
- }
-
- protected ISideAffixedNodeBorderItemLocator getPositionLocator() {
- return new PortPositionLocator(getHostFigure(), PositionConstants.NONE);
- }
-
- /**
- * {@inheritDoc}
- */
- protected IFigure getHostFigure() {
- return ((GraphicalEditPart) getHost()).getFigure();
- }
-}
+/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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.editpolicies; + +import java.util.Collections; +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.requests.ChangeBoundsRequest; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +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.l10n.DiagramUIMessages; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; +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.ISideAffixedNodeBorderItemLocator; +import org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator; + + +public class SideAffixedNodesCreationEditPolicy extends DefaultCreationEditPolicy { + + /** + * {@inheritDoc} + */ + @Override + protected 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 + ISideAffixedNodeBorderItemLocator locator = getPositionLocator(); + if (locator == null) { + return null; + } + final Rectangle preferredBounds = locator.getPreferredLocation(new Rectangle(requestedLocation, new Dimension(-1, -1))); + 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(-1, -1)); + NodeSnapHelper helper = new NodeSnapHelper(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; + } + + protected ISideAffixedNodeBorderItemLocator getPositionLocator() { + return new PortPositionLocator(getHostFigure(), PositionConstants.NONE); + } + + /** + * {@inheritDoc} + */ + protected IFigure getHostFigure() { + return ((GraphicalEditPart) getHost()).getFigure(); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/edge/AssociationFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/edge/AssociationFigure.java index bb16580e6f1..67dc93522ed 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/edge/AssociationFigure.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/edge/AssociationFigure.java @@ -1,552 +1,552 @@ -/*****************************************************************************
- * Copyright (c) 2009 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.figure.edge;
-
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.PolygonDecoration;
-import org.eclipse.draw2d.PolylineDecoration;
-import org.eclipse.draw2d.RotatableDecoration;
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel;
-import org.eclipse.swt.SWT;
-
-/**
- * this is the figure to display a association figure.
- */
-public class AssociationFigure extends UMLEdgeFigure {
-
- /** the end of the association is an aggregation i.e. this a transparent diamond. */
- public static final int aggregation = 2;
-
- /** the end of the association is a composition so this a black diamond. */
- public static final int composition = 4;
-
- /** the end of the association is navigable so this is an arrow. */
- public static final int navigable = 1;
-
- /** the end of contained the property. */
- public static final int owned = 8;
-
- /** The association name label. */
- private WrappingLabel fAssociationNameLabel;
-
- /** The multiplicity source label. */
- private WrappingLabel fMultiplicitySourceLabel;
-
- /** The multiplicity target label. */
- private WrappingLabel fMultiplicityTargetLabel;
-
- /** The role source label. */
- private WrappingLabel fRoleSourceLabel;
-
- /** The role target label. */
- private WrappingLabel fRoleTargetLabel;
-
- /** Source decoration type */
- private int sourceType;
-
- /** Target decoration type */
- private int targetType;
-
- /**
- * Instantiates a new association figure.
- */
- public AssociationFigure() {
- super();
- setAntialias(SWT.ON);
- createContents();
- }
-
- /**
- * create an association figure.
- *
- * @param targetType
- * the type of end of the association {@link AssociationFigure#navigable}
- * @param sourceType
- * the type of end of the association {@link AssociationFigure#navigable}
- */
- public AssociationFigure(int sourceType, int targetType) {
- super();
- this.setEnd(sourceType, targetType);
- createContents();
- }
-
- /**
- * Creates the contents.
- */
- @Override
- protected void createContents() {
- super.createContents();
- fAssociationNameLabel = new PapyrusWrappingLabel();
- fAssociationNameLabel.setText("");
- this.add(fAssociationNameLabel);
- // fAppliedStereotypeAssociationLabel = new WrappingLabel();
- // fAppliedStereotypeAssociationLabel.setText("");
- //
- // this.add(fAppliedStereotypeAssociationLabel);
- fRoleSourceLabel = new PapyrusWrappingLabel();
- fRoleSourceLabel.setText("");
- this.add(fRoleSourceLabel);
- fMultiplicitySourceLabel = new PapyrusWrappingLabel();
- fMultiplicitySourceLabel.setText("");
- this.add(fMultiplicitySourceLabel);
- fRoleTargetLabel = new PapyrusWrappingLabel();
- fRoleTargetLabel.setText("");
- this.add(fRoleTargetLabel);
- fMultiplicityTargetLabel = new PapyrusWrappingLabel();
- fMultiplicityTargetLabel.setText("");
- this.add(fMultiplicityTargetLabel);
- }
-
- /**
- * Gets the aggregation decoration.
- *
- * @return the aggregation decoration
- */
- protected RotatableDecoration getAggregationDecoration() {
- PolygonDecoration decoration = new PolygonDecoration();
- PointList decorationPointList = new PointList();
- decorationPointList.addPoint(0, 0);
- decorationPointList.addPoint(-2, 2);
- decorationPointList.addPoint(-4, 0);
- decorationPointList.addPoint(-2, -2);
- decoration.setTemplate(decorationPointList);
- decoration.setBackgroundColor(org.eclipse.draw2d.ColorConstants.white);
- decoration.setScale(4, 2);
- return decoration;
- }
-
- /**
- * Gets the applied stereotype association label.
- *
- * @return the applied stereotype association label
- */
- public WrappingLabel getAppliedStereotypeAssociationLabel() {
- return appliedStereotypeLabel;
- }
-
- /**
- * Gets the association name label.
- *
- * @return the association name label
- */
- public WrappingLabel getAssociationNameLabel() {
- return fAssociationNameLabel;
- }
-
- /**
- * Gets the composition decoration.
- *
- * @return the composition decoration
- */
- protected RotatableDecoration getCompositionDecoration() {
- PolygonDecoration decoration = new PolygonDecoration();
- PointList decorationPointList = new PointList();
- decorationPointList.addPoint(0, 0);
- decorationPointList.addPoint(-2, 2);
- decorationPointList.addPoint(-4, 0);
- decorationPointList.addPoint(-2, -2);
- decoration.setTemplate(decorationPointList);
- decoration.setScale(4, 2);
- return decoration;
- }
-
- /**
- * Gets the decoration.
- *
- * @param typeDecoration
- * the type decoration
- *
- * @return the decoration
- */
- public RotatableDecoration getDecoration(int typeDecoration) {
- // test if this a owned decoration
- int ownedValue = typeDecoration / owned;
- int remain = typeDecoration % owned;
- int compositeValue = remain / composition;
- remain = remain % composition;
- int aggregationValue = remain / aggregation;
- remain = remain % aggregation;
- int navigationValue = remain / navigable;
- // the end association is contained by the association?
- if (ownedValue == 1) {
- // this is composite.
- if (compositeValue == 1) {
- if (navigationValue == 1) {
- return getOwnedNavigableCompositionDecoration();
- }
- return getOwnedCompositionDecoration();
- }
- // an aggregation?
- else if (aggregationValue == 1) {
- if (navigationValue == 1) {
- return getOwnedNavigableAggregationDecoration();
- }
- return getOwnedAggregationDecoration();
- }
- // Is it navigable?
- else if (navigationValue == 1) {
- return getOwnedNavigationDecoration();
- } else {
- return getOwnedDecoration();
- }
- } else {
- // this is composite.
- if (compositeValue == 1) {
- if (navigationValue == 1) {
- return getNavigableCompositionDecoration();
- }
- return getCompositionDecoration();
- }
- // an aggregation?
- else if (aggregationValue == 1) {
- if (navigationValue == 1) {
- return getNavigableAggregationDecoration();
- }
- return getAggregationDecoration();
- }
- // Is it naviagable?
- else if (navigationValue == 1) {
- return getNavigationDecoration();
- }
- }
- return null;
- }
-
- /**
- * Gets the multiplicity source label.
- *
- * @return the multiplicity source label
- */
- public WrappingLabel getMultiplicitySourceLabel() {
- return fMultiplicitySourceLabel;
- }
-
- /**
- * Gets the multiplicity target label.
- *
- * @return the multiplicity target label
- */
- public WrappingLabel getMultiplicityTargetLabel() {
- return fMultiplicityTargetLabel;
- }
-
- /**
- * Gets the navigable aggregation decoration.
- *
- * @return the navigable aggregation decoration
- */
- protected RotatableDecoration getNavigableAggregationDecoration() {
- return getDiamondNavigableAggregationDecoration();
- }
-
- /**
- * Gets the navigable composition decoration.
- *
- * @return the navigable composition decoration
- */
- protected RotatableDecoration getNavigableCompositionDecoration() {
- return getDiamondNavigableCompositionDecoration();
- }
-
- /**
- * Gets the diamond navigable composition decoration.
- *
- * @return the diamond navigable composition decoration
- */
- private RotatableDecoration getDiamondNavigableCompositionDecoration() {
- PolygonDecoration decoration = new PolygonDecoration();
- PointList decorationPointList = new PointList();
- decorationPointList.addPoint(0, 1);
- decorationPointList.addPoint(-2, 3);
- decorationPointList.addPoint(-4, 3);
- decorationPointList.addPoint(-6, 1);
- decorationPointList.addPoint(-6, 0);
- decorationPointList.addPoint(-15, 6);
- decorationPointList.addPoint(-24, 0);
- decorationPointList.addPoint(-40, 8);
- decorationPointList.addPoint(-24, 0);
- decorationPointList.addPoint(-40, -8);
- decorationPointList.addPoint(-24, 0);
- decorationPointList.addPoint(-15, -6);
- decorationPointList.addPoint(-6, 0);
- decorationPointList.addPoint(-6, -1);
- decorationPointList.addPoint(-4, -3);
- decorationPointList.addPoint(-2, -3);
- decorationPointList.addPoint(0, -1); // color Point
- // decorationPointList.addPoint(-1, -1);
- // decorationPointList.addPoint(-1, 1);
- // decorationPointList.addPoint(-2, 3);
- // decorationPointList.addPoint(-2, -3);
- // decorationPointList.addPoint(-3, -3);
- // decorationPointList.addPoint(-3, 3);
- // decorationPointList.addPoint(-4, 3);
- // decorationPointList.addPoint(-4, -3);
- // decorationPointList.addPoint(-5, -2);
- // decorationPointList.addPoint(-5, 2);
- // decorationPointList.addPoint(-6, 1);
- // decorationPointList.addPoint(-6, -1);
- decoration.setScale(1, 0.75);
- decoration.setTemplate(decorationPointList);
- return decoration;
- }
-
- /**
- * Gets the diamond navigable aggregation decoration.
- *
- * @return the diamond navigable aggregation decoration
- */
- private RotatableDecoration getDiamondNavigableAggregationDecoration() {
- PolygonDecoration decoration = new PolygonDecoration();
- PointList decorationPointList = new PointList();
- decorationPointList.addPoint(0, 1);
- decorationPointList.addPoint(-2, 3);
- decorationPointList.addPoint(-4, 3);
- decorationPointList.addPoint(-6, 1);
- decorationPointList.addPoint(-6, 0);
- decorationPointList.addPoint(-15, 5);
- decorationPointList.addPoint(-24, 0);
- decorationPointList.addPoint(-40, 5);
- decorationPointList.addPoint(-24, 0);
- decorationPointList.addPoint(-40, -5);
- decorationPointList.addPoint(-24, 0);
- decorationPointList.addPoint(-15, -5);
- decorationPointList.addPoint(-6, 0);
- decorationPointList.addPoint(-6, -1);
- decorationPointList.addPoint(-4, -3);
- decorationPointList.addPoint(-2, -3);
- decorationPointList.addPoint(0, -1); // color Point
- decorationPointList.addPoint(-1, -1);
- decorationPointList.addPoint(-1, -1);
- decorationPointList.addPoint(-1, 1);
- decorationPointList.addPoint(-2, 3);
- decorationPointList.addPoint(-2, -3);
- decorationPointList.addPoint(-3, -3);
- decorationPointList.addPoint(-3, 3);
- decorationPointList.addPoint(-4, 3);
- decorationPointList.addPoint(-4, -3);
- decorationPointList.addPoint(-5, -2);
- decorationPointList.addPoint(-5, 2);
- decorationPointList.addPoint(-6, 1);
- decorationPointList.addPoint(-6, -1);
- decoration.setScale(1, 0.75);
- decoration.setTemplate(decorationPointList);
- decoration.setBackgroundColor(org.eclipse.draw2d.ColorConstants.white);
- return decoration;
- }
-
- /**
- * Gets the navigation decoration.
- *
- * @return the navigation decoration
- */
- protected RotatableDecoration getNavigationDecoration() {
- PolylineDecoration dec = new PolylineDecoration();
- dec.setScale(15, 5);
- dec.setLineWidth(1);
- return dec;
- }
-
- /**
- * Gets the owned aggregation decoration.
- *
- * @return the owned aggregation decoration
- */
- protected RotatableDecoration getOwnedAggregationDecoration() {
- PolygonDecoration decoration = new PolygonDecoration();
- PointList decorationPointList = new PointList();
- decorationPointList.addPoint(0, 1);
- decorationPointList.addPoint(-2, 3);
- decorationPointList.addPoint(-4, 3);
- decorationPointList.addPoint(-6, 1);
- decorationPointList.addPoint(-6, 0);
- decorationPointList.addPoint(-15, 6);
- decorationPointList.addPoint(-24, 0);
- decorationPointList.addPoint(-15, -6);
- decorationPointList.addPoint(-6, 0);
- decorationPointList.addPoint(-6, -1);
- decorationPointList.addPoint(-4, -3);
- decorationPointList.addPoint(-2, -3);
- decorationPointList.addPoint(0, -1); // color Point
- decorationPointList.addPoint(-1, -1);
- decorationPointList.addPoint(-1, 1);
- decorationPointList.addPoint(-2, 3);
- decorationPointList.addPoint(-2, -3);
- decorationPointList.addPoint(-3, -3);
- decorationPointList.addPoint(-3, 3);
- decorationPointList.addPoint(-4, 3);
- decorationPointList.addPoint(-4, -3);
- decorationPointList.addPoint(-5, -2);
- decorationPointList.addPoint(-5, 2);
- decorationPointList.addPoint(-6, 1);
- decorationPointList.addPoint(-6, -1);
- decoration.setScale(3, 2);
- decoration.setTemplate(decorationPointList);
- decoration.setBackgroundColor(org.eclipse.draw2d.ColorConstants.white);
- return decoration;
- }
-
- /**
- * Gets the owned composition decoration.
- *
- * @return the owned composition decoration
- */
- protected RotatableDecoration getOwnedCompositionDecoration() {
- PolygonDecoration decoration = new PolygonDecoration();
- PointList decorationPointList = new PointList();
- decorationPointList.addPoint(0, 1);
- decorationPointList.addPoint(-2, 3);
- decorationPointList.addPoint(-4, 3);
- decorationPointList.addPoint(-6, 1);
- decorationPointList.addPoint(-6, 0);
- decorationPointList.addPoint(-15, 6);
- decorationPointList.addPoint(-24, 0);
- decorationPointList.addPoint(-15, -6);
- decorationPointList.addPoint(-6, 0);
- decorationPointList.addPoint(-6, -1);
- decorationPointList.addPoint(-4, -3);
- decorationPointList.addPoint(-2, -3);
- decorationPointList.addPoint(0, -1); // color Point
- // decorationPointList.addPoint(-1, -1);
- // decorationPointList.addPoint(-1, 1);
- // decorationPointList.addPoint(-2, 3);
- // decorationPointList.addPoint(-2, -3);
- // decorationPointList.addPoint(-3, -3);
- // decorationPointList.addPoint(-3, 3);
- // decorationPointList.addPoint(-4, 3);
- // decorationPointList.addPoint(-4, -3);
- // decorationPointList.addPoint(-5, -2);
- // decorationPointList.addPoint(-5, 2);
- // decorationPointList.addPoint(-6, 1);
- // decorationPointList.addPoint(-6, -1);
- decoration.setScale(3, 2);
- decoration.setTemplate(decorationPointList);
- return decoration;
- }
-
- /**
- * Gets the owned decoration.
- *
- * @return the owned decoration
- */
- protected RotatableDecoration getOwnedDecoration() {
- PolygonDecoration decoration = new PolygonDecoration();
- PointList decorationPointList = new PointList();
- decorationPointList.addPoint(0, 1);
- decorationPointList.addPoint(-2, 3);
- decorationPointList.addPoint(-4, 3);
- decorationPointList.addPoint(-6, 1);
- decorationPointList.addPoint(-6, -1);
- decorationPointList.addPoint(-4, -3);
- decorationPointList.addPoint(-2, -3);
- decorationPointList.addPoint(0, -1);
- decoration.setTemplate(decorationPointList);
- decoration.setScale(1, 1);
- return decoration;
- }
-
- /**
- * Gets the owned navigable aggregation decoration.
- *
- * @return the owned navigable aggregation decoration
- */
- protected RotatableDecoration getOwnedNavigableAggregationDecoration() {
- return getDiamondNavigableAggregationDecoration();
- }
-
- /**
- * Gets the owned navigable composition decoration.
- *
- * @return the owned navigable composition decoration
- */
- protected RotatableDecoration getOwnedNavigableCompositionDecoration() {
- return getDiamondNavigableCompositionDecoration();
- }
-
- /**
- * Gets the owned navigation decoration.
- *
- * @return the owned navigation decoration
- */
- protected RotatableDecoration getOwnedNavigationDecoration() {
- PolygonDecoration decoration = new PolygonDecoration();
- PointList decorationPointList = new PointList();
- decorationPointList.addPoint(0, 1);
- decorationPointList.addPoint(-2, 3);
- decorationPointList.addPoint(-4, 3);
- decorationPointList.addPoint(-6, 1);
- decorationPointList.addPoint(-6, 0);
- decorationPointList.addPoint(-18, 6);
- decorationPointList.addPoint(-6, 0);
- decorationPointList.addPoint(-18, -6);
- decorationPointList.addPoint(-6, 0);
- decorationPointList.addPoint(-6, -1);
- decorationPointList.addPoint(-4, -3);
- decorationPointList.addPoint(-2, -3);
- decorationPointList.addPoint(0, -1);
- decoration.setScale(1, 1);
- decoration.setTemplate(decorationPointList);
- return decoration;
- }
-
- /**
- * Gets the role source label.
- *
- * @return the role source label
- */
- public WrappingLabel getRoleSourceLabel() {
- return fRoleSourceLabel;
- }
-
- /**
- * Gets the role target label.
- *
- * @return the role target label
- */
- public WrappingLabel getRoleTargetLabel() {
- return fRoleTargetLabel;
- }
-
- /**
- * {@inheritedDoc}
- */
- @Override
- public void paintFigure(Graphics graphics) {
- graphics.setAntialias(SWT.ON);
- super.paintFigure(graphics);
- }
-
- /**
- * used to display end of the association.
- *
- * @param targetType
- * the type of end of the association {@link AssociationFigure#navigable}
- * @param sourceType
- * the type of end of the association {@link AssociationFigure#navigable}
- */
- public void setEnd(int sourceType, int targetType) {
- this.sourceType = sourceType;
- this.targetType = targetType;
- this.setSourceDecoration(getDecoration(sourceType));
- this.setTargetDecoration(getDecoration(targetType));
- }
-
- @Override
- public void resetStyle() {
- super.resetStyle();
- setSourceDecoration(getDecoration(sourceType));
- setTargetDecoration(getDecoration(targetType));
- }
-}
+/***************************************************************************** + * Copyright (c) 2009 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.figure.edge; + +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.PolygonDecoration; +import org.eclipse.draw2d.PolylineDecoration; +import org.eclipse.draw2d.RotatableDecoration; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; +import org.eclipse.swt.SWT; + +/** + * this is the figure to display a association figure. + */ +public class AssociationFigure extends UMLEdgeFigure { + + /** the end of the association is an aggregation i.e. this a transparent diamond. */ + public static final int aggregation = 2; + + /** the end of the association is a composition so this a black diamond. */ + public static final int composition = 4; + + /** the end of the association is navigable so this is an arrow. */ + public static final int navigable = 1; + + /** the end of contained the property. */ + public static final int owned = 8; + + /** The association name label. */ + private WrappingLabel fAssociationNameLabel; + + /** The multiplicity source label. */ + private WrappingLabel fMultiplicitySourceLabel; + + /** The multiplicity target label. */ + private WrappingLabel fMultiplicityTargetLabel; + + /** The role source label. */ + private WrappingLabel fRoleSourceLabel; + + /** The role target label. */ + private WrappingLabel fRoleTargetLabel; + + /** Source decoration type */ + private int sourceType; + + /** Target decoration type */ + private int targetType; + + /** + * Instantiates a new association figure. + */ + public AssociationFigure() { + super(); + setAntialias(SWT.ON); + createContents(); + } + + /** + * create an association figure. + * + * @param targetType + * the type of end of the association {@link AssociationFigure#navigable} + * @param sourceType + * the type of end of the association {@link AssociationFigure#navigable} + */ + public AssociationFigure(int sourceType, int targetType) { + super(); + this.setEnd(sourceType, targetType); + createContents(); + } + + /** + * Creates the contents. + */ + @Override + protected void createContents() { + super.createContents(); + fAssociationNameLabel = new PapyrusWrappingLabel(); + fAssociationNameLabel.setText(""); + this.add(fAssociationNameLabel); + // fAppliedStereotypeAssociationLabel = new WrappingLabel(); + // fAppliedStereotypeAssociationLabel.setText(""); + // + // this.add(fAppliedStereotypeAssociationLabel); + fRoleSourceLabel = new PapyrusWrappingLabel(); + fRoleSourceLabel.setText(""); + this.add(fRoleSourceLabel); + fMultiplicitySourceLabel = new PapyrusWrappingLabel(); + fMultiplicitySourceLabel.setText(""); + this.add(fMultiplicitySourceLabel); + fRoleTargetLabel = new PapyrusWrappingLabel(); + fRoleTargetLabel.setText(""); + this.add(fRoleTargetLabel); + fMultiplicityTargetLabel = new PapyrusWrappingLabel(); + fMultiplicityTargetLabel.setText(""); + this.add(fMultiplicityTargetLabel); + } + + /** + * Gets the aggregation decoration. + * + * @return the aggregation decoration + */ + protected RotatableDecoration getAggregationDecoration() { + PolygonDecoration decoration = new PolygonDecoration(); + PointList decorationPointList = new PointList(); + decorationPointList.addPoint(0, 0); + decorationPointList.addPoint(-2, 2); + decorationPointList.addPoint(-4, 0); + decorationPointList.addPoint(-2, -2); + decoration.setTemplate(decorationPointList); + decoration.setBackgroundColor(org.eclipse.draw2d.ColorConstants.white); + decoration.setScale(4, 2); + return decoration; + } + + /** + * Gets the applied stereotype association label. + * + * @return the applied stereotype association label + */ + public WrappingLabel getAppliedStereotypeAssociationLabel() { + return appliedStereotypeLabel; + } + + /** + * Gets the association name label. + * + * @return the association name label + */ + public WrappingLabel getAssociationNameLabel() { + return fAssociationNameLabel; + } + + /** + * Gets the composition decoration. + * + * @return the composition decoration + */ + protected RotatableDecoration getCompositionDecoration() { + PolygonDecoration decoration = new PolygonDecoration(); + PointList decorationPointList = new PointList(); + decorationPointList.addPoint(0, 0); + decorationPointList.addPoint(-2, 2); + decorationPointList.addPoint(-4, 0); + decorationPointList.addPoint(-2, -2); + decoration.setTemplate(decorationPointList); + decoration.setScale(4, 2); + return decoration; + } + + /** + * Gets the decoration. + * + * @param typeDecoration + * the type decoration + * + * @return the decoration + */ + public RotatableDecoration getDecoration(int typeDecoration) { + // test if this a owned decoration + int ownedValue = typeDecoration / owned; + int remain = typeDecoration % owned; + int compositeValue = remain / composition; + remain = remain % composition; + int aggregationValue = remain / aggregation; + remain = remain % aggregation; + int navigationValue = remain / navigable; + // the end association is contained by the association? + if (ownedValue == 1) { + // this is composite. + if (compositeValue == 1) { + if (navigationValue == 1) { + return getOwnedNavigableCompositionDecoration(); + } + return getOwnedCompositionDecoration(); + } + // an aggregation? + else if (aggregationValue == 1) { + if (navigationValue == 1) { + return getOwnedNavigableAggregationDecoration(); + } + return getOwnedAggregationDecoration(); + } + // Is it navigable? + else if (navigationValue == 1) { + return getOwnedNavigationDecoration(); + } else { + return getOwnedDecoration(); + } + } else { + // this is composite. + if (compositeValue == 1) { + if (navigationValue == 1) { + return getNavigableCompositionDecoration(); + } + return getCompositionDecoration(); + } + // an aggregation? + else if (aggregationValue == 1) { + if (navigationValue == 1) { + return getNavigableAggregationDecoration(); + } + return getAggregationDecoration(); + } + // Is it naviagable? + else if (navigationValue == 1) { + return getNavigationDecoration(); + } + } + return null; + } + + /** + * Gets the multiplicity source label. + * + * @return the multiplicity source label + */ + public WrappingLabel getMultiplicitySourceLabel() { + return fMultiplicitySourceLabel; + } + + /** + * Gets the multiplicity target label. + * + * @return the multiplicity target label + */ + public WrappingLabel getMultiplicityTargetLabel() { + return fMultiplicityTargetLabel; + } + + /** + * Gets the navigable aggregation decoration. + * + * @return the navigable aggregation decoration + */ + protected RotatableDecoration getNavigableAggregationDecoration() { + return getDiamondNavigableAggregationDecoration(); + } + + /** + * Gets the navigable composition decoration. + * + * @return the navigable composition decoration + */ + protected RotatableDecoration getNavigableCompositionDecoration() { + return getDiamondNavigableCompositionDecoration(); + } + + /** + * Gets the diamond navigable composition decoration. + * + * @return the diamond navigable composition decoration + */ + private RotatableDecoration getDiamondNavigableCompositionDecoration() { + PolygonDecoration decoration = new PolygonDecoration(); + PointList decorationPointList = new PointList(); + decorationPointList.addPoint(0, 1); + decorationPointList.addPoint(-2, 3); + decorationPointList.addPoint(-4, 3); + decorationPointList.addPoint(-6, 1); + decorationPointList.addPoint(-6, 0); + decorationPointList.addPoint(-15, 6); + decorationPointList.addPoint(-24, 0); + decorationPointList.addPoint(-40, 8); + decorationPointList.addPoint(-24, 0); + decorationPointList.addPoint(-40, -8); + decorationPointList.addPoint(-24, 0); + decorationPointList.addPoint(-15, -6); + decorationPointList.addPoint(-6, 0); + decorationPointList.addPoint(-6, -1); + decorationPointList.addPoint(-4, -3); + decorationPointList.addPoint(-2, -3); + decorationPointList.addPoint(0, -1); // color Point + // decorationPointList.addPoint(-1, -1); + // decorationPointList.addPoint(-1, 1); + // decorationPointList.addPoint(-2, 3); + // decorationPointList.addPoint(-2, -3); + // decorationPointList.addPoint(-3, -3); + // decorationPointList.addPoint(-3, 3); + // decorationPointList.addPoint(-4, 3); + // decorationPointList.addPoint(-4, -3); + // decorationPointList.addPoint(-5, -2); + // decorationPointList.addPoint(-5, 2); + // decorationPointList.addPoint(-6, 1); + // decorationPointList.addPoint(-6, -1); + decoration.setScale(1, 0.75); + decoration.setTemplate(decorationPointList); + return decoration; + } + + /** + * Gets the diamond navigable aggregation decoration. + * + * @return the diamond navigable aggregation decoration + */ + private RotatableDecoration getDiamondNavigableAggregationDecoration() { + PolygonDecoration decoration = new PolygonDecoration(); + PointList decorationPointList = new PointList(); + decorationPointList.addPoint(0, 1); + decorationPointList.addPoint(-2, 3); + decorationPointList.addPoint(-4, 3); + decorationPointList.addPoint(-6, 1); + decorationPointList.addPoint(-6, 0); + decorationPointList.addPoint(-15, 5); + decorationPointList.addPoint(-24, 0); + decorationPointList.addPoint(-40, 5); + decorationPointList.addPoint(-24, 0); + decorationPointList.addPoint(-40, -5); + decorationPointList.addPoint(-24, 0); + decorationPointList.addPoint(-15, -5); + decorationPointList.addPoint(-6, 0); + decorationPointList.addPoint(-6, -1); + decorationPointList.addPoint(-4, -3); + decorationPointList.addPoint(-2, -3); + decorationPointList.addPoint(0, -1); // color Point + decorationPointList.addPoint(-1, -1); + decorationPointList.addPoint(-1, -1); + decorationPointList.addPoint(-1, 1); + decorationPointList.addPoint(-2, 3); + decorationPointList.addPoint(-2, -3); + decorationPointList.addPoint(-3, -3); + decorationPointList.addPoint(-3, 3); + decorationPointList.addPoint(-4, 3); + decorationPointList.addPoint(-4, -3); + decorationPointList.addPoint(-5, -2); + decorationPointList.addPoint(-5, 2); + decorationPointList.addPoint(-6, 1); + decorationPointList.addPoint(-6, -1); + decoration.setScale(1, 0.75); + decoration.setTemplate(decorationPointList); + decoration.setBackgroundColor(org.eclipse.draw2d.ColorConstants.white); + return decoration; + } + + /** + * Gets the navigation decoration. + * + * @return the navigation decoration + */ + protected RotatableDecoration getNavigationDecoration() { + PolylineDecoration dec = new PolylineDecoration(); + dec.setScale(15, 5); + dec.setLineWidth(1); + return dec; + } + + /** + * Gets the owned aggregation decoration. + * + * @return the owned aggregation decoration + */ + protected RotatableDecoration getOwnedAggregationDecoration() { + PolygonDecoration decoration = new PolygonDecoration(); + PointList decorationPointList = new PointList(); + decorationPointList.addPoint(0, 1); + decorationPointList.addPoint(-2, 3); + decorationPointList.addPoint(-4, 3); + decorationPointList.addPoint(-6, 1); + decorationPointList.addPoint(-6, 0); + decorationPointList.addPoint(-15, 6); + decorationPointList.addPoint(-24, 0); + decorationPointList.addPoint(-15, -6); + decorationPointList.addPoint(-6, 0); + decorationPointList.addPoint(-6, -1); + decorationPointList.addPoint(-4, -3); + decorationPointList.addPoint(-2, -3); + decorationPointList.addPoint(0, -1); // color Point + decorationPointList.addPoint(-1, -1); + decorationPointList.addPoint(-1, 1); + decorationPointList.addPoint(-2, 3); + decorationPointList.addPoint(-2, -3); + decorationPointList.addPoint(-3, -3); + decorationPointList.addPoint(-3, 3); + decorationPointList.addPoint(-4, 3); + decorationPointList.addPoint(-4, -3); + decorationPointList.addPoint(-5, -2); + decorationPointList.addPoint(-5, 2); + decorationPointList.addPoint(-6, 1); + decorationPointList.addPoint(-6, -1); + decoration.setScale(3, 2); + decoration.setTemplate(decorationPointList); + decoration.setBackgroundColor(org.eclipse.draw2d.ColorConstants.white); + return decoration; + } + + /** + * Gets the owned composition decoration. + * + * @return the owned composition decoration + */ + protected RotatableDecoration getOwnedCompositionDecoration() { + PolygonDecoration decoration = new PolygonDecoration(); + PointList decorationPointList = new PointList(); + decorationPointList.addPoint(0, 1); + decorationPointList.addPoint(-2, 3); + decorationPointList.addPoint(-4, 3); + decorationPointList.addPoint(-6, 1); + decorationPointList.addPoint(-6, 0); + decorationPointList.addPoint(-15, 6); + decorationPointList.addPoint(-24, 0); + decorationPointList.addPoint(-15, -6); + decorationPointList.addPoint(-6, 0); + decorationPointList.addPoint(-6, -1); + decorationPointList.addPoint(-4, -3); + decorationPointList.addPoint(-2, -3); + decorationPointList.addPoint(0, -1); // color Point + // decorationPointList.addPoint(-1, -1); + // decorationPointList.addPoint(-1, 1); + // decorationPointList.addPoint(-2, 3); + // decorationPointList.addPoint(-2, -3); + // decorationPointList.addPoint(-3, -3); + // decorationPointList.addPoint(-3, 3); + // decorationPointList.addPoint(-4, 3); + // decorationPointList.addPoint(-4, -3); + // decorationPointList.addPoint(-5, -2); + // decorationPointList.addPoint(-5, 2); + // decorationPointList.addPoint(-6, 1); + // decorationPointList.addPoint(-6, -1); + decoration.setScale(3, 2); + decoration.setTemplate(decorationPointList); + return decoration; + } + + /** + * Gets the owned decoration. + * + * @return the owned decoration + */ + protected RotatableDecoration getOwnedDecoration() { + PolygonDecoration decoration = new PolygonDecoration(); + PointList decorationPointList = new PointList(); + decorationPointList.addPoint(0, 1); + decorationPointList.addPoint(-2, 3); + decorationPointList.addPoint(-4, 3); + decorationPointList.addPoint(-6, 1); + decorationPointList.addPoint(-6, -1); + decorationPointList.addPoint(-4, -3); + decorationPointList.addPoint(-2, -3); + decorationPointList.addPoint(0, -1); + decoration.setTemplate(decorationPointList); + decoration.setScale(1, 1); + return decoration; + } + + /** + * Gets the owned navigable aggregation decoration. + * + * @return the owned navigable aggregation decoration + */ + protected RotatableDecoration getOwnedNavigableAggregationDecoration() { + return getDiamondNavigableAggregationDecoration(); + } + + /** + * Gets the owned navigable composition decoration. + * + * @return the owned navigable composition decoration + */ + protected RotatableDecoration getOwnedNavigableCompositionDecoration() { + return getDiamondNavigableCompositionDecoration(); + } + + /** + * Gets the owned navigation decoration. + * + * @return the owned navigation decoration + */ + protected RotatableDecoration getOwnedNavigationDecoration() { + PolygonDecoration decoration = new PolygonDecoration(); + PointList decorationPointList = new PointList(); + decorationPointList.addPoint(0, 1); + decorationPointList.addPoint(-2, 3); + decorationPointList.addPoint(-4, 3); + decorationPointList.addPoint(-6, 1); + decorationPointList.addPoint(-6, 0); + decorationPointList.addPoint(-18, 6); + decorationPointList.addPoint(-6, 0); + decorationPointList.addPoint(-18, -6); + decorationPointList.addPoint(-6, 0); + decorationPointList.addPoint(-6, -1); + decorationPointList.addPoint(-4, -3); + decorationPointList.addPoint(-2, -3); + decorationPointList.addPoint(0, -1); + decoration.setScale(1, 1); + decoration.setTemplate(decorationPointList); + return decoration; + } + + /** + * Gets the role source label. + * + * @return the role source label + */ + public WrappingLabel getRoleSourceLabel() { + return fRoleSourceLabel; + } + + /** + * Gets the role target label. + * + * @return the role target label + */ + public WrappingLabel getRoleTargetLabel() { + return fRoleTargetLabel; + } + + /** + * {@inheritedDoc} + */ + @Override + public void paintFigure(Graphics graphics) { + graphics.setAntialias(SWT.ON); + super.paintFigure(graphics); + } + + /** + * used to display end of the association. + * + * @param targetType + * the type of end of the association {@link AssociationFigure#navigable} + * @param sourceType + * the type of end of the association {@link AssociationFigure#navigable} + */ + public void setEnd(int sourceType, int targetType) { + this.sourceType = sourceType; + this.targetType = targetType; + this.setSourceDecoration(getDecoration(sourceType)); + this.setTargetDecoration(getDecoration(targetType)); + } + + @Override + public void resetStyle() { + super.resetStyle(); + setSourceDecoration(getDecoration(sourceType)); + setTargetDecoration(getDecoration(targetType)); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/edge/CommonEdgeFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/edge/CommonEdgeFigure.java index 407b8e98c94..4935072e7c7 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/edge/CommonEdgeFigure.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/edge/CommonEdgeFigure.java @@ -1,49 +1,49 @@ -/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.figure.edge;
-
-
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.edge.PapyrusEdgeFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.Activator;
-
-/**
- *
- * This figure allows to use the Papyrus Preference Store to know if connection point must be drawn or not.
- * This class should be located in oep.infra.gmfdiag.common, but there is a dependency problem with oep.infra.gmfdiag.preferences
- *
- */
-public class CommonEdgeFigure extends PapyrusEdgeFigure {
-
- /**
- *
- * Constructor.
- *
- */
- public CommonEdgeFigure() {
- super();
- }
-
- /**
- *
- * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.edge.PapyrusEdgeFigure#getDrawBendpointPreferenceValue()
- *
- * @return
- */
- @Override
- protected boolean getDrawBendpointPreferenceValue() {
- final String value = PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.DRAW_CONNECTION_POINT);
- return Activator.getDefault().getPreferenceStore().getBoolean(value);
- }
-}
+/***************************************************************************** + * Copyright (c) 2013 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.figure.edge; + + +import org.eclipse.papyrus.infra.gmfdiag.common.figure.edge.PapyrusEdgeFigure; +import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper; +import org.eclipse.papyrus.infra.gmfdiag.preferences.Activator; + +/** + * + * This figure allows to use the Papyrus Preference Store to know if connection point must be drawn or not. + * This class should be located in oep.infra.gmfdiag.common, but there is a dependency problem with oep.infra.gmfdiag.preferences + * + */ +public class CommonEdgeFigure extends PapyrusEdgeFigure { + + /** + * + * Constructor. + * + */ + public CommonEdgeFigure() { + super(); + } + + /** + * + * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.edge.PapyrusEdgeFigure#getDrawBendpointPreferenceValue() + * + * @return + */ + @Override + protected boolean getDrawBendpointPreferenceValue() { + final String value = PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.DRAW_CONNECTION_POINT); + return Activator.getDefault().getPreferenceStore().getBoolean(value); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/EllipseFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/EllipseFigure.java index 1aa9f107439..e4ad4285dca 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/EllipseFigure.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/EllipseFigure.java @@ -1,76 +1,76 @@ -/******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- ****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.figure.node;
-
-
-
-import org.eclipse.draw2d.ConnectionAnchor;
-import org.eclipse.draw2d.geometry.PrecisionPoint;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.IOvalAnchorableFigure;
-import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
-import org.eclipse.gmf.runtime.gef.ui.figures.SlidableOvalAnchor;
-
-/**
- * Draws a circle figure. The figures bounds are guaranteed to be the circle
- * diameter
- *
- * @author mhanner
- */
-public class EllipseFigure extends DefaultSizeNodeFigure implements IOvalAnchorableFigure {
-
-
- /**
- * Constructor for StateLineFigure.
- *
- * @param width
- * figure width
- * @param height
- * figure height
- */
- public EllipseFigure(int width, int height) {
- super(width, height);
- }
-
-
-
- /** Return <code>getBounds()</code>. */
- @Override
- public final Rectangle getOvalBounds() {
- return getBounds();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#createAnchor(org.eclipse.draw2d.geometry.PrecisionPoint)
- */
- @Override
- protected ConnectionAnchor createAnchor(PrecisionPoint p) {
- if (p == null) {
- // If the old terminal for the connection anchor cannot be resolved (by SlidableAnchor) a null
- // PrecisionPoint will passed in - this is handled here
- return createDefaultAnchor();
- }
- return new SlidableOvalAnchor(this, p);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#createDefaultAnchor()
- */
- @Override
- protected ConnectionAnchor createDefaultAnchor() {
- return new SlidableOvalAnchor(this);
- }
-}
+/****************************************************************************** + * Copyright (c) 2003, 2004 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + ****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.common.figure.node; + + + +import org.eclipse.draw2d.ConnectionAnchor; +import org.eclipse.draw2d.geometry.PrecisionPoint; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gmf.runtime.draw2d.ui.figures.IOvalAnchorableFigure; +import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure; +import org.eclipse.gmf.runtime.gef.ui.figures.SlidableOvalAnchor; + +/** + * Draws a circle figure. The figures bounds are guaranteed to be the circle + * diameter + * + * @author mhanner + */ +public class EllipseFigure extends DefaultSizeNodeFigure implements IOvalAnchorableFigure { + + + /** + * Constructor for StateLineFigure. + * + * @param width + * figure width + * @param height + * figure height + */ + public EllipseFigure(int width, int height) { + super(width, height); + } + + + + /** Return <code>getBounds()</code>. */ + @Override + public final Rectangle getOvalBounds() { + return getBounds(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#createAnchor(org.eclipse.draw2d.geometry.PrecisionPoint) + */ + @Override + protected ConnectionAnchor createAnchor(PrecisionPoint p) { + if (p == null) { + // If the old terminal for the connection anchor cannot be resolved (by SlidableAnchor) a null + // PrecisionPoint will passed in - this is handled here + return createDefaultAnchor(); + } + return new SlidableOvalAnchor(this, p); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#createDefaultAnchor() + */ + @Override + protected ConnectionAnchor createDefaultAnchor() { + return new SlidableOvalAnchor(this); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/CmdHandler.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/CmdHandler.java index 790efdb7c0c..a28e547a3e7 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/CmdHandler.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/CmdHandler.java @@ -1,45 +1,45 @@ -/*****************************************************************************
- * Copyright (c) 2014 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:
- * Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.handlers;
-
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.ui.PlatformUI;
-
-
-/**
- * Simple superclass for handlers. It converts a selection into an EObject.
- * Used by C++ code generator and Qompass designer
- */
-public abstract class CmdHandler extends AbstractHandler {
-
- /**
- * Convert selected elements within model explorer or diagram to an eObject
- */
- public void updateSelectedEObject() {
- // Retrieve selected elements
- IStructuredSelection selection = (IStructuredSelection) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
-
- if (selection != null) {
- selectedEObject = EMFHelper.getEObject(selection.getFirstElement());
- }
- }
-
- /**
- * Store the selected EObject. Accessible for subclasses
- */
- protected EObject selectedEObject;
-}
+/***************************************************************************** + * Copyright (c) 2014 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: + * Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.common.handlers; + + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.ui.PlatformUI; + + +/** + * Simple superclass for handlers. It converts a selection into an EObject. + * Used by C++ code generator and Qompass designer + */ +public abstract class CmdHandler extends AbstractHandler { + + /** + * Convert selected elements within model explorer or diagram to an eObject + */ + public void updateSelectedEObject() { + // Retrieve selected elements + IStructuredSelection selection = (IStructuredSelection) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); + + if (selection != null) { + selectedEObject = EMFHelper.getEObject(selection.getFirstElement()); + } + } + + /** + * Store the selected EObject. Accessible for subclasses + */ + protected EObject selectedEObject; +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationBranchEndLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationBranchEndLabelHelper.java index 1f24886c72c..70cb50b79be 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationBranchEndLabelHelper.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationBranchEndLabelHelper.java @@ -1,85 +1,85 @@ -/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.helper;
-
-import java.util.Iterator;
-
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.uml2.uml.Association;
-import org.eclipse.uml2.uml.Classifier;
-import org.eclipse.uml2.uml.Property;
-
-/**
- * Helper for labels displaying {@link Property}
- */
-public class AssociationBranchEndLabelHelper extends AssociationEndPropertyLabelHelper {
-
- private static AssociationBranchEndLabelHelper labelHelper;
-
- public static AssociationBranchEndLabelHelper getInstance() {
- if (labelHelper == null) {
- labelHelper = new AssociationBranchEndLabelHelper();
- }
- return labelHelper;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Property getUMLElement(GraphicalEditPart editPart) {
- if ((View) editPart.getModel() != null && ((View) editPart.getModel()).eContainer() != null) {
- if (MultiAssociationHelper.getSemanticBranchEnd(((Edge) ((View) editPart.getModel()).eContainer())) != null) {
- return MultiAssociationHelper.getSemanticBranchEnd(((Edge) ((View) editPart.getModel()).eContainer()));
- }
- if (((Edge) ((View) editPart.getModel()).eContainer()).getTarget() == null) {
- return null;
- }
- Classifier target = (Classifier) ((Edge) ((View) editPart.getModel()).eContainer()).getTarget().getElement();
- Property propertyToDisplay = null;
- if (((View) editPart.getModel()) != null && (((View) editPart.getModel()).getElement() instanceof Association)) {
- // look for the property that is typed by the classifier
- Iterator<Property> propertiesIterator = ((Association) ((View) editPart.getModel()).getElement()).getMemberEnds().iterator();
- // find the last
- while (propertiesIterator.hasNext()) {
- Property currentProperty = propertiesIterator.next();
- if (currentProperty.getType().equals(target)) {
- propertyToDisplay = currentProperty;
- }
- }
- }
- if (propertyToDisplay != null) {
- return propertyToDisplay;
- }
- // /in the case of reorient the property must be not found,
- // so we have to find the property that is different from the source.
- Classifier source = (Classifier) ((Edge) ((View) editPart.getModel()).eContainer()).getSource().getElement();
- if (((View) editPart.getModel()) != null && (((View) editPart.getModel()).getElement() instanceof Association)) {
- // look for the property that is typed by the classifier
- Iterator<Property> propertiesIterator = ((Association) ((View) editPart.getModel()).getElement()).getMemberEnds().iterator();
- // find the last
- while (propertiesIterator.hasNext()) {
- Property currentProperty = propertiesIterator.next();
- if (!currentProperty.getType().equals(source)) {
- propertyToDisplay = currentProperty;
- }
- }
- }
- return propertyToDisplay;
- }
- return null;
- }
-}
+/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.helper; + +import java.util.Iterator; + +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gmf.runtime.notation.Edge; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.uml2.uml.Association; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.Property; + +/** + * Helper for labels displaying {@link Property} + */ +public class AssociationBranchEndLabelHelper extends AssociationEndPropertyLabelHelper { + + private static AssociationBranchEndLabelHelper labelHelper; + + public static AssociationBranchEndLabelHelper getInstance() { + if (labelHelper == null) { + labelHelper = new AssociationBranchEndLabelHelper(); + } + return labelHelper; + } + + /** + * {@inheritDoc} + */ + @Override + public Property getUMLElement(GraphicalEditPart editPart) { + if ((View) editPart.getModel() != null && ((View) editPart.getModel()).eContainer() != null) { + if (MultiAssociationHelper.getSemanticBranchEnd(((Edge) ((View) editPart.getModel()).eContainer())) != null) { + return MultiAssociationHelper.getSemanticBranchEnd(((Edge) ((View) editPart.getModel()).eContainer())); + } + if (((Edge) ((View) editPart.getModel()).eContainer()).getTarget() == null) { + return null; + } + Classifier target = (Classifier) ((Edge) ((View) editPart.getModel()).eContainer()).getTarget().getElement(); + Property propertyToDisplay = null; + if (((View) editPart.getModel()) != null && (((View) editPart.getModel()).getElement() instanceof Association)) { + // look for the property that is typed by the classifier + Iterator<Property> propertiesIterator = ((Association) ((View) editPart.getModel()).getElement()).getMemberEnds().iterator(); + // find the last + while (propertiesIterator.hasNext()) { + Property currentProperty = propertiesIterator.next(); + if (currentProperty.getType().equals(target)) { + propertyToDisplay = currentProperty; + } + } + } + if (propertyToDisplay != null) { + return propertyToDisplay; + } + // /in the case of reorient the property must be not found, + // so we have to find the property that is different from the source. + Classifier source = (Classifier) ((Edge) ((View) editPart.getModel()).eContainer()).getSource().getElement(); + if (((View) editPart.getModel()) != null && (((View) editPart.getModel()).getElement() instanceof Association)) { + // look for the property that is typed by the classifier + Iterator<Property> propertiesIterator = ((Association) ((View) editPart.getModel()).getElement()).getMemberEnds().iterator(); + // find the last + while (propertiesIterator.hasNext()) { + Property currentProperty = propertiesIterator.next(); + if (!currentProperty.getType().equals(source)) { + propertyToDisplay = currentProperty; + } + } + } + return propertyToDisplay; + } + return null; + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationEndPropertyLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationEndPropertyLabelHelper.java index fa492dbfd77..2c1ee27ccff 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationEndPropertyLabelHelper.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationEndPropertyLabelHelper.java @@ -1,20 +1,20 @@ -/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.helper;
-
-
-
-public abstract class AssociationEndPropertyLabelHelper extends PropertyLabelHelper {
-
- // CSS are not yet supported for association ends
-
-}
+/***************************************************************************** + * Copyright (c) 2012 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.helper; + + + +public abstract class AssociationEndPropertyLabelHelper extends PropertyLabelHelper { + + // CSS are not yet supported for association ends + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationEndSourceMultiplicityLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationEndSourceMultiplicityLabelHelper.java index 811956e6769..6b160ac577b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationEndSourceMultiplicityLabelHelper.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationEndSourceMultiplicityLabelHelper.java @@ -1,20 +1,20 @@ -package org.eclipse.papyrus.uml.diagram.common.helper;
-
-import java.util.Map;
-
-public class AssociationEndSourceMultiplicityLabelHelper extends AssociationEndSourceLabelHelper {
-
- private static AssociationEndSourceMultiplicityLabelHelper labelHelper;
-
- public static AssociationEndSourceMultiplicityLabelHelper getInstance() {
- if (labelHelper == null) {
- labelHelper = new AssociationEndSourceMultiplicityLabelHelper();
- }
- return labelHelper;
- }
-
- @Override
- protected void setupMasks(Map<String, String> masks) {
- // masks list is empty for the single multiplicity symbol
- }
-}
+package org.eclipse.papyrus.uml.diagram.common.helper; + +import java.util.Map; + +public class AssociationEndSourceMultiplicityLabelHelper extends AssociationEndSourceLabelHelper { + + private static AssociationEndSourceMultiplicityLabelHelper labelHelper; + + public static AssociationEndSourceMultiplicityLabelHelper getInstance() { + if (labelHelper == null) { + labelHelper = new AssociationEndSourceMultiplicityLabelHelper(); + } + return labelHelper; + } + + @Override + protected void setupMasks(Map<String, String> masks) { + // masks list is empty for the single multiplicity symbol + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationEndTargetMultiplicityLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationEndTargetMultiplicityLabelHelper.java index a7b2e66e3b4..3f4c1da1068 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationEndTargetMultiplicityLabelHelper.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/AssociationEndTargetMultiplicityLabelHelper.java @@ -1,20 +1,20 @@ -package org.eclipse.papyrus.uml.diagram.common.helper;
-
-import java.util.Map;
-
-public class AssociationEndTargetMultiplicityLabelHelper extends AssociationEndTargetLabelHelper {
-
- private static AssociationEndTargetMultiplicityLabelHelper labelHelper;
-
- public static AssociationEndTargetMultiplicityLabelHelper getInstance() {
- if (labelHelper == null) {
- labelHelper = new AssociationEndTargetMultiplicityLabelHelper();
- }
- return labelHelper;
- }
-
- @Override
- protected void setupMasks(Map<String, String> masks) {
- // masks list is empty for the single multiplicity symbol
- }
-}
+package org.eclipse.papyrus.uml.diagram.common.helper; + +import java.util.Map; + +public class AssociationEndTargetMultiplicityLabelHelper extends AssociationEndTargetLabelHelper { + + private static AssociationEndTargetMultiplicityLabelHelper labelHelper; + + public static AssociationEndTargetMultiplicityLabelHelper getInstance() { + if (labelHelper == null) { + labelHelper = new AssociationEndTargetMultiplicityLabelHelper(); + } + return labelHelper; + } + + @Override + protected void setupMasks(Map<String, String> masks) { + // masks list is empty for the single multiplicity symbol + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/MultiAssociationHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/MultiAssociationHelper.java index ceb0f035bf2..4e9b6c96e0e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/MultiAssociationHelper.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/MultiAssociationHelper.java @@ -1,33 +1,33 @@ -/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) - Initial API and implementation
- /*****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.helper;
-
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.uml2.uml.Property;
-
-
-public class MultiAssociationHelper extends ElementHelper {
-
- protected static final String SEMANTIC_BRANCH = "Semantic_Branch_Style"; //$NON-NLS-1$
-
- public static Property getSemanticBranchEnd(View view) {
- org.eclipse.gmf.runtime.notation.EObjectValueStyle semanticStyle = (org.eclipse.gmf.runtime.notation.EObjectValueStyle) view.getNamedStyle(NotationPackage.eINSTANCE.getEObjectValueStyle(), SEMANTIC_BRANCH);
- return semanticStyle == null ? null : (Property) semanticStyle.getEObjectValue();
- }
-
- public static void setSemanticBranchEnd(View view, Property end) {
- org.eclipse.gmf.runtime.notation.EObjectValueStyle semanticStyle = (org.eclipse.gmf.runtime.notation.EObjectValueStyle) view.getNamedStyle(NotationPackage.eINSTANCE.getEObjectValueStyle(), SEMANTIC_BRANCH);
- semanticStyle.setEObjectValue(end);
- }
-}
+/***************************************************************************** + * Copyright (c) 2014 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) - Initial API and implementation + /*****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.helper; + +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.uml2.uml.Property; + + +public class MultiAssociationHelper extends ElementHelper { + + protected static final String SEMANTIC_BRANCH = "Semantic_Branch_Style"; //$NON-NLS-1$ + + public static Property getSemanticBranchEnd(View view) { + org.eclipse.gmf.runtime.notation.EObjectValueStyle semanticStyle = (org.eclipse.gmf.runtime.notation.EObjectValueStyle) view.getNamedStyle(NotationPackage.eINSTANCE.getEObjectValueStyle(), SEMANTIC_BRANCH); + return semanticStyle == null ? null : (Property) semanticStyle.getEObjectValue(); + } + + public static void setSemanticBranchEnd(View view, Property end) { + org.eclipse.gmf.runtime.notation.EObjectValueStyle semanticStyle = (org.eclipse.gmf.runtime.notation.EObjectValueStyle) view.getNamedStyle(NotationPackage.eINSTANCE.getEObjectValueStyle(), SEMANTIC_BRANCH); + semanticStyle.setEObjectValue(end); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/listeners/AbstractPapyrusModifcationTriggerListener.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/listeners/AbstractPapyrusModifcationTriggerListener.java index 244f425f6ca..772f87221de 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/listeners/AbstractPapyrusModifcationTriggerListener.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/listeners/AbstractPapyrusModifcationTriggerListener.java @@ -1,135 +1,135 @@ -/*****************************************************************************
- * Copyright (c) 2011 Atos.
- *
- *
- * 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:
- * Atos - Initial API and implementation
- * Arthur Daussy Bug 366026 - [ActivityDiagram] Refactoring in order to try respect Generation Gap Pattern
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.listeners;
-
-import java.util.Collection;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature.Setting;
-import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.transaction.NotificationFilter;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.TriggerListener;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil;
-
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Iterables;
-
-/**
- * Abstract method used to trigger model modification by listenning the ressource set
- *
- * @author adaussy
- *
- */
-public abstract class AbstractPapyrusModifcationTriggerListener extends TriggerListener {
- @Override
- protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
- if (notification != null) {
- ICommand cc = getModificationCommand(notification);
- if (cc != null) {
- return new GMFtoEMFCommandWrapper(cc);
- }
- }
- return null;
- }
-
- @Override
- public abstract NotificationFilter getFilter();
-
- /**
- * Command which will react to the trigger
- *
- * @param notif
- * @return
- */
- protected abstract ICommand getModificationCommand(Notification notif);
-
- /**
- * Return the main edipart which correspond to the {@link EObject} passed in argument
- *
- * @param eObject
- * @param rootEditPart
- * {@link IGraphicalEditPart} root from which the search will start
- * @return
- */
- protected IGraphicalEditPart getChildByEObject(final EObject eObject, IGraphicalEditPart rootEditPart, boolean isEdge) {
- return DiagramEditPartsUtil.getChildByEObject(eObject, rootEditPart, isEdge);
- }
-
-
- /**
- * Get the referencing views
- *
- * @param oldEObject
- * @param predicates
- * Additionnal predecate use to speciy search
- * @return
- */
- protected Iterable<View> getReferencingView(EObject oldEObject, Predicate<? super View>... predicates) {
- ECrossReferenceAdapter eCrossReferencer = ECrossReferenceAdapter.getCrossReferenceAdapter(oldEObject);
- Collection<Setting> settings = eCrossReferencer.getInverseReferences(oldEObject, false);
- Predicate<Setting> predicate = new Predicate<Setting>() {
-
- @Override
- public boolean apply(Setting input) {
- EObject from = input.getEObject();
- /*
- * Is a view
- */
- if (from instanceof View && NotationPackage.Literals.VIEW__ELEMENT.equals(input.getEStructuralFeature())) {
- return true;
- }
- return false;
- }
- };
-
- Iterable<Setting> referencingView = Iterables.filter(settings, predicate);
- Iterable<View> views = Iterables.transform(referencingView, new Function<Setting, View>() {
-
- @Override
- public View apply(Setting from) {
- return (View) from.getEObject();
- }
- });
-
- return Iterables.filter(views, Predicates.and(predicates));
- }
-
- /**
- * Get the transactionnal editing domain from EObject
- *
- * @param o
- * @return
- */
- protected TransactionalEditingDomain getEditingDomain(Object o) {
- EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(o);
- if (editingDomain instanceof TransactionalEditingDomain) {
- TransactionalEditingDomain transEditingDomain = (TransactionalEditingDomain) editingDomain;
- return transEditingDomain;
- }
- throw new RuntimeException("Enable to retreive editing domin from object");
- }
-}
+/***************************************************************************** + * Copyright (c) 2011 Atos. + * + * + * 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: + * Atos - Initial API and implementation + * Arthur Daussy Bug 366026 - [ActivityDiagram] Refactoring in order to try respect Generation Gap Pattern + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.listeners; + +import java.util.Collection; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature.Setting; +import org.eclipse.emf.ecore.util.ECrossReferenceAdapter; +import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.transaction.NotificationFilter; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.TriggerListener; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.Iterables; + +/** + * Abstract method used to trigger model modification by listenning the ressource set + * + * @author adaussy + * + */ +public abstract class AbstractPapyrusModifcationTriggerListener extends TriggerListener { + @Override + protected Command trigger(TransactionalEditingDomain domain, Notification notification) { + if (notification != null) { + ICommand cc = getModificationCommand(notification); + if (cc != null) { + return new GMFtoEMFCommandWrapper(cc); + } + } + return null; + } + + @Override + public abstract NotificationFilter getFilter(); + + /** + * Command which will react to the trigger + * + * @param notif + * @return + */ + protected abstract ICommand getModificationCommand(Notification notif); + + /** + * Return the main edipart which correspond to the {@link EObject} passed in argument + * + * @param eObject + * @param rootEditPart + * {@link IGraphicalEditPart} root from which the search will start + * @return + */ + protected IGraphicalEditPart getChildByEObject(final EObject eObject, IGraphicalEditPart rootEditPart, boolean isEdge) { + return DiagramEditPartsUtil.getChildByEObject(eObject, rootEditPart, isEdge); + } + + + /** + * Get the referencing views + * + * @param oldEObject + * @param predicates + * Additionnal predecate use to speciy search + * @return + */ + protected Iterable<View> getReferencingView(EObject oldEObject, Predicate<? super View>... predicates) { + ECrossReferenceAdapter eCrossReferencer = ECrossReferenceAdapter.getCrossReferenceAdapter(oldEObject); + Collection<Setting> settings = eCrossReferencer.getInverseReferences(oldEObject, false); + Predicate<Setting> predicate = new Predicate<Setting>() { + + @Override + public boolean apply(Setting input) { + EObject from = input.getEObject(); + /* + * Is a view + */ + if (from instanceof View && NotationPackage.Literals.VIEW__ELEMENT.equals(input.getEStructuralFeature())) { + return true; + } + return false; + } + }; + + Iterable<Setting> referencingView = Iterables.filter(settings, predicate); + Iterable<View> views = Iterables.transform(referencingView, new Function<Setting, View>() { + + @Override + public View apply(Setting from) { + return (View) from.getEObject(); + } + }); + + return Iterables.filter(views, Predicates.and(predicates)); + } + + /** + * Get the transactionnal editing domain from EObject + * + * @param o + * @return + */ + protected TransactionalEditingDomain getEditingDomain(Object o) { + EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(o); + if (editingDomain instanceof TransactionalEditingDomain) { + TransactionalEditingDomain transEditingDomain = (TransactionalEditingDomain) editingDomain; + return transEditingDomain; + } + throw new RuntimeException("Enable to retreive editing domin from object"); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/HTMLCleaner.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/HTMLCleaner.java index 79ad21ca723..f6016e4ae35 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/HTMLCleaner.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/HTMLCleaner.java @@ -1,375 +1,375 @@ -/*****************************************************************************
- * Copyright (c) 2009 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:
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.parser;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Class that provides a html cleaner.
- */
-public class HTMLCleaner {
-
- /** map of special html strings and their real value */
- protected static final Map<String, String> specials = new HashMap<String, String>();
-
- /** symbol requiring new lines */
- protected static final List<String> newLine = new ArrayList<String>();
-
- /** map of special html strings and their real value */
- protected static final Map<String, String> xmlSpecials = new HashMap<String, String>();
-
- protected static final List<String> htmlTags = new ArrayList<String>();
-
- static {
- // initialize the special character map
- specials.put("nbsp", " "); // no-break space
- specials.put("iexcl", "¡"); // inverted exclamation mark
- specials.put("cent", "¢"); // cent sign
- specials.put("pound", "£"); // pound sign
- specials.put("curren", "¤"); // currency sign
- specials.put("yen", "¥"); // yen sign = yuan sign
- specials.put("brvbar", "¦"); // broken bar = brolen vertical bar
- specials.put("sect", "§"); // section sign
- specials.put("uml", "¨"); // diaeresis = spacing diaeresis
- specials.put("copy", "©"); // copyright sign
- specials.put("ordf", "ª"); // feminine ordinal indicator
- specials.put("laquo", "«"); // left-pointing double angle quotation mark = left pointing guillemet
- specials.put("not", "¬"); // not sign = discretionary hyphen
- specials.put("shy", ""); // soft hyphen = discretionary hyphen
- specials.put("reg", "®"); // registered sign = registered trade mark sign
- specials.put("macr", "¯"); // macron = spacing macron = overline = APL overbar
- specials.put("deg", "°"); // degree sign
- specials.put("plusmn", "±"); // plus-minus sign = plus-or-minus sign
- specials.put("sup2", "²"); // superscript two = superscript digit two = squared
- specials.put("sup3", "³"); // superscript three = superscript digit three = cubed
- specials.put("acute", "´"); // acute accent = spacing acute
- specials.put("micro", "µ"); // micro sign
- specials.put("para", "¶"); // pilcrow sign = paragraph sign
- specials.put("middot", "·"); // middle dot = Georgian comma = Greek middle dot
- specials.put("ccedil", "¸"); // cedilla = spacing cedilla
- specials.put("sup1", "¹"); // superscript one = superscript digit one
- specials.put("ordm", "º"); // masculine ordinal indicator
- specials.put("raquo", "»"); // right-pointing double angle quotation mark = right pointing guillemet
- specials.put("frac14", "¼"); // vulgar fraction one quarter = fraction one quarter
- specials.put("frac12", "½"); // vulgar fraction one half = fraction one half
- specials.put("frac34", "¾"); // vulgar fraction three quarters = fraction three quarters
- specials.put("iquest", "¿"); // inverted question mark = turned question mark
- specials.put("Agrave", "À"); // latin capital letter A with grave = latin capital letter A grave
- specials.put("Aacute", "Á"); // latin capital letter A with acute
- specials.put("Acirc", "Â"); // latin capital letter A with circumflex
- specials.put("Atilde", "Ã"); // latin capital letter A with tilde
- specials.put("Auml", "Ä"); // latin capital letter A with diaeresis
- specials.put("Aring", "Å"); // latin capital letter A with ring above = latin capital letter A ring
- specials.put("AElig", "Æ"); // latin capital letter AE = latin capital ligature AE
- specials.put("Ccedil", "Ç"); // latin capital letter C with cedilla
- specials.put("Egrave", "È"); // latin capital letter E with grave
- specials.put("Eacute", "É"); // latin capital letter E with acute
- specials.put("Ecirc", "Ê"); // latin capital letter E with circumflex
- specials.put("Euml", "Ë"); // latin capital letter E with diaeresis
- specials.put("Igrave", "Ì"); // latin capital letter I with grave
- specials.put("Iacute", "Í"); // latin capital letter I with acute
- specials.put("Icirc", "Î"); // latin capital letter I with circumflex
- specials.put("Iuml", "Ï"); // latin capital letter I with diaeresis
- specials.put("ETH", "Ð"); // latin capital letter ETH
- specials.put("Ntilde", "Ñ"); // latin capital letter N with tilde
- specials.put("Ograve", "Ò"); // latin capital letter O with grave
- specials.put("Oacute", "Ó"); // latin capital letter O with acute
- specials.put("Ocirc", "Ô"); // latin capital letter O with circumflex
- specials.put("Otilde", "Õ"); // latin capital letter O with tilde
- specials.put("Ouml", "Ö"); // latin capital letter O with diaeresis
- specials.put("times", "×"); // multiplication sign
- specials.put("Oslash", "Ø"); // latin capital letter O with stroke = latin capital letter O slash
- specials.put("Ugrave", "Ù"); // latin capital letter U with grave
- specials.put("Uacute", "Ú"); // latin capital letter U with acute
- specials.put("Ucirc", "Û"); // latin capital letter U with circumflex
- specials.put("Uuml", "Ü"); // latin capital letter U with diaeresis
- specials.put("Yacute", "Ý"); // latin capital letter Y with acute
- specials.put("THORN", "Þ"); // latin capital letter THORN
- specials.put("szlig", "ß"); // latin small letter sharp s = ess-zed
- specials.put("agrave", "à"); // latin small letter a with grave = latin small letter a grave
- specials.put("aacute", "á"); // latin small letter a with acute
- specials.put("acirc", "â"); // latin small letter a with circumflex
- specials.put("atilde", "ã"); // latin small letter a with tilde
- specials.put("auml", "ä"); // latin small letter a with diaeresis
- specials.put("aring", "å"); // latin small letter a with ring above = latin small letter a ring
- specials.put("aelig", "æ"); // latin small letter ae = latin small ligature ae
- specials.put("ccedil", "ç"); // latin small letter c with cedilla
- specials.put("egrave", "è"); // latin small letter e with grave
- specials.put("eacute", "é"); // latin small letter e with acute
- specials.put("ecirc", "ê"); // latin small letter e with circumflex
- specials.put("euml", "ë"); // latin small letter e with diaeresis
- specials.put("igrave", "ì"); // latin small letter i with grave
- specials.put("iacute", "í"); // latin small letter i with acute
- specials.put("icirc", "î"); // latin small letter i with circumflex
- specials.put("iuml", "ï"); // latin small letter i with diaeresis
- specials.put("eth", "ð"); // latin small letter eth
- specials.put("ntilde", "ñ"); // latin small letter n with tilde
- specials.put("ograve", "ò"); // latin small letter o with grave
- specials.put("oacute", "ó"); // latin small letter o with acute
- specials.put("ocirc", "ô"); // latin small letter o with circumflex
- specials.put("otilde", "õ"); // latin small letter o with tilde
- specials.put("ouml", "ö"); // latin small letter o with diaeresis
- specials.put("divide", "÷"); // division sign
- specials.put("oslash", "ø"); // latin small letter o with stroke = latin small letter o slash
- specials.put("ugrave", "ù"); // latin small letter u with grave
- specials.put("uacute", "ú"); // latin small letter u with acute
- specials.put("ucirc", "û"); // latin small letter u with circumflex
- specials.put("uuml", "ü"); // latin small letter u with diaeresis
- specials.put("yacute", "ý"); // latin small letter y with acute
- specials.put("thorn", "þ"); // latin small letter thorn with
- specials.put("yuml", "ÿ"); // latin small letter y with diaeresis
- specials.put("quot", "\""); // quotation mark = APL quote
- specials.put("radic", "√"); // square root = radical sign
- specials.put("infin", "∞"); // infinity
- specials.put("cap", "∩"); // intersection = cap
- specials.put("int", "∫"); // integral
- xmlSpecials.put("amp", "&"); // ampersand
- xmlSpecials.put("lt", "<"); // less-than sign
- xmlSpecials.put("gt", ">"); // greater-than sign
- // new line list
- newLine.add("BR"); // new line request
- newLine.add("br");
- newLine.add("BR/");
- newLine.add("br/");
- newLine.add("br /");
- newLine.add("BR /");
- newLine.add("/H1"); // end of header
- newLine.add("/H2");
- newLine.add("/H3");
- newLine.add("/h1");
- newLine.add("/h2");
- newLine.add("/h3");
- newLine.add("/p"); // end of paragraph
- newLine.add("/P");
- newLine.add("/li"); // end of item list
-
- htmlTags.add("h1");
- htmlTags.add("H1");
- htmlTags.add("h2");
- htmlTags.add("H2");
- htmlTags.add("h3");
- htmlTags.add("H3");
- htmlTags.add("BR");
- htmlTags.add("/BR");
- htmlTags.add("br");
- htmlTags.add("/br");
- htmlTags.add("strong");
- htmlTags.add("/strong");
- htmlTags.add("b");
- htmlTags.add("/b");
- htmlTags.add("u");
- htmlTags.add("/u");
- htmlTags.add("i");
- htmlTags.add("/i");
- htmlTags.add("ul");
- htmlTags.add("/ul");
- htmlTags.add("li");
- htmlTags.add("/li");
- htmlTags.add("p");
- htmlTags.add("/p");
-
- }
-
- public static String removeHTMLTags(String htmlString) throws Exception {
- StringBuffer buffer = new StringBuffer();
- // indicating if parser is in tag
- boolean inTag = false;
- // indicating if parser is in special character
- boolean inSpecial = false;
- // skip the next character
- boolean skip = false;
- // ignore or keep whitespace ?
- boolean keepWhitespace = true;
- // ignore or keep whitespace ?
- boolean keepCarriageReturn = false;
- int length = htmlString.length();
- for (int i = 0; i < length; i++) {
- skip = false;
- char c = htmlString.charAt(i);
- if (c == '<') { // opening a new tag...
-
- // should do specific check for new lines (<BR>, <P>, <H1>,
- // <H2>, etc..)
- // get tag value
- int closingTagIndex = htmlString.indexOf('>', i);
- if (closingTagIndex > i + 1) {
- String tagValue = htmlString.substring(i + 1, closingTagIndex);
-
- if (tagValue != null) {
- if (htmlTags.contains(tagValue.toLowerCase()) || newLine.contains(tagValue.toLowerCase())) {
- inTag = true;
- if (newLine.contains(tagValue)) {
- if (keepCarriageReturn) {
- buffer.append("\n");
- keepCarriageReturn = false;
- }
- keepWhitespace = false;
- }
- } else {
- buffer.append('<');
- }
- } else {
- buffer.append('<');
- }
- } else {
- buffer.append('<');
- }
-
- } else if (c == '>' && inTag) { // closing tag. must be in tag to
- // close it...
- inTag = false;
- skip = true;
- keepWhitespace = true;
- } else if (c == '&') {
- // this is a special character
- // look for next ';', which closes the special character
- int nextSemiColonIndex = htmlString.indexOf(';', i);
- if (nextSemiColonIndex > i + 1) {
- String specialCharacter = htmlString.substring(i + 1, htmlString.indexOf(';', i));
- String replacement = specials.get(specialCharacter);
- if (replacement == null) {
- replacement = xmlSpecials.get(specialCharacter);
- }
- if (replacement != null) {
- inSpecial = true;
- buffer.append(replacement);
- } else {
- // simple '&' in a non html comment => keep it
- buffer.append('&');
- keepWhitespace = true;
- }
- } else {
- // simple '&' in a non html comment => keep it
- buffer.append('&');
- keepWhitespace = true;
- }
- } else if (c == ';' && inSpecial) {
- inSpecial = false;
- skip = true;
- keepWhitespace = true;
- } else if (c == ' ' || c == '\t') {
- if (keepWhitespace) {
- buffer.append(" ");
- }
- keepWhitespace = false;
- } else if (c == '\n' || c == '\r') {
- if (keepCarriageReturn) {
- buffer.append("\n");
- keepCarriageReturn = false;
- keepWhitespace = false;
- }
- } else if (!skip && !inSpecial && !inTag) {
- buffer.append(c);
- keepWhitespace = true;
- keepCarriageReturn = true;
- }
- }
- return buffer.toString();
- }
-
- /**
- * Returns a string derived from the specified string. It removes htlm tags,
- * adding new line separator when useful.
- *
- * @param htmlString
- * the string to clean. It should be neither <code>null</code>,
- * nor empty
- * @return a cleaned string.
- */
- public static String cleanHTMLTags(String htmlString) {
- StringBuffer buffer = new StringBuffer();
- // indicating if parser is in tag
- boolean inTag = false;
- // indicating if parser is in special character
- boolean inSpecial = false;
- // skip the next character
- boolean skip = false;
- // ignore or keep whitespace ?
- boolean keepWhitespace = true;
- // ignore or keep whitespace ?
- boolean keepCarriageReturn = false;
- int length = htmlString.length();
- for (int i = 0; i < length; i++) {
- skip = false;
- char c = htmlString.charAt(i);
- if (c == ' ' || c == '\t') {
- if (keepWhitespace) {
- buffer.append(" ");
- }
- keepWhitespace = false;
- } else if (c == '\n' || c == '\r') {
- if (keepCarriageReturn) {
- buffer.append("\n");
- keepCarriageReturn = false;
- keepWhitespace = false;
- }
- } else if (!skip && !inSpecial && !inTag) {
- buffer.append(c);
- keepWhitespace = true;
- keepCarriageReturn = true;
- }
- }
- return buffer.toString();
- }
-
- /**
- * Pre-clean the specified string
- *
- * @param htmlString
- * the string to clean
- * @return the cleaned string
- */
- public static String preClean(String htmlString) throws Exception {
- if (htmlString == null) {
- return "";
- }
- StringBuffer buffer = new StringBuffer();
- // indicating if parser is in special character
- boolean inSpecial = false;
- // skip the next character
- boolean skip = false;
- int length = htmlString.length();
- for (int i = 0; i < length; i++) {
- skip = false;
- char c = htmlString.charAt(i);
- if (c == '&') {
- int nextSemicolon = htmlString.indexOf(';', i);
- // this is a special character
- // look for next ';', which closes the special character
- if (nextSemicolon > i + 1) {
- inSpecial = true;
- String specialCharacter = htmlString.substring(i + 1, nextSemicolon);
- // replace the value with the specified
- String replacement = specials.get(specialCharacter);
- if (replacement != null) {
- buffer.append(replacement);
- } else if (xmlSpecials.get(specialCharacter) != null) {
- buffer.append("&" + specialCharacter + ";");
- }
- } else {
- inSpecial = false;
- buffer.append('&');
- }
- } else if (c == ';' && inSpecial) {
- inSpecial = false;
- skip = true;
- } else if (!skip && !inSpecial) {
- buffer.append(c);
- }
- }
- return buffer.toString();
- }
-}
+/***************************************************************************** + * Copyright (c) 2009 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.parser; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Class that provides a html cleaner. + */ +public class HTMLCleaner { + + /** map of special html strings and their real value */ + protected static final Map<String, String> specials = new HashMap<String, String>(); + + /** symbol requiring new lines */ + protected static final List<String> newLine = new ArrayList<String>(); + + /** map of special html strings and their real value */ + protected static final Map<String, String> xmlSpecials = new HashMap<String, String>(); + + protected static final List<String> htmlTags = new ArrayList<String>(); + + static { + // initialize the special character map + specials.put("nbsp", " "); // no-break space + specials.put("iexcl", "¡"); // inverted exclamation mark + specials.put("cent", "¢"); // cent sign + specials.put("pound", "£"); // pound sign + specials.put("curren", "¤"); // currency sign + specials.put("yen", "¥"); // yen sign = yuan sign + specials.put("brvbar", "¦"); // broken bar = brolen vertical bar + specials.put("sect", "§"); // section sign + specials.put("uml", "¨"); // diaeresis = spacing diaeresis + specials.put("copy", "©"); // copyright sign + specials.put("ordf", "ª"); // feminine ordinal indicator + specials.put("laquo", "«"); // left-pointing double angle quotation mark = left pointing guillemet + specials.put("not", "¬"); // not sign = discretionary hyphen + specials.put("shy", ""); // soft hyphen = discretionary hyphen + specials.put("reg", "®"); // registered sign = registered trade mark sign + specials.put("macr", "¯"); // macron = spacing macron = overline = APL overbar + specials.put("deg", "°"); // degree sign + specials.put("plusmn", "±"); // plus-minus sign = plus-or-minus sign + specials.put("sup2", "²"); // superscript two = superscript digit two = squared + specials.put("sup3", "³"); // superscript three = superscript digit three = cubed + specials.put("acute", "´"); // acute accent = spacing acute + specials.put("micro", "µ"); // micro sign + specials.put("para", "¶"); // pilcrow sign = paragraph sign + specials.put("middot", "·"); // middle dot = Georgian comma = Greek middle dot + specials.put("ccedil", "¸"); // cedilla = spacing cedilla + specials.put("sup1", "¹"); // superscript one = superscript digit one + specials.put("ordm", "º"); // masculine ordinal indicator + specials.put("raquo", "»"); // right-pointing double angle quotation mark = right pointing guillemet + specials.put("frac14", "¼"); // vulgar fraction one quarter = fraction one quarter + specials.put("frac12", "½"); // vulgar fraction one half = fraction one half + specials.put("frac34", "¾"); // vulgar fraction three quarters = fraction three quarters + specials.put("iquest", "¿"); // inverted question mark = turned question mark + specials.put("Agrave", "À"); // latin capital letter A with grave = latin capital letter A grave + specials.put("Aacute", "Á"); // latin capital letter A with acute + specials.put("Acirc", "Â"); // latin capital letter A with circumflex + specials.put("Atilde", "Ã"); // latin capital letter A with tilde + specials.put("Auml", "Ä"); // latin capital letter A with diaeresis + specials.put("Aring", "Å"); // latin capital letter A with ring above = latin capital letter A ring + specials.put("AElig", "Æ"); // latin capital letter AE = latin capital ligature AE + specials.put("Ccedil", "Ç"); // latin capital letter C with cedilla + specials.put("Egrave", "È"); // latin capital letter E with grave + specials.put("Eacute", "É"); // latin capital letter E with acute + specials.put("Ecirc", "Ê"); // latin capital letter E with circumflex + specials.put("Euml", "Ë"); // latin capital letter E with diaeresis + specials.put("Igrave", "Ì"); // latin capital letter I with grave + specials.put("Iacute", "Í"); // latin capital letter I with acute + specials.put("Icirc", "Î"); // latin capital letter I with circumflex + specials.put("Iuml", "Ï"); // latin capital letter I with diaeresis + specials.put("ETH", "Ð"); // latin capital letter ETH + specials.put("Ntilde", "Ñ"); // latin capital letter N with tilde + specials.put("Ograve", "Ò"); // latin capital letter O with grave + specials.put("Oacute", "Ó"); // latin capital letter O with acute + specials.put("Ocirc", "Ô"); // latin capital letter O with circumflex + specials.put("Otilde", "Õ"); // latin capital letter O with tilde + specials.put("Ouml", "Ö"); // latin capital letter O with diaeresis + specials.put("times", "×"); // multiplication sign + specials.put("Oslash", "Ø"); // latin capital letter O with stroke = latin capital letter O slash + specials.put("Ugrave", "Ù"); // latin capital letter U with grave + specials.put("Uacute", "Ú"); // latin capital letter U with acute + specials.put("Ucirc", "Û"); // latin capital letter U with circumflex + specials.put("Uuml", "Ü"); // latin capital letter U with diaeresis + specials.put("Yacute", "Ý"); // latin capital letter Y with acute + specials.put("THORN", "Þ"); // latin capital letter THORN + specials.put("szlig", "ß"); // latin small letter sharp s = ess-zed + specials.put("agrave", "à"); // latin small letter a with grave = latin small letter a grave + specials.put("aacute", "á"); // latin small letter a with acute + specials.put("acirc", "â"); // latin small letter a with circumflex + specials.put("atilde", "ã"); // latin small letter a with tilde + specials.put("auml", "ä"); // latin small letter a with diaeresis + specials.put("aring", "å"); // latin small letter a with ring above = latin small letter a ring + specials.put("aelig", "æ"); // latin small letter ae = latin small ligature ae + specials.put("ccedil", "ç"); // latin small letter c with cedilla + specials.put("egrave", "è"); // latin small letter e with grave + specials.put("eacute", "é"); // latin small letter e with acute + specials.put("ecirc", "ê"); // latin small letter e with circumflex + specials.put("euml", "ë"); // latin small letter e with diaeresis + specials.put("igrave", "ì"); // latin small letter i with grave + specials.put("iacute", "í"); // latin small letter i with acute + specials.put("icirc", "î"); // latin small letter i with circumflex + specials.put("iuml", "ï"); // latin small letter i with diaeresis + specials.put("eth", "ð"); // latin small letter eth + specials.put("ntilde", "ñ"); // latin small letter n with tilde + specials.put("ograve", "ò"); // latin small letter o with grave + specials.put("oacute", "ó"); // latin small letter o with acute + specials.put("ocirc", "ô"); // latin small letter o with circumflex + specials.put("otilde", "õ"); // latin small letter o with tilde + specials.put("ouml", "ö"); // latin small letter o with diaeresis + specials.put("divide", "÷"); // division sign + specials.put("oslash", "ø"); // latin small letter o with stroke = latin small letter o slash + specials.put("ugrave", "ù"); // latin small letter u with grave + specials.put("uacute", "ú"); // latin small letter u with acute + specials.put("ucirc", "û"); // latin small letter u with circumflex + specials.put("uuml", "ü"); // latin small letter u with diaeresis + specials.put("yacute", "ý"); // latin small letter y with acute + specials.put("thorn", "þ"); // latin small letter thorn with + specials.put("yuml", "ÿ"); // latin small letter y with diaeresis + specials.put("quot", "\""); // quotation mark = APL quote + specials.put("radic", "√"); // square root = radical sign + specials.put("infin", "∞"); // infinity + specials.put("cap", "∩"); // intersection = cap + specials.put("int", "∫"); // integral + xmlSpecials.put("amp", "&"); // ampersand + xmlSpecials.put("lt", "<"); // less-than sign + xmlSpecials.put("gt", ">"); // greater-than sign + // new line list + newLine.add("BR"); // new line request + newLine.add("br"); + newLine.add("BR/"); + newLine.add("br/"); + newLine.add("br /"); + newLine.add("BR /"); + newLine.add("/H1"); // end of header + newLine.add("/H2"); + newLine.add("/H3"); + newLine.add("/h1"); + newLine.add("/h2"); + newLine.add("/h3"); + newLine.add("/p"); // end of paragraph + newLine.add("/P"); + newLine.add("/li"); // end of item list + + htmlTags.add("h1"); + htmlTags.add("H1"); + htmlTags.add("h2"); + htmlTags.add("H2"); + htmlTags.add("h3"); + htmlTags.add("H3"); + htmlTags.add("BR"); + htmlTags.add("/BR"); + htmlTags.add("br"); + htmlTags.add("/br"); + htmlTags.add("strong"); + htmlTags.add("/strong"); + htmlTags.add("b"); + htmlTags.add("/b"); + htmlTags.add("u"); + htmlTags.add("/u"); + htmlTags.add("i"); + htmlTags.add("/i"); + htmlTags.add("ul"); + htmlTags.add("/ul"); + htmlTags.add("li"); + htmlTags.add("/li"); + htmlTags.add("p"); + htmlTags.add("/p"); + + } + + public static String removeHTMLTags(String htmlString) throws Exception { + StringBuffer buffer = new StringBuffer(); + // indicating if parser is in tag + boolean inTag = false; + // indicating if parser is in special character + boolean inSpecial = false; + // skip the next character + boolean skip = false; + // ignore or keep whitespace ? + boolean keepWhitespace = true; + // ignore or keep whitespace ? + boolean keepCarriageReturn = false; + int length = htmlString.length(); + for (int i = 0; i < length; i++) { + skip = false; + char c = htmlString.charAt(i); + if (c == '<') { // opening a new tag... + + // should do specific check for new lines (<BR>, <P>, <H1>, + // <H2>, etc..) + // get tag value + int closingTagIndex = htmlString.indexOf('>', i); + if (closingTagIndex > i + 1) { + String tagValue = htmlString.substring(i + 1, closingTagIndex); + + if (tagValue != null) { + if (htmlTags.contains(tagValue.toLowerCase()) || newLine.contains(tagValue.toLowerCase())) { + inTag = true; + if (newLine.contains(tagValue)) { + if (keepCarriageReturn) { + buffer.append("\n"); + keepCarriageReturn = false; + } + keepWhitespace = false; + } + } else { + buffer.append('<'); + } + } else { + buffer.append('<'); + } + } else { + buffer.append('<'); + } + + } else if (c == '>' && inTag) { // closing tag. must be in tag to + // close it... + inTag = false; + skip = true; + keepWhitespace = true; + } else if (c == '&') { + // this is a special character + // look for next ';', which closes the special character + int nextSemiColonIndex = htmlString.indexOf(';', i); + if (nextSemiColonIndex > i + 1) { + String specialCharacter = htmlString.substring(i + 1, htmlString.indexOf(';', i)); + String replacement = specials.get(specialCharacter); + if (replacement == null) { + replacement = xmlSpecials.get(specialCharacter); + } + if (replacement != null) { + inSpecial = true; + buffer.append(replacement); + } else { + // simple '&' in a non html comment => keep it + buffer.append('&'); + keepWhitespace = true; + } + } else { + // simple '&' in a non html comment => keep it + buffer.append('&'); + keepWhitespace = true; + } + } else if (c == ';' && inSpecial) { + inSpecial = false; + skip = true; + keepWhitespace = true; + } else if (c == ' ' || c == '\t') { + if (keepWhitespace) { + buffer.append(" "); + } + keepWhitespace = false; + } else if (c == '\n' || c == '\r') { + if (keepCarriageReturn) { + buffer.append("\n"); + keepCarriageReturn = false; + keepWhitespace = false; + } + } else if (!skip && !inSpecial && !inTag) { + buffer.append(c); + keepWhitespace = true; + keepCarriageReturn = true; + } + } + return buffer.toString(); + } + + /** + * Returns a string derived from the specified string. It removes htlm tags, + * adding new line separator when useful. + * + * @param htmlString + * the string to clean. It should be neither <code>null</code>, + * nor empty + * @return a cleaned string. + */ + public static String cleanHTMLTags(String htmlString) { + StringBuffer buffer = new StringBuffer(); + // indicating if parser is in tag + boolean inTag = false; + // indicating if parser is in special character + boolean inSpecial = false; + // skip the next character + boolean skip = false; + // ignore or keep whitespace ? + boolean keepWhitespace = true; + // ignore or keep whitespace ? + boolean keepCarriageReturn = false; + int length = htmlString.length(); + for (int i = 0; i < length; i++) { + skip = false; + char c = htmlString.charAt(i); + if (c == ' ' || c == '\t') { + if (keepWhitespace) { + buffer.append(" "); + } + keepWhitespace = false; + } else if (c == '\n' || c == '\r') { + if (keepCarriageReturn) { + buffer.append("\n"); + keepCarriageReturn = false; + keepWhitespace = false; + } + } else if (!skip && !inSpecial && !inTag) { + buffer.append(c); + keepWhitespace = true; + keepCarriageReturn = true; + } + } + return buffer.toString(); + } + + /** + * Pre-clean the specified string + * + * @param htmlString + * the string to clean + * @return the cleaned string + */ + public static String preClean(String htmlString) throws Exception { + if (htmlString == null) { + return ""; + } + StringBuffer buffer = new StringBuffer(); + // indicating if parser is in special character + boolean inSpecial = false; + // skip the next character + boolean skip = false; + int length = htmlString.length(); + for (int i = 0; i < length; i++) { + skip = false; + char c = htmlString.charAt(i); + if (c == '&') { + int nextSemicolon = htmlString.indexOf(';', i); + // this is a special character + // look for next ';', which closes the special character + if (nextSemicolon > i + 1) { + inSpecial = true; + String specialCharacter = htmlString.substring(i + 1, nextSemicolon); + // replace the value with the specified + String replacement = specials.get(specialCharacter); + if (replacement != null) { + buffer.append(replacement); + } else if (xmlSpecials.get(specialCharacter) != null) { + buffer.append("&" + specialCharacter + ";"); + } + } else { + inSpecial = false; + buffer.append('&'); + } + } else if (c == ';' && inSpecial) { + inSpecial = false; + skip = true; + } else if (!skip && !inSpecial) { + buffer.append(c); + } + } + return buffer.toString(); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/providers/ImportedElementEditPolicyProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/providers/ImportedElementEditPolicyProvider.java index 3917d04f16c..fc6c3c737a0 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/providers/ImportedElementEditPolicyProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/providers/ImportedElementEditPolicyProvider.java @@ -1,45 +1,45 @@ -/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.providers;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.common.core.service.IOperation;
-import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalReferenceEditPolicy;
-import org.eclipse.papyrus.infra.gmfdiag.common.providers.ExternalReferenceEditPolicyProvider;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.ImportedElementEditPolicy;
-import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
-
-/**
- * UML-Specific implementation of the ExternalReferenceEditPolicyProvider
- *
- * @author Camille Letavernier
- *
- */
-public class ImportedElementEditPolicyProvider extends ExternalReferenceEditPolicyProvider {
-
- @Override
- public boolean provides(IOperation operation) {
- if (super.provides(operation)) {
- CreateEditPoliciesOperation createOperation = (CreateEditPoliciesOperation) operation;
- return UMLUtil.resolveUMLElement(createOperation.getEditPart()) != null;
- }
-
- return false;
- }
-
- @Override
- public void createEditPolicies(EditPart editPart) {
- editPart.installEditPolicy(ExternalReferenceEditPolicy.EDIT_POLICY_ROLE, new ImportedElementEditPolicy());
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2014 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.providers; + +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.common.core.service.IOperation; +import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalReferenceEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.providers.ExternalReferenceEditPolicyProvider; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.ImportedElementEditPolicy; +import org.eclipse.papyrus.uml.tools.utils.UMLUtil; + +/** + * UML-Specific implementation of the ExternalReferenceEditPolicyProvider + * + * @author Camille Letavernier + * + */ +public class ImportedElementEditPolicyProvider extends ExternalReferenceEditPolicyProvider { + + @Override + public boolean provides(IOperation operation) { + if (super.provides(operation)) { + CreateEditPoliciesOperation createOperation = (CreateEditPoliciesOperation) operation; + return UMLUtil.resolveUMLElement(createOperation.getEditPart()) != null; + } + + return false; + } + + @Override + public void createEditPolicies(EditPart editPart) { + editPart.installEditPolicy(ExternalReferenceEditPolicy.EDIT_POLICY_ROLE, new ImportedElementEditPolicy()); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/providers/PapyrusDiagramGlobalActionHandler.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/providers/PapyrusDiagramGlobalActionHandler.java index 259090b55e5..ca001a2f6fc 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/providers/PapyrusDiagramGlobalActionHandler.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/providers/PapyrusDiagramGlobalActionHandler.java @@ -1,310 +1,310 @@ -/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.providers;
-
-import java.awt.Toolkit;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.edit.command.CopyToClipboardCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.gef.RootEditPart;
-import org.eclipse.gef.commands.CompoundCommand;
-import org.eclipse.gef.requests.GroupRequest;
-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.ui.action.global.GlobalActionId;
-import org.eclipse.gmf.runtime.common.ui.services.action.global.IGlobalActionContext;
-import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
-import org.eclipse.gmf.runtime.diagram.ui.render.clipboard.AWTClipboardHelper;
-import org.eclipse.gmf.runtime.diagram.ui.render.internal.providers.ImageSupportGlobalActionHandler;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.ui.properties.actions.PropertyPageViewAction;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.uml.diagram.common.helper.CleanDiagramHelper;
-import org.eclipse.papyrus.uml.diagram.common.service.PasteCommandService;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * this class has in charge to launch command for cut copy paste (graphically)
- * it is also used to launch the copy into bmp like as writer software
- *
- */
-@SuppressWarnings("restriction")
-public class PapyrusDiagramGlobalActionHandler extends ImageSupportGlobalActionHandler {
-
- @Override
- public boolean canHandle(IGlobalActionContext cntxt) {
- /* Check if the active part is a IDiagramWorkbenchPart */
- IWorkbenchPart part = cntxt.getActivePart();
- part = (IWorkbenchPart) part.getAdapter(IDiagramWorkbenchPart.class);
- if (!(part instanceof IDiagramWorkbenchPart)) {
- return false;
- }
-
- /* Check if the selection is a structured selection */
- if (!(cntxt.getSelection() instanceof IStructuredSelection)) {
- return false;
- }
-
- /* Check the action id */
- String actionId = cntxt.getActionId();
- if (actionId.equals(GlobalActionId.COPY)) {
- return canCopy(cntxt);
- } else if (actionId.equals(GlobalActionId.CUT)) {
- return canCut(cntxt);
- } else if (actionId.equals(GlobalActionId.PASTE)) {
- return canPaste(cntxt);
- }
- return false;
- }
-
- @Override
- protected boolean canPaste(IGlobalActionContext cntxt) {
- /* Get the selected edit parts */
- Object[] objectsArray = ((IStructuredSelection) cntxt.getSelection()).toArray();
-
- if (objectsArray.length > 0 && objectsArray[0] instanceof GraphicalEditPart) {
- ICommand pastecommand = PasteCommandService.getInstance().getPasteViewCommand(((GraphicalEditPart) objectsArray[0]), Toolkit.getDefaultToolkit().getSystemClipboard(), ((GraphicalEditPart) objectsArray[0]).getEditingDomain().getClipboard());
- return pastecommand.canExecute();
- }
-
- if (!AWTClipboardHelper.getInstance().isImageCopySupported()) {
- return super.canPaste(cntxt);
- }
-
- /* Check if the clipboard has data for the drawing surface */
- return AWTClipboardHelper.getInstance().hasCustomData();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.gmf.runtime.common.ui.services.action.global.IGlobalActionHandler
- * #getCommand(org.eclipse.gmf.runtime.common.ui.services.action.
- * global.IGlobalActionContext)
- */
- @Override
- public ICommand getCommand(IGlobalActionContext cntxt) {
- /* Check if the active part is a IDiagramWorkbenchPart */
- IWorkbenchPart part = cntxt.getActivePart();
- part = (IWorkbenchPart) part.getAdapter(IDiagramWorkbenchPart.class);
- if (!(part instanceof IDiagramWorkbenchPart)) {
- return null;
- }
-
- /* Get the model operation context */
- IDiagramWorkbenchPart diagramPart = (IDiagramWorkbenchPart) part;
-
- /* Create a command */
- ICommand command = null;
-
- /* Check the action id */
- String actionId = cntxt.getActionId();
- if (actionId.equals(GlobalActionId.DELETE)) {
- CompoundCommand deleteCC = getDeleteCommand(diagramPart, cntxt);
- /* Set the command */
- if (deleteCC != null && deleteCC.canExecute()) {
- command = new CommandProxy(deleteCC);
- }
- } else if (actionId.equals(GlobalActionId.COPY)) {
- command = getCopyCommand(cntxt, diagramPart, false);
- } else if (actionId.equals(GlobalActionId.CUT)) {
- command = getCutCommand(cntxt, diagramPart);
- } else if (actionId.equals(GlobalActionId.PASTE)) {
-
- /* Get the selected edit parts */
- Object[] objectsArray = ((IStructuredSelection) cntxt.getSelection()).toArray();
-
- if (objectsArray.length > 0 && objectsArray[0] instanceof GraphicalEditPart) {
-
- ICommand pastecommand = PasteCommandService.getInstance().getPasteViewCommand(((GraphicalEditPart) objectsArray[0]), Toolkit.getDefaultToolkit().getSystemClipboard(), ((GraphicalEditPart) objectsArray[0]).getEditingDomain().getClipboard());
-
- if (pastecommand.canExecute()) {
- ((GraphicalEditPart) objectsArray[0]).getEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(pastecommand));
- RootEditPart topEditPart = ((GraphicalEditPart) objectsArray[0]).getRoot();
- if (topEditPart.getChildren().get(0) instanceof DiagramEditPart) {
- CleanDiagramHelper.getInstance().run((DiagramEditPart) topEditPart.getChildren().get(0));
- }
-
- }
- return null;
- }
-
- } else if (actionId.equals(GlobalActionId.SAVE)) {
- part.getSite().getPage().saveEditor((IEditorPart) diagramPart, false);
- } else if (actionId.equals(GlobalActionId.PROPERTIES)) {
- new PropertyPageViewAction().run();
- }
-
- return command;
- }
-
- /**
- * @see org.eclipse.gmf.runtime.diagram.ui.providers.DiagramGlobalActionHandler#getCopyCommand(org.eclipse.gmf.runtime.common.ui.services.action.global.IGlobalActionContext, org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart, boolean) this
- * class also copy in the clipboard of the editing domain
- * selected elements
- *
- */
-
- @Override
- protected ICommand getCopyCommand(IGlobalActionContext cntxt, IDiagramWorkbenchPart diagramPart, boolean isUndoable) {
- /* Get the selected edit parts */
- Object[] objectsArray = ((IStructuredSelection) cntxt.getSelection()).toArray();
- CompositeCommand compositeCommand = new CompositeCommand(GlobalActionId.COPY);
- if (objectsArray.length > 0 && objectsArray[0] instanceof GraphicalEditPart) {
- // ((GraphicalEditPart)objectsArray[0]).getEditingDomain().setClipboard(((IStructuredSelection)
- // cntxt.getSelection()).toList());
- compositeCommand.add(new EMFtoGMFCommandWrapper(CopyToClipboardCommand.create(((GraphicalEditPart) objectsArray[0]).getEditingDomain(), getNotation(((IStructuredSelection) cntxt.getSelection()).toList()))));
- }
- if (objectsArray.length > 0 && objectsArray[0] instanceof ConnectionEditPart) {
- // ((GraphicalEditPart)objectsArray[0]).getEditingDomain().setClipboard(((IStructuredSelection)
- // cntxt.getSelection()).toList());
- compositeCommand.add(new EMFtoGMFCommandWrapper(CopyToClipboardCommand.create(((ConnectionEditPart) objectsArray[0]).getEditingDomain(), getNotation(((IStructuredSelection) cntxt.getSelection()).toList()))));
- }
- compositeCommand.add(super.getCopyCommand(cntxt, diagramPart, isUndoable));
- return compositeCommand;
- }
-
- /**
- * @see org.eclipse.gmf.runtime.diagram.ui.providers.DiagramGlobalActionHandler#getCutCommand(org.eclipse.gmf.runtime.common.ui.services.action.global.IGlobalActionContext, org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart)
- *
- * @param cntxt
- * @param diagramPart
- * @return
- */
-
- @Override
- protected ICommand getCutCommand(IGlobalActionContext cntxt, IDiagramWorkbenchPart diagramPart) {
- Object[] objectsArray = ((IStructuredSelection) cntxt.getSelection()).toArray();
- CompositeCommand compositeCommand = new CompositeCommand(GlobalActionId.CUT);
- if (objectsArray.length > 0 && objectsArray[0] instanceof GraphicalEditPart) {
- // ((GraphicalEditPart)objectsArray[0]).getEditingDomain().setClipboard(((IStructuredSelection)
- // cntxt.getSelection()).toList());
- compositeCommand.add(new EMFtoGMFCommandWrapper(CopyToClipboardCommand.create(((GraphicalEditPart) objectsArray[0]).getEditingDomain(), getNotation(((IStructuredSelection) cntxt.getSelection()).toList()))));
-
- }
- if (objectsArray.length > 0 && objectsArray[0] instanceof ConnectionEditPart) {
- // ((GraphicalEditPart)objectsArray[0]).getEditingDomain().setClipboard(((IStructuredSelection)
- // cntxt.getSelection()).toList());
- compositeCommand.add(new EMFtoGMFCommandWrapper(CopyToClipboardCommand.create(((ConnectionEditPart) objectsArray[0]).getEditingDomain(), getNotation(((IStructuredSelection) cntxt.getSelection()).toList()))));
- }
- ICommand cutCommand = super.getCutCommand(cntxt, diagramPart);
- if (cutCommand != null) {
- compositeCommand.add(cutCommand);
- }
- return compositeCommand;
- }
-
- /**
- * Returns appropriate delete command for this context.
- *
- * @param part
- * the workbench part
- * @param cntxt
- * the <code>IGlobalActionContext</code> holding the necessary
- * information needed by this action handler
- * @return CompoundCommand command
- */
- private CompoundCommand getDeleteCommand(IDiagramWorkbenchPart part, IGlobalActionContext cntxt) {
- /* Create the delete request */
- GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
-
- CompoundCommand deleteCC = new CompoundCommand(cntxt.getLabel());
-
- TransactionalEditingDomain editingDomain = getEditingDomain(part);
-
- if (editingDomain == null) {
- return deleteCC;
- }
-
- CompositeTransactionalCommand compositeCommand = new CompositeTransactionalCommand(editingDomain, cntxt.getLabel());
- /* Get the selected edit parts */
- Object[] objects = ((IStructuredSelection) cntxt.getSelection()).toArray();
- for (int i = 0; i < objects.length; i++) {
- /* Get the next part */
- EditPart editPart = (EditPart) objects[i];
-
- /* Send the request to the edit part */
- org.eclipse.gef.commands.Command command = editPart.getCommand(deleteReq);
- if (command != null) {
- compositeCommand.compose(new CommandProxy(command));
- // deleteCC.add(editPart.getCommand(deleteReq));
- }
- }
- if (!compositeCommand.isEmpty()) {
- deleteCC.add(new ICommandProxy(compositeCommand));
- }
-
- return deleteCC;
- }
-
- /**
- * Gets the transactional editing domain associated with the workbench <code>part</code>.
- *
- * @param part
- * the diagram workbench part
- * @return the editing domain, or <code>null</code> if there is none.
- */
- private TransactionalEditingDomain getEditingDomain(IDiagramWorkbenchPart part) {
-
- TransactionalEditingDomain result = null;
-
- IEditingDomainProvider provider = (IEditingDomainProvider) part.getAdapter(IEditingDomainProvider.class);
-
- if (provider != null) {
- EditingDomain domain = provider.getEditingDomain();
-
- if (domain != null && domain instanceof TransactionalEditingDomain) {
- result = (TransactionalEditingDomain) domain;
- }
- }
-
- return result;
- }
-
- /**
- * get the list of notation element from the a list of editpart
- *
- * @param editPartList
- * the list of editpart
- * @return the list of notation element
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- protected List getNotation(List editPartList) {
- ArrayList notationList = new ArrayList();
- Iterator iterator = editPartList.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object instanceof EditPart) {
- notationList.add(((EditPart) object).getModel());
- }
- }
- return notationList;
- }
-}
+/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.providers; + +import java.awt.Toolkit; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.emf.edit.command.CopyToClipboardCommand; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.edit.domain.IEditingDomainProvider; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.RequestConstants; +import org.eclipse.gef.RootEditPart; +import org.eclipse.gef.commands.CompoundCommand; +import org.eclipse.gef.requests.GroupRequest; +import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.ui.action.global.GlobalActionId; +import org.eclipse.gmf.runtime.common.ui.services.action.global.IGlobalActionContext; +import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart; +import org.eclipse.gmf.runtime.diagram.ui.render.clipboard.AWTClipboardHelper; +import org.eclipse.gmf.runtime.diagram.ui.render.internal.providers.ImageSupportGlobalActionHandler; +import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; +import org.eclipse.gmf.runtime.emf.ui.properties.actions.PropertyPageViewAction; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper; +import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.uml.diagram.common.helper.CleanDiagramHelper; +import org.eclipse.papyrus.uml.diagram.common.service.PasteCommandService; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPart; + +/** + * this class has in charge to launch command for cut copy paste (graphically) + * it is also used to launch the copy into bmp like as writer software + * + */ +@SuppressWarnings("restriction") +public class PapyrusDiagramGlobalActionHandler extends ImageSupportGlobalActionHandler { + + @Override + public boolean canHandle(IGlobalActionContext cntxt) { + /* Check if the active part is a IDiagramWorkbenchPart */ + IWorkbenchPart part = cntxt.getActivePart(); + part = (IWorkbenchPart) part.getAdapter(IDiagramWorkbenchPart.class); + if (!(part instanceof IDiagramWorkbenchPart)) { + return false; + } + + /* Check if the selection is a structured selection */ + if (!(cntxt.getSelection() instanceof IStructuredSelection)) { + return false; + } + + /* Check the action id */ + String actionId = cntxt.getActionId(); + if (actionId.equals(GlobalActionId.COPY)) { + return canCopy(cntxt); + } else if (actionId.equals(GlobalActionId.CUT)) { + return canCut(cntxt); + } else if (actionId.equals(GlobalActionId.PASTE)) { + return canPaste(cntxt); + } + return false; + } + + @Override + protected boolean canPaste(IGlobalActionContext cntxt) { + /* Get the selected edit parts */ + Object[] objectsArray = ((IStructuredSelection) cntxt.getSelection()).toArray(); + + if (objectsArray.length > 0 && objectsArray[0] instanceof GraphicalEditPart) { + ICommand pastecommand = PasteCommandService.getInstance().getPasteViewCommand(((GraphicalEditPart) objectsArray[0]), Toolkit.getDefaultToolkit().getSystemClipboard(), ((GraphicalEditPart) objectsArray[0]).getEditingDomain().getClipboard()); + return pastecommand.canExecute(); + } + + if (!AWTClipboardHelper.getInstance().isImageCopySupported()) { + return super.canPaste(cntxt); + } + + /* Check if the clipboard has data for the drawing surface */ + return AWTClipboardHelper.getInstance().hasCustomData(); + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.gmf.runtime.common.ui.services.action.global.IGlobalActionHandler + * #getCommand(org.eclipse.gmf.runtime.common.ui.services.action. + * global.IGlobalActionContext) + */ + @Override + public ICommand getCommand(IGlobalActionContext cntxt) { + /* Check if the active part is a IDiagramWorkbenchPart */ + IWorkbenchPart part = cntxt.getActivePart(); + part = (IWorkbenchPart) part.getAdapter(IDiagramWorkbenchPart.class); + if (!(part instanceof IDiagramWorkbenchPart)) { + return null; + } + + /* Get the model operation context */ + IDiagramWorkbenchPart diagramPart = (IDiagramWorkbenchPart) part; + + /* Create a command */ + ICommand command = null; + + /* Check the action id */ + String actionId = cntxt.getActionId(); + if (actionId.equals(GlobalActionId.DELETE)) { + CompoundCommand deleteCC = getDeleteCommand(diagramPart, cntxt); + /* Set the command */ + if (deleteCC != null && deleteCC.canExecute()) { + command = new CommandProxy(deleteCC); + } + } else if (actionId.equals(GlobalActionId.COPY)) { + command = getCopyCommand(cntxt, diagramPart, false); + } else if (actionId.equals(GlobalActionId.CUT)) { + command = getCutCommand(cntxt, diagramPart); + } else if (actionId.equals(GlobalActionId.PASTE)) { + + /* Get the selected edit parts */ + Object[] objectsArray = ((IStructuredSelection) cntxt.getSelection()).toArray(); + + if (objectsArray.length > 0 && objectsArray[0] instanceof GraphicalEditPart) { + + ICommand pastecommand = PasteCommandService.getInstance().getPasteViewCommand(((GraphicalEditPart) objectsArray[0]), Toolkit.getDefaultToolkit().getSystemClipboard(), ((GraphicalEditPart) objectsArray[0]).getEditingDomain().getClipboard()); + + if (pastecommand.canExecute()) { + ((GraphicalEditPart) objectsArray[0]).getEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(pastecommand)); + RootEditPart topEditPart = ((GraphicalEditPart) objectsArray[0]).getRoot(); + if (topEditPart.getChildren().get(0) instanceof DiagramEditPart) { + CleanDiagramHelper.getInstance().run((DiagramEditPart) topEditPart.getChildren().get(0)); + } + + } + return null; + } + + } else if (actionId.equals(GlobalActionId.SAVE)) { + part.getSite().getPage().saveEditor((IEditorPart) diagramPart, false); + } else if (actionId.equals(GlobalActionId.PROPERTIES)) { + new PropertyPageViewAction().run(); + } + + return command; + } + + /** + * @see org.eclipse.gmf.runtime.diagram.ui.providers.DiagramGlobalActionHandler#getCopyCommand(org.eclipse.gmf.runtime.common.ui.services.action.global.IGlobalActionContext, org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart, boolean) this + * class also copy in the clipboard of the editing domain + * selected elements + * + */ + + @Override + protected ICommand getCopyCommand(IGlobalActionContext cntxt, IDiagramWorkbenchPart diagramPart, boolean isUndoable) { + /* Get the selected edit parts */ + Object[] objectsArray = ((IStructuredSelection) cntxt.getSelection()).toArray(); + CompositeCommand compositeCommand = new CompositeCommand(GlobalActionId.COPY); + if (objectsArray.length > 0 && objectsArray[0] instanceof GraphicalEditPart) { + // ((GraphicalEditPart)objectsArray[0]).getEditingDomain().setClipboard(((IStructuredSelection) + // cntxt.getSelection()).toList()); + compositeCommand.add(new EMFtoGMFCommandWrapper(CopyToClipboardCommand.create(((GraphicalEditPart) objectsArray[0]).getEditingDomain(), getNotation(((IStructuredSelection) cntxt.getSelection()).toList())))); + } + if (objectsArray.length > 0 && objectsArray[0] instanceof ConnectionEditPart) { + // ((GraphicalEditPart)objectsArray[0]).getEditingDomain().setClipboard(((IStructuredSelection) + // cntxt.getSelection()).toList()); + compositeCommand.add(new EMFtoGMFCommandWrapper(CopyToClipboardCommand.create(((ConnectionEditPart) objectsArray[0]).getEditingDomain(), getNotation(((IStructuredSelection) cntxt.getSelection()).toList())))); + } + compositeCommand.add(super.getCopyCommand(cntxt, diagramPart, isUndoable)); + return compositeCommand; + } + + /** + * @see org.eclipse.gmf.runtime.diagram.ui.providers.DiagramGlobalActionHandler#getCutCommand(org.eclipse.gmf.runtime.common.ui.services.action.global.IGlobalActionContext, org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart) + * + * @param cntxt + * @param diagramPart + * @return + */ + + @Override + protected ICommand getCutCommand(IGlobalActionContext cntxt, IDiagramWorkbenchPart diagramPart) { + Object[] objectsArray = ((IStructuredSelection) cntxt.getSelection()).toArray(); + CompositeCommand compositeCommand = new CompositeCommand(GlobalActionId.CUT); + if (objectsArray.length > 0 && objectsArray[0] instanceof GraphicalEditPart) { + // ((GraphicalEditPart)objectsArray[0]).getEditingDomain().setClipboard(((IStructuredSelection) + // cntxt.getSelection()).toList()); + compositeCommand.add(new EMFtoGMFCommandWrapper(CopyToClipboardCommand.create(((GraphicalEditPart) objectsArray[0]).getEditingDomain(), getNotation(((IStructuredSelection) cntxt.getSelection()).toList())))); + + } + if (objectsArray.length > 0 && objectsArray[0] instanceof ConnectionEditPart) { + // ((GraphicalEditPart)objectsArray[0]).getEditingDomain().setClipboard(((IStructuredSelection) + // cntxt.getSelection()).toList()); + compositeCommand.add(new EMFtoGMFCommandWrapper(CopyToClipboardCommand.create(((ConnectionEditPart) objectsArray[0]).getEditingDomain(), getNotation(((IStructuredSelection) cntxt.getSelection()).toList())))); + } + ICommand cutCommand = super.getCutCommand(cntxt, diagramPart); + if (cutCommand != null) { + compositeCommand.add(cutCommand); + } + return compositeCommand; + } + + /** + * Returns appropriate delete command for this context. + * + * @param part + * the workbench part + * @param cntxt + * the <code>IGlobalActionContext</code> holding the necessary + * information needed by this action handler + * @return CompoundCommand command + */ + private CompoundCommand getDeleteCommand(IDiagramWorkbenchPart part, IGlobalActionContext cntxt) { + /* Create the delete request */ + GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE); + + CompoundCommand deleteCC = new CompoundCommand(cntxt.getLabel()); + + TransactionalEditingDomain editingDomain = getEditingDomain(part); + + if (editingDomain == null) { + return deleteCC; + } + + CompositeTransactionalCommand compositeCommand = new CompositeTransactionalCommand(editingDomain, cntxt.getLabel()); + /* Get the selected edit parts */ + Object[] objects = ((IStructuredSelection) cntxt.getSelection()).toArray(); + for (int i = 0; i < objects.length; i++) { + /* Get the next part */ + EditPart editPart = (EditPart) objects[i]; + + /* Send the request to the edit part */ + org.eclipse.gef.commands.Command command = editPart.getCommand(deleteReq); + if (command != null) { + compositeCommand.compose(new CommandProxy(command)); + // deleteCC.add(editPart.getCommand(deleteReq)); + } + } + if (!compositeCommand.isEmpty()) { + deleteCC.add(new ICommandProxy(compositeCommand)); + } + + return deleteCC; + } + + /** + * Gets the transactional editing domain associated with the workbench <code>part</code>. + * + * @param part + * the diagram workbench part + * @return the editing domain, or <code>null</code> if there is none. + */ + private TransactionalEditingDomain getEditingDomain(IDiagramWorkbenchPart part) { + + TransactionalEditingDomain result = null; + + IEditingDomainProvider provider = (IEditingDomainProvider) part.getAdapter(IEditingDomainProvider.class); + + if (provider != null) { + EditingDomain domain = provider.getEditingDomain(); + + if (domain != null && domain instanceof TransactionalEditingDomain) { + result = (TransactionalEditingDomain) domain; + } + } + + return result; + } + + /** + * get the list of notation element from the a list of editpart + * + * @param editPartList + * the list of editpart + * @return the list of notation element + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + protected List getNotation(List editPartList) { + ArrayList notationList = new ArrayList(); + Iterator iterator = editPartList.iterator(); + while (iterator.hasNext()) { + Object object = iterator.next(); + if (object instanceof EditPart) { + notationList.add(((EditPart) object).getModel()); + } + } + return notationList; + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeLocationEnum.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeLocationEnum.java index bbff436f6ac..a96ce57b962 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeLocationEnum.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeLocationEnum.java @@ -1,47 +1,47 @@ -/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
- * 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:
- * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 460356 : Refactor Stereotype Display
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype;
-
-
-/**
- * This enumeration is used to list the existing possible locations of a Stereotype property to be displayed
- *
- * @author Céline JANSSENS
- *
- */
-public enum StereotypeLocationEnum {
- /**
- * Defines the Brace Label on top of the figure that contains the list of Stereotype Properties
- */
- IN_BRACE,
-
- /**
- * Defines the Compartment into the figure dedicated to the Stereotype Properties
- */
- IN_COMPARTMENT,
-
- /**
- * Defines the Brace Label into a separate Comment Figure that contains the list of Stereotype Properties
- * {@link Deprecated Not used}
- */
- @Deprecated IN_COMMENT_BRACE,
-
- /**
- * Defines the Compartment into a separate Comment Figure dedicated to the Stereotype Properties
- */
- IN_COMMENT
-
-
-}
+/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation + * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 460356 : Refactor Stereotype Display + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.common.stereotype; + + +/** + * This enumeration is used to list the existing possible locations of a Stereotype property to be displayed + * + * @author Céline JANSSENS + * + */ +public enum StereotypeLocationEnum { + /** + * Defines the Brace Label on top of the figure that contains the list of Stereotype Properties + */ + IN_BRACE, + + /** + * Defines the Compartment into the figure dedicated to the Stereotype Properties + */ + IN_COMPARTMENT, + + /** + * Defines the Brace Label into a separate Comment Figure that contains the list of Stereotype Properties + * {@link Deprecated Not used} + */ + @Deprecated IN_COMMENT_BRACE, + + /** + * Defines the Compartment into a separate Comment Figure dedicated to the Stereotype Properties + */ + IN_COMMENT + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/IStereotypeViewFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/IStereotypeViewFactory.java index 63d53c9061e..85cfc687b50 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/IStereotypeViewFactory.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/IStereotypeViewFactory.java @@ -1,78 +1,78 @@ -/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
- * 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:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
- *
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display;
-
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * This Factory creates the different Stereotype View related to the Location.
- *
- * @author Céline JANSSENS
- *
- */
-public interface IStereotypeViewFactory {
-
- /**
- * Create Property View according to a specific Location.
- *
- * @param property
- * The UML property for the View to be created
- * @param stereotype
- * The UML Stereotype for which the property is required
- * @param location
- * The property location can be:
- * <ul>
- * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMMENT_LOCATION}</li>
- * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMPARTMENT_LOCATION}</li>
- * <li>{@link StereotypeDisplayConstant#STEREOTYPE_BRACE_LOCATION}</li>
- * </ul>
- * @param owner
- * The Compartment View that should contained the Property View
- */
- public void createPropertyView(Property property, Stereotype stereotype, View owner, String location);
-
- /**
- * Create Compartment View according to a specific Location.
- *
- * @param stereotype
- * The UML Stereotype for which the property is required
- * @param location
- * The property location can be:
- * <ul>
- * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMMENT_LOCATION}</li>
- * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMPARTMENT_LOCATION}</li>
- * <li>{@link StereotypeDisplayConstant#STEREOTYPE_BRACE_LOCATION}</li>
- * </ul>
- */
- public void createCompartmentView(Stereotype stereotype, String location);
-
-
- /**
- * Create Label View.
- *
- * @param stereotype
- * The UML Stereotype for which the property is required
- *
- */
- public void createLabelView(Stereotype stereotype);
-
-
-
-
-}
+/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display + * + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.common.stereotype.display; + +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.Stereotype; + +/** + * This Factory creates the different Stereotype View related to the Location. + * + * @author Céline JANSSENS + * + */ +public interface IStereotypeViewFactory { + + /** + * Create Property View according to a specific Location. + * + * @param property + * The UML property for the View to be created + * @param stereotype + * The UML Stereotype for which the property is required + * @param location + * The property location can be: + * <ul> + * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMMENT_LOCATION}</li> + * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMPARTMENT_LOCATION}</li> + * <li>{@link StereotypeDisplayConstant#STEREOTYPE_BRACE_LOCATION}</li> + * </ul> + * @param owner + * The Compartment View that should contained the Property View + */ + public void createPropertyView(Property property, Stereotype stereotype, View owner, String location); + + /** + * Create Compartment View according to a specific Location. + * + * @param stereotype + * The UML Stereotype for which the property is required + * @param location + * The property location can be: + * <ul> + * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMMENT_LOCATION}</li> + * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMPARTMENT_LOCATION}</li> + * <li>{@link StereotypeDisplayConstant#STEREOTYPE_BRACE_LOCATION}</li> + * </ul> + */ + public void createCompartmentView(Stereotype stereotype, String location); + + + /** + * Create Label View. + * + * @param stereotype + * The UML Stereotype for which the property is required + * + */ + public void createLabelView(Stereotype stereotype); + + + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/IStereotypeViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/IStereotypeViewProvider.java index 8d3e740f8c0..98ddb564a0b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/IStereotypeViewProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/IStereotypeViewProvider.java @@ -1,79 +1,79 @@ -/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
- * 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:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display;
-
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * This interface provides the View of the Stereotype Structure
- * If the view doesn't exist it creates the node thanks to the {@link IStereotypeViewFactory } Class.
- * It should never return null;
- *
- * @author Céline JANSSENS
- *
- */
-public interface IStereotypeViewProvider {
-
- /**
- * Get the Property View for a specific location
- *
- * @param property
- * The UML property for the View to be created
- * @param stereotype
- * The UML Stereotype for which the property is required
- * @param location
- * The property location can be:
- * <ul>
- * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMMENT_LOCATION}</li>
- * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMPARTMENT_LOCATION}</li>
- * <li>{@link StereotypeDisplayConstant#STEREOTYPE_BRACE_LOCATION}</li>
- * </ul>
- * @return The Property view (existing or newly created)
- */
- public View getProperty(Property property, Stereotype stereotype, Enum location);
-
- /**
- * Get the Compartment View for a specific location
- *
- *
- * @param stereotype
- * The UML Stereotype for which the property is required
- * @param location
- * The property location can be:
- * <ul>
- * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMMENT_LOCATION}</li>
- * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMPARTMENT_LOCATION}</li>
- * <li>{@link StereotypeDisplayConstant#STEREOTYPE_BRACE_LOCATION}</li>
- * </ul>
- * @return The Compartment view (existing or newly created)
- */
- public View getCompartment(Stereotype stereotype, Enum location);
-
-
- /**
- * Get the Label View for a specific location
- *
- *
- * @param stereotype
- * The UML Stereotype for which the property is required
- *
- * @return The Label view (existing or newly created)
- */
- public View getLabel(Stereotype stereotype);
-
-}
+/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.common.stereotype.display; + +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.Stereotype; + +/** + * This interface provides the View of the Stereotype Structure + * If the view doesn't exist it creates the node thanks to the {@link IStereotypeViewFactory } Class. + * It should never return null; + * + * @author Céline JANSSENS + * + */ +public interface IStereotypeViewProvider { + + /** + * Get the Property View for a specific location + * + * @param property + * The UML property for the View to be created + * @param stereotype + * The UML Stereotype for which the property is required + * @param location + * The property location can be: + * <ul> + * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMMENT_LOCATION}</li> + * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMPARTMENT_LOCATION}</li> + * <li>{@link StereotypeDisplayConstant#STEREOTYPE_BRACE_LOCATION}</li> + * </ul> + * @return The Property view (existing or newly created) + */ + public View getProperty(Property property, Stereotype stereotype, Enum location); + + /** + * Get the Compartment View for a specific location + * + * + * @param stereotype + * The UML Stereotype for which the property is required + * @param location + * The property location can be: + * <ul> + * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMMENT_LOCATION}</li> + * <li>{@link StereotypeDisplayConstant#STEREOTYPE_COMPARTMENT_LOCATION}</li> + * <li>{@link StereotypeDisplayConstant#STEREOTYPE_BRACE_LOCATION}</li> + * </ul> + * @return The Compartment view (existing or newly created) + */ + public View getCompartment(Stereotype stereotype, Enum location); + + + /** + * Get the Label View for a specific location + * + * + * @param stereotype + * The UML Stereotype for which the property is required + * + * @return The Label view (existing or newly created) + */ + public View getLabel(Stereotype stereotype); + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/StereotypeViewFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/StereotypeViewFactory.java index 5c6df821bca..c3d481a89b4 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/StereotypeViewFactory.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/StereotypeViewFactory.java @@ -1,207 +1,207 @@ -/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
- * 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:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
- *
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display;
-
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.CreateAppliedStereotypeCompartmentCommand;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.CreateAppliedStereotypePropertyViewCommand;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.CreateStereotypeLabelCommand;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
-import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * This Factory implement {@link IStereotypeViewFactory} and is in charge of creating Stereotype Views.
- *
- * @author Céline JANSSENS
- *
- */
-public class StereotypeViewFactory implements IStereotypeViewFactory {
-
- private View mainView;
- private TransactionalEditingDomain domain;
-
- /**
- * Constructor.
- *
- * @param mainView
- * The View on which the Stereotype is applied (i.e: A Shape, an Edge, An Operation, ...)
- *
- */
- public StereotypeViewFactory(View mainView) {
- super();
- this.mainView = mainView;
- this.domain = CommandUtil.resolveEditingDomain(mainView);
- }
-
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewFactory#createPropertyView(org.eclipse.gmf.runtime.notation.View, org.eclipse.uml2.uml.Property, org.eclipse.uml2.uml.Stereotype, org.eclipse.gmf.runtime.notation.View,
- * java.lang.String)
- *
- */
- @Override
- public void createPropertyView(Property property, Stereotype stereotype, View owner, String location) {
-
- if (StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_LOCATION.equals(location)) {
- createStereotypePropertyInCompartment(owner, property);
- } else if (StereotypeDisplayConstant.STEREOTYPE_BRACE_LOCATION.equals(location)) {
- createStereotypePropertyInBrace(owner, property);
- } else if (StereotypeDisplayConstant.STEREOTYPE_COMMENT_LOCATION.equals(location)) {
- createStereotypePropertyInComment(owner, property);
- }
-
- }
-
-
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewFactory#createCompartmentView(org.eclipse.gmf.runtime.notation.View, org.eclipse.uml2.uml.Stereotype, java.lang.String)
- *
- */
- @Override
- public void createCompartmentView(Stereotype stereotype, String location) {
- if (StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_LOCATION.equals(location)) {
- createStereotypeCompartmentInCompartment(stereotype);
- } else if (StereotypeDisplayConstant.STEREOTYPE_BRACE_LOCATION.equals(location)) {
- createStereotypeCompartmentInBrace(stereotype);
- } else if (StereotypeDisplayConstant.STEREOTYPE_COMMENT_LOCATION.equals(location)) {
- createStereotypeCompartmentInComment(stereotype);
- }
-
-
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewFactory#createLabelView(org.eclipse.gmf.runtime.notation.View, org.eclipse.uml2.uml.Stereotype)
- */
- @Override
- public void createLabelView(Stereotype stereotype) {
- createStereotypeLabel(stereotype);
-
- }
-
-
- /**
- * Execute the creation Compartment command
- *
- * @param stereotype
- * Stereotype for which the View is created
- */
- private void createStereotypeCompartmentInComment(Stereotype stereotype) {
- View comment = StereotypeDisplayUtil.getInstance().getStereotypeComment(mainView);
- CreateAppliedStereotypeCompartmentCommand command = new CreateAppliedStereotypeCompartmentCommand(domain, comment, stereotype, StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_TYPE);
- CommandUtil.executeUnsafeCommand(command, mainView);
-
- }
-
-
-
-
-
- /**
- * Create the Compartment of Stereotype to be shown into the Compartment of the Shape.
- *
- * @param stereotype
- * The Stereotype of the Compartment that is retrieved.
- */
- private void createStereotypeCompartmentInBrace(Stereotype stereotype) {
- CreateAppliedStereotypeCompartmentCommand command = new CreateAppliedStereotypeCompartmentCommand(domain, mainView, stereotype, StereotypeDisplayConstant.STEREOTYPE_BRACE_TYPE);
- CommandUtil.executeUnsafeCommand(command, mainView);
-
- }
-
- /**
- * Create the Compartment of Stereotype to be shown into the Compartment of the Shape.
- *
- * @param stereotype
- * The Stereotype of the Compartment that is retrieved.
- */
- private void createStereotypeCompartmentInCompartment(Stereotype stereotype) {
- CreateAppliedStereotypeCompartmentCommand command = new CreateAppliedStereotypeCompartmentCommand(domain, mainView, stereotype, StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_TYPE);
- CommandUtil.executeUnsafeCommand(command, mainView);
-
- }
-
- /**
- * Create the Property of the Stereotype to be shown into the Compartment of the Shape.
- *
- *
- * @param compartment
- * The Compartment View that is the Owner of the new Property
- * @param property
- * The UML Property of the Stereotype to be retrieved.
- *
- */
- private void createStereotypePropertyInCompartment(View compartment, Property property) {
- CreateAppliedStereotypePropertyViewCommand command = new CreateAppliedStereotypePropertyViewCommand(domain, compartment, property, StereotypeDisplayConstant.STEREOTYPE_PROPERTY_TYPE);
- CommandUtil.executeUnsafeCommand(command, mainView);
-
- }
-
- /**
- * Create the Property of the Stereotype to be shown into the Brace of the Shape.
- *
- *
- * @param compartment
- * The Compartment View that is the Owner of the new Property
- * @param property
- * The UML Property of the Stereotype to be retrieved.
- *
- */
- private void createStereotypePropertyInBrace(View compartmentView, Property property) {
- CreateAppliedStereotypePropertyViewCommand command = new CreateAppliedStereotypePropertyViewCommand(domain, mainView, property, StereotypeDisplayConstant.STEREOTYPE_BRACE_TYPE);
- CommandUtil.executeUnsafeCommand(command, mainView);
-
- }
-
- /**
- * Create the Property of the Stereotype to be shown into the Comment of the Shape.
- *
- *
- * @param compartment
- * The Compartment View that is the Owner of the new Property
- * @param property
- * The UML Property of the Stereotype to be retrieved.
- *
- */
- private void createStereotypePropertyInComment(View compartmentView, Property property) {
- CreateAppliedStereotypePropertyViewCommand command = new CreateAppliedStereotypePropertyViewCommand(domain, compartmentView, property, StereotypeDisplayConstant.STEREOTYPE_PROPERTY_TYPE);
- CommandUtil.executeUnsafeCommand(command, mainView);
-
- }
-
-
-
- /**
- * Execute the {@link CreateStereotypeLabelCommand}
- *
- * @param view
- * The view that required a Stereotype Label
- */
- private void createStereotypeLabel(final Stereotype stereotype) {
- CreateStereotypeLabelCommand command = new CreateStereotypeLabelCommand(domain, mainView, stereotype);
- CommandUtil.executeUnsafeCommand(command, mainView);
- }
-
-
-
-
-
-}
+/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display + * + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.common.stereotype.display; + +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.CreateAppliedStereotypeCompartmentCommand; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.CreateAppliedStereotypePropertyViewCommand; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.CreateStereotypeLabelCommand; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil; +import org.eclipse.papyrus.uml.diagram.common.util.CommandUtil; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.Stereotype; + +/** + * This Factory implement {@link IStereotypeViewFactory} and is in charge of creating Stereotype Views. + * + * @author Céline JANSSENS + * + */ +public class StereotypeViewFactory implements IStereotypeViewFactory { + + private View mainView; + private TransactionalEditingDomain domain; + + /** + * Constructor. + * + * @param mainView + * The View on which the Stereotype is applied (i.e: A Shape, an Edge, An Operation, ...) + * + */ + public StereotypeViewFactory(View mainView) { + super(); + this.mainView = mainView; + this.domain = CommandUtil.resolveEditingDomain(mainView); + } + + + /** + * @see org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewFactory#createPropertyView(org.eclipse.gmf.runtime.notation.View, org.eclipse.uml2.uml.Property, org.eclipse.uml2.uml.Stereotype, org.eclipse.gmf.runtime.notation.View, + * java.lang.String) + * + */ + @Override + public void createPropertyView(Property property, Stereotype stereotype, View owner, String location) { + + if (StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_LOCATION.equals(location)) { + createStereotypePropertyInCompartment(owner, property); + } else if (StereotypeDisplayConstant.STEREOTYPE_BRACE_LOCATION.equals(location)) { + createStereotypePropertyInBrace(owner, property); + } else if (StereotypeDisplayConstant.STEREOTYPE_COMMENT_LOCATION.equals(location)) { + createStereotypePropertyInComment(owner, property); + } + + } + + + + /** + * @see org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewFactory#createCompartmentView(org.eclipse.gmf.runtime.notation.View, org.eclipse.uml2.uml.Stereotype, java.lang.String) + * + */ + @Override + public void createCompartmentView(Stereotype stereotype, String location) { + if (StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_LOCATION.equals(location)) { + createStereotypeCompartmentInCompartment(stereotype); + } else if (StereotypeDisplayConstant.STEREOTYPE_BRACE_LOCATION.equals(location)) { + createStereotypeCompartmentInBrace(stereotype); + } else if (StereotypeDisplayConstant.STEREOTYPE_COMMENT_LOCATION.equals(location)) { + createStereotypeCompartmentInComment(stereotype); + } + + + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewFactory#createLabelView(org.eclipse.gmf.runtime.notation.View, org.eclipse.uml2.uml.Stereotype) + */ + @Override + public void createLabelView(Stereotype stereotype) { + createStereotypeLabel(stereotype); + + } + + + /** + * Execute the creation Compartment command + * + * @param stereotype + * Stereotype for which the View is created + */ + private void createStereotypeCompartmentInComment(Stereotype stereotype) { + View comment = StereotypeDisplayUtil.getInstance().getStereotypeComment(mainView); + CreateAppliedStereotypeCompartmentCommand command = new CreateAppliedStereotypeCompartmentCommand(domain, comment, stereotype, StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_TYPE); + CommandUtil.executeUnsafeCommand(command, mainView); + + } + + + + + + /** + * Create the Compartment of Stereotype to be shown into the Compartment of the Shape. + * + * @param stereotype + * The Stereotype of the Compartment that is retrieved. + */ + private void createStereotypeCompartmentInBrace(Stereotype stereotype) { + CreateAppliedStereotypeCompartmentCommand command = new CreateAppliedStereotypeCompartmentCommand(domain, mainView, stereotype, StereotypeDisplayConstant.STEREOTYPE_BRACE_TYPE); + CommandUtil.executeUnsafeCommand(command, mainView); + + } + + /** + * Create the Compartment of Stereotype to be shown into the Compartment of the Shape. + * + * @param stereotype + * The Stereotype of the Compartment that is retrieved. + */ + private void createStereotypeCompartmentInCompartment(Stereotype stereotype) { + CreateAppliedStereotypeCompartmentCommand command = new CreateAppliedStereotypeCompartmentCommand(domain, mainView, stereotype, StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_TYPE); + CommandUtil.executeUnsafeCommand(command, mainView); + + } + + /** + * Create the Property of the Stereotype to be shown into the Compartment of the Shape. + * + * + * @param compartment + * The Compartment View that is the Owner of the new Property + * @param property + * The UML Property of the Stereotype to be retrieved. + * + */ + private void createStereotypePropertyInCompartment(View compartment, Property property) { + CreateAppliedStereotypePropertyViewCommand command = new CreateAppliedStereotypePropertyViewCommand(domain, compartment, property, StereotypeDisplayConstant.STEREOTYPE_PROPERTY_TYPE); + CommandUtil.executeUnsafeCommand(command, mainView); + + } + + /** + * Create the Property of the Stereotype to be shown into the Brace of the Shape. + * + * + * @param compartment + * The Compartment View that is the Owner of the new Property + * @param property + * The UML Property of the Stereotype to be retrieved. + * + */ + private void createStereotypePropertyInBrace(View compartmentView, Property property) { + CreateAppliedStereotypePropertyViewCommand command = new CreateAppliedStereotypePropertyViewCommand(domain, mainView, property, StereotypeDisplayConstant.STEREOTYPE_BRACE_TYPE); + CommandUtil.executeUnsafeCommand(command, mainView); + + } + + /** + * Create the Property of the Stereotype to be shown into the Comment of the Shape. + * + * + * @param compartment + * The Compartment View that is the Owner of the new Property + * @param property + * The UML Property of the Stereotype to be retrieved. + * + */ + private void createStereotypePropertyInComment(View compartmentView, Property property) { + CreateAppliedStereotypePropertyViewCommand command = new CreateAppliedStereotypePropertyViewCommand(domain, compartmentView, property, StereotypeDisplayConstant.STEREOTYPE_PROPERTY_TYPE); + CommandUtil.executeUnsafeCommand(command, mainView); + + } + + + + /** + * Execute the {@link CreateStereotypeLabelCommand} + * + * @param view + * The view that required a Stereotype Label + */ + private void createStereotypeLabel(final Stereotype stereotype) { + CreateStereotypeLabelCommand command = new CreateStereotypeLabelCommand(domain, mainView, stereotype); + CommandUtil.executeUnsafeCommand(command, mainView); + } + + + + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/StereotypeViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/StereotypeViewProvider.java index d374ace68dd..da586f45b71 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/StereotypeViewProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/StereotypeViewProvider.java @@ -1,225 +1,225 @@ -/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
- * 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:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
-
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display;
-
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * This Class Implement the interface {@link IStereotypeViewProvider} to provide Stereotype Views.
- *
- * @see IStereotypeViewProvider
- *
- * @author Céline JANSSENS
- *
- */
-public class StereotypeViewProvider implements IStereotypeViewProvider {
-
- private View mainView;
-
- private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
-
- /**
- * Constructor.
- *
- * @param mainView
- * The View on which the Stereotype is applied (i.e: A Shape, an Edge, An Operation, ...)
- */
- public StereotypeViewProvider(View mainView) {
- super();
- this.mainView = mainView;
-
- }
-
-
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewProvider#getProperty(org.eclipse.uml2.uml.Property, org.eclipse.uml2.uml.Stereotype, java.lang.String)
- *
- */
- @Override
- public View getProperty(Property property, Stereotype stereotype, Enum location) {
- View propertyView = null;
- if (StereotypeLocationEnum.IN_COMPARTMENT.equals(location)) {
- propertyView = getStereotypePropertyInCompartment(mainView, stereotype, property);
- } else if (StereotypeLocationEnum.IN_BRACE.equals(location)) {
- propertyView = getStereotypePropertyInBrace(mainView, stereotype, property);
- } else if (StereotypeLocationEnum.IN_COMMENT.equals(location)) {
- propertyView = getStereotypePropertyInComment(mainView, stereotype, property);
- }
- return propertyView;
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewProvider#getCompartment(org.eclipse.uml2.uml.Property, org.eclipse.uml2.uml.Stereotype, java.lang.String)
- *
- */
- @Override
- public View getCompartment(Stereotype stereotype, Enum location) {
- View compartmentView = null;
- if (StereotypeLocationEnum.IN_COMPARTMENT.equals(location)) {
- compartmentView = getStereotypeCompartmentInCompartment(mainView, stereotype);
- } else if (StereotypeLocationEnum.IN_BRACE.equals(location)) {
- compartmentView = getStereotypeCompartmentInBrace(mainView, stereotype);
- } else if (StereotypeLocationEnum.IN_COMMENT.equals(location)) {
- compartmentView = getStereotypeCompartmentInComment(mainView, stereotype);
- }
- return compartmentView;
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewProvider#getLabel(org.eclipse.uml2.uml.Property, org.eclipse.uml2.uml.Stereotype, java.lang.String)
- *
- */
- @Override
- public View getLabel(Stereotype stereotype) {
- return getStereotypeLabel(mainView, stereotype);
-
- }
-
-
- /**
- * Retrieve the Stereotype Compartment related to a Stereotype and create it if null.
- *
- * @param view
- * The view on which the Compartment is checked
- * @param stereotype
- * The Stereotype of the Compartment that is retrieved.
- * @return The Compartment related to the Stereotype (existing or newly created)
- */
- public View getStereotypeLabel(final View view, final Stereotype stereotype) {
- View label = helper.getStereotypeLabel(view, stereotype);
-
- return label;
- }
-
-
- /**
- * Retrieve the Stereotype Compartment View related to a Stereotype in Compartment and create it if null.
- *
- * @param view
- * The view on which the Compartment is checked
- * @param stereotype
- * The Stereotype of the Compartment that is retrieved.
- * @return The Compartment related to the Stereotype (existing or newly created)
- */
- public View getStereotypeCompartmentInCompartment(final View view, final Stereotype stereotype) {
- View compartment = helper.getStereotypeCompartment(view, stereotype);
-
- return compartment;
- }
-
-
- /**
- * Retrieve the Stereotype Compartment View related to a Stereotype in Brace and create it if null.
- *
- * @param view
- * The view on which the Compartment is checked
- * @param stereotype
- * The Stereotype of the Compartment that is retrieved.
- * @return The Compartment related to the Stereotype (existing or newly created)
- */
- public View getStereotypeCompartmentInBrace(final View view, final Stereotype stereotype) {
- View compartment = helper.getStereotypeBraceCompartment(view, stereotype);
-
- return compartment;
- }
-
-
- /**
- * Retrieve the Stereotype Compartment View related to a Stereotype in Comment and create it if null.
- *
- * @param view
- * The view on which the Compartment is checked
- * @param stereotype
- * The Stereotype of the Compartment that is retrieved.
- * @return The Compartment related to the Stereotype (existing or newly created)
- */
- public View getStereotypeCompartmentInComment(View view, Stereotype stereotype) {
- View comment = helper.getStereotypeComment(view);
- View compartment = helper.getStereotypeCompartment(comment, stereotype);
-
- return compartment;
- }
-
- /**
- * Retrieve the Stereotype Property related to a Stereotype and create it if null.
- *
- * @param view
- * The view on which the Compartment is checked
- * @param stereotype
- * The Stereotype of the Compartment that is retrieved.
- * @param property
- * The UML Property of the Stereotype to be retrieved.
- *
- * @return The Property related with the Stereotype (existing or newly created)
- */
- public View getStereotypePropertyInCompartment(final View view, final Stereotype stereotype, final Property property) {
- View propertyView = helper.getStereotypeProperty(view, stereotype, property);
-
-
- return propertyView;
- }
-
-
- /**
- * Retrieve the Stereotype Property View related to a Stereotype in Brace and create it if null.
- *
- * @param view
- * The view on which the Compartment is checked
- * @param stereotype
- * The Stereotype of the Compartment that is retrieved.
- * @param property
- * The UML Property of the Stereotype to be retrieved.
- *
- * @return The Property related with the Stereotype (existing or newly created)
- */
- public View getStereotypePropertyInBrace(View view, Stereotype stereotype, Property property) {
-
- View propertyView = helper.getStereotypePropertyInBrace(view, stereotype, property);
-
- return propertyView;
-
- }
-
-
-
- /**
- * Retrieve the Stereotype Property View related to a Stereotype in Comment and create it if null.
- *
- * @param view
- * The view on which the Compartment is checked
- * @param stereotype
- * The Stereotype of the Compartment that is retrieved.
- * @param property
- * The UML Property of the Stereotype to be retrieved.
- *
- * @return The Property related with the Stereotype (existing or newly created)
- */
- public View getStereotypePropertyInComment(View view, Stereotype stereotype, Property property) {
-
- View propertyView = helper.getStereotypePropertyInComment(view, stereotype, property);
-
- return propertyView;
-
- }
-
-
-
-}
+/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display + + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.common.stereotype.display; + +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.Stereotype; + +/** + * This Class Implement the interface {@link IStereotypeViewProvider} to provide Stereotype Views. + * + * @see IStereotypeViewProvider + * + * @author Céline JANSSENS + * + */ +public class StereotypeViewProvider implements IStereotypeViewProvider { + + private View mainView; + + private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance(); + + /** + * Constructor. + * + * @param mainView + * The View on which the Stereotype is applied (i.e: A Shape, an Edge, An Operation, ...) + */ + public StereotypeViewProvider(View mainView) { + super(); + this.mainView = mainView; + + } + + + + /** + * @see org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewProvider#getProperty(org.eclipse.uml2.uml.Property, org.eclipse.uml2.uml.Stereotype, java.lang.String) + * + */ + @Override + public View getProperty(Property property, Stereotype stereotype, Enum location) { + View propertyView = null; + if (StereotypeLocationEnum.IN_COMPARTMENT.equals(location)) { + propertyView = getStereotypePropertyInCompartment(mainView, stereotype, property); + } else if (StereotypeLocationEnum.IN_BRACE.equals(location)) { + propertyView = getStereotypePropertyInBrace(mainView, stereotype, property); + } else if (StereotypeLocationEnum.IN_COMMENT.equals(location)) { + propertyView = getStereotypePropertyInComment(mainView, stereotype, property); + } + return propertyView; + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewProvider#getCompartment(org.eclipse.uml2.uml.Property, org.eclipse.uml2.uml.Stereotype, java.lang.String) + * + */ + @Override + public View getCompartment(Stereotype stereotype, Enum location) { + View compartmentView = null; + if (StereotypeLocationEnum.IN_COMPARTMENT.equals(location)) { + compartmentView = getStereotypeCompartmentInCompartment(mainView, stereotype); + } else if (StereotypeLocationEnum.IN_BRACE.equals(location)) { + compartmentView = getStereotypeCompartmentInBrace(mainView, stereotype); + } else if (StereotypeLocationEnum.IN_COMMENT.equals(location)) { + compartmentView = getStereotypeCompartmentInComment(mainView, stereotype); + } + return compartmentView; + } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.stereotype.display.IStereotypeViewProvider#getLabel(org.eclipse.uml2.uml.Property, org.eclipse.uml2.uml.Stereotype, java.lang.String) + * + */ + @Override + public View getLabel(Stereotype stereotype) { + return getStereotypeLabel(mainView, stereotype); + + } + + + /** + * Retrieve the Stereotype Compartment related to a Stereotype and create it if null. + * + * @param view + * The view on which the Compartment is checked + * @param stereotype + * The Stereotype of the Compartment that is retrieved. + * @return The Compartment related to the Stereotype (existing or newly created) + */ + public View getStereotypeLabel(final View view, final Stereotype stereotype) { + View label = helper.getStereotypeLabel(view, stereotype); + + return label; + } + + + /** + * Retrieve the Stereotype Compartment View related to a Stereotype in Compartment and create it if null. + * + * @param view + * The view on which the Compartment is checked + * @param stereotype + * The Stereotype of the Compartment that is retrieved. + * @return The Compartment related to the Stereotype (existing or newly created) + */ + public View getStereotypeCompartmentInCompartment(final View view, final Stereotype stereotype) { + View compartment = helper.getStereotypeCompartment(view, stereotype); + + return compartment; + } + + + /** + * Retrieve the Stereotype Compartment View related to a Stereotype in Brace and create it if null. + * + * @param view + * The view on which the Compartment is checked + * @param stereotype + * The Stereotype of the Compartment that is retrieved. + * @return The Compartment related to the Stereotype (existing or newly created) + */ + public View getStereotypeCompartmentInBrace(final View view, final Stereotype stereotype) { + View compartment = helper.getStereotypeBraceCompartment(view, stereotype); + + return compartment; + } + + + /** + * Retrieve the Stereotype Compartment View related to a Stereotype in Comment and create it if null. + * + * @param view + * The view on which the Compartment is checked + * @param stereotype + * The Stereotype of the Compartment that is retrieved. + * @return The Compartment related to the Stereotype (existing or newly created) + */ + public View getStereotypeCompartmentInComment(View view, Stereotype stereotype) { + View comment = helper.getStereotypeComment(view); + View compartment = helper.getStereotypeCompartment(comment, stereotype); + + return compartment; + } + + /** + * Retrieve the Stereotype Property related to a Stereotype and create it if null. + * + * @param view + * The view on which the Compartment is checked + * @param stereotype + * The Stereotype of the Compartment that is retrieved. + * @param property + * The UML Property of the Stereotype to be retrieved. + * + * @return The Property related with the Stereotype (existing or newly created) + */ + public View getStereotypePropertyInCompartment(final View view, final Stereotype stereotype, final Property property) { + View propertyView = helper.getStereotypeProperty(view, stereotype, property); + + + return propertyView; + } + + + /** + * Retrieve the Stereotype Property View related to a Stereotype in Brace and create it if null. + * + * @param view + * The view on which the Compartment is checked + * @param stereotype + * The Stereotype of the Compartment that is retrieved. + * @param property + * The UML Property of the Stereotype to be retrieved. + * + * @return The Property related with the Stereotype (existing or newly created) + */ + public View getStereotypePropertyInBrace(View view, Stereotype stereotype, Property property) { + + View propertyView = helper.getStereotypePropertyInBrace(view, stereotype, property); + + return propertyView; + + } + + + + /** + * Retrieve the Stereotype Property View related to a Stereotype in Comment and create it if null. + * + * @param view + * The view on which the Compartment is checked + * @param stereotype + * The Stereotype of the Compartment that is retrieved. + * @param property + * The UML Property of the Stereotype to be retrieved. + * + * @return The Property related with the Stereotype (existing or newly created) + */ + public View getStereotypePropertyInComment(View view, Stereotype stereotype, Property property) { + + View propertyView = helper.getStereotypePropertyInComment(view, stereotype, property); + + return propertyView; + + } + + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/AddAppliedQNStereotypeToDisplayCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/AddAppliedQNStereotypeToDisplayCommand.java index 62fad89c3bd..6dc5ccbf28b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/AddAppliedQNStereotypeToDisplayCommand.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/AddAppliedQNStereotypeToDisplayCommand.java @@ -1,70 +1,70 @@ -/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command;
-
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayCommandExecution;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * The Class AddQNAppliedStereotypeToDisplayCommand used to set the list of applied stereotype to
- * display with the qualifiedName.
- */
-public class AddAppliedQNStereotypeToDisplayCommand extends RecordingCommand {
-
-
- private Stereotype stereotype;
-
- private View view;
- private TransactionalEditingDomain domain;
- private String depth;
-
- private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
- private static StereotypeDisplayCommandExecution commandHelper = StereotypeDisplayCommandExecution.getInstance();
-
-
- /**
- * Instantiates a new sets the applied stereotype to display command.
- *
- * @param domain
- * the domain
- * @param object
- * the object
- * @param stereotypeList
- * the stereotype list
- */
- public AddAppliedQNStereotypeToDisplayCommand(final TransactionalEditingDomain domain, final View view,
- final Stereotype stereotype, final String depth) {
- super(domain, "Display Stereotype with Qualified Name");
- this.depth = depth;
- this.domain = domain;
- this.view = view;
- this.stereotype = stereotype;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doExecute() {
- View label = helper.getStereotypeLabel(view, stereotype);
- commandHelper.setUserDepth(domain, stereotype, label, "full");
-
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command; + +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayCommandExecution; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil; +import org.eclipse.uml2.uml.Stereotype; + +/** + * The Class AddQNAppliedStereotypeToDisplayCommand used to set the list of applied stereotype to + * display with the qualifiedName. + */ +public class AddAppliedQNStereotypeToDisplayCommand extends RecordingCommand { + + + private Stereotype stereotype; + + private View view; + private TransactionalEditingDomain domain; + private String depth; + + private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance(); + private static StereotypeDisplayCommandExecution commandHelper = StereotypeDisplayCommandExecution.getInstance(); + + + /** + * Instantiates a new sets the applied stereotype to display command. + * + * @param domain + * the domain + * @param object + * the object + * @param stereotypeList + * the stereotype list + */ + public AddAppliedQNStereotypeToDisplayCommand(final TransactionalEditingDomain domain, final View view, + final Stereotype stereotype, final String depth) { + super(domain, "Display Stereotype with Qualified Name"); + this.depth = depth; + this.domain = domain; + this.view = view; + this.stereotype = stereotype; + } + + + /** + * {@inheritDoc} + */ + @Override + protected void doExecute() { + View label = helper.getStereotypeLabel(view, stereotype); + commandHelper.setUserDepth(domain, stereotype, label, "full"); + + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/AddAppliedStereotypePropertiesToDisplayCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/AddAppliedStereotypePropertiesToDisplayCommand.java index 52a5c8defb5..46f5b292199 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/AddAppliedStereotypePropertiesToDisplayCommand.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/AddAppliedStereotypePropertiesToDisplayCommand.java @@ -1,88 +1,88 @@ -/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command;
-
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayCommandExecution;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * The Class AddAppliedStereotypeToDisplayCommand used to set the list of applied stereotype to
- * display
- */
-public class AddAppliedStereotypePropertiesToDisplayCommand extends RecordingCommand {
-
-
- private Property property;
- private Stereotype stereotype;
- private View view;
- private TransactionalEditingDomain domain;
- private String location;
-
- private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
- private static StereotypeDisplayCommandExecution commandHelper = StereotypeDisplayCommandExecution.getInstance();
-
-
-
- /**
- * add a new sets the applied stereotype properties to display command.
- *
- * @param domain
- * the domain
- * @param object
- * the object
- * @param stereotypeList
- * the stereotype list
- */
- public AddAppliedStereotypePropertiesToDisplayCommand(TransactionalEditingDomain domain, View view,
- Property property, Stereotype stereotype, String location) {
- super(domain, "Display a Stereotype Property");
- this.property = property;
- this.stereotype = stereotype;
- this.domain = domain;
- this.view = view;
- this.location = location;
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doExecute() {
- View propertyView = null;
-
- switch (StereotypeLocationEnum.valueOf(location)) {
- case IN_BRACE:
- propertyView = helper.getStereotypePropertyInBrace(view, stereotype, property);
- break;
- case IN_COMMENT:
- propertyView = helper.getStereotypePropertyInComment(view, stereotype, property);
- break;
- case IN_COMPARTMENT:
- propertyView = helper.getStereotypeProperty(view, stereotype, property);
- break;
- }
-
- commandHelper.setUserVisibility(domain, propertyView, true);
- }
-
-
-
-}
+/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command; + +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayCommandExecution; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.Stereotype; + +/** + * The Class AddAppliedStereotypeToDisplayCommand used to set the list of applied stereotype to + * display + */ +public class AddAppliedStereotypePropertiesToDisplayCommand extends RecordingCommand { + + + private Property property; + private Stereotype stereotype; + private View view; + private TransactionalEditingDomain domain; + private String location; + + private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance(); + private static StereotypeDisplayCommandExecution commandHelper = StereotypeDisplayCommandExecution.getInstance(); + + + + /** + * add a new sets the applied stereotype properties to display command. + * + * @param domain + * the domain + * @param object + * the object + * @param stereotypeList + * the stereotype list + */ + public AddAppliedStereotypePropertiesToDisplayCommand(TransactionalEditingDomain domain, View view, + Property property, Stereotype stereotype, String location) { + super(domain, "Display a Stereotype Property"); + this.property = property; + this.stereotype = stereotype; + this.domain = domain; + this.view = view; + this.location = location; + + } + + /** + * {@inheritDoc} + */ + @Override + protected void doExecute() { + View propertyView = null; + + switch (StereotypeLocationEnum.valueOf(location)) { + case IN_BRACE: + propertyView = helper.getStereotypePropertyInBrace(view, stereotype, property); + break; + case IN_COMMENT: + propertyView = helper.getStereotypePropertyInComment(view, stereotype, property); + break; + case IN_COMPARTMENT: + propertyView = helper.getStereotypeProperty(view, stereotype, property); + break; + } + + commandHelper.setUserVisibility(domain, propertyView, true); + } + + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/AddAppliedStereotypeToDisplayCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/AddAppliedStereotypeToDisplayCommand.java index 8a0ddd21b7e..213348a1dad 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/AddAppliedStereotypeToDisplayCommand.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/AddAppliedStereotypeToDisplayCommand.java @@ -1,71 +1,71 @@ -/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command;
-
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayCommandExecution;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
-
-/**
- * The Class AddAppliedStereotypeToDisplayCommand used to set the list of applied stereotype to
- * display
- */
-public class AddAppliedStereotypeToDisplayCommand extends RecordingCommand {
-
- /** The qualified name. */
- private String stereotypeName;
-
- private View view;
- private TransactionalEditingDomain domain;
-
- private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
- private static StereotypeDisplayCommandExecution commandHelper = StereotypeDisplayCommandExecution.getInstance();
-
-
-
- /**
- * Instantiates a new sets the applied stereotype to display command.
- *
- * @param domain
- * the domain
- * @param object
- * the object
- * @param stereotypeList
- * the stereotype list
- */
- public AddAppliedStereotypeToDisplayCommand(final TransactionalEditingDomain domain, final View view,
- final String stereotypeName) {
- super(domain, "Display Stereotype Label");
- this.stereotypeName = stereotypeName;
- this.domain = domain;
- this.view = view;
-
-
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doExecute() {
- View label = helper.getStereotypeLabel(view, stereotypeName);
- commandHelper.setUserVisibility(domain, label, true);
-
-
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command; + +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayCommandExecution; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil; + +/** + * The Class AddAppliedStereotypeToDisplayCommand used to set the list of applied stereotype to + * display + */ +public class AddAppliedStereotypeToDisplayCommand extends RecordingCommand { + + /** The qualified name. */ + private String stereotypeName; + + private View view; + private TransactionalEditingDomain domain; + + private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance(); + private static StereotypeDisplayCommandExecution commandHelper = StereotypeDisplayCommandExecution.getInstance(); + + + + /** + * Instantiates a new sets the applied stereotype to display command. + * + * @param domain + * the domain + * @param object + * the object + * @param stereotypeList + * the stereotype list + */ + public AddAppliedStereotypeToDisplayCommand(final TransactionalEditingDomain domain, final View view, + final String stereotypeName) { + super(domain, "Display Stereotype Label"); + this.stereotypeName = stereotypeName; + this.domain = domain; + this.view = view; + + + + } + + /** + * {@inheritDoc} + */ + @Override + protected void doExecute() { + View label = helper.getStereotypeLabel(view, stereotypeName); + commandHelper.setUserVisibility(domain, label, true); + + + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateAppliedStereotypeCommentViewCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateAppliedStereotypeCommentViewCommand.java index 5d03a2b62b1..7ec78e6c100 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateAppliedStereotypeCommentViewCommand.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateAppliedStereotypeCommentViewCommand.java @@ -1,192 +1,192 @@ -/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 460356 : Refactor Stereotype Display
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command;
-
-import java.util.ArrayList;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.notation.BasicCompartment;
-import org.eclipse.gmf.runtime.notation.Bounds;
-import org.eclipse.gmf.runtime.notation.Connector;
-import org.eclipse.gmf.runtime.notation.DecorationNode;
-import org.eclipse.gmf.runtime.notation.EObjectValueStyle;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.IdentityAnchor;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.NotationFactory;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
-import org.eclipse.gmf.runtime.notation.TitleStyle;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
-
-/**
- * the goal of this command is to create a comment in the notation that represent a compartment of stereotypes
- *
- */
-public class CreateAppliedStereotypeCommentViewCommand extends RecordingCommand {
-
- protected View owner;
- protected EObject base_element;
- protected int x;
- protected int y;
- protected TransactionalEditingDomain domain;
- protected Boolean isBorderedElement;
-
- /**
- *
- * Constructor.
- *
- * @param domain
- * @param owner
- * @param StereotypeApplication
- * @param displayit
- */
- public CreateAppliedStereotypeCommentViewCommand(TransactionalEditingDomain domain, View owner, int x, int y, EObject base_Element, boolean isABordererElement) {
- super(domain, "CreateAppliedStereotypeCommentView");
- this.owner = owner;
- this.base_element = base_Element;
- this.x = x;
- this.y = y;
- this.domain = domain;
- this.isBorderedElement = isABordererElement;
-
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void doExecute() {
-
- // create the node
- Node node = NotationFactory.eINSTANCE.createShape();
- Bounds bounds = NotationFactory.eINSTANCE.createBounds();
- bounds.setX(x);
- bounds.setY(y);
- node.setLayoutConstraint(bounds);
- TitleStyle ts = NotationFactory.eINSTANCE.createTitleStyle();
- node.getStyles().add(ts);
- node.setElement(null);
- node.setType(StereotypeDisplayConstant.STEREOTYPE_COMMENT_TYPE);
-
- connectCommentNode(owner, node);
-
- EObjectValueStyle eObjectValueStyle = (EObjectValueStyle) node.createStyle(NotationPackage.eINSTANCE.getEObjectValueStyle());
- eObjectValueStyle.setEObjectValue(base_element);
- eObjectValueStyle.setName(StereotypeDisplayConstant.STEREOTYPE_COMMENT_RELATION_NAME);
-
- // create the link
- Connector edge = NotationFactory.eINSTANCE.createConnector();
- edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
- RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
- ArrayList<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
- points.add(new RelativeBendpoint());
- points.add(new RelativeBendpoint());
- bendpoints.setPoints(points);
- edge.setBendpoints(bendpoints);
- ViewUtil.insertChildView(owner.getDiagram(), edge, -1, true);
- edge.setType(StereotypeDisplayConstant.STEREOTYPE_COMMENT_LINK_TYPE);
- edge.setElement(base_element);
- IdentityAnchor anchor = NotationFactory.eINSTANCE.createIdentityAnchor();
- edge.setSourceAnchor(anchor);
- anchor = NotationFactory.eINSTANCE.createIdentityAnchor();
- edge.setTargetAnchor(anchor);
- edge.setSource(owner);
- edge.setTarget(node);
- edge.setElement(null);
- eObjectValueStyle = (EObjectValueStyle) edge.createStyle(NotationPackage.eINSTANCE.getEObjectValueStyle());
- eObjectValueStyle.setEObjectValue(base_element);
- eObjectValueStyle.setName(StereotypeDisplayConstant.STEREOTYPE_COMMENT_RELATION_NAME);
-
-
-
-
-
- }
-
- /**
- * add the comment node form the owner
- *
- * @param owner
- * the view from which we want to display a comment stereotype, cannot be null
- * @param commentNode
- * node that represent the comment , cannot be null
- */
- private void connectCommentNode(View owner, Node commentNode) {
-
- // in the case of the edge the comment has to be placed into the common parent of each end
- if (owner instanceof Edge) {
- View viewSource = ((Edge) owner).getSource();
- View viewTarget = ((Edge) owner).getSource();
- // list of source parents
- ArrayList<View> parentsSource = getParentTree(viewSource);
- // list of source targets
- ArrayList<View> parentsTarget = getParentTree(viewTarget);
- View commonParent = null;
- int index = 0;
- // find the common
- while (commonParent == null && index < parentsSource.size()) {
- if (parentsTarget.contains(parentsSource.get(index))) {
- commonParent = parentsSource.get(index);
- if (!(commonParent instanceof BasicCompartment)) {
- commonParent = null;
- }
- }
- index++;
- }
- // a common has been found
- if (commonParent != null) {
- ((Bounds) commentNode.getLayoutConstraint()).setX(100);
- ((Bounds) commentNode.getLayoutConstraint()).setY(100);
- ViewUtil.insertChildView(commonParent, commentNode, ViewUtil.APPEND, true);
- return;
- }
- }
- // generic case
- View econtainer = (View) owner.eContainer();
- // for the case of a port
- if (isBorderedElement) {
- if (econtainer.eContainer() != null) {
- econtainer = (View) econtainer.eContainer();
- }
- }
- ViewUtil.insertChildView(econtainer, commentNode, ViewUtil.APPEND, true);
-
- }
-
- /**
- * @param view
- * the view for which we look for its parents, cannot be null
- * @return the list of parents of a view
- */
- private ArrayList<View> getParentTree(View view) {
- ArrayList<View> parents = new ArrayList<View>();
- View currentView = view;
- while (currentView != null) {
- currentView = (View) currentView.eContainer();
- if (currentView != null) {
- if (!(currentView instanceof DecorationNode) && !(currentView instanceof BasicCompartment)) {
- // parents.addAll(currentView.getChildren());
- }
- parents.add(currentView);
- }
-
- }
- return parents;
- }
-}
+/***************************************************************************** + * Copyright (c) 2012 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 460356 : Refactor Stereotype Display + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command; + +import java.util.ArrayList; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; +import org.eclipse.gmf.runtime.notation.BasicCompartment; +import org.eclipse.gmf.runtime.notation.Bounds; +import org.eclipse.gmf.runtime.notation.Connector; +import org.eclipse.gmf.runtime.notation.DecorationNode; +import org.eclipse.gmf.runtime.notation.EObjectValueStyle; +import org.eclipse.gmf.runtime.notation.Edge; +import org.eclipse.gmf.runtime.notation.IdentityAnchor; +import org.eclipse.gmf.runtime.notation.Node; +import org.eclipse.gmf.runtime.notation.NotationFactory; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.gmf.runtime.notation.RelativeBendpoints; +import org.eclipse.gmf.runtime.notation.TitleStyle; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant; + +/** + * the goal of this command is to create a comment in the notation that represent a compartment of stereotypes + * + */ +public class CreateAppliedStereotypeCommentViewCommand extends RecordingCommand { + + protected View owner; + protected EObject base_element; + protected int x; + protected int y; + protected TransactionalEditingDomain domain; + protected Boolean isBorderedElement; + + /** + * + * Constructor. + * + * @param domain + * @param owner + * @param StereotypeApplication + * @param displayit + */ + public CreateAppliedStereotypeCommentViewCommand(TransactionalEditingDomain domain, View owner, int x, int y, EObject base_Element, boolean isABordererElement) { + super(domain, "CreateAppliedStereotypeCommentView"); + this.owner = owner; + this.base_element = base_Element; + this.x = x; + this.y = y; + this.domain = domain; + this.isBorderedElement = isABordererElement; + + } + + @SuppressWarnings("unchecked") + @Override + public void doExecute() { + + // create the node + Node node = NotationFactory.eINSTANCE.createShape(); + Bounds bounds = NotationFactory.eINSTANCE.createBounds(); + bounds.setX(x); + bounds.setY(y); + node.setLayoutConstraint(bounds); + TitleStyle ts = NotationFactory.eINSTANCE.createTitleStyle(); + node.getStyles().add(ts); + node.setElement(null); + node.setType(StereotypeDisplayConstant.STEREOTYPE_COMMENT_TYPE); + + connectCommentNode(owner, node); + + EObjectValueStyle eObjectValueStyle = (EObjectValueStyle) node.createStyle(NotationPackage.eINSTANCE.getEObjectValueStyle()); + eObjectValueStyle.setEObjectValue(base_element); + eObjectValueStyle.setName(StereotypeDisplayConstant.STEREOTYPE_COMMENT_RELATION_NAME); + + // create the link + Connector edge = NotationFactory.eINSTANCE.createConnector(); + edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); + RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); + ArrayList<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2); + points.add(new RelativeBendpoint()); + points.add(new RelativeBendpoint()); + bendpoints.setPoints(points); + edge.setBendpoints(bendpoints); + ViewUtil.insertChildView(owner.getDiagram(), edge, -1, true); + edge.setType(StereotypeDisplayConstant.STEREOTYPE_COMMENT_LINK_TYPE); + edge.setElement(base_element); + IdentityAnchor anchor = NotationFactory.eINSTANCE.createIdentityAnchor(); + edge.setSourceAnchor(anchor); + anchor = NotationFactory.eINSTANCE.createIdentityAnchor(); + edge.setTargetAnchor(anchor); + edge.setSource(owner); + edge.setTarget(node); + edge.setElement(null); + eObjectValueStyle = (EObjectValueStyle) edge.createStyle(NotationPackage.eINSTANCE.getEObjectValueStyle()); + eObjectValueStyle.setEObjectValue(base_element); + eObjectValueStyle.setName(StereotypeDisplayConstant.STEREOTYPE_COMMENT_RELATION_NAME); + + + + + + } + + /** + * add the comment node form the owner + * + * @param owner + * the view from which we want to display a comment stereotype, cannot be null + * @param commentNode + * node that represent the comment , cannot be null + */ + private void connectCommentNode(View owner, Node commentNode) { + + // in the case of the edge the comment has to be placed into the common parent of each end + if (owner instanceof Edge) { + View viewSource = ((Edge) owner).getSource(); + View viewTarget = ((Edge) owner).getSource(); + // list of source parents + ArrayList<View> parentsSource = getParentTree(viewSource); + // list of source targets + ArrayList<View> parentsTarget = getParentTree(viewTarget); + View commonParent = null; + int index = 0; + // find the common + while (commonParent == null && index < parentsSource.size()) { + if (parentsTarget.contains(parentsSource.get(index))) { + commonParent = parentsSource.get(index); + if (!(commonParent instanceof BasicCompartment)) { + commonParent = null; + } + } + index++; + } + // a common has been found + if (commonParent != null) { + ((Bounds) commentNode.getLayoutConstraint()).setX(100); + ((Bounds) commentNode.getLayoutConstraint()).setY(100); + ViewUtil.insertChildView(commonParent, commentNode, ViewUtil.APPEND, true); + return; + } + } + // generic case + View econtainer = (View) owner.eContainer(); + // for the case of a port + if (isBorderedElement) { + if (econtainer.eContainer() != null) { + econtainer = (View) econtainer.eContainer(); + } + } + ViewUtil.insertChildView(econtainer, commentNode, ViewUtil.APPEND, true); + + } + + /** + * @param view + * the view for which we look for its parents, cannot be null + * @return the list of parents of a view + */ + private ArrayList<View> getParentTree(View view) { + ArrayList<View> parents = new ArrayList<View>(); + View currentView = view; + while (currentView != null) { + currentView = (View) currentView.eContainer(); + if (currentView != null) { + if (!(currentView instanceof DecorationNode) && !(currentView instanceof BasicCompartment)) { + // parents.addAll(currentView.getChildren()); + } + parents.add(currentView); + } + + } + return parents; + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateAppliedStereotypeCompartmentCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateAppliedStereotypeCompartmentCommand.java index 0ad7663047d..ec1437d86c2 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateAppliedStereotypeCompartmentCommand.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateAppliedStereotypeCompartmentCommand.java @@ -1,90 +1,90 @@ -/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command;
-
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.NotationFactory;
-import org.eclipse.gmf.runtime.notation.StringValueStyle;
-import org.eclipse.gmf.runtime.notation.TitleStyle;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * the goal of this command is to create a basic compartment in the notation that represent a compartment of stereotypes
- *
- */
-public class CreateAppliedStereotypeCompartmentCommand extends RecordingCommand {
-
- protected StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
-
- protected View node;
-
- protected Stereotype stereotype;
-
- protected Node parent;
-
- protected String type;
-
- /**
- *
- * Constructor.
- *
- * @param domain
- * @param node
- * The EditPart view of the Compartment
- * @param StereotypeApplication
- * @param displayit
- */
- public CreateAppliedStereotypeCompartmentCommand(TransactionalEditingDomain domain, View node, Stereotype stereotype, String type) {
- super(domain, "CreateStereotypeCompartment");
- this.node = node;
- this.stereotype = stereotype;
- this.type = type;
-
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void doExecute() {
-
- // Create the Graphical Compartment
- Node compartment = NotationFactory.eINSTANCE.createBasicCompartment();
- compartment.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
-
- // Create Title Style
- TitleStyle ts = NotationFactory.eINSTANCE.createTitleStyle();
- compartment.getStyles().add(ts);
-
- // Create Stereotype Name Style
- StringValueStyle stereotypeNameStyle = NotationFactory.eINSTANCE.createStringValueStyle();
- stereotypeNameStyle.setName(StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_NAME);
- stereotypeNameStyle.setStringValue(stereotype.getQualifiedName());
- compartment.getStyles().add(stereotypeNameStyle);
-
- // Complete the creation
- compartment.setElement(stereotype);
- compartment.setType(type);
- ViewUtil.insertChildView(node, compartment, ViewUtil.APPEND, StereotypeDisplayConstant.PERSISTENT);
- compartment.setMutable(true);
-
- }
-
-
-
-}
+/***************************************************************************** + * Copyright (c) 2012 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command; + +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; +import org.eclipse.gmf.runtime.notation.Node; +import org.eclipse.gmf.runtime.notation.NotationFactory; +import org.eclipse.gmf.runtime.notation.StringValueStyle; +import org.eclipse.gmf.runtime.notation.TitleStyle; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil; +import org.eclipse.uml2.uml.Stereotype; + +/** + * the goal of this command is to create a basic compartment in the notation that represent a compartment of stereotypes + * + */ +public class CreateAppliedStereotypeCompartmentCommand extends RecordingCommand { + + protected StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance(); + + protected View node; + + protected Stereotype stereotype; + + protected Node parent; + + protected String type; + + /** + * + * Constructor. + * + * @param domain + * @param node + * The EditPart view of the Compartment + * @param StereotypeApplication + * @param displayit + */ + public CreateAppliedStereotypeCompartmentCommand(TransactionalEditingDomain domain, View node, Stereotype stereotype, String type) { + super(domain, "CreateStereotypeCompartment"); + this.node = node; + this.stereotype = stereotype; + this.type = type; + + } + + @SuppressWarnings("unchecked") + @Override + public void doExecute() { + + // Create the Graphical Compartment + Node compartment = NotationFactory.eINSTANCE.createBasicCompartment(); + compartment.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); + + // Create Title Style + TitleStyle ts = NotationFactory.eINSTANCE.createTitleStyle(); + compartment.getStyles().add(ts); + + // Create Stereotype Name Style + StringValueStyle stereotypeNameStyle = NotationFactory.eINSTANCE.createStringValueStyle(); + stereotypeNameStyle.setName(StereotypeDisplayConstant.STEREOTYPE_COMPARTMENT_NAME); + stereotypeNameStyle.setStringValue(stereotype.getQualifiedName()); + compartment.getStyles().add(stereotypeNameStyle); + + // Complete the creation + compartment.setElement(stereotype); + compartment.setType(type); + ViewUtil.insertChildView(node, compartment, ViewUtil.APPEND, StereotypeDisplayConstant.PERSISTENT); + compartment.setMutable(true); + + } + + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateAppliedStereotypePropertyViewCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateAppliedStereotypePropertyViewCommand.java index c109a891b98..b676b5d91e9 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateAppliedStereotypePropertyViewCommand.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateAppliedStereotypePropertyViewCommand.java @@ -1,69 +1,69 @@ -/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotypes Display
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.notation.DecorationNode;
-import org.eclipse.gmf.runtime.notation.NotationFactory;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Property;
-
-/**
- * the goal of this command is to create a basic compartment in the notation that represent a compartment of stereotypes
- *
- */
-public class CreateAppliedStereotypePropertyViewCommand extends RecordingCommand {
-
- protected View owner;
-
- protected Property property;
-
- protected EObject stereotypeApplication;
-
- protected Element element;
-
- protected String type;
-
- public CreateAppliedStereotypePropertyViewCommand(TransactionalEditingDomain domain, View owner, Property property, final String type) {
-
- super(domain, "CreateStereotypePropertyView");
- this.owner = owner;
- this.property = property;
- this.type = type;
-
- }
-
- @Override
- public void doExecute() {
-
- // Create Stereotype Property into Notation Structure
-
- // Create property Label
- DecorationNode propertyLabel = NotationFactory.eINSTANCE.createDecorationNode();
- propertyLabel.setType(type);
- propertyLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
- propertyLabel.setElement(property);
-
- // Add the new Label to it's owner Object
- ViewUtil.insertChildView(owner, propertyLabel, ViewUtil.APPEND, StereotypeDisplayConstant.PERSISTENT);
- propertyLabel.setMutable(true);
-
- }
-}
+/***************************************************************************** + * Copyright (c) 2012 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotypes Display + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; +import org.eclipse.gmf.runtime.notation.DecorationNode; +import org.eclipse.gmf.runtime.notation.NotationFactory; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Property; + +/** + * the goal of this command is to create a basic compartment in the notation that represent a compartment of stereotypes + * + */ +public class CreateAppliedStereotypePropertyViewCommand extends RecordingCommand { + + protected View owner; + + protected Property property; + + protected EObject stereotypeApplication; + + protected Element element; + + protected String type; + + public CreateAppliedStereotypePropertyViewCommand(TransactionalEditingDomain domain, View owner, Property property, final String type) { + + super(domain, "CreateStereotypePropertyView"); + this.owner = owner; + this.property = property; + this.type = type; + + } + + @Override + public void doExecute() { + + // Create Stereotype Property into Notation Structure + + // Create property Label + DecorationNode propertyLabel = NotationFactory.eINSTANCE.createDecorationNode(); + propertyLabel.setType(type); + propertyLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); + propertyLabel.setElement(property); + + // Add the new Label to it's owner Object + ViewUtil.insertChildView(owner, propertyLabel, ViewUtil.APPEND, StereotypeDisplayConstant.PERSISTENT); + propertyLabel.setMutable(true); + + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateStereotypeLabelCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateStereotypeLabelCommand.java index 36b35c3c3b3..56414fe3d21 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateStereotypeLabelCommand.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/CreateStereotypeLabelCommand.java @@ -1,92 +1,92 @@ -/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
- * 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:
- * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotypes Display
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command;
-
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.notation.DecorationNode;
-import org.eclipse.gmf.runtime.notation.NotationFactory;
-import org.eclipse.gmf.runtime.notation.StringValueStyle;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * @author Céline JANSSENS
- *
- */
-public class CreateStereotypeLabelCommand extends RecordingCommand {
-
- private static final String STEREOTYPE_LABEL_COMMAND_NAME = "Stereotype Label Creation Command";
-
-
- protected View owner;
-
- protected Stereotype stereotype;
-
- protected boolean isVisible;
-
- protected Element element;
-
- /**
- * Constructor.
- *
- * @param domain
- * Transactional domain
- * @param owner
- * Owner of the Label Created
- * @param stereoApplication
- * Stereotype application which the Label will be based on
- * @param isVisible
- * if the Label is Visible when created
- */
- public CreateStereotypeLabelCommand(TransactionalEditingDomain domain, View owner, Stereotype stereotype) {
- super(domain, STEREOTYPE_LABEL_COMMAND_NAME);
- this.owner = owner;
- this.stereotype = stereotype;
-
- }
-
- /**
- * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
- *
- */
- @SuppressWarnings("unchecked")
- @Override
- protected void doExecute() {
-
-
- // Create Label
- DecorationNode label = NotationFactory.eINSTANCE.createDecorationNode();
- label.setType(StereotypeDisplayConstant.STEREOTYPE_LABEL_TYPE);
- label.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- label.setElement(stereotype);
-
- // Create Stereotype Name Style
- StringValueStyle stereotypeNameStyle = NotationFactory.eINSTANCE.createStringValueStyle();
- stereotypeNameStyle.setName(StereotypeDisplayConstant.STEREOTYPE_LABEL_NAME);
- stereotypeNameStyle.setStringValue(stereotype.getQualifiedName());
- label.getStyles().add(stereotypeNameStyle);
-
- // Add the new Label to it's owner Object
- ViewUtil.insertChildView(owner, label, ViewUtil.APPEND, StereotypeDisplayConstant.PERSISTENT);
-
- label.setMutable(true);
-
-
- }
-}
+/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation + * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotypes Display + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command; + +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; +import org.eclipse.gmf.runtime.notation.DecorationNode; +import org.eclipse.gmf.runtime.notation.NotationFactory; +import org.eclipse.gmf.runtime.notation.StringValueStyle; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayConstant; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Stereotype; + +/** + * @author Céline JANSSENS + * + */ +public class CreateStereotypeLabelCommand extends RecordingCommand { + + private static final String STEREOTYPE_LABEL_COMMAND_NAME = "Stereotype Label Creation Command"; + + + protected View owner; + + protected Stereotype stereotype; + + protected boolean isVisible; + + protected Element element; + + /** + * Constructor. + * + * @param domain + * Transactional domain + * @param owner + * Owner of the Label Created + * @param stereoApplication + * Stereotype application which the Label will be based on + * @param isVisible + * if the Label is Visible when created + */ + public CreateStereotypeLabelCommand(TransactionalEditingDomain domain, View owner, Stereotype stereotype) { + super(domain, STEREOTYPE_LABEL_COMMAND_NAME); + this.owner = owner; + this.stereotype = stereotype; + + } + + /** + * @see org.eclipse.emf.transaction.RecordingCommand#doExecute() + * + */ + @SuppressWarnings("unchecked") + @Override + protected void doExecute() { + + + // Create Label + DecorationNode label = NotationFactory.eINSTANCE.createDecorationNode(); + label.setType(StereotypeDisplayConstant.STEREOTYPE_LABEL_TYPE); + label.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); + label.setElement(stereotype); + + // Create Stereotype Name Style + StringValueStyle stereotypeNameStyle = NotationFactory.eINSTANCE.createStringValueStyle(); + stereotypeNameStyle.setName(StereotypeDisplayConstant.STEREOTYPE_LABEL_NAME); + stereotypeNameStyle.setStringValue(stereotype.getQualifiedName()); + label.getStyles().add(stereotypeNameStyle); + + // Add the new Label to it's owner Object + ViewUtil.insertChildView(owner, label, ViewUtil.APPEND, StereotypeDisplayConstant.PERSISTENT); + + label.setMutable(true); + + + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/RemoveAppliedStereotypePropertiesToDisplayCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/RemoveAppliedStereotypePropertiesToDisplayCommand.java index ad0be179740..8536d65a2fd 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/RemoveAppliedStereotypePropertiesToDisplayCommand.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/RemoveAppliedStereotypePropertiesToDisplayCommand.java @@ -1,82 +1,82 @@ -/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command;
-
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayCommandExecution;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * The Class RemoveAppliedStereotypeToDisplayCommand used to set the list of applied stereotype to
- * display
- */
-public class RemoveAppliedStereotypePropertiesToDisplayCommand extends RecordingCommand {
-
-
- private View view;
- private TransactionalEditingDomain domain;
- private Stereotype stereotype;
- private Property property;
- private String location;
-
- private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
- private static StereotypeDisplayCommandExecution commandHelper = StereotypeDisplayCommandExecution.getInstance();
-
- /**
- * Instantiates a new sets the applied stereotype to display command.
- *
- * @param domain
- * the domain
- * @param object
- * the object
- * @param stereotypePropertyList
- * the stereotype list
- */
- public RemoveAppliedStereotypePropertiesToDisplayCommand(TransactionalEditingDomain domain, View view,
- final Property property, final Stereotype stereotype, final String location) {
- super(domain, "Hide a Stereotype Property");
- this.property = property;
- this.stereotype = stereotype;
- this.domain = domain;
- this.view = view;
- this.location = location;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doExecute() {
- View propertyView = null;
- switch (StereotypeLocationEnum.valueOf(location)) {
- case IN_COMPARTMENT:
- propertyView = helper.getStereotypeProperty(view, stereotype, property);
- break;
- case IN_BRACE:
- propertyView = helper.getStereotypePropertyInBrace(view, stereotype, property);
- break;
- case IN_COMMENT:
- propertyView = helper.getStereotypePropertyInComment(view, stereotype, property);
- break;
- }
-
- commandHelper.setUserVisibility(domain, propertyView, false);
-
- }
-}
+/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command; + +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayCommandExecution; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.Stereotype; + +/** + * The Class RemoveAppliedStereotypeToDisplayCommand used to set the list of applied stereotype to + * display + */ +public class RemoveAppliedStereotypePropertiesToDisplayCommand extends RecordingCommand { + + + private View view; + private TransactionalEditingDomain domain; + private Stereotype stereotype; + private Property property; + private String location; + + private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance(); + private static StereotypeDisplayCommandExecution commandHelper = StereotypeDisplayCommandExecution.getInstance(); + + /** + * Instantiates a new sets the applied stereotype to display command. + * + * @param domain + * the domain + * @param object + * the object + * @param stereotypePropertyList + * the stereotype list + */ + public RemoveAppliedStereotypePropertiesToDisplayCommand(TransactionalEditingDomain domain, View view, + final Property property, final Stereotype stereotype, final String location) { + super(domain, "Hide a Stereotype Property"); + this.property = property; + this.stereotype = stereotype; + this.domain = domain; + this.view = view; + this.location = location; + } + + /** + * {@inheritDoc} + */ + @Override + protected void doExecute() { + View propertyView = null; + switch (StereotypeLocationEnum.valueOf(location)) { + case IN_COMPARTMENT: + propertyView = helper.getStereotypeProperty(view, stereotype, property); + break; + case IN_BRACE: + propertyView = helper.getStereotypePropertyInBrace(view, stereotype, property); + break; + case IN_COMMENT: + propertyView = helper.getStereotypePropertyInComment(view, stereotype, property); + break; + } + + commandHelper.setUserVisibility(domain, propertyView, false); + + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/RemoveAppliedStereotypeToDisplayCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/RemoveAppliedStereotypeToDisplayCommand.java index 1b54a707f73..eb5c49ccc81 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/RemoveAppliedStereotypeToDisplayCommand.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/RemoveAppliedStereotypeToDisplayCommand.java @@ -1,67 +1,67 @@ -/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command;
-
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayCommandExecution;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * The Class RemoveAppliedStereotypeToDisplayCommand used to set the list of applied stereotype to
- * display
- */
-public class RemoveAppliedStereotypeToDisplayCommand extends RecordingCommand {
-
-
- private View view;
- private TransactionalEditingDomain domain;
- private Stereotype stereotype;
-
- private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance();
- private static StereotypeDisplayCommandExecution commandHelper = StereotypeDisplayCommandExecution.getInstance();
-
-
-
-
- /**
- * Instantiates a new sets the applied stereotype to display command.
- *
- * @param domain
- * the domain
- * @param object
- * the object
- * @param stereotypeList
- * the stereotype list
- */
-
- public RemoveAppliedStereotypeToDisplayCommand(TransactionalEditingDomain domain, View view,
- Stereotype stereotype) {
- super(domain, "Hide Stereotype Label");
- this.domain = domain;
- this.view = view;
- this.stereotype = stereotype;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doExecute() {
- View label = helper.getStereotypeLabel(view, stereotype);
- commandHelper.setUserVisibility(domain, label, false);
- }
-}
+/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command; + +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayCommandExecution; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper.StereotypeDisplayUtil; +import org.eclipse.uml2.uml.Stereotype; + +/** + * The Class RemoveAppliedStereotypeToDisplayCommand used to set the list of applied stereotype to + * display + */ +public class RemoveAppliedStereotypeToDisplayCommand extends RecordingCommand { + + + private View view; + private TransactionalEditingDomain domain; + private Stereotype stereotype; + + private static StereotypeDisplayUtil helper = StereotypeDisplayUtil.getInstance(); + private static StereotypeDisplayCommandExecution commandHelper = StereotypeDisplayCommandExecution.getInstance(); + + + + + /** + * Instantiates a new sets the applied stereotype to display command. + * + * @param domain + * the domain + * @param object + * the object + * @param stereotypeList + * the stereotype list + */ + + public RemoveAppliedStereotypeToDisplayCommand(TransactionalEditingDomain domain, View view, + Stereotype stereotype) { + super(domain, "Hide Stereotype Label"); + this.domain = domain; + this.view = view; + this.stereotype = stereotype; + } + + /** + * {@inheritDoc} + */ + @Override + protected void doExecute() { + View label = helper.getStereotypeLabel(view, stereotype); + commandHelper.setUserVisibility(domain, label, false); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/SetPersistentViewCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/SetPersistentViewCommand.java index 4b0237b8262..0787a987baf 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/SetPersistentViewCommand.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/SetPersistentViewCommand.java @@ -1,85 +1,85 @@ -/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
- * 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:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 Stereotype Display
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command;
-
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * This Command set a view and all its ancestors persistent.
- * The method {@link View#persist()} makes all the sibling persistent, this Command does not.
- *
- * @author Céline JANSSENS
- *
- */
-public class SetPersistentViewCommand extends RecordingCommand {
-
- protected View view;
-
- protected final static String LABEL_COMMAND = "Set Persistency"; //$NON-NLS-1$
-
- /**
- *
- * Constructor.
- *
- * @param domain
- * Transactional Domain
- * @param view
- * The view to make persistent
- */
- public SetPersistentViewCommand(TransactionalEditingDomain domain, View view) {
-
- super(domain, LABEL_COMMAND);
- this.view = view;
- }
-
-
- /**
- * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
- *
- */
- @Override
- protected void doExecute() {
- makeViewPersistant(view);
-
- }
-
- /**
- * Recursive method that makes a view and all its ancestors persistent.
- *
- * @param view
- * The view to make persistent ( cannot be {@code null})
- */
- @SuppressWarnings("unchecked")
- protected void makeViewPersistant(final View view) {
- if (view != null) {
- if (view.eContainer() != null && view.eContainer() instanceof View) {
-
- // Make the Parent Persistent
- makeViewPersistant((View) view.eContainer());
- // Move the view from the Transient List to the Persistent Children list
- if (!(view instanceof Edge)) {
- ((View) view.eContainer()).getPersistedChildren().add(view);
- ((View) view.eContainer()).getTransientChildren().remove(view);
- }
-
-
-
- }
- }
- }
-}
+/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 Stereotype Display + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command; + +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.notation.Edge; +import org.eclipse.gmf.runtime.notation.View; + +/** + * This Command set a view and all its ancestors persistent. + * The method {@link View#persist()} makes all the sibling persistent, this Command does not. + * + * @author Céline JANSSENS + * + */ +public class SetPersistentViewCommand extends RecordingCommand { + + protected View view; + + protected final static String LABEL_COMMAND = "Set Persistency"; //$NON-NLS-1$ + + /** + * + * Constructor. + * + * @param domain + * Transactional Domain + * @param view + * The view to make persistent + */ + public SetPersistentViewCommand(TransactionalEditingDomain domain, View view) { + + super(domain, LABEL_COMMAND); + this.view = view; + } + + + /** + * @see org.eclipse.emf.transaction.RecordingCommand#doExecute() + * + */ + @Override + protected void doExecute() { + makeViewPersistant(view); + + } + + /** + * Recursive method that makes a view and all its ancestors persistent. + * + * @param view + * The view to make persistent ( cannot be {@code null}) + */ + @SuppressWarnings("unchecked") + protected void makeViewPersistant(final View view) { + if (view != null) { + if (view.eContainer() != null && view.eContainer() instanceof View) { + + // Make the Parent Persistent + makeViewPersistant((View) view.eContainer()); + // Move the view from the Transient List to the Persistent Children list + if (!(view instanceof Edge)) { + ((View) view.eContainer()).getPersistedChildren().add(view); + ((View) view.eContainer()).getTransientChildren().remove(view); + } + + + + } + } + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/UnsetPersistentViewCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/UnsetPersistentViewCommand.java index 7648cf62cad..490c072545d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/UnsetPersistentViewCommand.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/command/UnsetPersistentViewCommand.java @@ -1,78 +1,78 @@ -/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
- * 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:
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
- * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 Stereotype Display
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command;
-
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * This Command set a view Transcient.
- *
- *
- * @author Céline JANSSENS
- *
- */
-public class UnsetPersistentViewCommand extends RecordingCommand {
-
- protected View view;
-
- protected final static String LABEL_COMMAND = "Unset Persistency"; //$NON-NLS-1$
-
- /**
- *
- * Constructor.
- *
- * @param domain
- * Transactional Domain
- * @param view
- * The view to make persistent
- */
- public UnsetPersistentViewCommand(TransactionalEditingDomain domain, View view) {
-
- super(domain, LABEL_COMMAND);
- this.view = view;
- }
-
-
- /**
- * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
- *
- */
- @Override
- protected void doExecute() {
- makeViewTranscient(view);
-
- }
-
- /**
- * Recursive method that makes a view and all its ancestors persistent.
- *
- * @param view
- * The view to make persistent ( cannot be {@code null})
- */
- @SuppressWarnings("unchecked")
- protected void makeViewTranscient(final View view) {
- if (view != null) {
- if (view.eContainer() != null && view.eContainer() instanceof View) {
-
- // Move the view from the Transient List to the Persistent Children list
- ((View) view.eContainer()).getTransientChildren().add(view);
- ((View) view.eContainer()).getPersistedChildren().remove(view);
-
- }
- }
- }
-}
+/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation + * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 Stereotype Display + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.common.stereotype.display.command; + +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.notation.View; + +/** + * This Command set a view Transcient. + * + * + * @author Céline JANSSENS + * + */ +public class UnsetPersistentViewCommand extends RecordingCommand { + + protected View view; + + protected final static String LABEL_COMMAND = "Unset Persistency"; //$NON-NLS-1$ + + /** + * + * Constructor. + * + * @param domain + * Transactional Domain + * @param view + * The view to make persistent + */ + public UnsetPersistentViewCommand(TransactionalEditingDomain domain, View view) { + + super(domain, LABEL_COMMAND); + this.view = view; + } + + + /** + * @see org.eclipse.emf.transaction.RecordingCommand#doExecute() + * + */ + @Override + protected void doExecute() { + makeViewTranscient(view); + + } + + /** + * Recursive method that makes a view and all its ancestors persistent. + * + * @param view + * The view to make persistent ( cannot be {@code null}) + */ + @SuppressWarnings("unchecked") + protected void makeViewTranscient(final View view) { + if (view != null) { + if (view.eContainer() != null && view.eContainer() instanceof View) { + + // Move the view from the Transient List to the Persistent Children list + ((View) view.eContainer()).getTransientChildren().add(view); + ((View) view.eContainer()).getPersistedChildren().remove(view); + + } + } + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/helper/StereotypeUserActionHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/helper/StereotypeUserActionHelper.java index 96504c9bdc4..548217c1bf6 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/helper/StereotypeUserActionHelper.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/display/helper/StereotypeUserActionHelper.java @@ -1,123 +1,123 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper;
-
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.AddAppliedQNStereotypeToDisplayCommand;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.AddAppliedStereotypePropertiesToDisplayCommand;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.AddAppliedStereotypeToDisplayCommand;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.RemoveAppliedStereotypePropertiesToDisplayCommand;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.RemoveAppliedStereotypeToDisplayCommand;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * The Class AppliedStereotypeHelper.
- * Helper used in the User interaction to display Stereotypes from the Property View.
- * Note: this class is to be used instead of <i>AppliedStereotypeHelper</i> which is deprecated)
- */
-public class StereotypeUserActionHelper {
-
-
-
- /**
- * add new applied stereotypes to display with the qualified name.
- *
- * @param domain
- * the transactionnal edit domain
- * @param view
- * the emodel element that is the display of the uml element
- * @param appliedStereotypeList
- * the list of stereotype with qualified name to display
- *
- * @return the command to display it
- */
- public static RecordingCommand getAddAppliedStereotypeToDisplayWithQNCommand(TransactionalEditingDomain domain, View view, Stereotype stereotype, String depth) {
- return new AddAppliedQNStereotypeToDisplayCommand(domain, view, stereotype, depth);
- }
-
- /**
- * Gets the adds the applied stereotype command.
- *
- * @param domain
- * the domain
- * @param view
- * the view
- * @param appliedStereotypeListToAdd
- * the applied stereotype list to add
- * @param presentationKind
- * the presentation kind
- *
- * @return the adds the applied stereotype command
- */
- public static RecordingCommand getAddAppliedStereotypeCommand(TransactionalEditingDomain domain, View view, String stereotypeName) {
- return new AddAppliedStereotypeToDisplayCommand(domain, view, stereotypeName);
- }
-
- /**
- * Gets the adds the applied stereotype propertiescommand.
- *
- * @param domain
- * the domain
- * @param view
- * the view
- * @param appliedStereotypeListToAdd
- * the applied stereotype properties list to add
- *
- * @return the adds the applied stereotype command
- */
- public static RecordingCommand getAddAppliedStereotypePropertiesCommand(TransactionalEditingDomain domain, View view, Stereotype stereotype, Property property, String location) {
- return new AddAppliedStereotypePropertiesToDisplayCommand(domain, view, property, stereotype, location);
- }
-
- /**
- * Gets the removes the applied stereotype command.
- *
- * @param domain
- * the domain
- * @param view
- * the view
- * @param appliedStereotypeListToRemove
- * the applied stereotype list to remove
- * @param presentationKind
- * the presentation kind
- *
- * @return the removes the applied stereotype command
- */
- public static RecordingCommand getRemoveAppliedStereotypeCommand(TransactionalEditingDomain domain, View view, Stereotype stereotype) {
- return new RemoveAppliedStereotypeToDisplayCommand(domain, view, stereotype);
- }
-
- /**
- * Gets the remove applied stereotype properties command.
- *
- * @param domain
- * the domain
- * @param view
- * the view
- * @param appliedStereotypeListToRemove
- * the applied stereotype list to remove
- *
- * @return the removes the applied stereotype properties command
- */
- public static RecordingCommand getRemoveAppliedStereotypePropertiesCommand(TransactionalEditingDomain domain, View view, Property property, Stereotype stereotype, String location) {
- return new RemoveAppliedStereotypePropertiesToDisplayCommand(domain, view, property, stereotype, location);
- }
-
-
-
-}
+/***************************************************************************** + * Copyright (c) 2008 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: + * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation + * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.stereotype.display.helper; + +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.AddAppliedQNStereotypeToDisplayCommand; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.AddAppliedStereotypePropertiesToDisplayCommand; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.AddAppliedStereotypeToDisplayCommand; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.RemoveAppliedStereotypePropertiesToDisplayCommand; +import org.eclipse.papyrus.uml.diagram.common.stereotype.display.command.RemoveAppliedStereotypeToDisplayCommand; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.Stereotype; + +/** + * The Class AppliedStereotypeHelper. + * Helper used in the User interaction to display Stereotypes from the Property View. + * Note: this class is to be used instead of <i>AppliedStereotypeHelper</i> which is deprecated) + */ +public class StereotypeUserActionHelper { + + + + /** + * add new applied stereotypes to display with the qualified name. + * + * @param domain + * the transactionnal edit domain + * @param view + * the emodel element that is the display of the uml element + * @param appliedStereotypeList + * the list of stereotype with qualified name to display + * + * @return the command to display it + */ + public static RecordingCommand getAddAppliedStereotypeToDisplayWithQNCommand(TransactionalEditingDomain domain, View view, Stereotype stereotype, String depth) { + return new AddAppliedQNStereotypeToDisplayCommand(domain, view, stereotype, depth); + } + + /** + * Gets the adds the applied stereotype command. + * + * @param domain + * the domain + * @param view + * the view + * @param appliedStereotypeListToAdd + * the applied stereotype list to add + * @param presentationKind + * the presentation kind + * + * @return the adds the applied stereotype command + */ + public static RecordingCommand getAddAppliedStereotypeCommand(TransactionalEditingDomain domain, View view, String stereotypeName) { + return new AddAppliedStereotypeToDisplayCommand(domain, view, stereotypeName); + } + + /** + * Gets the adds the applied stereotype propertiescommand. + * + * @param domain + * the domain + * @param view + * the view + * @param appliedStereotypeListToAdd + * the applied stereotype properties list to add + * + * @return the adds the applied stereotype command + */ + public static RecordingCommand getAddAppliedStereotypePropertiesCommand(TransactionalEditingDomain domain, View view, Stereotype stereotype, Property property, String location) { + return new AddAppliedStereotypePropertiesToDisplayCommand(domain, view, property, stereotype, location); + } + + /** + * Gets the removes the applied stereotype command. + * + * @param domain + * the domain + * @param view + * the view + * @param appliedStereotypeListToRemove + * the applied stereotype list to remove + * @param presentationKind + * the presentation kind + * + * @return the removes the applied stereotype command + */ + public static RecordingCommand getRemoveAppliedStereotypeCommand(TransactionalEditingDomain domain, View view, Stereotype stereotype) { + return new RemoveAppliedStereotypeToDisplayCommand(domain, view, stereotype); + } + + /** + * Gets the remove applied stereotype properties command. + * + * @param domain + * the domain + * @param view + * the view + * @param appliedStereotypeListToRemove + * the applied stereotype list to remove + * + * @return the removes the applied stereotype properties command + */ + public static RecordingCommand getRemoveAppliedStereotypePropertiesCommand(TransactionalEditingDomain domain, View view, Property property, Stereotype stereotype, String location) { + return new RemoveAppliedStereotypePropertiesToDisplayCommand(domain, view, property, stereotype, location); + } + + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/ui/dialogs/ShowHideRelatedLinkSelectionDialog.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/ui/dialogs/ShowHideRelatedLinkSelectionDialog.java index d7835d0a881..b56a07c34ed 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/ui/dialogs/ShowHideRelatedLinkSelectionDialog.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/ui/dialogs/ShowHideRelatedLinkSelectionDialog.java @@ -1,658 +1,658 @@ -/*****************************************************************************
- * Copyright (c) 2017 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- * Mickaël ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 517679
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.viewers.CellLabelProvider;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.EditingSupport;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ICheckStateProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.EdgeWithNoSemanticElementRepresentationImpl;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.StereotypePropertyReferenceEdgeRepresentation;
-import org.eclipse.papyrus.uml.diagram.common.dialogs.AbstractCheckedTreeColumnViewerSelectionDialog;
-import org.eclipse.papyrus.uml.diagram.common.messages.Messages;
-import org.eclipse.papyrus.uml.diagram.common.util.LinkEndsMapper;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.uml2.uml.Comment;
-import org.eclipse.uml2.uml.Constraint;
-
-/**
- *
- * The dialog used to select the link to show hide according to the selected gmf nodes
- *
- */
-public class ShowHideRelatedLinkSelectionDialog extends AbstractCheckedTreeColumnViewerSelectionDialog {
-
- /**
- * the width for the first column
- */
- private final int FIRST_COLUMN_WIDTH = 200;
-
- /**
- * the width for the others columns
- */
- private final int OTHERS_COLUMN_WIDTH = 100;
-
- /**
- * the titles of the columns
- */
- private static final String[] columnsTitles = new String[] { Messages.ShowHideRelatedLinkSelectionDialog_LinksToDisplay, Messages.ShowHideRelatedLinkSelectionDialog_LinkKind, Messages.ShowHideRelatedLinkSelectionDialog_Ends,
- Messages.ShowHideRelatedLinkSelectionDialog_Sources, Messages.ShowHideRelatedLinkSelectionDialog_Targets };
-
- /**
- * the mapping between model links and link end mapper
- */
- private final Map<EObject, LinkEndsMapper> mapLink;
-
- /**
- * the checkStateProvider to use
- */
- private ICheckStateProvider checkedStateProvider;
-
- /**
- * the checkStateListener used to refresh selection
- */
- private ICheckStateListener checkedStateListener;
-
- /**
- * a map between the gmf graphical elements and the availables model links
- */
- private final Map<EditPart, Set<EObject>> availableLinks;
-
- /**
- * the selection
- */
- private final Set<EObject> selectedElements;
-
-
- /**
- *
- * Constructor.
- *
- * @param parent
- * the parent shell
- * @param labelProvider
- * the label provider
- * @param contentProvider
- * the content provider
- * @param availableLinks
- * a map linking selected editparts and their available links
- * @param linkEndsMapping
- * a map between the links and their ends
- */
- public ShowHideRelatedLinkSelectionDialog(final Shell parent, final ILabelProvider labelProvider, final ITreeContentProvider contentProvider, final Map<EditPart, Set<EObject>> availableLinks, final Map<EObject, LinkEndsMapper> linkEndsMapping) {
- super(parent, labelProvider, contentProvider, SWT.CENTER | SWT.BORDER | SWT.FULL_SELECTION, columnsTitles.length);
- this.mapLink = linkEndsMapping;
- this.availableLinks = new HashMap<EditPart, Set<EObject>>(availableLinks);
- this.selectedElements = new HashSet<EObject>();
- setContainerMode(true);
- init();
- }
-
- /**
- *
- * @see org.eclipse.papyrus.uml.diagram.common.dialogs.CustomCheckedTreeSelectionDialog#setInitialSelection(java.lang.Object)
- *
- * @param selection
- */
- public void setInitialSelection(final Collection<EObject> initialSelection) {
- this.selectedElements.addAll(initialSelection);
- super.setInitialSelection(initialSelection.toArray());
- }
-
-
- /**
- *
- * @param columnIndex
- * @return
- */
- @Override
- protected EditingSupport getEditingSupport(int columnIndex) {
- return null;
- }
-
- /**
- * Initialize the columns Width, the columns Titles and the LabelProvider for the viewer.
- *
- */
- protected void init() {
- setColumnTitles(columnsTitles);
- int[] columnWidth = new int[columnsTitles.length];
- columnWidth[0] = FIRST_COLUMN_WIDTH;
- for (int i = 1; i < columnsTitles.length; i++) {
- columnWidth[i] = OTHERS_COLUMN_WIDTH;
- }
- setColumnWidths(columnWidth);
- setColumnCellLabelProvider(new CellLabelProvider[] { new EObjectLabelProvider(), new LinkEClassLabelProvider(), new EndsElementLabelProvider(), new SourceElementLabelProvider(), new TargetElementLabelProvider() });
- }
-
- /**
- *
- * @see org.eclipse.papyrus.uml.diagram.common.dialogs.AbstractCheckedTreeColumnViewerSelectionDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- *
- * @param parent
- * @return
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- Control ctrl = super.createDialogArea(parent);
- this.checkedStateProvider = getOrCreateCheckStateProvider();
- getTreeViewer().setCheckStateProvider(this.checkedStateProvider);
- this.checkedStateListener = getOrCreateCheckStateListener();
- getTreeViewer().addCheckStateListener(this.checkedStateListener);
- updateTree(getTreeViewer());
- return ctrl;
- }
-
- @Override
- public void create() {
- super.create();
- updateTree(getTreeViewer());
- }
-
- /**
- *
- * @return
- * the checkedStateListener to use
- */
- protected ICheckStateListener getOrCreateCheckStateListener() {
- if (this.checkedStateListener == null) {
- this.checkedStateListener = new ICheckStateListener() {
-
- /**
- *
- * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
- *
- * @param event
- */
- @Override
- public void checkStateChanged(CheckStateChangedEvent event) {
- final Object currentElement = event.getElement();
- boolean isChecked = event.getChecked();
- if (currentElement instanceof EditPart) {
- // we update the selected element list
- if (isChecked) {
- selectedElements.addAll(availableLinks.get(currentElement));
- } else {
- selectedElements.removeAll(availableLinks.get(currentElement));
- }
-
- // in some case, the EditPart can be a link which appears as possible elements of an other selected edit part
- final View view = (View) ((EditPart) currentElement).getAdapter(View.class);
- if (view instanceof Edge) {
- final EObject element = view.getElement();
- for (final Set<EObject> currentCol : availableLinks.values()) {
- if (currentCol.contains(element)) {
- if (isChecked) {
- selectedElements.add(element);
- } else {
- selectedElements.remove(element);
- }
- }
- }
- }
- } else {
- // we update the selected element list
- if (isChecked) {
- selectedElements.add((EObject) currentElement);
- } else {
- selectedElements.remove(currentElement);
- }
- }
- updateTree(getTreeViewer());
- }
- };
- }
- return this.checkedStateListener;
- }
-
- /**
- *
- * @param treeViewer
- */
- // TODO : probably not the best way...
- protected final void updateTree(final TreeViewer treeViewer) {
- for (final TreeItem items : getTreeViewer().getTree().getItems()) {
- updateTreeItems(getTreeViewer(), items, getOrCreateCheckStateProvider());
- }
- }
-
- /**
- *
- * @param treeViewer
- * @param item
- * @param stateProvider
- */
- private void updateTreeItems(final TreeViewer treeViewer, final TreeItem item, final ICheckStateProvider stateProvider) {
- boolean isChecked = stateProvider.isChecked(item.getData());
- boolean isGrayed = stateProvider.isGrayed(item.getData());
- item.setChecked(isChecked);
- item.setGrayed(isGrayed);
- for (final TreeItem child : item.getItems()) {
- updateTreeItems(treeViewer, child, stateProvider);
- }
- }
-
- /**
- *
- * @return
- * the checkedStateProvider to use for this dialog
- */
- protected ICheckStateProvider getOrCreateCheckStateProvider() {
- if (this.checkedStateProvider == null) {
- this.checkedStateProvider = new ICheckStateProvider() {
-
- /**
- *
- * @see org.eclipse.jface.viewers.ICheckStateProvider#isGrayed(java.lang.Object)
- *
- * @param element
- * @return
- */
- @Override
- public boolean isGrayed(Object element) {
- boolean isGrayed = false;
- if (element instanceof EditPart) {
- Set<EObject> values = availableLinks.get(element);
- final Collection<EObject> tmp = new ArrayList<EObject>(selectedElements);
- tmp.retainAll(values);
- isGrayed = tmp.size() != values.size();
- }
- return isGrayed;
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.ICheckStateProvider#isChecked(java.lang.Object)
- *
- * @param element
- * @return
- */
- @Override
- public boolean isChecked(Object element) {
- boolean isChecked = false;
- if (element instanceof EditPart) {
- final Collection<?> possibleLinks = availableLinks.get(element);
- Collection<EObject> tmp = new ArrayList<EObject>(selectedElements);
- tmp.retainAll(possibleLinks);
- isChecked = tmp.size() > 0;
-
-
- final View view = (View) ((EditPart) element).getAdapter(View.class);
- if (!isChecked && view instanceof Edge) {// the edge edit part could be selected as grayed because the link is already selected for an another edit part
- final EObject eobject = view.getElement();
- isChecked = selectedElements.contains(eobject);
- }
-
-
- } else if (element instanceof EObject) {
- isChecked = selectedElements.contains(element);
- }
- return isChecked;
- }
- };
- }
- return this.checkedStateProvider;
- }
-
- /**
- * This provider is used by the 2nd column
- *
- */
- protected class LinkEClassLabelProvider extends ColumnLabelProvider {
-
- /** label provider */
- private final ILabelProvider labelProvider;
-
- public LinkEClassLabelProvider() {
- labelProvider = getLabelProvider();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Image getImage(final Object element) {
- if (element instanceof EdgeWithNoSemanticElementRepresentationImpl) {
- return null;
- }
- if (element instanceof EObject) {
- return labelProvider.getImage(element);
- }
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getText(final Object element) {
- if (element instanceof EdgeWithNoSemanticElementRepresentationImpl) {
- final EObject source = ((EdgeWithNoSemanticElementRepresentationImpl) element).getSource();
- if (source instanceof Comment) {
- return Messages.ShowHideRelatedLinkSelectionDialog_CommentLink;
- }
- if (source instanceof Constraint) {
- return Messages.ShowHideRelatedLinkSelectionDialog_ConstraintLink;
- } else if (element instanceof StereotypePropertyReferenceEdgeRepresentation) {
- return Messages.ShowHideRelatedLinkSelectionDialog_StereotypePropertyReferenceLabel;
- }
- }
- if (element instanceof EObject) {
- return ((EObject) element).eClass().getName();
- }
- return ""; //$NON-NLS-1$
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
- *
- * @param cell
- */
- @Override
- public void update(ViewerCell cell) {
- cell.setImage(getImage(cell.getElement()));
- cell.setText(getText(cell.getElement()));
- }
- }
-
-
- /**
- * This provider is used by the 2nd column
- *
- */
- protected class EObjectLabelProvider extends ColumnLabelProvider {
-
- /** label provider */
- private final ILabelProvider labelProvider;
-
- public EObjectLabelProvider() {
- labelProvider = getLabelProvider();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Image getImage(Object element) {
- if (element instanceof EdgeWithNoSemanticElementRepresentationImpl) {
- final EObject source = ((EdgeWithNoSemanticElementRepresentationImpl) element).getSource();
- if (source instanceof Comment || source instanceof Constraint) {
- return labelProvider.getImage(source);
- }
- }
- return labelProvider.getImage(element);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getText(Object element) {
- if (element instanceof EdgeWithNoSemanticElementRepresentationImpl) {
- final EObject source = ((EdgeWithNoSemanticElementRepresentationImpl) element).getSource();
- if (source instanceof Comment) {
- return Messages.ShowHideRelatedLinkSelectionDialog_CommentLink;
- } else if (source instanceof Constraint) {
- return Messages.ShowHideRelatedLinkSelectionDialog_ConstraintLink;
- } else if (element instanceof StereotypePropertyReferenceEdgeRepresentation) {
- return ((StereotypePropertyReferenceEdgeRepresentation) element).getStereotypeQualifiedName() + "::" + ((StereotypePropertyReferenceEdgeRepresentation) element).getFeatureToSet();//$NON-NLS-1$
- }
- }
- return labelProvider.getText(element);
- }
-
-
- /**
- *
- * @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
- *
- * @param cell
- */
- @Override
- public void update(ViewerCell cell) {
- cell.setImage(getImage(cell.getElement()));
- cell.setText(getText(cell.getElement()));
- }
- }
-
- /**
- * This provider is used by the 2nd column
- *
- */
- protected class TargetElementLabelProvider extends AbstractLinkEndColumnsLabelProvider {
-
- /**
- *
- * Constructor.
- *
- * @param labelProvider
- */
- public TargetElementLabelProvider(final ILabelProvider labelProvider) {
- super(labelProvider);
- }
-
- /**
- *
- * Constructor.
- *
- */
- public TargetElementLabelProvider() {
- super(getLabelProvider());
- }
-
- /**
- *
- * @see org.eclipse.papyrus.uml.diagram.menu.dialogs.ShowHideRelatedLinkSelectionDialog.AbstractLinkEndColumnsLabelProvider#getValues(java.lang.Object)
- *
- * @param element
- * @return
- */
- @Override
- protected Collection<?> getValues(Object element) {
- final LinkEndsMapper mapper = mapLink.get(element);
- if (mapper != null) {
- return mapper.getTargets();
- }
- return Collections.emptyList();
- }
- }
-
- /**
- * This provider is used by the 2nd column
- *
- */
- protected class SourceElementLabelProvider extends AbstractLinkEndColumnsLabelProvider {
-
- /**
- *
- * Constructor.
- *
- * @param labelProvider
- */
- public SourceElementLabelProvider(final ILabelProvider labelProvider) {
- super(labelProvider);
- }
-
- /**
- *
- * Constructor.
- *
- */
- public SourceElementLabelProvider() {
- super(getLabelProvider());
- }
-
- /**
- *
- * @param element
- * @return
- */
- @Override
- protected Collection<?> getValues(Object element) {
- final LinkEndsMapper mapper = mapLink.get(element);
- if (mapper != null) {
- return mapper.getSources();
- }
- return Collections.emptyList();
- }
- }
-
- public abstract class AbstractLinkEndColumnsLabelProvider extends ColumnLabelProvider {
-
- /**
- * utils constants for label provider
- */
- public static final String START_LIST = "["; //$NON-NLS-1$
-
- public static final String END_LIST = "]"; //$NON-NLS-1$
-
- public static final String VALUE_SEPARATOR = ","; //$NON-NLS-1$
-
- /**
- * the label provider to use
- */
- private final ILabelProvider labelProvider;
-
- /**
- *
- * Constructor.
- *
- * @param labelProvider
- */
- public AbstractLinkEndColumnsLabelProvider(final ILabelProvider labelProvider) {
- this.labelProvider = labelProvider;
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object)
- *
- * @param element
- * @return
- */
- @Override
- public Image getImage(Object element) {
- return null;
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
- *
- * @param cell
- */
- @Override
- public void update(ViewerCell cell) {
- cell.setImage(getImage(cell.getElement()));
- cell.setText(getText(cell.getElement()));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getText(Object element) {
- final StringBuilder builder = new StringBuilder();
- final Collection<?> ends = getValues(element);
- if (!ends.isEmpty()) {
- builder.append(START_LIST);
- final Iterator<?> iter = ends.iterator();
- while (iter.hasNext()) {
- final Object current = iter.next();
- if (current instanceof Comment) {
- builder.append(Messages.ShowHideRelatedLinkSelectionDialog_Comment_);
- }
- builder.append(this.labelProvider.getText(current));
- if (iter.hasNext()) {
- builder.append(VALUE_SEPARATOR);
- }
- }
- builder.append(END_LIST);
- }
- return builder.toString();
- }
-
- protected abstract Collection<?> getValues(final Object element);
- }
-
- /**
- * This provider is used by the 2nd column
- *
- */
- protected class EndsElementLabelProvider extends AbstractLinkEndColumnsLabelProvider {
-
- /**
- *
- * Constructor.
- *
- * @param labelProvider
- */
- public EndsElementLabelProvider(final ILabelProvider labelProvider) {
- super(labelProvider);
- }
-
- /**
- *
- * Constructor.
- *
- */
- public EndsElementLabelProvider() {
- super(getLabelProvider());
- }
-
- /**
- *
- * @see org.eclipse.papyrus.uml.diagram.menu.dialogs.ShowHideRelatedLinkSelectionDialog.AbstractLinkEndColumnsLabelProvider#getValues(java.lang.Object)
- *
- * @param element
- * @return
- */
- @Override
- protected Collection<?> getValues(Object element) {
- final LinkEndsMapper mapper = mapLink.get(element);
- if (mapper != null) {
- return mapper.getEnds();
- }
- return Collections.emptyList();
- }
- }
-
-
-}
+/***************************************************************************** + * Copyright (c) 2017 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * Mickaël ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 517679 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.ui.dialogs; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.notation.Edge; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.jface.viewers.CellLabelProvider; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.ICheckStateProvider; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.EdgeWithNoSemanticElementRepresentationImpl; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.StereotypePropertyReferenceEdgeRepresentation; +import org.eclipse.papyrus.uml.diagram.common.dialogs.AbstractCheckedTreeColumnViewerSelectionDialog; +import org.eclipse.papyrus.uml.diagram.common.messages.Messages; +import org.eclipse.papyrus.uml.diagram.common.util.LinkEndsMapper; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.TreeItem; +import org.eclipse.uml2.uml.Comment; +import org.eclipse.uml2.uml.Constraint; + +/** + * + * The dialog used to select the link to show hide according to the selected gmf nodes + * + */ +public class ShowHideRelatedLinkSelectionDialog extends AbstractCheckedTreeColumnViewerSelectionDialog { + + /** + * the width for the first column + */ + private final int FIRST_COLUMN_WIDTH = 200; + + /** + * the width for the others columns + */ + private final int OTHERS_COLUMN_WIDTH = 100; + + /** + * the titles of the columns + */ + private static final String[] columnsTitles = new String[] { Messages.ShowHideRelatedLinkSelectionDialog_LinksToDisplay, Messages.ShowHideRelatedLinkSelectionDialog_LinkKind, Messages.ShowHideRelatedLinkSelectionDialog_Ends, + Messages.ShowHideRelatedLinkSelectionDialog_Sources, Messages.ShowHideRelatedLinkSelectionDialog_Targets }; + + /** + * the mapping between model links and link end mapper + */ + private final Map<EObject, LinkEndsMapper> mapLink; + + /** + * the checkStateProvider to use + */ + private ICheckStateProvider checkedStateProvider; + + /** + * the checkStateListener used to refresh selection + */ + private ICheckStateListener checkedStateListener; + + /** + * a map between the gmf graphical elements and the availables model links + */ + private final Map<EditPart, Set<EObject>> availableLinks; + + /** + * the selection + */ + private final Set<EObject> selectedElements; + + + /** + * + * Constructor. + * + * @param parent + * the parent shell + * @param labelProvider + * the label provider + * @param contentProvider + * the content provider + * @param availableLinks + * a map linking selected editparts and their available links + * @param linkEndsMapping + * a map between the links and their ends + */ + public ShowHideRelatedLinkSelectionDialog(final Shell parent, final ILabelProvider labelProvider, final ITreeContentProvider contentProvider, final Map<EditPart, Set<EObject>> availableLinks, final Map<EObject, LinkEndsMapper> linkEndsMapping) { + super(parent, labelProvider, contentProvider, SWT.CENTER | SWT.BORDER | SWT.FULL_SELECTION, columnsTitles.length); + this.mapLink = linkEndsMapping; + this.availableLinks = new HashMap<EditPart, Set<EObject>>(availableLinks); + this.selectedElements = new HashSet<EObject>(); + setContainerMode(true); + init(); + } + + /** + * + * @see org.eclipse.papyrus.uml.diagram.common.dialogs.CustomCheckedTreeSelectionDialog#setInitialSelection(java.lang.Object) + * + * @param selection + */ + public void setInitialSelection(final Collection<EObject> initialSelection) { + this.selectedElements.addAll(initialSelection); + super.setInitialSelection(initialSelection.toArray()); + } + + + /** + * + * @param columnIndex + * @return + */ + @Override + protected EditingSupport getEditingSupport(int columnIndex) { + return null; + } + + /** + * Initialize the columns Width, the columns Titles and the LabelProvider for the viewer. + * + */ + protected void init() { + setColumnTitles(columnsTitles); + int[] columnWidth = new int[columnsTitles.length]; + columnWidth[0] = FIRST_COLUMN_WIDTH; + for (int i = 1; i < columnsTitles.length; i++) { + columnWidth[i] = OTHERS_COLUMN_WIDTH; + } + setColumnWidths(columnWidth); + setColumnCellLabelProvider(new CellLabelProvider[] { new EObjectLabelProvider(), new LinkEClassLabelProvider(), new EndsElementLabelProvider(), new SourceElementLabelProvider(), new TargetElementLabelProvider() }); + } + + /** + * + * @see org.eclipse.papyrus.uml.diagram.common.dialogs.AbstractCheckedTreeColumnViewerSelectionDialog#createDialogArea(org.eclipse.swt.widgets.Composite) + * + * @param parent + * @return + */ + @Override + protected Control createDialogArea(Composite parent) { + Control ctrl = super.createDialogArea(parent); + this.checkedStateProvider = getOrCreateCheckStateProvider(); + getTreeViewer().setCheckStateProvider(this.checkedStateProvider); + this.checkedStateListener = getOrCreateCheckStateListener(); + getTreeViewer().addCheckStateListener(this.checkedStateListener); + updateTree(getTreeViewer()); + return ctrl; + } + + @Override + public void create() { + super.create(); + updateTree(getTreeViewer()); + } + + /** + * + * @return + * the checkedStateListener to use + */ + protected ICheckStateListener getOrCreateCheckStateListener() { + if (this.checkedStateListener == null) { + this.checkedStateListener = new ICheckStateListener() { + + /** + * + * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent) + * + * @param event + */ + @Override + public void checkStateChanged(CheckStateChangedEvent event) { + final Object currentElement = event.getElement(); + boolean isChecked = event.getChecked(); + if (currentElement instanceof EditPart) { + // we update the selected element list + if (isChecked) { + selectedElements.addAll(availableLinks.get(currentElement)); + } else { + selectedElements.removeAll(availableLinks.get(currentElement)); + } + + // in some case, the EditPart can be a link which appears as possible elements of an other selected edit part + final View view = (View) ((EditPart) currentElement).getAdapter(View.class); + if (view instanceof Edge) { + final EObject element = view.getElement(); + for (final Set<EObject> currentCol : availableLinks.values()) { + if (currentCol.contains(element)) { + if (isChecked) { + selectedElements.add(element); + } else { + selectedElements.remove(element); + } + } + } + } + } else { + // we update the selected element list + if (isChecked) { + selectedElements.add((EObject) currentElement); + } else { + selectedElements.remove(currentElement); + } + } + updateTree(getTreeViewer()); + } + }; + } + return this.checkedStateListener; + } + + /** + * + * @param treeViewer + */ + // TODO : probably not the best way... + protected final void updateTree(final TreeViewer treeViewer) { + for (final TreeItem items : getTreeViewer().getTree().getItems()) { + updateTreeItems(getTreeViewer(), items, getOrCreateCheckStateProvider()); + } + } + + /** + * + * @param treeViewer + * @param item + * @param stateProvider + */ + private void updateTreeItems(final TreeViewer treeViewer, final TreeItem item, final ICheckStateProvider stateProvider) { + boolean isChecked = stateProvider.isChecked(item.getData()); + boolean isGrayed = stateProvider.isGrayed(item.getData()); + item.setChecked(isChecked); + item.setGrayed(isGrayed); + for (final TreeItem child : item.getItems()) { + updateTreeItems(treeViewer, child, stateProvider); + } + } + + /** + * + * @return + * the checkedStateProvider to use for this dialog + */ + protected ICheckStateProvider getOrCreateCheckStateProvider() { + if (this.checkedStateProvider == null) { + this.checkedStateProvider = new ICheckStateProvider() { + + /** + * + * @see org.eclipse.jface.viewers.ICheckStateProvider#isGrayed(java.lang.Object) + * + * @param element + * @return + */ + @Override + public boolean isGrayed(Object element) { + boolean isGrayed = false; + if (element instanceof EditPart) { + Set<EObject> values = availableLinks.get(element); + final Collection<EObject> tmp = new ArrayList<EObject>(selectedElements); + tmp.retainAll(values); + isGrayed = tmp.size() != values.size(); + } + return isGrayed; + } + + /** + * + * @see org.eclipse.jface.viewers.ICheckStateProvider#isChecked(java.lang.Object) + * + * @param element + * @return + */ + @Override + public boolean isChecked(Object element) { + boolean isChecked = false; + if (element instanceof EditPart) { + final Collection<?> possibleLinks = availableLinks.get(element); + Collection<EObject> tmp = new ArrayList<EObject>(selectedElements); + tmp.retainAll(possibleLinks); + isChecked = tmp.size() > 0; + + + final View view = (View) ((EditPart) element).getAdapter(View.class); + if (!isChecked && view instanceof Edge) {// the edge edit part could be selected as grayed because the link is already selected for an another edit part + final EObject eobject = view.getElement(); + isChecked = selectedElements.contains(eobject); + } + + + } else if (element instanceof EObject) { + isChecked = selectedElements.contains(element); + } + return isChecked; + } + }; + } + return this.checkedStateProvider; + } + + /** + * This provider is used by the 2nd column + * + */ + protected class LinkEClassLabelProvider extends ColumnLabelProvider { + + /** label provider */ + private final ILabelProvider labelProvider; + + public LinkEClassLabelProvider() { + labelProvider = getLabelProvider(); + } + + /** + * {@inheritDoc} + */ + @Override + public Image getImage(final Object element) { + if (element instanceof EdgeWithNoSemanticElementRepresentationImpl) { + return null; + } + if (element instanceof EObject) { + return labelProvider.getImage(element); + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String getText(final Object element) { + if (element instanceof EdgeWithNoSemanticElementRepresentationImpl) { + final EObject source = ((EdgeWithNoSemanticElementRepresentationImpl) element).getSource(); + if (source instanceof Comment) { + return Messages.ShowHideRelatedLinkSelectionDialog_CommentLink; + } + if (source instanceof Constraint) { + return Messages.ShowHideRelatedLinkSelectionDialog_ConstraintLink; + } else if (element instanceof StereotypePropertyReferenceEdgeRepresentation) { + return Messages.ShowHideRelatedLinkSelectionDialog_StereotypePropertyReferenceLabel; + } + } + if (element instanceof EObject) { + return ((EObject) element).eClass().getName(); + } + return ""; //$NON-NLS-1$ + } + + /** + * + * @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell) + * + * @param cell + */ + @Override + public void update(ViewerCell cell) { + cell.setImage(getImage(cell.getElement())); + cell.setText(getText(cell.getElement())); + } + } + + + /** + * This provider is used by the 2nd column + * + */ + protected class EObjectLabelProvider extends ColumnLabelProvider { + + /** label provider */ + private final ILabelProvider labelProvider; + + public EObjectLabelProvider() { + labelProvider = getLabelProvider(); + } + + /** + * {@inheritDoc} + */ + @Override + public Image getImage(Object element) { + if (element instanceof EdgeWithNoSemanticElementRepresentationImpl) { + final EObject source = ((EdgeWithNoSemanticElementRepresentationImpl) element).getSource(); + if (source instanceof Comment || source instanceof Constraint) { + return labelProvider.getImage(source); + } + } + return labelProvider.getImage(element); + } + + /** + * {@inheritDoc} + */ + @Override + public String getText(Object element) { + if (element instanceof EdgeWithNoSemanticElementRepresentationImpl) { + final EObject source = ((EdgeWithNoSemanticElementRepresentationImpl) element).getSource(); + if (source instanceof Comment) { + return Messages.ShowHideRelatedLinkSelectionDialog_CommentLink; + } else if (source instanceof Constraint) { + return Messages.ShowHideRelatedLinkSelectionDialog_ConstraintLink; + } else if (element instanceof StereotypePropertyReferenceEdgeRepresentation) { + return ((StereotypePropertyReferenceEdgeRepresentation) element).getStereotypeQualifiedName() + "::" + ((StereotypePropertyReferenceEdgeRepresentation) element).getFeatureToSet();//$NON-NLS-1$ + } + } + return labelProvider.getText(element); + } + + + /** + * + * @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell) + * + * @param cell + */ + @Override + public void update(ViewerCell cell) { + cell.setImage(getImage(cell.getElement())); + cell.setText(getText(cell.getElement())); + } + } + + /** + * This provider is used by the 2nd column + * + */ + protected class TargetElementLabelProvider extends AbstractLinkEndColumnsLabelProvider { + + /** + * + * Constructor. + * + * @param labelProvider + */ + public TargetElementLabelProvider(final ILabelProvider labelProvider) { + super(labelProvider); + } + + /** + * + * Constructor. + * + */ + public TargetElementLabelProvider() { + super(getLabelProvider()); + } + + /** + * + * @see org.eclipse.papyrus.uml.diagram.menu.dialogs.ShowHideRelatedLinkSelectionDialog.AbstractLinkEndColumnsLabelProvider#getValues(java.lang.Object) + * + * @param element + * @return + */ + @Override + protected Collection<?> getValues(Object element) { + final LinkEndsMapper mapper = mapLink.get(element); + if (mapper != null) { + return mapper.getTargets(); + } + return Collections.emptyList(); + } + } + + /** + * This provider is used by the 2nd column + * + */ + protected class SourceElementLabelProvider extends AbstractLinkEndColumnsLabelProvider { + + /** + * + * Constructor. + * + * @param labelProvider + */ + public SourceElementLabelProvider(final ILabelProvider labelProvider) { + super(labelProvider); + } + + /** + * + * Constructor. + * + */ + public SourceElementLabelProvider() { + super(getLabelProvider()); + } + + /** + * + * @param element + * @return + */ + @Override + protected Collection<?> getValues(Object element) { + final LinkEndsMapper mapper = mapLink.get(element); + if (mapper != null) { + return mapper.getSources(); + } + return Collections.emptyList(); + } + } + + public abstract class AbstractLinkEndColumnsLabelProvider extends ColumnLabelProvider { + + /** + * utils constants for label provider + */ + public static final String START_LIST = "["; //$NON-NLS-1$ + + public static final String END_LIST = "]"; //$NON-NLS-1$ + + public static final String VALUE_SEPARATOR = ","; //$NON-NLS-1$ + + /** + * the label provider to use + */ + private final ILabelProvider labelProvider; + + /** + * + * Constructor. + * + * @param labelProvider + */ + public AbstractLinkEndColumnsLabelProvider(final ILabelProvider labelProvider) { + this.labelProvider = labelProvider; + } + + /** + * + * @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object) + * + * @param element + * @return + */ + @Override + public Image getImage(Object element) { + return null; + } + + /** + * + * @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell) + * + * @param cell + */ + @Override + public void update(ViewerCell cell) { + cell.setImage(getImage(cell.getElement())); + cell.setText(getText(cell.getElement())); + } + + /** + * {@inheritDoc} + */ + @Override + public String getText(Object element) { + final StringBuilder builder = new StringBuilder(); + final Collection<?> ends = getValues(element); + if (!ends.isEmpty()) { + builder.append(START_LIST); + final Iterator<?> iter = ends.iterator(); + while (iter.hasNext()) { + final Object current = iter.next(); + if (current instanceof Comment) { + builder.append(Messages.ShowHideRelatedLinkSelectionDialog_Comment_); + } + builder.append(this.labelProvider.getText(current)); + if (iter.hasNext()) { + builder.append(VALUE_SEPARATOR); + } + } + builder.append(END_LIST); + } + return builder.toString(); + } + + protected abstract Collection<?> getValues(final Object element); + } + + /** + * This provider is used by the 2nd column + * + */ + protected class EndsElementLabelProvider extends AbstractLinkEndColumnsLabelProvider { + + /** + * + * Constructor. + * + * @param labelProvider + */ + public EndsElementLabelProvider(final ILabelProvider labelProvider) { + super(labelProvider); + } + + /** + * + * Constructor. + * + */ + public EndsElementLabelProvider() { + super(getLabelProvider()); + } + + /** + * + * @see org.eclipse.papyrus.uml.diagram.menu.dialogs.ShowHideRelatedLinkSelectionDialog.AbstractLinkEndColumnsLabelProvider#getValues(java.lang.Object) + * + * @param element + * @return + */ + @Override + protected Collection<?> getValues(Object element) { + final LinkEndsMapper mapper = mapLink.get(element); + if (mapper != null) { + return mapper.getEnds(); + } + return Collections.emptyList(); + } + } + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/LinkEndsMapper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/LinkEndsMapper.java index 01a3d186950..aafd52a2103 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/LinkEndsMapper.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/LinkEndsMapper.java @@ -1,106 +1,106 @@ -/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.util;
-
-import java.util.Collection;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.uml2.uml.Connector;
-
-/**
- *
- * A utils class to map links, with their sources and targets OR with ends, when source/target have no sense for the link (example for {@link Connector})
- *
- */
-public class LinkEndsMapper {
-
- /**
- * the link
- */
- private final EObject link;
-
- /**
- * the ends of the links
- */
- private final Collection<?> ends;
-
- /**
- * the targets of the links
- */
- private final Collection<?> targets;
-
- /**
- * the sources of the links
- */
- private final Collection<?> sources;
-
- /**
- *
- * Constructor.
- *
- * @param link
- * the represented link
- * @param ends
- * the ends for this link (could be <code>null</code>)
- * @param sources
- * the sources for this link (could be <code>null</code>)
- * @param targets
- * the targets for this link (could be <code>null</code>)
- */
- public LinkEndsMapper(final EObject link, final Collection<?> ends, final Collection<?> sources, final Collection<?> targets) {
- this.link = link;
- this.ends = ends;
- this.targets = targets;
- this.sources = sources;
- }
-
- /**
- *
- * @return
- * the link represented by the instance of this class
- */
- public EObject getLink() {
- return link;
- }
-
- /**
- *
- * @return
- * the ends for the links
- */
- public Collection<?> getEnds() {
- return ends;
- }
-
- /**
- *
- * @return
- * the targets for the links
- */
- public Collection<?> getTargets() {
- return targets;
- }
-
- /**
- *
- * @return
- * the sources for the link
- */
- public Collection<?> getSources() {
- return sources;
- }
-
-
-}
+/***************************************************************************** + * Copyright (c) 2013 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.common.util; + +import java.util.Collection; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.uml2.uml.Connector; + +/** + * + * A utils class to map links, with their sources and targets OR with ends, when source/target have no sense for the link (example for {@link Connector}) + * + */ +public class LinkEndsMapper { + + /** + * the link + */ + private final EObject link; + + /** + * the ends of the links + */ + private final Collection<?> ends; + + /** + * the targets of the links + */ + private final Collection<?> targets; + + /** + * the sources of the links + */ + private final Collection<?> sources; + + /** + * + * Constructor. + * + * @param link + * the represented link + * @param ends + * the ends for this link (could be <code>null</code>) + * @param sources + * the sources for this link (could be <code>null</code>) + * @param targets + * the targets for this link (could be <code>null</code>) + */ + public LinkEndsMapper(final EObject link, final Collection<?> ends, final Collection<?> sources, final Collection<?> targets) { + this.link = link; + this.ends = ends; + this.targets = targets; + this.sources = sources; + } + + /** + * + * @return + * the link represented by the instance of this class + */ + public EObject getLink() { + return link; + } + + /** + * + * @return + * the ends for the links + */ + public Collection<?> getEnds() { + return ends; + } + + /** + * + * @return + * the targets for the links + */ + public Collection<?> getTargets() { + return targets; + } + + /** + * + * @return + * the sources for the link + */ + public Collection<?> getSources() { + return sources; + } + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/UMLModelTester.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/UMLModelTester.java index 28edeecf777..eb1ca234b62 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/UMLModelTester.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/UMLModelTester.java @@ -1,124 +1,124 @@ -/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.util;
-
-import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.core.resource.NotFoundException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
-import org.eclipse.papyrus.infra.ui.util.EditorHelper;
-import org.eclipse.papyrus.uml.tools.model.UmlModel;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Profile;
-
-/**
- *
- * @author Camille Letavernier
- *
- */
-public class UMLModelTester extends PropertyTester {
-
- /** Tester ID for UML Model nature */
- public final static String IS_UML_MODEL = "isUMLModel";
-
- /** Tester ID for UML Profile nature */
- public final static String IS_UML_PROFILE = "isUMLProfile";
-
- /** Test the receiver against the selected property */
- @Override
- public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- Object currentValue = null;
- if (IS_UML_MODEL.equals(property)) {
- currentValue = testUMLModelNature(receiver);
- return (currentValue == expectedValue);
- } else if (IS_UML_PROFILE.equals(property)) {
- currentValue = testUMLProfileNature(receiver);
- return (currentValue == expectedValue);
- }
-
- return false;
- }
-
- /** True if root object is a UML Model */
- protected boolean testUMLModelNature(Object receiver) {
- EObject root = getRoot(receiver);
-
- /*
- * For controlled resources, it is very important to consider root of UML model can be a Package. Of course, we
- * can still exclude Profile, which should be dedicated to profile diagrams.
- */
- return root instanceof Package && !(root instanceof Profile);
- }
-
- /** True if root object is a UML Profile */
- protected boolean testUMLProfileNature(Object receiver) {
- return (getRoot(receiver) instanceof Profile);
- }
-
- private EObject getRoot(Object receiver) {
- ModelSet modelSet = getModelSet(receiver);
- if (modelSet == null) {
- return null;
- }
- return getRoot(modelSet);
- }
-
- private ModelSet getModelSet(Object receiver) {
- if (receiver instanceof IWorkbenchPart) {
- try {
-
- /* First, retrieve the ModelSet from the Active Part (e.g. ActiveEditor, ModelExplorer, ...) */
- IWorkbenchPart currentPart = (IWorkbenchPart) receiver;
- ServicesRegistry servicesRegistry = (ServicesRegistry) currentPart.getAdapter(ServicesRegistry.class);
-
- if (servicesRegistry != null) {
- return ServiceUtils.getInstance().getModelSet(servicesRegistry);
- }
-
- /* If not found, retrieve the ModelSet from the Active Editor */
- IEditorPart activeEditor = EditorHelper.getCurrentEditor();
- if (activeEditor != null) {
- servicesRegistry = (ServicesRegistry) activeEditor.getAdapter(ServicesRegistry.class);
-
- if (servicesRegistry != null) {
- return ServiceUtils.getInstance().getModelSet(servicesRegistry);
- }
- }
- } catch (Exception ex) {
- return null; // NPE (getActiveEditor) or ServiceException (Service registry cannot be found). In both cases, we just don't handle the event. Fail silently.
- }
- }
-
- return null;
- }
-
- /** Returns the root EObject of currently opened model */
- private EObject getRoot(ModelSet modelSet) {
- UmlModel openedModel = (UmlModel) modelSet.getModel(UmlModel.MODEL_ID);
- if (openedModel != null) {
- EObject root;
- try {
- root = openedModel.lookupRoot();
- } catch (NotFoundException e) {
- return null;
- }
- return root;
- }
-
- return null;
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2013 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.util; + +import org.eclipse.core.expressions.PropertyTester; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.NotFoundException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.core.utils.ServiceUtils; +import org.eclipse.papyrus.infra.ui.util.EditorHelper; +import org.eclipse.papyrus.uml.tools.model.UmlModel; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.uml2.uml.Package; +import org.eclipse.uml2.uml.Profile; + +/** + * + * @author Camille Letavernier + * + */ +public class UMLModelTester extends PropertyTester { + + /** Tester ID for UML Model nature */ + public final static String IS_UML_MODEL = "isUMLModel"; + + /** Tester ID for UML Profile nature */ + public final static String IS_UML_PROFILE = "isUMLProfile"; + + /** Test the receiver against the selected property */ + @Override + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { + Object currentValue = null; + if (IS_UML_MODEL.equals(property)) { + currentValue = testUMLModelNature(receiver); + return (currentValue == expectedValue); + } else if (IS_UML_PROFILE.equals(property)) { + currentValue = testUMLProfileNature(receiver); + return (currentValue == expectedValue); + } + + return false; + } + + /** True if root object is a UML Model */ + protected boolean testUMLModelNature(Object receiver) { + EObject root = getRoot(receiver); + + /* + * For controlled resources, it is very important to consider root of UML model can be a Package. Of course, we + * can still exclude Profile, which should be dedicated to profile diagrams. + */ + return root instanceof Package && !(root instanceof Profile); + } + + /** True if root object is a UML Profile */ + protected boolean testUMLProfileNature(Object receiver) { + return (getRoot(receiver) instanceof Profile); + } + + private EObject getRoot(Object receiver) { + ModelSet modelSet = getModelSet(receiver); + if (modelSet == null) { + return null; + } + return getRoot(modelSet); + } + + private ModelSet getModelSet(Object receiver) { + if (receiver instanceof IWorkbenchPart) { + try { + + /* First, retrieve the ModelSet from the Active Part (e.g. ActiveEditor, ModelExplorer, ...) */ + IWorkbenchPart currentPart = (IWorkbenchPart) receiver; + ServicesRegistry servicesRegistry = (ServicesRegistry) currentPart.getAdapter(ServicesRegistry.class); + + if (servicesRegistry != null) { + return ServiceUtils.getInstance().getModelSet(servicesRegistry); + } + + /* If not found, retrieve the ModelSet from the Active Editor */ + IEditorPart activeEditor = EditorHelper.getCurrentEditor(); + if (activeEditor != null) { + servicesRegistry = (ServicesRegistry) activeEditor.getAdapter(ServicesRegistry.class); + + if (servicesRegistry != null) { + return ServiceUtils.getInstance().getModelSet(servicesRegistry); + } + } + } catch (Exception ex) { + return null; // NPE (getActiveEditor) or ServiceException (Service registry cannot be found). In both cases, we just don't handle the event. Fail silently. + } + } + + return null; + } + + /** Returns the root EObject of currently opened model */ + private EObject getRoot(ModelSet modelSet) { + UmlModel openedModel = (UmlModel) modelSet.getModel(UmlModel.MODEL_ID); + if (openedModel != null) { + EObject root; + try { + root = openedModel.lookupRoot(); + } catch (NotFoundException e) { + return null; + } + return root; + } + + return null; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/ViewUtils.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/ViewUtils.java index d30229a6f73..20ad595a342 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/ViewUtils.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/ViewUtils.java @@ -1,95 +1,95 @@ -/*****************************************************************************
- * Copyright (c) 2012 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
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.common.util;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPartViewer;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.viewers.StructuredSelection;
-
-/**
- * @since 3.0
- */
-public class ViewUtils {
-
-
- public static String getContainingDiagramType(final View view) {
- if (view instanceof Diagram) {
- final Diagram diagram = (Diagram) view;
- return diagram.getType();
- }
- final EObject eContainer = view.eContainer();
- if (eContainer instanceof View) {
- final View parentView = (View) eContainer;
- return getContainingDiagramType(parentView);
- }
- return null;
- }
-
-
- public static boolean isContained(final View child, final View parent) {
- View view = child;
- while (view != null) {
- if (view == parent) {
- return true;
- }
- final EObject eContainer = view.eContainer();
- if (eContainer instanceof View) {
- view = (View) eContainer;
- } else {
- break;
- }
- }
- return false;
- }
-
- /**
- * @since 3.0
- */
- public static boolean isViewFor(final View view, final EClass... eClasses) {
- final EObject element = view.getElement();
- for (final EClass eClass : eClasses) {
- if (eClass.isInstance(element)) {
- return true;
- }
- }
- return false;
- }
-
- /** Returns whether the given View contains a child View for the given {@link EObject} */
- public static boolean containsViewFor(final View parentView, final EObject eObject) {
- if (parentView.getElement() == eObject) {
- return true;
- }
- @SuppressWarnings("unchecked")
- final EList<View> children = parentView.getChildren();
- for (final View child : children) {
- if (containsViewFor(child, eObject)) {
- return true;
- }
- }
- return false;
- }
-
-
-
- public static void selectInViewer(final View view, final EditPartViewer viewer) {
- final EditPart editPart = (EditPart) viewer.getEditPartRegistry().get(view);
- if (editPart != null) {
- viewer.setSelection(new StructuredSelection(editPart));
- }
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2012 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 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.util; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPartViewer; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.jface.viewers.StructuredSelection; + +/** + * @since 3.0 + */ +public class ViewUtils { + + + public static String getContainingDiagramType(final View view) { + if (view instanceof Diagram) { + final Diagram diagram = (Diagram) view; + return diagram.getType(); + } + final EObject eContainer = view.eContainer(); + if (eContainer instanceof View) { + final View parentView = (View) eContainer; + return getContainingDiagramType(parentView); + } + return null; + } + + + public static boolean isContained(final View child, final View parent) { + View view = child; + while (view != null) { + if (view == parent) { + return true; + } + final EObject eContainer = view.eContainer(); + if (eContainer instanceof View) { + view = (View) eContainer; + } else { + break; + } + } + return false; + } + + /** + * @since 3.0 + */ + public static boolean isViewFor(final View view, final EClass... eClasses) { + final EObject element = view.getElement(); + for (final EClass eClass : eClasses) { + if (eClass.isInstance(element)) { + return true; + } + } + return false; + } + + /** Returns whether the given View contains a child View for the given {@link EObject} */ + public static boolean containsViewFor(final View parentView, final EObject eObject) { + if (parentView.getElement() == eObject) { + return true; + } + @SuppressWarnings("unchecked") + final EList<View> children = parentView.getChildren(); + for (final View child : children) { + if (containsViewFor(child, eObject)) { + return true; + } + } + return false; + } + + + + public static void selectInViewer(final View view, final EditPartViewer viewer) { + final EditPart editPart = (EditPart) viewer.getEditPartRegistry().get(view); + if (editPart != null) { + viewer.setSelection(new StructuredSelection(editPart)); + } + } + +} |