From 2b33421abeb16cc8907d54f1030f6a603c859fe9 Mon Sep 17 00:00:00 2001 From: cletavernie Date: Wed, 2 Nov 2011 10:21:39 +0000 Subject: 362162: [Architecture - Refactoring] The plug-ins should be renamed to match their layer's qualified name https://bugs.eclipse.org/bugs/show_bug.cgi?id=362162 --- .../.classpath | 7 - .../.project | 28 - .../.settings/org.eclipse.jdt.core.prefs | 8 - .../META-INF/MANIFEST.MF | 25 - .../about.html | 28 - .../build.properties | 7 - .../messages.properties | 23 - .../plugin.properties | 11 - .../plugin.xml | 18 - ...rus.diagram.common.groups.groupcontainment.exsd | 205 ---- .../papyrus/diagram/common/groups/Activator.java | 65 -- .../papyrus/diagram/common/groups/Messages.java | 100 -- .../commands/ChangeGraphicalParentCommand.java | 476 -------- .../groups/commands/ChangeModelParentCommand.java | 132 --- .../ChooseChildrenNotificationCommand.java | 214 ---- .../commands/ChooseParentNotificationCommand.java | 219 ---- .../commands/CommandResultMessagesError.java | 10 - .../groups/commands/SetUpReferencesCommand.java | 100 -- .../groups/commands/UpdateReferencesCommand.java | 157 --- .../groups/commands/utlis/CommandsUtils.java | 1172 -------------------- .../core/GroupNotificationBuilderFactory.java | 90 -- .../core/PendingGroupNotificationsManager.java | 181 --- .../groupcontainment/GroupContainmentRegistry.java | 268 ----- .../core/ui/CheckboxIGraphicalFocusListenner.java | 52 - .../ui/ChooseChildrenNotificationConfigurator.java | 293 ----- .../ui/ChooseParentNotificationConfigurator.java | 264 ----- .../core/ui/CompositeCreatorWithCommand.java | 122 -- .../groups/core/ui/NotificationConfigurator.java | 157 --- .../common/groups/core/ui/utils/CreatorUtils.java | 121 -- .../groups/core/utils/DefaultModelParent.java | 59 - .../diagram/common/groups/core/utils/Utils.java | 1048 ----------------- .../edit/policies/CreateInGroupEditPolicy.java | 214 ---- .../edit/policies/XYLayoutEditGroupPolicy.java | 456 -------- .../AbstractContainerNodeDescriptor.java | 158 --- .../groups/preferences/OpacityFactoryHelper.java | 84 -- .../common/groups/preferences/OpacityGroup.java | 66 -- .../appearance/ChooseGraphicalParentSection.java | 47 - .../ChooseGraphicalParentSectionFilter.java | 50 - .../utils/GraphicalAndModelElementComparator.java | 176 --- .../common/groups/utils/GroupRequestConstants.java | 55 - .../.classpath | 7 + .../.project | 28 + .../.settings/org.eclipse.jdt.core.prefs | 8 + .../META-INF/MANIFEST.MF | 25 + .../about.html | 28 + .../build.properties | 7 + .../messages.properties | 23 + .../plugin.properties | 11 + .../plugin.xml | 18 + ...rus.diagram.common.groups.groupcontainment.exsd | 205 ++++ .../papyrus/diagram/common/groups/Activator.java | 65 ++ .../papyrus/diagram/common/groups/Messages.java | 100 ++ .../commands/ChangeGraphicalParentCommand.java | 476 ++++++++ .../groups/commands/ChangeModelParentCommand.java | 132 +++ .../ChooseChildrenNotificationCommand.java | 214 ++++ .../commands/ChooseParentNotificationCommand.java | 219 ++++ .../commands/CommandResultMessagesError.java | 10 + .../groups/commands/SetUpReferencesCommand.java | 100 ++ .../groups/commands/UpdateReferencesCommand.java | 157 +++ .../groups/commands/utlis/CommandsUtils.java | 1172 ++++++++++++++++++++ .../core/GroupNotificationBuilderFactory.java | 90 ++ .../core/PendingGroupNotificationsManager.java | 181 +++ .../groupcontainment/GroupContainmentRegistry.java | 268 +++++ .../core/ui/CheckboxIGraphicalFocusListenner.java | 52 + .../ui/ChooseChildrenNotificationConfigurator.java | 293 +++++ .../ui/ChooseParentNotificationConfigurator.java | 264 +++++ .../core/ui/CompositeCreatorWithCommand.java | 122 ++ .../groups/core/ui/NotificationConfigurator.java | 157 +++ .../common/groups/core/ui/utils/CreatorUtils.java | 121 ++ .../groups/core/utils/DefaultModelParent.java | 59 + .../diagram/common/groups/core/utils/Utils.java | 1048 +++++++++++++++++ .../edit/policies/CreateInGroupEditPolicy.java | 214 ++++ .../edit/policies/XYLayoutEditGroupPolicy.java | 456 ++++++++ .../AbstractContainerNodeDescriptor.java | 158 +++ .../groups/preferences/OpacityFactoryHelper.java | 84 ++ .../common/groups/preferences/OpacityGroup.java | 66 ++ .../appearance/ChooseGraphicalParentSection.java | 47 + .../ChooseGraphicalParentSectionFilter.java | 50 + .../utils/GraphicalAndModelElementComparator.java | 176 +++ .../common/groups/utils/GroupRequestConstants.java | 55 + 80 files changed, 6966 insertions(+), 6966 deletions(-) delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/.classpath delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/.project delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/.settings/org.eclipse.jdt.core.prefs delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/META-INF/MANIFEST.MF delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/about.html delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/build.properties delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/messages.properties delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/plugin.properties delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/plugin.xml delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/schema/org.eclipse.papyrus.diagram.common.groups.groupcontainment.exsd delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/Activator.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/Messages.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChangeGraphicalParentCommand.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChangeModelParentCommand.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChooseChildrenNotificationCommand.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChooseParentNotificationCommand.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/CommandResultMessagesError.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/SetUpReferencesCommand.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/UpdateReferencesCommand.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/utlis/CommandsUtils.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/GroupNotificationBuilderFactory.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/PendingGroupNotificationsManager.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/groupcontainment/GroupContainmentRegistry.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/CheckboxIGraphicalFocusListenner.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/ChooseChildrenNotificationConfigurator.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/ChooseParentNotificationConfigurator.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/CompositeCreatorWithCommand.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/NotificationConfigurator.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/utils/CreatorUtils.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/utils/DefaultModelParent.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/utils/Utils.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/edit/policies/CreateInGroupEditPolicy.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/edit/policies/XYLayoutEditGroupPolicy.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/groupcontainment/AbstractContainerNodeDescriptor.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/preferences/OpacityFactoryHelper.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/preferences/OpacityGroup.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/tabbedproperties/appearance/ChooseGraphicalParentSection.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/tabbedproperties/appearance/ChooseGraphicalParentSectionFilter.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/utils/GraphicalAndModelElementComparator.java delete mode 100644 plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/utils/GroupRequestConstants.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/.classpath create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/.project create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/.settings/org.eclipse.jdt.core.prefs create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/META-INF/MANIFEST.MF create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/about.html create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/build.properties create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/messages.properties create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/plugin.properties create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/plugin.xml create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/schema/org.eclipse.papyrus.diagram.common.groups.groupcontainment.exsd create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/Activator.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/Messages.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChangeGraphicalParentCommand.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChangeModelParentCommand.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChooseChildrenNotificationCommand.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChooseParentNotificationCommand.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/CommandResultMessagesError.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/SetUpReferencesCommand.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/UpdateReferencesCommand.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/utlis/CommandsUtils.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/GroupNotificationBuilderFactory.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/PendingGroupNotificationsManager.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/groupcontainment/GroupContainmentRegistry.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/CheckboxIGraphicalFocusListenner.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/ChooseChildrenNotificationConfigurator.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/ChooseParentNotificationConfigurator.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/CompositeCreatorWithCommand.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/NotificationConfigurator.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/utils/CreatorUtils.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/utils/DefaultModelParent.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/utils/Utils.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/edit/policies/CreateInGroupEditPolicy.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/edit/policies/XYLayoutEditGroupPolicy.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/groupcontainment/AbstractContainerNodeDescriptor.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/preferences/OpacityFactoryHelper.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/preferences/OpacityGroup.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/tabbedproperties/appearance/ChooseGraphicalParentSection.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/tabbedproperties/appearance/ChooseGraphicalParentSectionFilter.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/utils/GraphicalAndModelElementComparator.java create mode 100644 plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/utils/GroupRequestConstants.java (limited to 'plugins') diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/.classpath b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/.classpath deleted file mode 100644 index 2d1a4302f04..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/.project b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/.project deleted file mode 100644 index ec8311ec2fa..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.papyrus.diagram.common.groups - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/.settings/org.eclipse.jdt.core.prefs b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index ef48b899f0b..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Thu May 20 10:49:25 CEST 2010 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/META-INF/MANIFEST.MF deleted file mode 100644 index 0aa275727d6..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/META-INF/MANIFEST.MF +++ /dev/null @@ -1,25 +0,0 @@ -Manifest-Version: 1.0 -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - org.eclipse.gmf.runtime.diagram.ui.properties, - org.eclipse.papyrus.diagram.common;bundle-version:="0.9.0", - org.eclipse.papyrus.ui.toolbox;bundle-version:="0.9.0", - org.eclipse.papyrus.preferences;bundle-version="0.9.0" -Export-Package: org.eclipse.papyrus.diagram.common.groups.commands, - org.eclipse.papyrus.diagram.common.groups.core.utils, - org.eclipse.papyrus.diagram.common.groups.edit.policies, - org.eclipse.papyrus.diagram.common.groups.groupcontainment, - org.eclipse.papyrus.diagram.common.groups.preferences, - org.eclipse.papyrus.diagram.common.groups.tabbedproperties.appearance, - org.eclipse.papyrus.diagram.common.groups.utils -Bundle-Vendor: %providerName -Bundle-ActivationPolicy: lazy -Bundle-Version: 0.9.0.qualifier -Bundle-Name: %pluginName -Bundle-Localization: plugin -Bundle-ManifestVersion: 2 -Bundle-Activator: org.eclipse.papyrus.diagram.common.groups.Activator -Bundle-SymbolicName: org.eclipse.papyrus.diagram.common.groups;singlet - on:=true -Bundle-RequiredExecutionEnvironment: J2SE-1.5 - diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/about.html b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/about.html deleted file mode 100644 index 82d49bf5f81..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/about.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -About - - -

About This Content

- -

June 5, 2007

-

License

- -

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

- -

If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at http://www.eclipse.org.

- - - diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/build.properties b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/build.properties deleted file mode 100644 index 7c52a3acb16..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/build.properties +++ /dev/null @@ -1,7 +0,0 @@ -# -#Mon Sep 12 09:29:44 CEST 2011 -bin.includes=META-INF/,.,plugin.xml,messages.properties,plugin.properties,schema/,about.html -output..=bin/ -src.includes=schema/,META-INF/,.,plugin.xml,messages.properties,plugin.properties,about.html -source..=src/ -bin..=bin/ diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/messages.properties b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/messages.properties deleted file mode 100644 index faaf1815b1c..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/messages.properties +++ /dev/null @@ -1,23 +0,0 @@ -#################################################################################### -# Copyright (c) 2010 Atos Origin. -# -# -# 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 -# -#################################################################################### -# Notification messages -ChooseContainedElementsCreator_Message=Choose which children should be contained in the group {0}. -ChooseContainedElementsCreator_CheckAll=Check / Uncheck all -ChooseContainedElementsCreator_Run=Assign -ChooseContainingGroupCreator_Message=Choose which parent these elements must be attached to. -ChooseContainingGroupCreator_Contained={0} must be contained by : -ChooseContainingGroupCreator_Run=Assign -ChooseParentNotificationCommand_ChooseGraphicalParent=Several Graphical parents are available, choose one of them : -ChooseParentNotificationCommand_ChooseModelParent=The zone in which you have created your element have several model parents available, this kind of zone should be avoided. Please choose one of them : -ChooseChildrenICompositeCreator_ChooseChildren=Choose graphical children: -ChooseParentNotificationCommand_ChooseGraphicalParentMessage=Select the graphical parent of -ChooseParentNotificationCommand_ChooseGraphicalChildrenMessage=Select the graphical children of -CommandsUtils_HandleGraphicalChildrenMovingOut_Label=Updating element which are not graphical children anymore \ No newline at end of file diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/plugin.properties b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/plugin.properties deleted file mode 100644 index 93449472c26..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/plugin.properties +++ /dev/null @@ -1,11 +0,0 @@ -########################################################################################## -# Copyright (c) 2010 Atos Origin . 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 Origin (Initial API and Implementation) -# -######################################################################################## -pluginName=Papyrus Common groups plugin (Incubation) -providerName=Eclipse Modeling Project diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/plugin.xml deleted file mode 100644 index 7e32c46ce8d..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/plugin.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/schema/org.eclipse.papyrus.diagram.common.groups.groupcontainment.exsd b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/schema/org.eclipse.papyrus.diagram.common.groups.groupcontainment.exsd deleted file mode 100644 index 6f6ec7fc5ad..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/schema/org.eclipse.papyrus.diagram.common.groups.groupcontainment.exsd +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - - - This extension point allows to register group types and their relationship with contained objects, in order to let the group framework handle the graphical parent reassignation. - -Diagrams using this extension point must register their diagram part to the group framework. -This can be achieved calling the code : - //configure group framework - EditingDomainRegisteringService.addGroupFrameworkForEditingDomain(getEditingDomain(), getDiagramEditPart()); -at the end of the initializeGraphicalViewer() method, -in the class org.eclipse.papyrus.diagram.***.Uml***DiagramForMultiEditor extending org.eclipse.papyrus.diagram.***.part.UMLDiagramEditor, which itself extends org.eclipse.papyrus.diagram.common.part.UmlGmfDiagramEditor. - - - - - - - - - - - The group containment extension allows to declare a set of group types, which can share the same contained elements. - -Node representing instances of these types can all be the graphical parent of a same element. - -Declaring them in this extension will let the groups framework handle conflicts for deciding which is the graphical parent. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A model container declaration must be used when a group is the model direct parent of its contained elements. - - - - - - - The type of edit part for which we should use this descriptor. - - - - - - - - - - The class describing the group type and how it is related to its contained children. -This class must implement org.eclipse.papyrus.diagram.common.groups.groupcontainment.IContainerNodeDescriptor - - - - - - - - - - - - - A reference container declaration must be used when a group is not the model direct parent of its contained elements, but contains elements through a reference with a specific feature. - - - - - - - The type of edit part for which we should use this descriptor. - - - - - - - - - - The class describing the group type and how it is related to its contained children. -This class must implement org.eclipse.papyrus.diagram.common.groups.groupcontainment.IContainerNodeDescriptor - - - - - - - - - - - - - - - 0.7.0 - - - - - - - - - <extension - point="org.eclipse.papyrus.diagram.common.groups.groupcontainment" - name="ActivityGroup" - id="org.eclipse.papyrus.diagram.activity.activitygroup"> - <modelContainer editPartType="org.eclipse.papyrus.diagram.activity.edit.parts.StructuredActivityNodeStructuredActivityNodeContentCompartmentEditPart" descriptor="org.eclipse.papyrus.diagram.activity.groupcontainment.StructuredActivityNodeContainment"/> - <modelContainer descriptor="org.eclipse.papyrus.diagram.activity.groupcontainment.ConditionalNodeContainment" editPartType="org.eclipse.papyrus.diagram.activity.edit.parts.ConditionalNodeStructuredActivityNodeContentCompartmentEditPart"> - </modelContainer> - <modelContainer descriptor="org.eclipse.papyrus.diagram.activity.groupcontainment.ExpansionRegionContainment" editPartType="org.eclipse.papyrus.diagram.activity.edit.parts.ExpansionRegionStructuredActivityNodeContentCompartmentEditPart"> - </modelContainer> - <modelContainer descriptor="org.eclipse.papyrus.diagram.activity.groupcontainment.LoopNodeContainment" editPartType="org.eclipse.papyrus.diagram.activity.edit.parts.LoopNodeStructuredActivityNodeContentCompartmentEditPart"> - </modelContainer> - <modelContainer descriptor="org.eclipse.papyrus.diagram.activity.groupcontainment.SequenceNodeContainment" editPartType="org.eclipse.papyrus.diagram.activity.edit.parts.SequenceNodeStructuredActivityNodeContentCompartmentEditPart"> - </modelContainer> - <referenceContainer descriptor="org.eclipse.papyrus.diagram.activity.groupcontainment.InterruptibleActivityRegionContainment" editPartType="org.eclipse.papyrus.diagram.activity.edit.parts.InterruptibleActivityRegionInterruptibleActivityRegionContentCompartmentEditPart"/> - <referenceContainer descriptor="org.eclipse.papyrus.diagram.activity.groupcontainment.ActivityPartitionContainment" editPartType="org.eclipse.papyrus.diagram.activity.edit.parts.ActivityPartitionActivityPartitionContentCompartmentEditPart"/> -</extension> - - - - - - - - - The interface org.eclipse.papyrus.diagram.common.groups.groupcontainment.IContainerNodeDescriptor must be implemented by classes used in the extensions. -The interface org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart is used as it is supposed to be implemented by all edit parts in Papyrus. - - - - - - - - - The activity diagram provides an extension for this extension point. -Its usage is described in the example, taken from the org.eclipse.papyrus.diagram.activity plugin. - -In this case, all ActivityGroup elements are described : - - The StructuredActivityNode and inheriting classes are described by modelContainer nodes. For convenience, the descriptors inherit from a single one. - - The InterruptibleActivityRegion are described by a referenceContainer with the InterruptibleActivityRegionContainment class, for the corresponding edit part class. - - The ActivityPartition are described by a referenceContainer with the ActivityPartitionDescriptor class, for the corresponding edit part class. - - - - - - - - - Copyright (c) 2010 Atos Origin. - - 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 Origin - Initial API and implementation - - - - diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/Activator.java b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/Activator.java deleted file mode 100644 index f3d7ffb6c81..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/Activator.java +++ /dev/null @@ -1,65 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * 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 Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.diagram.common.groups; - -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.papyrus.diagram.common.groups"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/Messages.java b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/Messages.java deleted file mode 100644 index 088164099d9..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/Messages.java +++ /dev/null @@ -1,100 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * 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 Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.diagram.common.groups; - -import org.eclipse.osgi.util.NLS; - -/** - * The class handling messages for the group framework - */ -public class Messages extends NLS { - - - /** - * Initialize from files - */ - static { - NLS.initializeMessages("messages", Messages.class); //$NON-NLS-1$ - } - - /** - * Private constructor - */ - private Messages() { - } - - /** - * Main message in ChooseElementsCreator - */ - public static String ChooseContainedElementsCreator_Message; - - /** - * Message to check/uncheck all checkboxes in ChooseElementsCreator - */ - public static String ChooseContainedElementsCreator_CheckAll; - - /** - * Message to run the action in ChooseContainedElementsCreator - */ - public static String ChooseContainedElementsCreator_Run; - - /** - * Main message in ChooseContainingGroupCreator - */ - public static String ChooseContainingGroupCreator_Message; - - /** - * Message to introduce a contained element in ChooseContainingGroupCreator - */ - public static String ChooseContainingGroupCreator_Contained; - - /** - * Message to run the action in ChooseContainingGroupCreator - */ - public static String ChooseContainingGroupCreator_Run; - - /** - * Message displayed when the user is asked to choose between graphical parents - */ - public static String ChooseParentNotificationCommand_ChooseGraphicalParent; - - /** - * Message display on the Choose graphical children notification - * e.g "Change graphical parent" - */ - public static String ChooseParentNotificationCommand_ChooseGraphicalParentMessage; - - /** - * Label of the Choose Children Notification - */ - public static String ChooseChildrenICompositeCreator_ChooseChildren; - - /** - * Message display to choose graphical children - */ - public static String ChooseParentNotificationCommand_ChooseGraphicalChildrenMessage; - - /** - * Message displayed when the user is asked to choose between model parents (This message is a warnig) - */ - public static String ChooseParentNotificationCommand_ChooseModelParent; - - /** - * Command label of HandleGraphicalChildrenMovingOut - */ - public static String CommandsUtils_HandleGraphicalChildrenMovingOut_Label; - - - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChangeGraphicalParentCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChangeGraphicalParentCommand.java deleted file mode 100644 index c6f45bb8b44..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChangeGraphicalParentCommand.java +++ /dev/null @@ -1,476 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin. - * - * - * 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 Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.diagram.common.groups.commands; - -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.draw2d.IFigure; -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.EditPart; -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.Request; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.gef.requests.ChangeBoundsRequest; -import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.gmf.runtime.notation.LayoutConstraint; -import org.eclipse.gmf.runtime.notation.Location; -import org.eclipse.gmf.runtime.notation.Node; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.diagram.common.groups.core.utils.Utils; -import org.eclipse.papyrus.diagram.common.groups.edit.policies.XYLayoutEditGroupPolicy; -import org.eclipse.papyrus.diagram.common.groups.utils.GroupRequestConstants; - -/** - * This command change the graphical parent of an edit part without changing the absolute position of the element - * - * @author arthur daussy - * - */ -public class ChangeGraphicalParentCommand extends AbstractTransactionalCommand { - - public enum Mode { - /** - * Case when the parent is in creation. - */ - CREATION_PARENT, - /** - * Case when the child is in creation - */ - CREATION_CHILD, - /** - * Case when the child is moving (ChangeBoundsRequest) - */ - MOVE_CHILD, - /** - * case when the parent is moving - */ - MOVE_PARENT, - /** - * Case when there is no need of a request. All elements has been placed annd all element ared fixed - */ - NORMAL - } - - - /** child part */ - private EditPart child; - - /** parent part */ - private EditPart parent; - - private Request request; - - private IGraphicalEditPart host; - - /** - * Current mode @see #mode - */ - private Mode mode; - - - - /** - * - * Command constructor. - * Create a command from to existing EditPart which exist at the time of the creation of the command - * - * @param domain - * editing domain - * @param label - * command label - * @param parent - * new parent edit part - * @param child - * child edit part to reroute parent - */ - public ChangeGraphicalParentCommand(TransactionalEditingDomain domain, String label, EditPart parent, EditPart child, IGraphicalEditPart getHost) { - super(domain, label, null); - this.parent = parent; - this.child = child; - this.request = null; - this.host = getHost; - this.mode = Mode.NORMAL; - } - - /** - * - * Command constructor. - * Create a command from to existing EditPart which exist at the time of the creation of the command. - * In this constructor the request is needed if any translation has to be made (e.g {@link ChangeBoundsRequest} @see - * {@link XYLayoutEditGroupPolicy#getCommand(Request)} - * - * @param domain - * editing domain - * @param label - * command label - * @param parent - * new parent edit part - * @param child - * child edit part to reroute parent - */ - public ChangeGraphicalParentCommand(TransactionalEditingDomain domain, String label, EditPart parent, EditPart child, IGraphicalEditPart getHost, Request request) { - super(domain, label, null); - this.parent = parent; - this.child = child; - this.request = request; - this.host = getHost; - this.mode = Mode.MOVE_PARENT; - } - - /** - * - * Constructor. - * - * @param domain - * editing domain - * @param label - * command label - * @param request - * Create element request to be able to find the IGraphicalEditPart of the create element - * ( WARNING the IGraphicalEditPart has to be already created at the execution time of this command and it has to be have it's bounds set) - * @param child - * IGraphicalEditPart of the child (has to be available a the creation time of the request) - */ - public ChangeGraphicalParentCommand(TransactionalEditingDomain domain, String label, CreateRequest request, EditPart child, IGraphicalEditPart getHost) { - super(domain, label, null); - this.parent = null; - this.child = child; - this.request = (CreateViewAndElementRequest)request; - this.host = getHost; - this.mode = Mode.CREATION_PARENT; - } - - /** - * This command change the view of the parent and the child edit part to make all the changes needed. - * - * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, - * org.eclipse.core.runtime.IAdaptable) - */ - protected CommandResult doExecuteWithResult(IProgressMonitor arg0, IAdaptable arg1) throws ExecutionException { - //Get the IGraphical edit part of the old parent - IGraphicalEditPart oldParentPart = (IGraphicalEditPart)child.getParent(); - Map editPartRegistry = getEditPartRegistery(); - if(editPartRegistry == null) { - return CommandResult.newErrorCommandResult(CommandResultMessagesError.THE_EDIT_PART_REGISTERY_WAS_NOT_FOUND); - } - //Get the view of the new parent, old parent and the child - // If the parent is null then check if the request is an creation request - if(parent == null) { - if(request instanceof CreateViewAndElementRequest) { - //If true try to get the EditPart of the element in creation - parent = getEditPartFromViewDescriptor((IGraphicalEditPart)child, (CreateViewAndElementRequest)request); - } - } else { - parent = Utils.getCompartementEditPartFromMainEditPart(editPartRegistry, parent); - } - if(parent == null) { - //If no parent is found then an error is thrown - return CommandResult.newErrorCommandResult(CommandResultMessagesError.IGRAPHICAL_EDIT_PART_NOT_CREATED_YET); - } - View newParentView = (View)parent.getModel(); - View childView = (View)child.getModel(); - /* - * Translate the new node to the corresponding location in its new father. - */ - CommandResult cmdChangeCoordinate = changeCoordinateInNewFather(oldParentPart, childView); - if(cmdChangeCoordinate != null) { - return cmdChangeCoordinate; - } - newParentView.insertChild(childView); - return CommandResult.newOKCommandResult(); - } - - /** - * This method will change the coordinate of the element on which we are changing it's parent. - * This method is not generic. It will handle differently if the command is came from a createRequest or the cahgneBounds request or without any - * request. - * This method should be reviewed later.(TODO) - * - * @param oldParentPart - * {@link IGraphicalEditPart} of the old paret - * @param childView - * View of the child - * @return - */ - private CommandResult changeCoordinateInNewFather(IGraphicalEditPart oldParentPart, View childView) { - /* - * Deleted because do not find the case where should it should be applied - * if(host != parent) { - */ - if(childView instanceof Node) { - IFigure parentCompartmentFigure = ((AbstractGraphicalEditPart)parent).getFigure(); - /* - * If the change graphical parent come after a move - */ - if(Mode.MOVE_CHILD.equals(mode) || Mode.MOVE_PARENT.equals(mode)) { - Rectangle newDimension = computeDeltaToChangeParent((IGraphicalEditPart)parent); - LayoutConstraint layoutConstraint = ((Node)childView).getLayoutConstraint(); - if(layoutConstraint instanceof Location) { - Location location = (Location)layoutConstraint; - location.setX(newDimension.x); - location.setY(newDimension.y); - } else { - return CommandResult.newErrorCommandResult("The layoutConstraint is not an instance of Location"); - } - /* - * If the change come after a creation or after nothing - */ - } else if(Mode.CREATION_CHILD.equals(mode) || Mode.CREATION_PARENT.equals(mode) || Mode.NORMAL.equals(mode)) { - /* - * Handle change graphical parent from a create request or with no request - * 1 - If the group in creation is the parent then - * 1.1 Used the Hack to force the figure to draw (in order to have it's position) - * 2 - Compute delta from computeDeltaToChangeParent - * 3 - Translate the location of the constraint - */ - Dimension newDimension; - if(parentCompartmentFigure.getBounds().isEmpty()) { - Rectangle oldBounds = parentCompartmentFigure.getBounds().getCopy(); - Point compLoc = emulateFigureCreation(parentCompartmentFigure); - newDimension = Utils.computeDeltaToChangeParent(oldParentPart, (IGraphicalEditPart)parent.getParent()); - reajustNewDimensionIfNeeded(parentCompartmentFigure, compLoc, newDimension); - parentCompartmentFigure.getBounds().setBounds(oldBounds); - } else { - newDimension = Utils.computeDeltaToChangeParent(oldParentPart, (IGraphicalEditPart)parent); - } - LayoutConstraint layoutConstraint = ((Node)childView).getLayoutConstraint(); - if(layoutConstraint instanceof Location) { - Location location = (Location)layoutConstraint; - Point newLocation = new Point(newDimension.width + location.getX(), newDimension.height + location.getY()); - location.setX(newLocation.x); - location.setY(newLocation.y); - } else { - return CommandResult.newErrorCommandResult("The layoutConstraint is not an instance of Location"); - } - } - - } else { - /* - * Error in group framework usage - */ - return CommandResult.newErrorCommandResult("The new containing edit part should be compartment node. The extension point org.eclipse.papyrus.diagram.common.groups.groupcontainment may have been incorrectly used."); - } - return null; - } - - /** - * Compute the new rectangle of the child from the original position set in the request and with the newParent {@link IGraphicalEditPart} - * - * @param newParent - * {@link IGraphicalEditPart} of the new parent - * @return new rectangle of the child - */ - private Rectangle computeDeltaToChangeParent(IGraphicalEditPart newParent) { - /* - * Get the absolute bound of a child - */ - Rectangle childAbsoluteRectangle = getChildAbsoluteBounds(); - if(childAbsoluteRectangle instanceof Rectangle) { - IFigure newPartFigure = ((IGraphicalEditPart)parent).getContentPane(); - newPartFigure.translateToRelative(childAbsoluteRectangle); - newPartFigure.translateFromParent(childAbsoluteRectangle); - Point negatedLayoutOrigin = newPartFigure.getClientArea().getLocation().getNegated(); - childAbsoluteRectangle.performTranslate(negatedLayoutOrigin.x, negatedLayoutOrigin.y); - /* - * Correct the position of the child in the parent if any @see getChildCorrectionFromParent - */ - Point negatedMoved = getChildCorrectionFromParent(); - childAbsoluteRectangle.performTranslate(negatedMoved.x, negatedMoved.y); - return childAbsoluteRectangle; - } - - return null; - } - - /** - * Get the EditpartRegistery - * - * @return Map if found null is not found - */ - private Map getEditPartRegistery() { - Map editPartRegistry = null; - //Check if the parent in valid compartment EditPart - if(parent != null) { - EditPartViewer parentViewer = parent.getViewer(); - if(parentViewer != null) { - editPartRegistry = parentViewer.getEditPartRegistry(); - } - } - if(editPartRegistry == null && child != null && child.getViewer() != null) { - editPartRegistry = child.getViewer().getEditPartRegistry(); - } - return editPartRegistry; - } - - - /** - * Used to readjusts the coordinate of the child if the parentComptmentFigure is not well set yet. - * Used to hack the system if the editPart is not properly set - * - * @param parentCompartmentFigure - * The compartment figure of the parent - * @param compLoc - * @see {@link #emulateFigureCreation(IFigure)} - * @param correctionDimension - * New {@link Dimension} which are going to modify in order to correctt the coordinatte of the child - */ - private void reajustNewDimensionIfNeeded(IFigure parentCompartmentFigure, Point compLoc, Dimension correctionDimension) { - if(compLoc != null) { - correctionDimension.shrink(compLoc.x + parentCompartmentFigure.getInsets().left, compLoc.y + parentCompartmentFigure.getInsets().top); - } - } - - /** - * Emulate the figure creation it's not already done. This allow the system to know the absolute solution even if the edit part of the parent is - * not yet finish - * - * @return null is the figure is already done. Return the translation needed to take into account the child position in it's parent ( e.g - * ActivityPartitionCompartement from its ActivityPartitionEditPart) - */ - private Point emulateFigureCreation(IFigure parentCompartmentFigure) { - if(parentCompartmentFigure.getBounds().isEmpty()) { - // layout parent node correctly to recover the correct location of compartment which has not been set previously - IFigure parentNodeFigure = parentCompartmentFigure.getParent(); - if(parentNodeFigure != null) { - IFigure grandParentFigure = parentNodeFigure.getParent(); - if(grandParentFigure != null) { - grandParentFigure.getLayoutManager().layout(grandParentFigure); - } - parentNodeFigure.getLayoutManager().layout(parentNodeFigure); - } - Point compLoc = parentCompartmentFigure.getBounds().getLocation(); - return compLoc; - } - return null; - - } - - /** - * This method is going to get the edit part from the request. - * 1 - Get descriptors - * 2 - Get View (adapter) - * 3 - Get IGraphicalEditPart if it exists - * - * @param anyPart - * Any IGraphicalEditPart in order to get the EditPartRegistery - * @return true if it as found the edit part - */ - private EditPart getEditPartFromViewDescriptor(IGraphicalEditPart anyPart, CreateViewAndElementRequest _request) { - - EditPart result = null; - Iterator descriptors = _request.getViewDescriptors().iterator(); - Map editPartRegistry = anyPart.getViewer().getEditPartRegistry(); - while(descriptors.hasNext()) { - CreateViewRequest.ViewDescriptor descriptor = (CreateViewRequest.ViewDescriptor)descriptors.next(); - Object view = descriptor.getAdapter(View.class); - if(view instanceof View) { - View childView = (View)view; - result = getCompartmentEditPartFromView(editPartRegistry, childView); - } - } - return result; - } - - /** - * Get a compartment editPart from a view and the editPartRegistery - * - * @param editPartRegistry - * EditPartRegistery - * @param view - * View of the element we want to find the compartment - * @return the EdiPart of compartment and null if not found - */ - public EditPart getCompartmentEditPartFromView(Map editPartRegistry, View view) { - EditPart resultCompartmentEditPart = null; - Object editPartAux = editPartRegistry.get(view); - if(editPartAux instanceof EditPart) { - EditPart _editPart = (EditPart)editPartAux; - resultCompartmentEditPart = Utils.getCompartementEditPartFromMainEditPart(editPartRegistry, _editPart); - } - return resultCompartmentEditPart; - } - - - - public Mode getMode() { - return mode; - } - - - public void setMode(Mode mode) { - this.mode = mode; - } - - /** - * Give the absolute rectangle of the child. (Depending of the mode) - * - * @return {@link Rectangle} of the child - */ - private Rectangle getChildAbsoluteBounds() { - Rectangle result = null; - if(child instanceof IGraphicalEditPart) { - switch(mode) { - case MOVE_CHILD: - if(request instanceof ChangeBoundsRequest) { - Object _origineConstraint = request.getExtendedData().get(GroupRequestConstants.CONSTRAINT_AFTER_MOVING); - if(_origineConstraint instanceof Rectangle) { - result = (Rectangle)_origineConstraint; - } - } - break; - case MOVE_PARENT: - result = Utils.getAbsoluteBounds((IGraphicalEditPart)child).getCopy(); - break; - default: - result = Utils.getAbsoluteBounds((IGraphicalEditPart)child).getCopy(); - break; - } - } - return result; - } - - /** - * Get the correction to be applied to the child in function of the mode - * - * @return {@link Point} to translate the child - */ - private Point getChildCorrectionFromParent() { - Point result = null; - if(child instanceof IGraphicalEditPart) { - switch(mode) { - case MOVE_PARENT: - result = ((ChangeBoundsRequest)request).getMoveDelta().getNegated(); - break; - default: - result = new Point(0, 0); - break; - } - } - return result; - } - - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChangeModelParentCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChangeModelParentCommand.java deleted file mode 100644 index 20096f93a25..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChangeModelParentCommand.java +++ /dev/null @@ -1,132 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin. - * - * - * 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 Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.diagram.common.groups.commands; - -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.gmf.runtime.emf.core.util.PackageUtil; -import org.eclipse.gmf.runtime.emf.type.core.internal.l10n.EMFTypeCoreMessages; - -/** - * This command will change the model parent of child to the IAdaptable parent. - * - * @author adaussy - * - */ -public class ChangeModelParentCommand extends AbstractTransactionalCommand { - - /** - * Child to add to the IAdaptable parent - */ - private Map chilrendToMove; - - private EObject targetContainer; - - private IAdaptable elementAdapter; - - /** - * - * Constructor. - * - * @param domain - * @param parentGroupAdapter - * @param chilrendToMove - * @param anyPart - * @param groupDescriptor - */ - public ChangeModelParentCommand(TransactionalEditingDomain domain, IAdaptable parentGroupAdapter, Map chilrendToMove, IGraphicalEditPart anyPart) { - super(domain, "Change model parent command", null); - this.chilrendToMove = chilrendToMove; - this.elementAdapter = parentGroupAdapter; - targetContainer = null; - // if(anyPart != null) { - // this.editPartRegistery = anyPart.getViewer().getEditPartRegistry(); - // } - - } - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor arg0, IAdaptable arg1) throws ExecutionException { - if(targetContainer == null) { - Object group = elementAdapter.getAdapter(EObject.class); - if(group instanceof EObject) { - targetContainer = (EObject)group; - } - } - if(targetContainer == null) { - return CommandResult.newErrorCommandResult("Unable to change the model parent of the object because the system was enable to find the EObject of the parent group"); - } - - for(Iterator i = getElementsToMove().keySet().iterator(); i.hasNext();) { - EObject element = (EObject)i.next(); - EReference feature = getTargetFeature(element); - if(feature != null && targetContainer.eClass().getEAllReferences().contains(feature)) { - if(feature.isMany()) { - @SuppressWarnings("rawtypes") - Collection coll = (Collection)targetContainer.eGet(feature); - coll.add(element); - } else { - targetContainer.eSet(feature, element); - } - } else { - return CommandResult.newErrorCommandResult(EMFTypeCoreMessages.moveElementsCommand_noTargetFeature); - } - } - - return CommandResult.newOKCommandResult(); - } - - private Map getElementsToMove() { - return chilrendToMove; - } - - protected EReference getTargetFeature(EObject element) { - EReference feature = (EReference)getElementsToMove().get(element); - if(feature == null) { - EReference oldContainmentFeature = element.eContainmentFeature(); - if(getTargetContainer().eClass().getEAllReferences().contains(oldContainmentFeature)) { - getElementsToMove().put(element, oldContainmentFeature); - feature = oldContainmentFeature; - } - } - if(feature == null) { - feature = PackageUtil.findFeature(getTargetContainer().eClass(), element.eClass()); - setTargetFeature(element, feature); - } - - return feature; - } - - private EObject getTargetContainer() { - return targetContainer; - } - - protected void setTargetFeature(EObject element, EReference targetFeature) { - getElementsToMove().put(element, targetFeature); - } - - - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChooseChildrenNotificationCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChooseChildrenNotificationCommand.java deleted file mode 100644 index dff860e6036..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChooseChildrenNotificationCommand.java +++ /dev/null @@ -1,214 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin. - * - * - * 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 Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.diagram.common.groups.commands; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.transaction.Transaction; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.diagram.common.groups.core.PendingGroupNotificationsManager; -import org.eclipse.papyrus.diagram.common.groups.core.ui.ChooseChildrenNotificationConfigurator; -import org.eclipse.papyrus.diagram.common.groups.core.ui.NotificationConfigurator; -import org.eclipse.papyrus.diagram.common.util.DiagramEditPartsUtil; - -/** - * This command will create a notification to ask the user to choose the graphical children of an element - * - * @author arthur daussy - * - */ -public class ChooseChildrenNotificationCommand extends AbstractTransactionalCommand { - - /** - * All possible graphical children - */ - private List allChildren; - - /** - * All children which are automatically chosen as graphical child - */ - private List automaticChildren; - - /** - * {@link IAdaptable} of the view (used to retrieve the {@link EditPart}) - */ - private IAdaptable adapter; - - /** - * {@link EditPart} on which we have to choose the graphical children - */ - private IGraphicalEditPart mainEditPart; - - - /** - * {@link EditPart} hosting the {@link EditPolicy} - */ - private IGraphicalEditPart host; - - /** - * Pending Group manager - */ - private PendingGroupNotificationsManager manager; - - /** - * List of all notification created and modifed - */ - private List createdNotificationConfigurator; - - /** - * {@link DiagramEditPart} - */ - private DiagramEditPart diagramPart; - - /** - * Construct the command for asking to choose graphical children of a adapter - * Constructor. - * - * @param domain - * @see {@link AbstractTransactionalCommand} - * @param label - * @see {@link AbstractTransactionalCommand} - * @param _allChildren - * @see {@link #allChildren} - * @param _automaticChildren - * @see {@link #automaticChildren} - * @param _adapter - * @see {@link #adapter} - */ - public ChooseChildrenNotificationCommand(TransactionalEditingDomain domain, String label, List _allChildren, List _automaticChildren, IAdaptable _adapter, IGraphicalEditPart getHost, DiagramEditPart _diagramPart) { - super(domain, label, null); - this.allChildren = _allChildren; - this.automaticChildren = _automaticChildren; - this.adapter = _adapter; - this.host = getHost; - this.diagramPart = _diagramPart; - this.manager = PendingGroupNotificationsManager.getInstanceForDiagram(DiagramEditPartsUtil.getDiagramEditPart(getHost)); - } - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - if(!getEditPartFromEditPartAdapter()) { - if(!allChildren.isEmpty()) { - getEditPartFromViewAdapter(allChildren.get(0)); - } - } - if(mainEditPart != null) { - createdNotificationConfigurator = new ArrayList(); - NotificationConfigurator configurator = PendingGroupNotificationsManager.getInstanceForDiagram(diagramPart).getChooseChildrenPendingNotification(mainEditPart); - ChooseChildrenNotificationConfigurator notificationConfigurator = null; - if(configurator == null) { - //If there is no a pending notification for this main edit part then it create one - if(!allChildren.isEmpty() && isChildrenToChoose()) { - notificationConfigurator = new ChooseChildrenNotificationConfigurator(mainEditPart, allChildren, automaticChildren, host, manager); - notificationConfigurator.runConfigurator(); - } - } else { - //Else update the old one if needed TODO TODO - // 1 - Compare if there is any modification TODO - if(configurator instanceof ChooseChildrenNotificationConfigurator) { - notificationConfigurator = (ChooseChildrenNotificationConfigurator)configurator; - if(notificationConfigurator.isThereAnyModification(mainEditPart, allChildren, automaticChildren, host)) { - // 2 - There are some update the old notification TODO - notificationConfigurator.closeNotification(); - if(!allChildren.isEmpty() && isChildrenToChoose()) { - notificationConfigurator = new ChooseChildrenNotificationConfigurator(mainEditPart, allChildren, automaticChildren, host, manager); - notificationConfigurator.runConfigurator(); - } - - } - } - } - if(notificationConfigurator != null) { - createdNotificationConfigurator.add(notificationConfigurator); - } - return CommandResult.newOKCommandResult(); - } - return CommandResult.newErrorCommandResult("The editPart of the adaptable element has not been found");//$NON-NLS-1$ - } - - /** - * Return true if there is some children on which the user should choose the graphical parent - * - * @return - */ - private boolean isChildrenToChoose() { - return (allChildren.size() > automaticChildren.size()); - } - - /** - * Set the main edit part attribute from the adapter - * - * @param any - * Any {@link IGraphicalEditPart} from which we can get the EditPartRegistery - * @return true if succeed - */ - private Boolean getEditPartFromEditPartAdapter() { - Object _mainEditPart = adapter.getAdapter(EditPart.class); - if(_mainEditPart instanceof IGraphicalEditPart) { - mainEditPart = (IGraphicalEditPart)_mainEditPart; - return true; - } - return false; - } - - /** - * Get the {@link IGraphicalEditPart} from view adapter - * - * @param any - * @return - */ - private Boolean getEditPartFromViewAdapter(IGraphicalEditPart any) { - Object view = adapter.getAdapter(View.class); - Map registery = any.getViewer().getEditPartRegistry(); - if(view instanceof View) { - View childView = (View)view; - Object auxPart = registery.get(childView); - if(auxPart instanceof IGraphicalEditPart) { - mainEditPart = (IGraphicalEditPart)auxPart; - return true; - } - } - return false; - } - - /** - * Inform that the command has been undone and delete or update the created notification - * - * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#didUndo(org.eclipse.emf.transaction.Transaction) - * @param tx - * a transaction that has been undone. - */ - @Override - protected void didUndo(Transaction tx) { - for(ChooseChildrenNotificationConfigurator notifConfigurator : createdNotificationConfigurator) { - notifConfigurator.closeNotification(); - } - super.didUndo(tx); - - - } - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChooseParentNotificationCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChooseParentNotificationCommand.java deleted file mode 100644 index d64ad9d2063..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/ChooseParentNotificationCommand.java +++ /dev/null @@ -1,219 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin. - * - * - * 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 Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.diagram.common.groups.commands; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.transaction.Transaction; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.requests.ChangeBoundsRequest; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.diagram.common.groups.Messages; -import org.eclipse.papyrus.diagram.common.groups.core.PendingGroupNotificationsManager; -import org.eclipse.papyrus.diagram.common.groups.core.ui.ChooseParentNotificationConfigurator; -import org.eclipse.papyrus.diagram.common.groups.core.ui.NotificationConfigurator; -import org.eclipse.papyrus.diagram.common.groups.utils.GroupRequestConstants; -import org.eclipse.papyrus.diagram.common.util.DiagramEditPartsUtil; - -/** - * Command to display the notification for choosing parent. - * This command handle two modes: - * - * @see #GRAPHICAL_MODE : Display the notification in order to choose the graphical parent - * @see #MODEL_MODE : Display the warning in order to choose the model parent and change automatically the graphical parent - * @author arthur daussy - */ -public class ChooseParentNotificationCommand extends AbstractTransactionalCommand { - - /** mode for graphical parent */ - public static final boolean GRAPHICAL_MODE = true; - - /** mode for model parent */ - public static final boolean MODEL_MODE = false; - - /** the mode to use this command with */ - private boolean mode; - - /** list of possible parent parts */ - private List parents; - - /** child part to choose parent for */ - private IGraphicalEditPart childEditPart; - - /** creation request */ - private Request request; - - /** EditPart of host of the {@link EditPolicy} */ - private IGraphicalEditPart host; - - /** - * Manage of the pending notification - */ - private PendingGroupNotificationsManager manager; - - /** - * {@link NotificationConfigurator} of the pointed childEditPart - */ - private ChooseParentNotificationConfigurator notifConfigurator; - - - /** - * Constructor for element creation. - * - * @param domain - * editing domain - * @param label - * command label - * @param parents - * possible parents - * @param request - * creation request - */ - public ChooseParentNotificationCommand(TransactionalEditingDomain domain, String label, List parents, Request request, Boolean mode, IGraphicalEditPart getHost) { - super(domain, label, null); - this.parents = parents; - this.request = request; - this.mode = mode; - this.host = getHost; - this.manager = PendingGroupNotificationsManager.getInstanceForDiagram(DiagramEditPartsUtil.getDiagramEditPart(getHost)); - } - - - - - - /** - * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, - * org.eclipse.core.runtime.IAdaptable) - */ - protected CommandResult doExecuteWithResult(IProgressMonitor arg0, IAdaptable arg1) throws ExecutionException { - if(parents != null) { - if(getEditPartFromDescriptor()) { - String label; - ChooseParentNotificationConfigurator configurator = null; - if(mode == GRAPHICAL_MODE) { - label = new String(Messages.ChooseParentNotificationCommand_ChooseGraphicalParent); - configurator = new ChooseParentNotificationConfigurator(parents, childEditPart, mode, host, manager, NotificationConfigurator.Mode.QUESTION_MODE, label); - } else { - label = new String(Messages.ChooseParentNotificationCommand_ChooseGraphicalParent); - configurator = new ChooseParentNotificationConfigurator(parents, childEditPart, mode, host, manager, NotificationConfigurator.Mode.WARNING_MODE, label); - } - if(configurator != null) { - notifConfigurator = configurator; - configurator.runConfigurator(); - return CommandResult.newOKCommandResult(); - } - } - } - return CommandResult.newErrorCommandResult(GroupRequestConstants.CHOOSE_PARENT_ERROR_NOTIFICATION); - - - } - - /** - * This method is going to get the edit part from the request. - * 1 - Get descriptors - * 2 - Get View (adapter) - * 3 - Get IGraphicalEditPart if it exist - * - * @return true if it as found the edit part - */ - private Boolean getEditPartFromDescriptor() { - if(request instanceof CreateViewAndElementRequest) { - CreateViewAndElementRequest createRequest = (CreateViewAndElementRequest)request; - Iterator descriptors = createRequest.getViewDescriptors().iterator(); - while(descriptors.hasNext()) { - CreateViewRequest.ViewDescriptor descriptor = (CreateViewRequest.ViewDescriptor)descriptors.next(); - Object view = descriptor.getAdapter(View.class); - if(view instanceof View) { - View childView = (View)view; - if(!parents.isEmpty()) { - Object childEditPartAux = parents.get(0).getViewer().getEditPartRegistry().get(childView); - if(childEditPartAux instanceof IGraphicalEditPart) { - childEditPart = (IGraphicalEditPart)childEditPartAux; - } - } - } - } - } else if(request instanceof ChangeBoundsRequest) { - ChangeBoundsRequest changeBoundsRequest = (ChangeBoundsRequest)request; - if(!changeBoundsRequest.getEditParts().isEmpty()) { - Object editPart = changeBoundsRequest.getEditParts().get(0); - if(editPart instanceof IGraphicalEditPart) { - IGraphicalEditPart _childEditPart = (IGraphicalEditPart)editPart; - View childView = _childEditPart.getNotationView(); - if(!parents.isEmpty()) { - Object childEditPartAux = parents.get(0).getViewer().getEditPartRegistry().get(childView); - if(childEditPartAux instanceof IGraphicalEditPart) { - childEditPart = (IGraphicalEditPart)childEditPartAux; - } - } - - } - } - } - if(childEditPart != null) { - return true; - } else { - return false; - } - } - - /** - * Set the list of possible parents - * - * @param parents - * list of possible parents - */ - public void setListOfParents(List parents) { - this.parents = parents; - } - - /** - * Set mode to use this command - * - * @param mode - * one of {@link #GRAPHICAL_MODE} or {@link #MODEL_MODE} - */ - public void setMode(boolean mode) { - this.mode = mode; - } - - /** - * Inform that the command has been undone and delete or update the created notification - * - * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#didUndo(org.eclipse.emf.transaction.Transaction) - * @param tx - * a transaction that has been undone. - */ - @Override - protected void didUndo(Transaction tx) { - if(notifConfigurator != null) { - notifConfigurator.closeNotification(); - } - super.didUndo(tx); - } - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/CommandResultMessagesError.java b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/CommandResultMessagesError.java deleted file mode 100644 index 52f70d5b413..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/CommandResultMessagesError.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.eclipse.papyrus.diagram.common.groups.commands; - - -public class CommandResultMessagesError { - - static final String IGRAPHICAL_EDIT_PART_NOT_CREATED_YET = "The IGraphicalEditPart of the parent is not created yet"; - - public static final String THE_EDIT_PART_REGISTERY_WAS_NOT_FOUND = "The EditPartRegistery was not found"; - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/SetUpReferencesCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/SetUpReferencesCommand.java deleted file mode 100644 index 8b855e90bad..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/SetUpReferencesCommand.java +++ /dev/null @@ -1,100 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin. - * - * - * 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 Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.diagram.common.groups.commands; - -import java.util.Collection; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.papyrus.diagram.common.groups.core.groupcontainment.GroupContainmentRegistry; -import org.eclipse.papyrus.diagram.common.groups.groupcontainment.AbstractContainerNodeDescriptor; - -/** - * Command to update referencing groups for a child element. - * (The child element is not necessary already created, it has just to be available through an adapter at runtime execution). - * - * @author arthur daussy - */ -public class SetUpReferencesCommand extends AbstractTransactionalCommand { - - private IAdaptable elementAdapter; - - private List graphicalParent; - - - /** - * Command constructor - * - * @param domain - * editing domain - * @param label - * command label - * @param adapter - * adapter to recover created element - */ - public SetUpReferencesCommand(TransactionalEditingDomain domain, String label, IAdaptable adapter, List _graphicalParents) { - super(domain, label, null); - elementAdapter = adapter; - this.graphicalParent = _graphicalParents; - } - - /** - * - * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, - * org.eclipse.core.runtime.IAdaptable) - * - * @param arg0 - * @param arg1 - * @return - * @throws ExecutionException - */ - @SuppressWarnings("unchecked") - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor arg0, IAdaptable arg1) throws ExecutionException { - Object createdElement = elementAdapter.getAdapter(EObject.class); - if(createdElement instanceof EObject) { - EObject eObjectCreatedElement = (EObject)createdElement; - for(IGraphicalEditPart parent : graphicalParent) { - EObject eObjectSourceReference = parent.resolveSemanticElement(); - AbstractContainerNodeDescriptor desc = GroupContainmentRegistry.getContainerDescriptor(parent); - List refs = desc.getReferenceFor(eObjectCreatedElement.eClass()); - for(EReference ref : refs) { - if(ref != null && ref.isMany()) { - Collection collection = (Collection)eObjectSourceReference.eGet(ref); - if(!collection.contains(eObjectCreatedElement)) { - collection.add(eObjectCreatedElement); - } - } else if(ref != null && !ref.isMany()) { - eObjectSourceReference.eSet(ref, eObjectCreatedElement); - } - } - - } - - } - - return CommandResult.newOKCommandResult(); - } - - - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/UpdateReferencesCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/UpdateReferencesCommand.java deleted file mode 100644 index 68f46584c3f..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/UpdateReferencesCommand.java +++ /dev/null @@ -1,157 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin. - * - * - * 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 Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.diagram.common.groups.commands; - -import java.util.Collection; -import java.util.List; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.papyrus.diagram.common.groups.core.utils.Utils; -import org.eclipse.papyrus.diagram.common.groups.groupcontainment.AbstractContainerNodeDescriptor; - -/** - * Update all references of a parent group. - * This class will set or unset references of the parent from a given child list - * - * @author arthur daussy - * - */ - -public class UpdateReferencesCommand extends AbstractTransactionalCommand { - - /** - * Mode used to set references - */ - public final static boolean SET_MODE = true; - - /** - * Mode used to unset references - */ - public final static boolean UNSET_MODE = false; - - /** - * List of all {@link IGraphicalEditPart} of all children - */ - private List childrenPart; - - /** - * {@link AbstractContainerNodeDescriptor} of the parent group - */ - private AbstractContainerNodeDescriptor descriptor; - - /** - * {@link IAdaptable} of the parent (Used to find {@link EObject} - */ - private IAdaptable elementAdapter; - - /** - * Current mode {@link UpdateReferencesCommand#UNSET_MODE} and {@link #SET_MODE} - */ - private boolean setMode = true; - - /** - * - * Constructor. - * - * @param domain - * @see {@link AbstractTransactionalCommand} - * @param label - * @see {@link AbstractTransactionalCommand} - * @param children - * @see {@link #childrenPart} - * @param descriptor - * @see {@link #descriptor} - * @param adapter - * @see {@link #elementAdapter} - */ - public UpdateReferencesCommand(TransactionalEditingDomain domain, String label, List children, AbstractContainerNodeDescriptor descriptor, IAdaptable adapter) { - super(domain, label, null); - this.descriptor = descriptor; - elementAdapter = adapter; - this.childrenPart = children; - - } - - /** - * - * Constructor. - * - * @param domain - * @see {@link AbstractTransactionalCommand} - * @param label - * @see {@link AbstractTransactionalCommand} - * @param children - * @see {@link #childrenPart} - * @param descriptor - * @see {@link #descriptor} - * @param adapter - * @see {@link #elementAdapter} - */ - public UpdateReferencesCommand(TransactionalEditingDomain domain, String label, List children, AbstractContainerNodeDescriptor descriptor, IAdaptable adapter, boolean mode) { - super(domain, label, null); - this.descriptor = descriptor; - elementAdapter = adapter; - this.childrenPart = children; - this.setMode = mode; - - } - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor arg0, IAdaptable arg1) throws ExecutionException { - Object createdElement = elementAdapter.getAdapter(EObject.class); - if(createdElement instanceof EObject) { - EObject eObjectCreatedElement = (EObject)createdElement; - for(IGraphicalEditPart part : childrenPart) { - EObject childElement = part.resolveSemanticElement(); - List refs = descriptor.getReferenceFor(childElement.eClass()); - for(EReference ref : refs) { - //Add reference to the father - if(ref != null && ref.isMany()) { - //ref.getEOpposite() - Collection collection = (Collection)eObjectCreatedElement.eGet(ref); - if(setMode) { - if(!collection.contains(childElement)) { - collection.add(childElement); - } - } else { - if(collection.contains(childElement)) { - collection.remove(childElement); - } - } - //Remove all element which have a model sons in the collection - } else if(ref != null && !ref.isMany()) { - if(setMode) { - eObjectCreatedElement.eSet(ref, childElement); - } else { - eObjectCreatedElement.eUnset(ref); - } - } - } - Utils.withDrawRedundantElementReferenced(childElement); - } - } - - return CommandResult.newOKCommandResult(); - } - - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/utlis/CommandsUtils.java b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/utlis/CommandsUtils.java deleted file mode 100644 index c6096a43368..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/commands/utlis/CommandsUtils.java +++ /dev/null @@ -1,1172 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * 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 Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.diagram.common.groups.commands.utlis; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.emf.transaction.util.Adaptable; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.requests.ChangeBoundsRequest; -import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; -import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter; -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.commands.SemanticCreateCommand; -import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand; -import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; -import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; -import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.diagram.common.groups.Messages; -import org.eclipse.papyrus.diagram.common.groups.commands.ChangeGraphicalParentCommand; -import org.eclipse.papyrus.diagram.common.groups.commands.ChangeGraphicalParentCommand.Mode; -import org.eclipse.papyrus.diagram.common.groups.commands.ChangeModelParentCommand; -import org.eclipse.papyrus.diagram.common.groups.commands.ChooseChildrenNotificationCommand; -import org.eclipse.papyrus.diagram.common.groups.commands.ChooseParentNotificationCommand; -import org.eclipse.papyrus.diagram.common.groups.commands.SetUpReferencesCommand; -import org.eclipse.papyrus.diagram.common.groups.commands.UpdateReferencesCommand; -import org.eclipse.papyrus.diagram.common.groups.core.groupcontainment.GroupContainmentRegistry; -import org.eclipse.papyrus.diagram.common.groups.core.utils.DefaultModelParent; -import org.eclipse.papyrus.diagram.common.groups.core.utils.Utils; -import org.eclipse.papyrus.diagram.common.groups.groupcontainment.AbstractContainerNodeDescriptor; -import org.eclipse.papyrus.diagram.common.groups.utils.GroupRequestConstants; - -/** - * Util class for command - * - * @author arthur daussy - * - */ -public class CommandsUtils { - - /** - * Parameter in a request which define which host (IGrapicalEditPart) has to handle the request - */ - public static final String NEW_PARENT_HOST = "New_parent_host"; - - /** - * Parameter in a request which define the graphical parent ((IGrapicalEditPart)) - */ - public static final String GRAPHICAL_PARENT = "Graphical_parent"; - - /** - * Get the semantic command to create a new element. - * This will set ups all references needed and create the semantic Container Parent Command - * - * @param requestAdapter - * Request adapter of the global request - * @param createElementCommand - * Create Element Request - * @param editingDomain - * TransactionalEditingDomain needed to create transactionnal command - * @param createElementRequest - * The request to create a new element - * @param createElementCommand - * The command to create the element just after its creation - * @return - */ - public static CompositeCommand getSemanticCommand(CreateElementRequestAdapter requestAdapter, TransactionalEditingDomain editingDomain, CreateElementRequest createElementRequest, Command createElementCommand, List graphicalParents) { - CompositeCommand semanticCommand; - /* - * create the semantic create wrapper command - */ - SemanticCreateCommand semanticContainerParentCommand = new SemanticCreateCommand(requestAdapter, createElementCommand); - /* - * Create a command to update references - */ - SetUpReferencesCommand setUpReferences = new SetUpReferencesCommand(editingDomain, semanticContainerParentCommand.getLabel(), requestAdapter, graphicalParents); - /* - * create the semantic global command - */ - semanticCommand = new CompositeCommand(semanticContainerParentCommand.getLabel()); - if(semanticCommand != null) { - semanticCommand.compose(semanticContainerParentCommand); - } - if(setUpReferences != null) { - semanticCommand.compose(setUpReferences); - } - return semanticCommand; - } - - /** - * Return the command which create the notification to asked to the user to choose the graphical parent of undetermined element (elements which - * have at least 2 possible graphical parent) - * FIXME change the composite command to a normal command (composite command is not needed anymore) - * - * @param editingDomain - * TransactionalEditingDomain in order to create the command - * @param request - * General request - * @return the composite command. This command is in two parts. The first represent the Notification to choose the model parent and if needed the - * command to chose the graphical parent. - */ - public static CompositeCommand getChooseParentNotification(TransactionalEditingDomain editingDomain, CreateViewAndElementRequest request, List graphicalParents, List modelParents, IGraphicalEditPart getHost) { - /* - * ChooseParentNotificationCommand - * 1 - Check if there is any choice to make - * 1.1 - Check that All list are initialized - * 1.2 - Check there are There at least 2 elements in one of the two least - * 2 - Create a composite command : - * 2.1 - Create the Graphical Choice command - * 2.2 - create the Model Choice command - */ - CompositeCommand choiceCommand = null; - if(graphicalParents != null && modelParents != null && (modelParents.size() > 1 || graphicalParents.size() > 1)) { - String chooseCommandLabel = "Print choice notifications";//$NON-NLS-1$ - choiceCommand = new CompositeCommand(chooseCommandLabel); - if(modelParents.size() > 1) { - ChooseParentNotificationCommand modelNotificationCommand = new ChooseParentNotificationCommand(editingDomain, chooseCommandLabel + " : Model ", modelParents, request, ChooseParentNotificationCommand.MODEL_MODE, getHost); - choiceCommand.compose(modelNotificationCommand); - } else { - if(graphicalParents.size() > 1) { - ChooseParentNotificationCommand graphicalNotificationCommand = new ChooseParentNotificationCommand(editingDomain, chooseCommandLabel + " : Graphical ", graphicalParents, request, ChooseParentNotificationCommand.GRAPHICAL_MODE, getHost); - choiceCommand.compose(graphicalNotificationCommand); - } - } - - } - return choiceCommand; - } - - /** - * Return the command which create the notification to asked to the user to choose the graphical parent of undetermined element (elements which - * have at least 2 possible graphical parent) - * FIXME change the composite command to a normal command (composite command is not needed anymore) - * - * @param editingDomain - * TransactionalEditingDomain in order to create the command - * @param childAdapter - * {@link IAdaptable} to find the {@link IGraphicalEditPart} of the child - * @return the composite command. This command is in two parts. The first represent the Notification to choose the model parent and if needed the - * command to chose the graphical parent. - */ - public static CompositeCommand getChooseParentNotification(TransactionalEditingDomain editingDomain, ChangeBoundsRequest request, List graphicalParents, List modelParents, IGraphicalEditPart getHost) { - /* - * ChooseParentNotificationCommand - * 1 - Check if there is any choice to make - * 1.1 - Check that All list are initialized - * 1.2 - Check there are There at least 2 elements in one of the two least - * 2 - Create a composite command : - * 2.1 - Create the Graphical Choice command - * 2.2 - create the Model Choice command - */ - CompositeCommand choiceCommand = null; - if(graphicalParents != null && modelParents != null && (modelParents.size() > 1 || graphicalParents.size() > 1)) { - String chooseCommandLabel = "Print choice notifications";//$NON-NLS-1$ - choiceCommand = new CompositeCommand(chooseCommandLabel); - if(modelParents.size() > 1) { - ChooseParentNotificationCommand modelNotificationCommand = new ChooseParentNotificationCommand(editingDomain, chooseCommandLabel + " : Model ", modelParents, request, ChooseParentNotificationCommand.MODEL_MODE, getHost); - choiceCommand.compose(modelNotificationCommand); - } else { - if(graphicalParents.size() > 1) { - ChooseParentNotificationCommand graphicalNotificationCommand = new ChooseParentNotificationCommand(editingDomain, chooseCommandLabel + " : Graphical ", graphicalParents, request, ChooseParentNotificationCommand.GRAPHICAL_MODE, getHost); - choiceCommand.compose(graphicalNotificationCommand); - } - } - - } - return choiceCommand; - } - - /** - * Check if the child already have a graphical parent and if its graphical parent is not a model parent on the new element in creation - * - * @param element - * Child we want to test - * @return true there a other group parent (which is not a parent of the new created element) - */ - public static boolean alreadyHaveGroupGraphicalParent(IGraphicalEditPart element, List modelParents) { - IGraphicalEditPart parent = (IGraphicalEditPart)element.getParent(); - //CHANGE - return GroupContainmentRegistry.isContainerConcerned(parent) && !(element.getParent().getChildren().contains(parent));//!modelParents.contains(parent); - } - - /** - * Get the depth at which the edit part is in the diagram - * - * @param part - * the edit part to test depth - * @return number of parents + 1 - */ - public static int getDepth(IGraphicalEditPart part) { - int depth = 0; - EditPart parentPart = part; - while(parentPart != null) { - parentPart = parentPart.getParent(); - depth++; - } - return depth; - } - - /** - * Select the best models containers among the list of possible parents - * - * @param parents - * group parents - * @return the best model container (deepest one) or null if none - */ - public static IGraphicalEditPart selectBestModelContainer(List parents) { - IGraphicalEditPart container = null; - int containerDepth = 0; - //For all elements in parents - for(IGraphicalEditPart parent : parents) { - // select model containers only - if(GroupContainmentRegistry.isContainerModel(parent)) { - // select part the deepest in the diagram - int depth = getDepth(parent); - if(depth > containerDepth) { - container = parent; - } - } - } - return container; - } - - /** - * This method is called if no model parent was found. It will return the command handled by a default container. - * - * @param request - * original request - * @param createElementRequest - * the creation request - * @param getHost - * Host of the {@link EditPolicy} - * @return the command as if handle by the default container. Return if the current container is the default container - * - */ - public static Command getCommandFromDefaultModelParent(CreateViewAndElementRequest request, CreateElementRequest createElementRequest, IGraphicalEditPart getHost) { - //If no model parent was found - //The system will look in the ancestor of the current host to find a element which can contain the new element and which is not a group - EClass typeToCreate = createElementRequest.getElementType().getEClass(); - IGraphicalEditPart hostParent = getHost; - - while(hostParent != null) { - EObject hostParentElement = hostParent.resolveSemanticElement(); - if(GroupContainmentRegistry.getDescriptorsWithContainerEClass(hostParentElement.eClass()).isEmpty()) { - for(EReference containmentRelation : hostParentElement.eClass().getEAllContainments()) { - if(containmentRelation.getEReferenceType().isSuperTypeOf(typeToCreate)) { - if(getHost.equals(hostParent)) { - request.getExtendedData().put(NEW_PARENT_HOST, hostParent); - createElementRequest.setContainer(hostParentElement); - return null; - } else { - //This edit part can not handle the creation. It send it to the new hostParent - request.getExtendedData().put(CommandsUtils.NEW_PARENT_HOST, hostParent); - Command cmd = hostParent.getCommand(request); - return cmd; - } - } - } - } - hostParent = (IGraphicalEditPart)hostParent.getParent(); - } - return null; - } - - /** - * This method is called if no model parent was found. It will return the command handled by a default container. (For change bound request) - * - * @param request - * The change boudn request - * @param currentEditPart - * The element being moved - * @param getHost - * The host of the current {@link EditPolicy} - * @return the command as if handle by the default container. Return if the current container is the default container - */ - public static Command getCommandFromDefaultModelParent(ChangeBoundsRequest request, IGraphicalEditPart currentEditPart, IGraphicalEditPart getHost) { - //If no model parent was found - //The system will look in the ancestor of the current host to find a element which can contain the new element and which is not a group - EClass typeToCreate = currentEditPart.resolveSemanticElement().eClass(); - IGraphicalEditPart hostParent = getHost; - - while(hostParent != null) { - EObject hostParentElement = hostParent.resolveSemanticElement(); - if(GroupContainmentRegistry.getDescriptorsWithContainerEClass(hostParentElement.eClass()).isEmpty()) { - for(EReference containmentRelation : hostParentElement.eClass().getEAllContainments()) { - if(containmentRelation.getEReferenceType().isSuperTypeOf(typeToCreate)) { - if(getHost.equals(hostParent)) { - return null; - } else { - //This edit part can not handle the creation. It send it to the new hostParent - request.getExtendedData().put(CommandsUtils.NEW_PARENT_HOST, hostParent); - Command cmd = hostParent.getCommand(request); - return cmd; - } - } - } - } - hostParent = (IGraphicalEditPart)hostParent.getParent(); - } - return null; - } - - /** - * Update model for all new direct child. - * - * @param directChildsToComplete - * List of all direct child - * @param descriptor - * descriptor of the group - * @param editingDomain - * Editing domain to create command - * @param parent - * RequestAdapter of the parent creation - * @param anyPart - * Igraphical editPart to get back EditPartRegistery - * @return CompositeCommand of all command updating model for each child - */ - public static ChangeModelParentCommand getUpdateChildrenModel(List directChildsToComplete, AbstractContainerNodeDescriptor descriptor, TransactionalEditingDomain editingDomain, IAdaptable parent, IGraphicalEditPart anyPart) { - ChangeModelParentCommand cmd = null; - Map elementToMove = new HashMap(); - if(!directChildsToComplete.isEmpty()) { - for(IGraphicalEditPart child : directChildsToComplete) { - EObject childEObject = child.resolveSemanticElement(); - EClass childEClass = childEObject.eClass(); - if(descriptor.canIBeModelParentOf(childEClass)) { - elementToMove.put(childEObject, descriptor.getContainmentReferenceFor(childEClass)); - } - } - } - if(!elementToMove.isEmpty()) { - cmd = new ChangeModelParentCommand(editingDomain, parent, elementToMove, anyPart); - } - return cmd; - } - - /** - * set the {@see GroupRequestConstants#GRAPHICAL_CHILDREN} parameter of the request in order to make the list of children available in the - * LayoutEditPolicy - * - * @param automaticChildren - * All the {@link IGraphicalEditPart} you want to add as graphical children - * @param request - * request on which you want to add the parameter - */ - public static void updateGraphicalChildren(List automaticChildren, Request request) { - if(!automaticChildren.isEmpty()) { - request.getExtendedData().put(GroupRequestConstants.GRAPHICAL_CHILDREN, automaticChildren); - } - } - - /** - * Create a notification to choose the graphical children of element in creation (request) - * - * @param allChildren - * All possible children - * @param automaticChildren - * All the children has been automatically graphical children - * @param request - * Creation request - * @param domain - * EditingDomain to create TransactionalCommand - * @param label - * Label of the command - * @param diagramPart - * @return The command or null is not possible - */ - public static CompositeCommand getChooseGraphicalChildrenNotificationCommand(List allChildren, List automaticChildren, CreateViewAndElementRequest request, TransactionalEditingDomain domain, String label, IGraphicalEditPart getHost, DiagramEditPart diagramPart) { - if(allChildren.size() > automaticChildren.size()) { - Iterator descriptors = request.getViewDescriptors().iterator(); - CompositeCommand compositeCommand = new CompositeCommand(label); - while(descriptors.hasNext()) { - CreateViewRequest.ViewDescriptor descriptor = (CreateViewRequest.ViewDescriptor)descriptors.next(); - ChooseChildrenNotificationCommand cmd = new ChooseChildrenNotificationCommand(domain, label, allChildren, automaticChildren, descriptor, getHost, diagramPart); - if(cmd != null) { - compositeCommand.compose(cmd); - } - } - return compositeCommand; - } - return null; - } - - /** - * @see #getChooseGraphicalChildrenNotificationCommand(List, List, CreateViewAndElementRequest, TransactionalEditingDomain, String, - * IGraphicalEditPart). - * This time the we directly give the IAdaptable element of the view - * @param allChildren - * @see #getChooseGraphicalChildrenNotificationCommand - * @param automaticChildren - * @see #getChooseGraphicalChildrenNotificationCommand - * @param adapter - * IAdaptable of the parent group (Used to get the view) - * @param domain - * @see #getChooseGraphicalChildrenNotificationCommand - * @param label - * @see #getChooseGraphicalChildrenNotificationCommand - * @param getHost - * @see #getChooseGraphicalChildrenNotificationCommand - * @return - */ - public static CompositeCommand getChooseGraphicalChildrenNotificationCommand(List allChildren, List automaticChildren, IAdaptable adapter, TransactionalEditingDomain domain, String label, IGraphicalEditPart getHost, DiagramEditPart diagramPart) { - CompositeCommand result = null; - ChooseChildrenNotificationCommand cmd = new ChooseChildrenNotificationCommand(domain, label, allChildren, automaticChildren, adapter, getHost, diagramPart); - if(cmd != null) { - result = new CompositeCommand(label); - result.compose(cmd); - } - return result; - } - - /** - * Give back the command to handle visually contained elements inside a new group in creation - * 0 - Check if the there is any descriptor (its means if the element in creation belong to the Group Framework - * 1 - Compute possible children elements (graphical and model) - * 2 - Update References - * 3 - Update Model (if needed) - * 4 - Reassign automatic graphical parent - * 5 - Create a notification command to choose the graphical parent if needed - * - * @param descriptors - * Descriptor of the group in creation - * @param request - * General request - * @param nameObject - * Name of the object (to find default size FIXME) - * @param diagramPart - * EditPart of the diagram - * @param editingDomain - * TransctionnalEditingDomain in order to create transactionnal command - * @param parentAdapter - * Parent adapter (Use to get the EObject back after creation and the {@link IGraphicalEditPart}) - * @param modelParents - * @return the composite command of all this steps - */ - public static CompositeCommand getHandleChildrenCommand(Set descriptors, Request request, DiagramEditPart diagramPart, TransactionalEditingDomain editingDomain, IAdaptable parentAdapter, List modelParents, IGraphicalEditPart getHost) { - CompositeCommand cc = null; - //Do the following only if the created element is a group - if(!descriptors.isEmpty()) { - //Command label - String handleChildrenLabel = "Handle Children command ";//$NON-NLS-1$ - for(AbstractContainerNodeDescriptor descriptor : descriptors) { - /* - * Child visually contained in the new group which can be graphical children of this new group - */ - List directChildsToComplete = new ArrayList(); - /* - * Old child visually contained before the request ( used in changeBound request ) - */ - List oldDirectChildsToComplete = null; - /* - * Initialize the two list directChildsToComplete and oldDirectChildsToComplete - */ - oldDirectChildsToComplete = initDirectChildLists(request, diagramPart, parentAdapter, descriptor, directChildsToComplete, oldDirectChildsToComplete); - - if((directChildsToComplete != null && !directChildsToComplete.isEmpty()) || (oldDirectChildsToComplete != null && !oldDirectChildsToComplete.isEmpty())) { - cc = new CompositeCommand(handleChildrenLabel); - /* - * List of elements atomically chosen as graphical child - */ - List newGraphicalChildren = new ArrayList();; - /* - * List of elements on which the user should be asked to choose the graphical parent - */ - List choiceToMakeChildren = new ArrayList();; - for(IGraphicalEditPart part : directChildsToComplete) { - if(alreadyHaveGroupGraphicalParent(part, modelParents)) { - if(isNotAlreadyAGraphicalSon(part, request, parentAdapter)) { - choiceToMakeChildren.add(part); - } - } else { - newGraphicalChildren.add(part); - } - } - /* - * Command to update model of directChild which can be contain by the moving group - */ - if(!directChildsToComplete.isEmpty()) { - ChangeModelParentCommand updateChildrenModel = getUpdateChildrenModel(directChildsToComplete, descriptor, editingDomain, parentAdapter, directChildsToComplete.get(0)); - if(updateChildrenModel != null) { - cc.compose(updateChildrenModel); - } - } - /* - * Command to update visually contained element to set their graphical parent with the parent Adapter - */ - if(!newGraphicalChildren.isEmpty()) { - updateGraphicalChildren(newGraphicalChildren, request); - } - String updateCommandeLabel = "Update children references";//$NON-NLS-1$ - /* - * Update all graphical children references and model - */ - updateReferencesAndModelOfGraphicalChildren(request, editingDomain, parentAdapter, cc, directChildsToComplete, oldDirectChildsToComplete, handleChildrenLabel + ":" + updateCommandeLabel + " -> " + "update reference graphical child", getHost, descriptor); - /* - * Command to update references of new child - */ - UpdateReferencesCommand updateRefCommand = new UpdateReferencesCommand(editingDomain, handleChildrenLabel + ":" + updateCommandeLabel + " -> " + "update reference new child", directChildsToComplete, descriptor, parentAdapter); - if(updateRefCommand != null) { - cc.compose(updateRefCommand); - } - /* - * Withdraw old referenced child which are not anymore has to be referenced - */ - withdrawOldChildrenReferences(editingDomain, parentAdapter, cc, handleChildrenLabel + ":" + updateCommandeLabel + " -> " + "remove reference from of child", descriptor, directChildsToComplete, oldDirectChildsToComplete); - - /* - * Command to create the graphical notification - */ - String chooseGraphicalChildrenLabel = "Notification for choosing graphical children";//$NON-NLS-1$ - CompositeCommand chooseGraphicalChildrenCommand = null; - if(request instanceof CreateViewAndElementRequest) { - chooseGraphicalChildrenCommand = getChooseGraphicalChildrenNotificationCommand(directChildsToComplete, newGraphicalChildren, (CreateViewAndElementRequest)request, editingDomain, chooseGraphicalChildrenLabel, getHost, diagramPart); - } else if(request instanceof ChangeBoundsRequest) { - chooseGraphicalChildrenCommand = getChooseGraphicalChildrenNotificationCommand(directChildsToComplete, newGraphicalChildren, parentAdapter, editingDomain, chooseGraphicalChildrenLabel, getHost, diagramPart); - } - if(chooseGraphicalChildrenCommand != null) { - cc.compose(chooseGraphicalChildrenCommand); - } - - cc.reduce(); - if(cc.isEmpty()) { - cc = null; - } - } - - } - - } - - return cc; - } - - /** - * True if the request is just a movin request - * - * @param request - * @return - */ - private static boolean isMovingRequest(ChangeBoundsRequest request) { - return request.getSizeDelta() == null || request.getSizeDelta().equals(0, 0); - } - - - /*** - * Update all the graphical children from a model point of view and a reference poitn of view - * note: It also update the the lists childlist and oldchildlist. It will withdraw the from those list all graphical children if the reques tis a - * simple move. If the request is a resize then all the grazphical children has to be taken into accoutn for next changes - * - * @param request - * {@link ChangeBoundsRequest} - * @param editingDomain - * {@link TransactionalEditingDomain} - * @param parentAdapter - * Parent adapter used to get the {@link IGraphicalEditPart} of the parent - * @param cc - * {@link CompositeCommand} use to compose new commands - * @param childList - * List of all the visual child after transformation - * @param oldChildsList - * List of all the visual child before transformation - * @param updateCommandeLabel - * Label used to compose command - * @param getHost - * Host of the request - */ - private static void updateReferencesAndModelOfGraphicalChildren(Request request, TransactionalEditingDomain editingDomain, IAdaptable parentAdapter, CompositeCommand cc, List childList, List oldChildsList, String updateCommandeLabel, IGraphicalEditPart getHost, AbstractContainerNodeDescriptor descriptor) { - if(request instanceof ChangeBoundsRequest) { - Object _movingPart = parentAdapter.getAdapter(EditPart.class); - if(_movingPart instanceof IGraphicalEditPart) { - List graphicalChilds = new ArrayList(); - IGraphicalEditPart movingEditPart = (IGraphicalEditPart)_movingPart; - //Look for all graphical children - graphicalChilds = getGraphicalChild(movingEditPart); - /* - * For all graphical children - * if request = moving request - * -> Suppress old references - * -> change model parent if needed - * -> Add new references - * if request = resizing - * -> If the resizing is from west side - * - Translate the node to unmodify the GMF comportment of resizing by west = node moving - * -> If after resizing the node are no longer in the group - * - Unset references - * - Change graphical parent - */ - ChangeBoundsRequest changeBoundRequest = (ChangeBoundsRequest)request; - for(IGraphicalEditPart graphicalChild : graphicalChilds) { - /* - * All groups that contains the node before transforming ( transforming = moving or resizing ) - */ - - List oldGroupContainer = Utils.createComputeListsOfAllGroupContainerVisually(graphicalChild, changeBoundRequest, false, movingEditPart); - /* - * All groups that contains the node after transforming - */ - List newGroupContainer = Utils.createComputeListsOfAllGroupContainerVisually(graphicalChild, changeBoundRequest, true, movingEditPart); - IGraphicalEditPart compartmentEditPart = (IGraphicalEditPart)Utils.getCompartementEditPartFromMainEditPart(movingEditPart.getViewer().getEditPartRegistry(), movingEditPart); - /* - * If is a moving request - * => Then the node should move with the group - */ - if(isMovingRequest(changeBoundRequest)) - handleMovingRequestForGraphicalChildren(editingDomain, cc, updateCommandeLabel, getHost, graphicalChild, oldGroupContainer, newGroupContainer, compartmentEditPart); - else { - cc = handleResizingRequestForGraphicalChildren(editingDomain, parentAdapter, cc, childList, getHost, descriptor, movingEditPart, graphicalChild, changeBoundRequest, newGroupContainer); - } - } - /* - * Remove graphical children of the lists of node to handle - */ - childList.removeAll(graphicalChilds); - oldChildsList.removeAll(graphicalChilds); - } - } - - } - - /** - * Handle resizing request for all graphical children - * - Erase the moving children after resize from WEST/NORT WHEST/WEST - * - Handle children going out after resizing - * - * @param editingDomain - * {@link TransactionalEditingDomain} - * @param parentAdapter - * {@link Adaptable} use to get the {@link IGraphicalEditPart} of the parent at runtime - * @param cc - * {@link CompositeCommand} Use to add new Command - * @param childList - * List of all the visual child after transformation - * @param getHost - * Host of the request - * @param descriptor - * Descriptor of the group - * @param movingEditPart - * {@link IGraphicalEditPart} of the moving Edit Part (TODO Use the adapter to erase one argument) - * @param graphicalChild - * {@link IGraphicalEditPart} of the graphical child you want to handle - * @param changeBoundRequest - * {@link ChangeBoundsRequest} - * @param newGroupContainer - * All group which can contain the node after transforming - * @return - */ - private static CompositeCommand handleResizingRequestForGraphicalChildren(TransactionalEditingDomain editingDomain, IAdaptable parentAdapter, CompositeCommand cc, List childList, IGraphicalEditPart getHost, AbstractContainerNodeDescriptor descriptor, IGraphicalEditPart movingEditPart, IGraphicalEditPart graphicalChild, ChangeBoundsRequest changeBoundRequest, List newGroupContainer) { - /* - * If this is a resizing request. - * Node should not move => Only case possible = Graphical child which go out from the group - * -> Unmove node if resizing from west - * -> Handle no coming out - */ - - int direction = changeBoundRequest.getResizeDirection(); - Point previousnLocation = graphicalChild.getFigure().getBounds().getLocation().getCopy(); - Point negatedMoeDelta = changeBoundRequest.getMoveDelta().getNegated().getCopy(); - boolean correctLocation = false; - switch(direction) { - case org.eclipse.draw2d.PositionConstants.WEST: - previousnLocation.translate(negatedMoeDelta.x, 0); - correctLocation = true; - break; - case org.eclipse.draw2d.PositionConstants.NORTH: - previousnLocation.translate(0, negatedMoeDelta.y); - correctLocation = true; - break; - case org.eclipse.draw2d.PositionConstants.NORTH_WEST: - previousnLocation.translate(negatedMoeDelta); - correctLocation = true; - break; - default: - break; - } - - if(!childList.contains(graphicalChild)) { - if(correctLocation) { - newGroupContainer.remove(movingEditPart); - newGroupContainer.remove(Utils.getCompartementEditPartFromMainEditPart(movingEditPart.getViewer().getEditPartRegistry(), movingEditPart)); - correctLocation = false; - } - cc = handleGraphicalChildrenMovingOut(editingDomain, parentAdapter, cc, getHost, descriptor, movingEditPart, graphicalChild, newGroupContainer); - } - if(correctLocation) { - SetBoundsCommand sbc = new SetBoundsCommand(editingDomain, "West or North resizing correcting relative coordiante", graphicalChild, previousnLocation); - if(sbc != null) { - cc.compose(sbc); - } - } - return cc; - } - - /** - * Handle all the graphical children of a group after a moving request - * - * @param editingDomain - * {@link TransactionalEditingDomain} - * @param cc - * {@link CommandProxy} to compose new commands - * @param updateCommandeLabel - * Label Used for the command - * @param getHost - * Host of the request - * @param graphicalChild - * Graphical child to handle - * @param oldGroupContainer - * All group that contained the node before transforming - * @param newGroupContainer - * All group that contains the node after transforming - * @param compartmentEditPart - * Compartment EditPart of the parent EditPart - */ - private static void handleMovingRequestForGraphicalChildren(TransactionalEditingDomain editingDomain, CompositeCommand cc, String updateCommandeLabel, IGraphicalEditPart getHost, IGraphicalEditPart graphicalChild, List oldGroupContainer, List newGroupContainer, IGraphicalEditPart compartmentEditPart) { - { - /* - * Suppress old reference - */ - for(IGraphicalEditPart parentGroup : oldGroupContainer) { - if(!newGroupContainer.contains(parentGroup) && !parentGroup.equals(compartmentEditPart)) { - /* - * Unset the reference - */ - UpdateReferencesCommand cmd1 = new UpdateReferencesCommand(editingDomain, updateCommandeLabel, Collections.singletonList(graphicalChild), GroupContainmentRegistry.getContainerDescriptor(parentGroup), parentGroup, UpdateReferencesCommand.UNSET_MODE); - if(cmd1 != null) { - cc.compose(cmd1); - } - } - } - //List of all model parent available (except the compartment edit part) - List modelParents = new ArrayList(); - EObject childEObject = ((IGraphicalEditPart)graphicalChild).resolveSemanticElement(); - //Does the child have already a valid model parent - boolean alreadyHaveValideModelParent = false; - AbstractContainerNodeDescriptor containerDescriptor = GroupContainmentRegistry.getContainerDescriptor(compartmentEditPart); - //If compartmentEditPart refer to a group which can be model parent then the child already have a model parent - if(containerDescriptor != null) { - alreadyHaveValideModelParent = containerDescriptor.canIBeModelParentOf(childEObject.eClass()); - } - //Add new reference and update model - for(IGraphicalEditPart newParentGroup : newGroupContainer) { - //set Reference - UpdateReferencesCommand cmd2 = new UpdateReferencesCommand(editingDomain, updateCommandeLabel, Collections.singletonList(graphicalChild), GroupContainmentRegistry.getContainerDescriptor(newParentGroup), newParentGroup, UpdateReferencesCommand.SET_MODE); - if(cmd2 != null) { - cc.compose(cmd2); - } - //Create a list of all model parent available. Set alreadyHaveValideModelParent to true if the child already have a model parent wich is on the new model parent - AbstractContainerNodeDescriptor desc = GroupContainmentRegistry.getContainerDescriptor(newParentGroup); - if(desc != null) { - if(desc.canIBeModelParentOf(childEObject.eClass())) { - modelParents.add(newParentGroup); - } - } - } - /* - * Do not have mode parent change it - */ - if(!alreadyHaveValideModelParent) { - Map child = null; - IGraphicalEditPart newModelParent = null; - if(!modelParents.isEmpty()) { - newModelParent = modelParents.get(0); - AbstractContainerNodeDescriptor newDesc = GroupContainmentRegistry.getContainerDescriptor(newModelParent); - if(newDesc != null && newModelParent != null) { - EReference ref = newDesc.getContainmentReferenceFor(childEObject.eClass()); - child = Collections.singletonMap(childEObject, ref); - } - } else { - DefaultModelParent parent = Utils.getDefaultModelParent(childEObject.eClass(), getHost); - child = Collections.singletonMap(childEObject, parent.geteReference()); - newModelParent = parent.getiGraphicalEditPart(); - } - if(child != null && newModelParent != null) { - ChangeModelParentCommand changeModelParent = new ChangeModelParentCommand(editingDomain, newModelParent, child, newModelParent); - if(changeModelParent != null) { - cc.compose(changeModelParent); - } - } - } - } - } - - /** - * Handle children movign out from a group after resizing - * - * @param editingDomain - * {@link TransactionalEditingDomain} - * @param parentAdapter - * Parent adapter to get the {@link IGraphicalEditPart} at runtime - * @param cc - * {@link CompositeCommand} use to compose new commande - * @param getHost - * Host of the request - * @param descriptor - * AbstractContainerNodeDescriptor of the parent - * @param movingEditPart - * {@link IGraphicalEditPart} of the parent - * @param graphicalChild - * All graphical children of the group - * @param newGroupContainer - * Group that containt the node after transforming - * @return - */ - private static CompositeCommand handleGraphicalChildrenMovingOut(TransactionalEditingDomain editingDomain, IAdaptable parentAdapter, CompositeCommand cc, IGraphicalEditPart getHost, AbstractContainerNodeDescriptor descriptor, IGraphicalEditPart movingEditPart, IGraphicalEditPart graphicalChild, List newGroupContainer) { - String label = Messages.CommandsUtils_HandleGraphicalChildrenMovingOut_Label; - if(cc == null) { - cc = new CompositeCommand(label); - } - UpdateReferencesCommand updateRefCommand = new UpdateReferencesCommand(editingDomain, label, Collections.singletonList(graphicalChild), descriptor, parentAdapter, UpdateReferencesCommand.UNSET_MODE); - if(updateRefCommand != null) { - cc.compose(updateRefCommand); - } - IGraphicalEditPart newParent = null; - if(!newGroupContainer.isEmpty()) { - newParent = newGroupContainer.get(0); - } else { - newParent = (IGraphicalEditPart)movingEditPart.getParent(); //here add a default parent - } - /* - * FIXME - * Change - * Test is it is a containing feature - * Then change containing parent - */ - ChangeGraphicalParentCommand changeParentCmd = new ChangeGraphicalParentCommand(editingDomain, label + ": Changing graphical parent", newParent, graphicalChild, getHost); - if(changeParentCmd != null) { - cc.compose(changeParentCmd); - } - return cc; - } - - - /** - * Get all {@link IGraphicalEditPart} which are graphical children from a {@link IGraphicalEditPart} parent - * - * @param parentEditPart - * {@link IGraphicalEditPart} parent - * @return A {@link List} of {@link IGraphicalEditPart} of all the child and null parent part is not set properly - */ - private static List getGraphicalChild(IGraphicalEditPart parentEditPart) { - EditPartViewer viewer = null; - List result = null; - if(parentEditPart != null) { - viewer = parentEditPart.getViewer(); - if(viewer != null) { - IGraphicalEditPart compartmentEditPart = (IGraphicalEditPart)Utils.getCompartementEditPartFromMainEditPart(viewer.getEditPartRegistry(), parentEditPart); - result = new ArrayList(); - for(Object child : compartmentEditPart.getChildren()) { - if(child instanceof IGraphicalEditPart && GroupContainmentRegistry.isNodeConcerned((IGraphicalEditPart)child)) { - result.add((IGraphicalEditPart)child); - } - } - } - } - return result; - } - - - /** - * Initialize the two list directChildsToComplete and oldDirectChildsToComplete in order to get back all the child visually contained after et - * before the request - * - * @param request - * {@link Request} send by the system (for now handle {@link CreateViewAndElementRequest} and {@link ChangeBoundsRequest}) - * @param diagramPart - * EditPart on the diagram - * @param parentAdapter - * {@link IAdaptable} of the parent group (used to get the {@link IGraphicalEditPart} and {@link View}) - * @param descriptor - * {@link AbstractContainerNodeDescriptor} of the parent group - * @param directChildsToComplete - * List of all elements which can be graphical child after the request - * @param oldDirectChildsToComplete - * List of all elements which were graphical child before the request - * @return oldDirectChildsToComplete or null if not needed ( in case of {@link CreateViewAndElementRequest}) - */ - private static List initDirectChildLists(Request request, IGraphicalEditPart diagramPart, IAdaptable parentAdapter, AbstractContainerNodeDescriptor descriptor, List directChildsToComplete, List oldDirectChildsToComplete) { - if(request instanceof CreateViewAndElementRequest) { - Utils.createComputedListsOfVisualYRelatedElements(directChildsToComplete, (CreateViewAndElementRequest)request, diagramPart, descriptor); - } else if(request instanceof ChangeBoundsRequest) { - Object _parentEditPart = parentAdapter.getAdapter(IGraphicalEditPart.class); - if(_parentEditPart instanceof IGraphicalEditPart) { - oldDirectChildsToComplete = new ArrayList(); - Utils.createComputedListsOfVisuallyRelatedElements(directChildsToComplete, (ChangeBoundsRequest)request, (IGraphicalEditPart)_parentEditPart, descriptor, true); - Utils.createComputedListsOfVisuallyRelatedElements(oldDirectChildsToComplete, (ChangeBoundsRequest)request, (IGraphicalEditPart)_parentEditPart, descriptor, false); - } - } - return oldDirectChildsToComplete; - } - - /** - * Withdraw all references of element which are no longer contained in the group. - * With graphically all the children which are not visually contained in the group - * - * @param editingDomain - * {@link TransactionalEditingDomain} - * @param parentAdapter - * {@link IAdaptable} of the parent group - * @param cc - * {@link CompositeCommand} to compose command the new command. (This command will be completed). If cc est nul then a new CompositeCommand - * is created - * @param handleChildrenLabel - * Label for the command - * @param descriptor - * {@link AbstractContainerNodeDescriptor} of the parent group - * @param directChildsToComplete - * List of all new element which are visually contained in the parent group - * @param oldDirectChildsToComplete - * List of all element which were visually contained in the parent group - * @return return the composite command or null is no command is in cc - */ - private static CompositeCommand withdrawOldChildrenReferences(TransactionalEditingDomain editingDomain, IAdaptable parentAdapter, CompositeCommand cc, String handleChildrenLabel, AbstractContainerNodeDescriptor descriptor, List directChildsToComplete, List oldDirectChildsToComplete) { - if(oldDirectChildsToComplete != null && !oldDirectChildsToComplete.isEmpty()) { - List childToWithdraw = new ArrayList(); - for(IGraphicalEditPart child : oldDirectChildsToComplete) { - if(!directChildsToComplete.contains(child)) { - childToWithdraw.add(child); - } - } - if(!childToWithdraw.isEmpty()) { - String unreferencinComandLabel = "Unset Reference"; - if(cc == null) { - cc = new CompositeCommand(handleChildrenLabel + ":" + unreferencinComandLabel); - } - UpdateReferencesCommand updateRefCommand = new UpdateReferencesCommand(editingDomain, handleChildrenLabel + ":" + unreferencinComandLabel, childToWithdraw, descriptor, parentAdapter, UpdateReferencesCommand.UNSET_MODE); - if(updateRefCommand != null) { - cc.compose(updateRefCommand); - } - - } - cc.reduce(); - if(cc.isEmpty()) { - cc = null; - } - - } - return cc; - } - - private static boolean isNotAlreadyAGraphicalSon(IGraphicalEditPart childPart, Request request, IAdaptable parentAdapter) { - if(request instanceof ChangeBoundsRequest) { - Object _editPart = parentAdapter.getAdapter(EditPart.class); - if(_editPart instanceof IGraphicalEditPart) { - IGraphicalEditPart parentPart = (IGraphicalEditPart)_editPart; - return !parentPart.getChildren().contains(childPart); - } - } - - return true; - } - - - /** - * Set in the reqest the current Graphical parent and the current Model Parent - * - * @param request - * request change want to set - * @param _graphicalParents - * List of all graphical parent available - * @param _modelParents - * List of all Model parent available - * @param getHost - * host of the edit policy - * @return Return the default graphical parent - */ - public static IGraphicalEditPart setRequestParentsParameters(Request request, List _graphicalParents, List _modelParents, EditPart getHost) { - /* - * Choose the default graphical parent - * 1 - If no graphical parent found then the host become the graphical parent - * else by default the the graphical parent of the list become the graphical parent - */ - IGraphicalEditPart graphicalParent = null; - if(!_graphicalParents.isEmpty()) { - graphicalParent = _graphicalParents.get(0); - - request.getExtendedData().put(GroupRequestConstants.GRAPHICAL_CONTAINERS, _graphicalParents); - } - if(_modelParents != null) { - request.getExtendedData().put(GroupRequestConstants.MODEL_CONTAINERS, _modelParents); - } - - - - return graphicalParent; - } - - /** - * Send the request to a suitable host. A suitable host is a host which can be a model parent of the editing element. This implementation allow - * you to deal with creation request - * - * @param request - * CreateViewAndElementRequest of the element in creation - * @param createElementRequest - * CreateElementRequest of the element in creation - * @param getHost - * Host of the editPolicy - * @param _modelParents - * All model parent available - * @return - */ - public static Command sendRequestSuitableHost(CreateViewAndElementRequest request, CreateElementRequest createElementRequest, IGraphicalEditPart getHost, List _modelParents) { - EObject modelContainer = null; - //If the system has found model parent - if(!_modelParents.isEmpty()) { - IGraphicalEditPart defaultGraphicalEditPart = _modelParents.get(0); - //If the current host is different the first element on the modelParent list the system send the request to its edit part - if(!getHost.equals(defaultGraphicalEditPart)) { - request.getExtendedData().put(NEW_PARENT_HOST, defaultGraphicalEditPart); - return defaultGraphicalEditPart.getCommand(request); - } - modelContainer = getHost.resolveSemanticElement(); - createElementRequest.setContainer(modelContainer); - } else { - /* - * If there is no model found for this element we use the default element - */ - Command cmd = getCommandFromDefaultModelParent(request, createElementRequest, getHost); - if(cmd != null) { - return cmd; - } - } - return null; - } - - /** - * Send the request to a suitable host. A suitable host is a host which can be a model parent of the editing element. This implementation allow - * you to deal with {@link ChangeBoundsRequest} - * - * @param request - * {@link ChangeBoundsRequest} - * @param getHost - * {@link EditPart} host of the {@link EditPolicy} - * @param _modelParents - * List of all {@link IGraphicalEditPart} which can be model parent of the moving element - * @param movingEditPart - * The {@link IGraphicalEditPart} of the moving {@link EditPart} - * @return - */ - public static Command sendRequestSuitableHost(ChangeBoundsRequest request, IGraphicalEditPart getHost, List _modelParents, IGraphicalEditPart movingEditPart) { - //If the system has found model parent - if(!_modelParents.isEmpty()) { - IGraphicalEditPart defaultModelParentEditPart; - //TODO redo tests with this - if(_modelParents.contains(movingEditPart.getParent())) { - defaultModelParentEditPart = (IGraphicalEditPart)movingEditPart.getParent(); - } else { - defaultModelParentEditPart = _modelParents.get(0); - } - //If the current host is different the first element on the modelParent list the system send the request to its edit part - if(!getHost.equals(defaultModelParentEditPart)) { - return defaultModelParentEditPart.getCommand(request); - } - - } else { - /* - * If there is no model found for this element we use the default element - * FIXME 1 - Check the safety of editParts.get(0) . Try to move several element in the same time - */ - - Command cmd = getCommandFromDefaultModelParent(request, movingEditPart, getHost); - if(cmd != null) { - return cmd; - } - - } - return null; - } - - /** - * This method handle request with multiple EditPart ( @see {@link ChangeBoundsRequest#getEditParts()} ). - * It will handle it by creating as many request as {@link EditPart} in {@link ChangeBoundsRequest#getEditParts()} and ask the host to handle it. - * - * @param request - * {@link ChangeBoundsRequest} - * @param label - * label of the resulting command if any - * @param getHost - * Host of the editPolicy - * @return Return the composite command if any. Null it the request has less than 2 edit part - */ - public static Command requestEditPartMultiplexor(ChangeBoundsRequest request, String label, IGraphicalEditPart getHost) { - CompositeCommand result = new CompositeCommand(label); - if(request.getEditParts().size() > 1) { - for(Object part : request.getEditParts()) { - ChangeBoundsRequest req = new ChangeBoundsRequest(); - req.setEditParts(Collections.singletonList(part)); - req.setMoveDelta(request.getMoveDelta()); - req.setSizeDelta(request.getSizeDelta()); - req.setLocation(request.getLocation()); - req.setResizeDirection(request.getResizeDirection()); - req.setCenteredResize(request.isCenteredResize()); - req.setConstrainedMove(request.isConstrainedMove()); - req.setConstrainedResize(request.isConstrainedResize()); - req.setSnapToEnabled(request.isSnapToEnabled()); - req.setType(RequestConstants.REQ_RESIZE_CHILDREN); - HashMap extendedData = new HashMap(request.getExtendedData()); - req.setExtendedData(extendedData); - // Command cmd = getHost.getCommand(req); - Command cmd = getHost.getEditPolicy(EditPolicy.LAYOUT_ROLE).getCommand(req); - if(cmd != null) { - result.compose(new CommandProxy(cmd)); - } - } - if(!result.isEmpty()) { - return new ICommandProxy(result); - } - } - return null; - } - - /** - * Compose the command to change the graphical parent - * - * @param label - * Label of the command - * @param result - * Resulting composite command - * @param movingEditPart - * The {@link IGraphicalEditPart} which is moving - * @param editingDomain - * {@link TransactionalEditingDomain} use to create Transactionnal Command - * @param graphicalParent - * The new graphical parent - * @param request - */ - public static void getChangeGraphicalParentCommand(String label, CompositeCommand result, IGraphicalEditPart movingEditPart, TransactionalEditingDomain editingDomain, IGraphicalEditPart graphicalParent, IGraphicalEditPart getHost, ChangeBoundsRequest request) { - if(graphicalParent != null) { - ChangeGraphicalParentCommand changeGraphicalParent = new ChangeGraphicalParentCommand(editingDomain, label + ": change graphical parent", graphicalParent, movingEditPart, (IGraphicalEditPart)getHost, request); - if(changeGraphicalParent != null) { - changeGraphicalParent.setMode(Mode.MOVE_CHILD); - result.compose(changeGraphicalParent); - } - } else { - ChangeGraphicalParentCommand changeGraphicalParent = new ChangeGraphicalParentCommand(editingDomain, label + ": change graphical parent", (IGraphicalEditPart)getHost, movingEditPart, (IGraphicalEditPart)getHost, request); - if(changeGraphicalParent != null) { - changeGraphicalParent.setMode(Mode.MOVE_CHILD); - result.compose(changeGraphicalParent); - } - } - } - - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/GroupNotificationBuilderFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/GroupNotificationBuilderFactory.java deleted file mode 100644 index 33f9394e8db..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/GroupNotificationBuilderFactory.java +++ /dev/null @@ -1,90 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * 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 Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.diagram.common.groups.core; - -import org.eclipse.emf.common.command.Command; -import org.eclipse.papyrus.diagram.common.groups.core.ui.CompositeCreatorWithCommand; -import org.eclipse.papyrus.ui.toolbox.notification.Type; -import org.eclipse.papyrus.ui.toolbox.notification.builders.NotificationBuilder; - -/** - * This class builds all the necessary notifications for the group framework. - * It allows to recover configured, ready to run, notification builders. - * - * @author vhemery - */ -public class GroupNotificationBuilderFactory { - - /** - * This class allow to recover a NotificationBuilder and a command defined by the notification execution. - */ - public static class NotificationBuilderAndResultingCommand { - - private NotificationBuilder builder; - - private CompositeCreatorWithCommand creator; - - public NotificationBuilderAndResultingCommand(NotificationBuilder notificationBuilder, CompositeCreatorWithCommand creatorWithCommand) { - builder = notificationBuilder; - creator = creatorWithCommand; - } - - public NotificationBuilder getBuilder() { - return builder; - } - - public Command getResultingCommand() { - return creator.getResultingCommand(); - } - - public CompositeCreatorWithCommand getCreator() { - return creator; - } - } - - /** - * Create a simple notification builder from a label - * - * @param label - * Title of your notification - * @return a NotificationBuilder - */ - public static NotificationBuilder getQuestionBuilder(String label) { - NotificationBuilder builder = NotificationBuilder.createInformationBuilder(); - builder.setType(Type.QUESTION); - builder.setTemporary(true); - builder.setAsynchronous(true); - builder.setTitle(label); - return builder; - - } - - /** - * Create a simple warning notification builder from a label - * - * @param label - * Title of your notification - * @return a NotificationBuilder - */ - public static NotificationBuilder getWarningBuilder(String label) { - NotificationBuilder builder = NotificationBuilder.createInformationBuilder(); - builder.setType(Type.WARNING); - builder.setTemporary(true); - builder.setAsynchronous(true); - builder.setTitle(label); - return builder; - - } - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/PendingGroupNotificationsManager.java b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/PendingGroupNotificationsManager.java deleted file mode 100644 index 9cdd59df424..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/PendingGroupNotificationsManager.java +++ /dev/null @@ -1,181 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * 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 Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.diagram.common.groups.core; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.papyrus.diagram.common.groups.core.ui.ChooseChildrenNotificationConfigurator; -import org.eclipse.papyrus.diagram.common.groups.core.ui.ChooseParentNotificationConfigurator; -import org.eclipse.papyrus.diagram.common.groups.core.ui.NotificationConfigurator; -import org.eclipse.papyrus.ui.toolbox.notification.INotification; - -/** - * The pending group notifications manager handles notifications which have not been resolved. - * It ensures that notifications are reconducted in the next notification and that old notifications are deleted. - * - * @author vhemery - */ -public class PendingGroupNotificationsManager { - - /** the instances */ - private static Map instances = new HashMap(); - - private DiagramEditPart diagramEditPart = null; - - private Map chooseParentNotifications = new HashMap(); - - private HashMap chooseChildrenNotifications = new HashMap(); - - private PendingGroupNotificationsManager(DiagramEditPart diagramPart) { - diagramEditPart = diagramPart; - } - - /** - * Delete this manager and its external references. - */ - public void delete() { - chooseParentNotifications.clear(); - chooseChildrenNotifications.clear(); - instances.remove(diagramEditPart); - diagramEditPart = null; - - } - - /** - * Access to an existing instance or create a new one for an active diagram - * - * @param diagramPart - * the active diagram part - * @return the PendingGroupNotificationsManager instance for the active diagram or null if the diagram is unactive - */ - public static PendingGroupNotificationsManager getInstanceForDiagram(DiagramEditPart diagramPart) { - if(diagramPart.isActive()) { - if(!instances.containsKey(diagramPart)) { - PendingGroupNotificationsManager instance = new PendingGroupNotificationsManager(diagramPart); - instances.put(diagramPart, instance); - return instance; - } else { - return instances.get(diagramPart); - } - } else { - return null; - } - } - - /** - * Delete the PendingGroupNotificationsManager instance corresponding to this diagram part - * - * @param diagramPart - * the diagram edit part - */ - public static void removeInstanceForDiagram(DiagramEditPart diagramPart) { - if(instances.containsKey(diagramPart)) { - instances.get(diagramPart).delete(); - } - } - - /** - * Update the map and delete the no longer needed notifications. - * The old notification entries are added to the map, unneccessary entries are removed. - * - * @param movedPartsAndParents - * the map with moved parts and their parent groups - */ - // public void updateParentAssignementsMap(Map> movedPartsAndParents) { - // Set newlyMovedParts = movedPartsAndParents.keySet(); - // if(newlyMovedParts.size() > 0) { - // // the parent assignment from the same diagram must be combined - // // 1. report unchanged assignments in the new map - // Map copy = new HashMap(chooseParentNotifications); - // for(Entry creatorEntry : copy.entrySet()) { - // if(!creatorEntry.getKey().isDeleted()) { - // // report - // ChooseContainingGroupCreator creator = creatorEntry.getValue(); - // Map> previousAssignement = creator.getElementsAndParents(); - // Set oldlyMovedParts = new HashSet(previousAssignement.keySet()); - // oldlyMovedParts.removeAll(newlyMovedParts); - // for(IGraphicalEditPart partToReport : oldlyMovedParts) { - // // do not report orphan parts - // if(partToReport.getParent() != null) { - // movedPartsAndParents.put(partToReport, previousAssignement.get(partToReport)); - // } - // } - // } else { - // // remove deleted notification from manager - // chooseParentNotifications.remove(creatorEntry.getKey()); - // } - // } - // // 2. delete old notification - // removeChooseParentNotification(); - // } - // // clean useless assignments with only one parent - // for(Entry> entry : new HashMap>(movedPartsAndParents).entrySet()) { - // if(entry.getValue().size() < 2) { - // movedPartsAndParents.remove(entry.getKey()); - // } - // } - // } - - /** - * Remove notifications to assign the graphical parent group - */ - public void removeChooseParentNotification(IGraphicalEditPart childEditPart) { - chooseParentNotifications.remove(childEditPart); - } - - /** - * Remove notification to assign a group's graphical children - * - * @param parentGroup - * the group - */ - public void removeChooseChildrenNotification(IGraphicalEditPart parentGroup) { - chooseChildrenNotifications.remove(parentGroup); - } - - - - /** - * Store a notification and its composite creator to let it be managed - * - * @param creator - * the composite creator - * @param notification - * the notification - */ - public void storeNotification(NotificationConfigurator configurator) { - if(configurator instanceof ChooseParentNotificationConfigurator) { - chooseParentNotifications.put(((ChooseParentNotificationConfigurator)configurator).getMainEditPart(), configurator); - } else if(configurator instanceof ChooseChildrenNotificationConfigurator) { - chooseChildrenNotifications.put(((ChooseChildrenNotificationConfigurator)configurator).getMainEditPart(), configurator); - } - } - - /** - * Get the {@link INotification} for choosing the children of an edit and return null is there none - * - * @param parentEditPart - * @return - */ - public NotificationConfigurator getChooseChildrenPendingNotification(IGraphicalEditPart parentEditPart) { - if(chooseChildrenNotifications.containsKey(parentEditPart)) { - return chooseChildrenNotifications.get(parentEditPart); - } else { - return null; - } - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/groupcontainment/GroupContainmentRegistry.java b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/groupcontainment/GroupContainmentRegistry.java deleted file mode 100644 index b9caf4e3bd5..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/groupcontainment/GroupContainmentRegistry.java +++ /dev/null @@ -1,268 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * 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 Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.diagram.common.groups.core.groupcontainment; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.diagram.common.groups.groupcontainment.AbstractContainerNodeDescriptor; - - -/** - * This registry recovers information from the extensions for the GroupContainment point. - * - * @author vhemery - */ -public class GroupContainmentRegistry { - - /** The GroupContainment extension point id */ - private static final String GROUP_EXTENSION_POINT = "org.eclipse.papyrus.diagram.common.groups.groupcontainment"; - - /** The name of the extension node for model containment */ - private static final String MODEL_CONTAINER_NODE = "modelContainer"; - - /** The name of the extension node for graphical container with model reference */ - private static final String REFERENCE_CONTAINER_NODE = "referenceContainer"; - - /** The name of the descriptor attribute */ - private static final String CONTAINER_DESCRIPTOR_ATTRIBUTE = "descriptor"; - - /** The name of the edit part type attribute */ - private static final String EDIT_PART_TYPE_ATTRIBUTE = "editPartType"; - - /** The map of descriptors for model containers, by type of edit part */ - private static Map modelContainersDescriptors = new HashMap(); - - /** The map of descriptors for graphical containers only, by type of edit part */ - private static Map graphicalContainersDescriptors = new HashMap(); - - /** The map of descriptor allowing to recover the group part from a view, by view type */ - private static Map descriptorForViewType = new HashMap(); - - - /** - * Initialize the values from the extension point - */ - static { - initialize(); - } - - /** - * Load all extensions and register the container descriptors - */ - public static void initialize() { - // Load extensions of edit part mapping - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = registry.getExtensionPoint(GROUP_EXTENSION_POINT); - for(IExtension extension : extensionPoint.getExtensions()) { - for(IConfigurationElement providing : extension.getConfigurationElements()) { - if(MODEL_CONTAINER_NODE.equals(providing.getName())) { - String editPartType = providing.getAttribute(EDIT_PART_TYPE_ATTRIBUTE); - if(editPartType != null) { - try { - Object provider = providing.createExecutableExtension(CONTAINER_DESCRIPTOR_ATTRIBUTE); - if(provider instanceof AbstractContainerNodeDescriptor) { - modelContainersDescriptors.put(editPartType, (AbstractContainerNodeDescriptor)provider); - } - } catch (CoreException e) { - // ignore this extension node - } - } - } else if(REFERENCE_CONTAINER_NODE.equals(providing.getName())) { - String editPartType = providing.getAttribute(EDIT_PART_TYPE_ATTRIBUTE); - if(editPartType != null) { - try { - Object provider = providing.createExecutableExtension(CONTAINER_DESCRIPTOR_ATTRIBUTE); - if(provider instanceof AbstractContainerNodeDescriptor) { - graphicalContainersDescriptors.put(editPartType, (AbstractContainerNodeDescriptor)provider); - } - } catch (CoreException e) { - // ignore this extension node - } - } - } - - } - } - } - - /** - * Get the AbstractContainerNodeDescriptor from a EClass - * - * @param containerEClass - * @return Set Return all the descriptor which match the corresponding EClass - */ - public static Set getDescriptorsWithContainerEClass(EClass containerEClass) { - Set descriptors = new HashSet(modelContainersDescriptors.size() + graphicalContainersDescriptors.size()); - Set descriptorsResult = new HashSet(modelContainersDescriptors.size() + graphicalContainersDescriptors.size()); - descriptors.addAll(modelContainersDescriptors.values()); - descriptors.addAll(graphicalContainersDescriptors.values()); - // filter descriptors - for(AbstractContainerNodeDescriptor descriptor : descriptors) { - if(descriptor.getContainerEClass().equals(containerEClass)) { - descriptorsResult.add(descriptor); - } - } - return descriptorsResult; - } - - /** - * Get all the references which can point to a group - * - * @return give back a set of ERefences pointing at group - */ - public static Set getAllERefencesFromNodeToGroup() { - Set referencesResult = new HashSet(); - Set descriptors = new HashSet(modelContainersDescriptors.size() + graphicalContainersDescriptors.size()); - descriptors.addAll(modelContainersDescriptors.values()); - descriptors.addAll(graphicalContainersDescriptors.values()); - for(AbstractContainerNodeDescriptor descriptor : descriptors) { - for(EReference ref : descriptor.getChildrenReferences()) { - EReference eoppositeRef = ref.getEOpposite(); - if(eoppositeRef != null) { - referencesResult.add(eoppositeRef); - } - } - - } - return referencesResult; - } - - /** - * Know whether the edit part is concerned by the group framework, which means there is a container descriptor for its class. - * - * @param editPart - * the edit part to test - * @return true if there is a descriptor - */ - public static boolean isContainerConcerned(IGraphicalEditPart editPart) { - if(editPart == null) { - return false; - } - String editPartClassName = editPart.getClass().getCanonicalName(); - return modelContainersDescriptors.containsKey(editPartClassName) || graphicalContainersDescriptors.containsKey(editPartClassName); - } - - /** - * Return true it the element pointed by the EditPart is a node whicj=h is concerned by the framework - * - * @param editPart - * of EObject you want to test - * @return - */ - public static boolean isNodeConcerned(IGraphicalEditPart editPart) { - EClass current = editPart.resolveSemanticElement().eClass(); - Set allReferences = new HashSet(); - for(AbstractContainerNodeDescriptor nodeDesc1 : modelContainersDescriptors.values()) { - allReferences.addAll(nodeDesc1.getChildrenReferences()); - } - for(AbstractContainerNodeDescriptor nodeDesc2 : graphicalContainersDescriptors.values()) { - allReferences.addAll(nodeDesc2.getChildrenReferences()); - } - for(EReference ref : allReferences) { - if(ref.getEReferenceType().isSuperTypeOf(current)) { - return true; - } - } - return false; - } - - /** - * Get the group descriptor of the edit part concerned by the group framework. - * Warning the edit part has to be exactly the same than the one register in the extension point. - * For example in the case of Activity Diagram. Onlu the compartment edit Part are register. - * - * @param editPart - * the edit part to get descriptor of - * @return container node descriptor or null if none - */ - public static AbstractContainerNodeDescriptor getContainerDescriptor(IGraphicalEditPart editPart) { - String editPartClassName = editPart.getClass().getCanonicalName(); - if(modelContainersDescriptors.containsKey(editPartClassName)) { - return modelContainersDescriptors.get(editPartClassName); - } else if(graphicalContainersDescriptors.containsKey(editPartClassName)) { - return graphicalContainersDescriptors.get(editPartClassName); - } else { - return null; - } - } - - /** - * Know whether the edit part concerned by the group framework is a model container. - * - * @param editPart - * the edit part to test - * @return true if the container is a direct model container - */ - public static boolean isContainerModel(IGraphicalEditPart editPart) { - String editPartClassName = editPart.getClass().getCanonicalName(); - return modelContainersDescriptors.containsKey(editPartClassName); - } - - /** - * Get the group compartment part (containing children elements) from a view of the node - * - * @param view - * a view, either of the compartment, or the primary node view - * @param diagramPart - * the diagram edit part to recover parts from views - * @return the group compartment part or null if none is adequate for the group framework - */ - public static IGraphicalEditPart getGroupContainingPartFromView(View view, DiagramEditPart diagramPart) { - String viewType = view.getType(); - if(descriptorForViewType.containsKey(viewType)) { - // the appropriate descriptor has already been found for this view type - AbstractContainerNodeDescriptor desc = descriptorForViewType.get(viewType); - if(desc != null) { - return desc.getPartFromView(view, diagramPart); - } else { - return null; - } - } else { - // find the the appropriate descriptor for this view type - for(AbstractContainerNodeDescriptor desc : modelContainersDescriptors.values()) { - IGraphicalEditPart res = desc.getPartFromView(view, diagramPart); - if(res != null) { - // register for further use - descriptorForViewType.put(viewType, desc); - return res; - } - } - for(AbstractContainerNodeDescriptor desc : graphicalContainersDescriptors.values()) { - IGraphicalEditPart res = desc.getPartFromView(view, diagramPart); - if(res != null) { - // register for further use - descriptorForViewType.put(viewType, desc); - return res; - } - } - // register no result for further use - descriptorForViewType.put(viewType, null); - return null; - } - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/CheckboxIGraphicalFocusListenner.java b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/CheckboxIGraphicalFocusListenner.java deleted file mode 100644 index 91f87e441c8..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/CheckboxIGraphicalFocusListenner.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.eclipse.papyrus.diagram.common.groups.core.ui; - -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseTrackListener; -import org.eclipse.swt.graphics.RGB; - - -public class CheckboxIGraphicalFocusListenner implements MouseTrackListener { - - - private int oldColor, newColor; - - private View parentView; - - private TransactionalEditingDomain editingDomain; - - - public CheckboxIGraphicalFocusListenner(IGraphicalEditPart parent) { - super(); - this.parentView = (View)parent.getModel(); - newColor = FigureUtilities.RGBToInteger(new RGB(255, 0, 0)); - - } - - - public void mouseEnter(MouseEvent arg0) { - - // SetPropertyCommand changeColor = new SetPropertyCommand( editingDomain,"blabla",parentView,NotationPackage.Literals.LINE_STYLE,newColor); - } - - public void mouseExit(MouseEvent arg0) { - // LineStyle lineStyle = (LineStyle)parentView.getStyle(NotationPackage.Literals.LINE_STYLE); - // if(lineStyle != null) { - // // line color - // //RGB lineRGB = PreferenceConverter.getColor(store, preferenceLineColorName); - // newColor = lineStyle.getLineColor(); - // lineStyle.setLineColor(oldColor); - // } - - - } - - public void mouseHover(MouseEvent arg0) { - // TODO Auto-generated method stub - - } - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/ChooseChildrenNotificationConfigurator.java b/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/ChooseChildrenNotificationConfigurator.java deleted file mode 100644 index 78ff2e44dca..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.diagram.common.groups/src/org/eclipse/papyrus/diagram/common/groups/core/ui/ChooseChildrenNotificationConfigurator.java +++ /dev/null @@ -1,293 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin. - * - * - * 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 Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.diagram.common.groups.core.ui; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; -import org.eclipse.papyrus.diagram.common.groups.Messages; -import org.eclipse.papyrus.diagram.common.groups.commands.ChangeGraphicalParentCommand; -import org.eclipse.papyrus.diagram.common.groups.core.PendingGroupNotificationsManager; -import org.eclipse.papyrus.diagram.common.groups.core.ui.utils.CreatorUtils; -import org.eclipse.papyrus.ui.toolbox.notification.ICompositeCreator; -import org.eclipse.papyrus.ui.toolbox.notification.builders.IContext; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Widget; -import org.eclipse.ui.forms.widgets.FormText; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * Create a IComposite creator to ask the user to choose the graphical parent of a list of possible children - * and then run the command to change the graphical parent - * - * @author arthur daussy - * - */ -public class ChooseChildrenNotificationConfigurator extends NotificationConfigurator { - - /** - * EditPart of the parent - */ - private IGraphicalEditPart parentEditPart; - - /** - * All possible graphical children - */ - protected List allChildren; - - /** - * All children which are automatically chosen as graphical child - */ - protected List automaticChildren; - - /** - * buttons for children - */ - private Map childCheckBoxes; - - /** - * {@link EditPart} hosting the {@link EditPolicy} - */ - protected IGraphicalEditPart host; - - - /** - * Construct a {@link ICompositeCreator} in order to asked the user to choose children among a given list - * Constructor. - * - * @param parentEditPart - * EditPart of the parent (This part can be the {@link CompartmentEditPart} or the main {@link EditPart} of the element - * @param allChildren - * @see {@link #allChildren} - * @param automaticChildren - * @see {@link #automaticChildren} - */ - public ChooseChildrenNotificationConfigurator(IGraphicalEditPart parentEditPart, List allChildren, List automaticChildren, IGraphicalEditPart host, PendingGroupNotificationsManager manager) { - super(parentEditPart, manager, Messages.ChooseChildrenICompositeCreator_ChooseChildren, Mode.QUESTION_MODE); - this.parentEditPart = parentEditPart; - this.allChildren = allChildren; - this.automaticChildren = automaticChildren; - this.host = host; - this.childCheckBoxes = new HashMap(); - } - - /** - * Run the notification and create a changeGrazphicalParent for each selected element - * - * @see org.eclipse.papyrus.ui.toolbox.notification.NotificationRunnable#run(org.eclipse.papyrus.ui.toolbox.notification.builders.IContext) - * @param context - */ - public void run(IContext context) { - TransactionalEditingDomain editingDomain = mainEditPart.getEditingDomain(); - Set childrenUpdated = new HashSet(); - for(Button checkBoxButton : childCheckBoxes.keySet()) { - if(checkBoxButton.getSelection() && checkBoxButton.isEnabled()) { - IGraphicalEditPart childPart = childCheckBoxes.get(checkBoxButton); - if(!childrenUpdated.contains(childPart)) { - changeGraphicalParentOf(editingDomain, childPart); - childrenUpdated.add(childPart); - } - } - } - closeNotitfication(context); - } - - /** - * @param editingDomain - * @param childPart - */ - private void changeGraphicalParentOf(TransactionalEditingDomain editingDomain, IGraphicalEditPart childPart) { - String label = "Change graphical parent" + " of " + CreatorUtils.getLabel(childPart) + " to " + CreatorUtils.getLabel(mainEditPart); - ChangeGraphicalParentCommand cmd = new ChangeGraphicalParentCommand(editingDomain, label, mainEditPart, childPart, host); - if(cmd != null && cmd.canExecute()) { - //Execute the command - editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd)); - } - } - - /** - * - * @see org.eclipse.papyrus.ui.toolbox.notification.ICompositeCreator#createComposite(org.eclipse.swt.widgets.Composite, - * org.eclipse.ui.forms.widgets.FormToolkit) - * - * @param parent - * @param toolkit - * @return - */ - public Composite createComposite(Composite parent, FormToolkit toolkit) { - if(toolkit == null) { - toolkit = new FormToolkit(parent.getDisplay()); - } - Composite top = toolkit.createComposite(parent, SWT.NONE); - top.setLayout(new FormLayout()); - FormText textLabel = toolkit.createFormText(top, false); - textLabel.setText(Messages.ChooseParentNotificationCommand_ChooseGraphicalChildrenMessage + CreatorUtils.getLabel(mainEditPart) + " :", false, true); - FormData data = new FormData(); - textLabel.setLayoutData(data); - Control previousElement = textLabel; - /* - * Create for each parents a checkbox - */ - createCheckBoxes(toolkit, top, previousElement); - - - return top; - } - - /** - * Create all the check boxes needed. - * If child is automatically assign to this parent then it appeares but it is disable - * If a child has already a parent: - * If its parent is the current EditPart then it is selected - * If not then it is not selected - * - * @param toolkit - * @see {@link ICompositeCreator} - * @param top - * @see {@link ICompositeCreator} - * @param previousElement - * A control element under which the check boxes bill be displayed - */ - private void createCheckBoxes(FormToolkit toolkit, Composite top, Control previousElement) { - FormData data; - for(final IGraphicalEditPart child : allChildren) { - String label = CreatorUtils.getLabel(child); - Button checkBox = toolkit.createButton(top, label, SWT.CHECK); - //FIXME finish the MouseTrackLMistenner - // checkBox.addMouseTrackListener(new CheckboxIGraphicalFocusListenner(child)); - //If the child has already parentEditPart as graphical parent the notification will not display it - if(!child.getParent().equals(mainEditPart)) { - if(automaticChildren.contains(child)) { - checkBox.setSelection(true); - checkBox.setEnabled(false); - - } else { - checkBox.setSelection(false); - } - data = CreatorUtils.getFormDataUnder(previousElement); - checkBox.setLayoutData(data); - previousElement = checkBox; - childCheckBoxes.put(checkBox, child); - } - // add dispose listener to remove from handled widgets - checkBox.addDisposeListener(new DisposeListener() { - - /** - * Remove widget from handled ones - * - * @param e - * the dispose event - */ - public void widgetDisposed(DisposeEvent e) { - childCheckBoxes.remove(e.widget); - } - }); - - checkBox.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - Widget check = e.widget; - if(check instanceof Button) { - boolean selection = ((Button)check).getSelection(); - for(Button b : getAllButtonFor(child)) { - b.setSelection(selection); - } - } - } - - /** - * This method will return a list of all button referencing a {@link IGraphicalEditPart} - * - * @param child - * The {@link IGraphicalEditPart} of which you want to find the {@link Button} - * @return List of all button - */ - private List