From ae4b6349f545d41c386ca6a15c8ed0403ae55044 Mon Sep 17 00:00:00 2001
From: cletavernie
Date: Mon, 19 Mar 2012 14:26:52 +0000
Subject: 359058: [Refactoring - Architecture] Identify the layers and
sub-layers for the Papyrus architecture
https://bugs.eclipse.org/bugs/show_bug.cgi?id=359058
---
.../org.eclipse.papyrus.navigator/.classpath | 7 +
deprecated/org.eclipse.papyrus.navigator/.project | 28 +
.../.settings/org.eclipse.jdt.core.prefs | 7 +
.../META-INF/MANIFEST.MF | 33 ++
.../org.eclipse.papyrus.navigator/about.html | 28 +
.../org.eclipse.papyrus.navigator/build.properties | 7 +
.../icons/ModelExplorer.gif | Bin 0 -> 114 bytes
.../icons/etool16/duplicate.png | Bin 0 -> 663 bytes
.../icons/etool16/rename.gif | Bin 0 -> 922 bytes
.../icons/etool16/search.gif | Bin 0 -> 545 bytes
.../plugin.properties | 14 +
.../org.eclipse.papyrus.navigator/plugin.xml | 270 ++++++++++
...rg.eclipse.papyrus.navigator.actionHandler.exsd | 135 +++++
.../schema/providerAdapterFactory.exsd | 79 +++
.../eclipse/papyrus/navigator/ModelNavigator.java | 592 +++++++++++++++++++++
.../actions/AbstractCommonActionProvider.java | 79 +++
.../actions/AbstractSubmenuActionProvider.java | 112 ++++
.../navigator/actions/CloseAllDiagramsAction.java | 65 +++
.../navigator/actions/CloseDiagramAction.java | 44 ++
.../actions/CreateChildActionProvider.java | 125 +++++
.../navigator/actions/CreateDiagramAction.java | 86 +++
.../actions/CreateDiagramActionProvider.java | 51 ++
.../navigator/actions/DeleteDiagramAction.java | 77 +++
.../navigator/actions/DiagramActionProvider.java | 64 +++
.../navigator/actions/DuplicateDiagramAction.java | 87 +++
.../actions/EditingDomainActionProvider.java | 255 +++++++++
.../navigator/actions/GenericTransformAction.java | 101 ++++
.../actions/GenericTransformActionProvider.java | 187 +++++++
.../navigator/actions/GenericTransformer.java | 437 +++++++++++++++
.../navigator/actions/GroupChildrenAction.java | 58 ++
.../navigator/actions/OpenDiagramAction.java | 62 +++
.../navigator/actions/RemoveTypePrefixAction.java | 80 +++
.../navigator/actions/RenameDiagramAction.java | 66 +++
.../actions/RenameNamedElementAction.java | 142 +++++
.../navigator/actions/SearchElementAction.java | 48 ++
.../commands/EObjectInheritanceCopyCommand.java | 391 ++++++++++++++
.../navigator/dialog/InformationDialog.java | 124 +++++
.../navigator/dialog/NavigatorSearchDialog.java | 274 ++++++++++
.../navigator/dnd/CommonDragAdapterAssistant.java | 45 ++
.../navigator/dnd/CommonDropAdapterAssistant.java | 116 ++++
.../factory/DefaultEMFActionsFactory.java | 180 +++++++
.../navigator/factory/GroupableAdapterFactory.java | 71 +++
.../navigator/factory/IActionHandlerFactory.java | 82 +++
.../navigator/factory/RenameActionFactory.java | 100 ++++
.../navigator/filters/DiResourceFilter.java | 45 ++
.../HideAdditionalResourcesViewerFilter.java | 34 ++
.../filters/HideDiagramsViewerFilter.java | 34 ++
.../filters/HideEAnnotationsViewerFilter.java | 34 ++
.../HideProfileApplicationsViewerFilter.java | 34 ++
.../papyrus/navigator/internal/Activator.java | 93 ++++
.../navigator/internal/AdditionalResources.java | 51 ++
.../internal/ltk/DeleteModelParticipant.java | 143 +++++
.../navigator/internal/ltk/DirtyEditorChange.java | 146 +++++
.../internal/ltk/ModelParticipantHelpers.java | 128 +++++
.../internal/ltk/MoveModelParticipant.java | 112 ++++
.../navigator/internal/ltk/RenameModelChange.java | 272 ++++++++++
.../internal/ltk/RenameModelParticipant.java | 137 +++++
.../navigator/internal/utils/NavigatorUtils.java | 262 +++++++++
.../internal/utils/StereotypeApplicationUtils.java | 128 +++++
.../preferences/INavigatorPreferenceConstants.java | 27 +
.../NavigatorPreferenceInitializer.java | 41 ++
.../preferences/NavigatorPreferencePage.java | 57 ++
.../TransformCommandShowPopupDialogGroup.java | 67 +++
.../navigator/providers/EObjectPackagingNode.java | 124 +++++
.../providers/GroupableLabelProvider.java | 41 ++
.../GroupableTreeArrayContentProvider.java | 278 ++++++++++
.../navigator/providers/IContentProvider.java | 12 +
.../providers/NavigatorComposedAdapterFactory.java | 71 +++
.../providers/NoTypePrefixLabelDecorator.java | 122 +++++
.../papyrus/navigator/providers/PackagingNode.java | 58 ++
.../providers/ProviderAdapterFactoryReader.java | 57 ++
.../navigator/providers/ToEditorSaveable.java | 116 ++++
.../navigator/providers/UMLContentProvider.java | 271 ++++++++++
.../navigator/providers/UMLLabelProvider.java | 227 ++++++++
.../papyrus/navigator/sorters/UMLViewerSorter.java | 37 ++
.../org.eclipse.papyrus.navigator/.classpath | 7 -
.../others/org.eclipse.papyrus.navigator/.project | 28 -
.../.settings/org.eclipse.jdt.core.prefs | 7 -
.../META-INF/MANIFEST.MF | 33 --
.../org.eclipse.papyrus.navigator/about.html | 28 -
.../org.eclipse.papyrus.navigator/build.properties | 7 -
.../icons/ModelExplorer.gif | Bin 114 -> 0 bytes
.../icons/etool16/duplicate.png | Bin 663 -> 0 bytes
.../icons/etool16/rename.gif | Bin 922 -> 0 bytes
.../icons/etool16/search.gif | Bin 545 -> 0 bytes
.../plugin.properties | 14 -
.../org.eclipse.papyrus.navigator/plugin.xml | 270 ----------
...rg.eclipse.papyrus.navigator.actionHandler.exsd | 135 -----
.../schema/providerAdapterFactory.exsd | 79 ---
.../eclipse/papyrus/navigator/ModelNavigator.java | 592 ---------------------
.../actions/AbstractCommonActionProvider.java | 79 ---
.../actions/AbstractSubmenuActionProvider.java | 112 ----
.../navigator/actions/CloseAllDiagramsAction.java | 65 ---
.../navigator/actions/CloseDiagramAction.java | 44 --
.../actions/CreateChildActionProvider.java | 125 -----
.../navigator/actions/CreateDiagramAction.java | 86 ---
.../actions/CreateDiagramActionProvider.java | 51 --
.../navigator/actions/DeleteDiagramAction.java | 77 ---
.../navigator/actions/DiagramActionProvider.java | 64 ---
.../navigator/actions/DuplicateDiagramAction.java | 87 ---
.../actions/EditingDomainActionProvider.java | 255 ---------
.../navigator/actions/GenericTransformAction.java | 101 ----
.../actions/GenericTransformActionProvider.java | 187 -------
.../navigator/actions/GenericTransformer.java | 437 ---------------
.../navigator/actions/GroupChildrenAction.java | 58 --
.../navigator/actions/OpenDiagramAction.java | 62 ---
.../navigator/actions/RemoveTypePrefixAction.java | 80 ---
.../navigator/actions/RenameDiagramAction.java | 66 ---
.../actions/RenameNamedElementAction.java | 142 -----
.../navigator/actions/SearchElementAction.java | 48 --
.../commands/EObjectInheritanceCopyCommand.java | 391 --------------
.../navigator/dialog/InformationDialog.java | 124 -----
.../navigator/dialog/NavigatorSearchDialog.java | 274 ----------
.../navigator/dnd/CommonDragAdapterAssistant.java | 45 --
.../navigator/dnd/CommonDropAdapterAssistant.java | 116 ----
.../factory/DefaultEMFActionsFactory.java | 180 -------
.../navigator/factory/GroupableAdapterFactory.java | 71 ---
.../navigator/factory/IActionHandlerFactory.java | 82 ---
.../navigator/factory/RenameActionFactory.java | 100 ----
.../navigator/filters/DiResourceFilter.java | 45 --
.../HideAdditionalResourcesViewerFilter.java | 34 --
.../filters/HideDiagramsViewerFilter.java | 34 --
.../filters/HideEAnnotationsViewerFilter.java | 34 --
.../HideProfileApplicationsViewerFilter.java | 34 --
.../papyrus/navigator/internal/Activator.java | 93 ----
.../navigator/internal/AdditionalResources.java | 51 --
.../internal/ltk/DeleteModelParticipant.java | 143 -----
.../navigator/internal/ltk/DirtyEditorChange.java | 146 -----
.../internal/ltk/ModelParticipantHelpers.java | 128 -----
.../internal/ltk/MoveModelParticipant.java | 112 ----
.../navigator/internal/ltk/RenameModelChange.java | 272 ----------
.../internal/ltk/RenameModelParticipant.java | 137 -----
.../navigator/internal/utils/NavigatorUtils.java | 262 ---------
.../internal/utils/StereotypeApplicationUtils.java | 128 -----
.../preferences/INavigatorPreferenceConstants.java | 27 -
.../NavigatorPreferenceInitializer.java | 41 --
.../preferences/NavigatorPreferencePage.java | 57 --
.../TransformCommandShowPopupDialogGroup.java | 67 ---
.../navigator/providers/EObjectPackagingNode.java | 124 -----
.../providers/GroupableLabelProvider.java | 41 --
.../GroupableTreeArrayContentProvider.java | 278 ----------
.../navigator/providers/IContentProvider.java | 12 -
.../providers/NavigatorComposedAdapterFactory.java | 71 ---
.../providers/NoTypePrefixLabelDecorator.java | 122 -----
.../papyrus/navigator/providers/PackagingNode.java | 58 --
.../providers/ProviderAdapterFactoryReader.java | 57 --
.../navigator/providers/ToEditorSaveable.java | 116 ----
.../navigator/providers/UMLContentProvider.java | 271 ----------
.../navigator/providers/UMLLabelProvider.java | 227 --------
.../papyrus/navigator/sorters/UMLViewerSorter.java | 37 --
150 files changed, 8068 insertions(+), 8068 deletions(-)
create mode 100644 deprecated/org.eclipse.papyrus.navigator/.classpath
create mode 100644 deprecated/org.eclipse.papyrus.navigator/.project
create mode 100644 deprecated/org.eclipse.papyrus.navigator/.settings/org.eclipse.jdt.core.prefs
create mode 100644 deprecated/org.eclipse.papyrus.navigator/META-INF/MANIFEST.MF
create mode 100644 deprecated/org.eclipse.papyrus.navigator/about.html
create mode 100644 deprecated/org.eclipse.papyrus.navigator/build.properties
create mode 100644 deprecated/org.eclipse.papyrus.navigator/icons/ModelExplorer.gif
create mode 100644 deprecated/org.eclipse.papyrus.navigator/icons/etool16/duplicate.png
create mode 100644 deprecated/org.eclipse.papyrus.navigator/icons/etool16/rename.gif
create mode 100644 deprecated/org.eclipse.papyrus.navigator/icons/etool16/search.gif
create mode 100644 deprecated/org.eclipse.papyrus.navigator/plugin.properties
create mode 100644 deprecated/org.eclipse.papyrus.navigator/plugin.xml
create mode 100644 deprecated/org.eclipse.papyrus.navigator/schema/org.eclipse.papyrus.navigator.actionHandler.exsd
create mode 100644 deprecated/org.eclipse.papyrus.navigator/schema/providerAdapterFactory.exsd
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/ModelNavigator.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractCommonActionProvider.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractSubmenuActionProvider.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseAllDiagramsAction.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseDiagramAction.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateChildActionProvider.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateDiagramAction.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateDiagramActionProvider.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/DeleteDiagramAction.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/DiagramActionProvider.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/DuplicateDiagramAction.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/EditingDomainActionProvider.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GenericTransformAction.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GenericTransformActionProvider.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GenericTransformer.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GroupChildrenAction.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/OpenDiagramAction.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/RemoveTypePrefixAction.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/RenameDiagramAction.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/RenameNamedElementAction.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/SearchElementAction.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/commands/EObjectInheritanceCopyCommand.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dialog/InformationDialog.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dialog/NavigatorSearchDialog.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dnd/CommonDragAdapterAssistant.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dnd/CommonDropAdapterAssistant.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/DefaultEMFActionsFactory.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/GroupableAdapterFactory.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/IActionHandlerFactory.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/RenameActionFactory.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/DiResourceFilter.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideAdditionalResourcesViewerFilter.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideDiagramsViewerFilter.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideEAnnotationsViewerFilter.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideProfileApplicationsViewerFilter.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/Activator.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/AdditionalResources.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/DeleteModelParticipant.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/DirtyEditorChange.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/ModelParticipantHelpers.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/MoveModelParticipant.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/RenameModelChange.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/RenameModelParticipant.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/utils/NavigatorUtils.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/utils/StereotypeApplicationUtils.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/INavigatorPreferenceConstants.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/NavigatorPreferenceInitializer.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/NavigatorPreferencePage.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/TransformCommandShowPopupDialogGroup.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/EObjectPackagingNode.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/GroupableLabelProvider.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/GroupableTreeArrayContentProvider.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/IContentProvider.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/NavigatorComposedAdapterFactory.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/NoTypePrefixLabelDecorator.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/PackagingNode.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/ProviderAdapterFactoryReader.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/ToEditorSaveable.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/UMLContentProvider.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/UMLLabelProvider.java
create mode 100644 deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/sorters/UMLViewerSorter.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/.classpath
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/.project
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/.settings/org.eclipse.jdt.core.prefs
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/META-INF/MANIFEST.MF
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/about.html
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/build.properties
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/icons/ModelExplorer.gif
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/icons/etool16/duplicate.png
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/icons/etool16/rename.gif
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/icons/etool16/search.gif
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/plugin.properties
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/plugin.xml
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/schema/org.eclipse.papyrus.navigator.actionHandler.exsd
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/schema/providerAdapterFactory.exsd
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/ModelNavigator.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractCommonActionProvider.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractSubmenuActionProvider.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseAllDiagramsAction.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseDiagramAction.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateChildActionProvider.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateDiagramAction.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateDiagramActionProvider.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/DeleteDiagramAction.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/DiagramActionProvider.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/DuplicateDiagramAction.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/EditingDomainActionProvider.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GenericTransformAction.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GenericTransformActionProvider.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GenericTransformer.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GroupChildrenAction.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/OpenDiagramAction.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/RemoveTypePrefixAction.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/RenameDiagramAction.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/RenameNamedElementAction.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/SearchElementAction.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/commands/EObjectInheritanceCopyCommand.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dialog/InformationDialog.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dialog/NavigatorSearchDialog.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dnd/CommonDragAdapterAssistant.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dnd/CommonDropAdapterAssistant.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/DefaultEMFActionsFactory.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/GroupableAdapterFactory.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/IActionHandlerFactory.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/RenameActionFactory.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/DiResourceFilter.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideAdditionalResourcesViewerFilter.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideDiagramsViewerFilter.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideEAnnotationsViewerFilter.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideProfileApplicationsViewerFilter.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/Activator.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/AdditionalResources.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/DeleteModelParticipant.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/DirtyEditorChange.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/ModelParticipantHelpers.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/MoveModelParticipant.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/RenameModelChange.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/RenameModelParticipant.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/utils/NavigatorUtils.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/utils/StereotypeApplicationUtils.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/INavigatorPreferenceConstants.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/NavigatorPreferenceInitializer.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/NavigatorPreferencePage.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/TransformCommandShowPopupDialogGroup.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/EObjectPackagingNode.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/GroupableLabelProvider.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/GroupableTreeArrayContentProvider.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/IContentProvider.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/NavigatorComposedAdapterFactory.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/NoTypePrefixLabelDecorator.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/PackagingNode.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/ProviderAdapterFactoryReader.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/ToEditorSaveable.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/UMLContentProvider.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/UMLLabelProvider.java
delete mode 100644 plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/sorters/UMLViewerSorter.java
diff --git a/deprecated/org.eclipse.papyrus.navigator/.classpath b/deprecated/org.eclipse.papyrus.navigator/.classpath
new file mode 100644
index 00000000000..64c5e31b7a2
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/deprecated/org.eclipse.papyrus.navigator/.project b/deprecated/org.eclipse.papyrus.navigator/.project
new file mode 100644
index 00000000000..80f0f97e73b
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/.project
@@ -0,0 +1,28 @@
+
+
+ org.eclipse.papyrus.navigator
+
+
+
+
+
+ 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/deprecated/org.eclipse.papyrus.navigator/.settings/org.eclipse.jdt.core.prefs b/deprecated/org.eclipse.papyrus.navigator/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..66cb186456f
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Wed Feb 04 16:43:43 GMT+01:00 2009
+eclipse.preferences.version=1
+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/deprecated/org.eclipse.papyrus.navigator/META-INF/MANIFEST.MF b/deprecated/org.eclipse.papyrus.navigator/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..546bd9bf6b3
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/META-INF/MANIFEST.MF
@@ -0,0 +1,33 @@
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.ui.navigator;bundle-version="3.3.101",
+ org.eclipse.emf.ecore.editor;bundle-version="2.4.0",
+ org.eclipse.uml2.uml.editor;bundle-version="2.2.0",
+ org.eclipse.papyrus.infra.core;bundle-version="0.9.0";visibility:=reexport,
+ org.eclipse.papyrus.infra.core.sasheditor.di;bundle-version="0.9.0";visibility:=reexport,
+ org.eclipse.ltk.core.refactoring;bundle-version="3.5.0",
+ org.eclipse.emf.converter;bundle-version="2.5.0",
+ org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="0.9.0",
+ org.eclipse.emf.transaction;bundle-version="1.4.0",
+ org.eclipse.gmf.runtime.notation;bundle-version="1.5.0",
+ org.eclipse.gef;bundle-version="3.7.1",
+ org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0"
+Export-Package: org.eclipse.papyrus.navigator,
+ org.eclipse.papyrus.navigator.actions,
+ org.eclipse.papyrus.navigator.dialog,
+ org.eclipse.papyrus.navigator.dnd,
+ org.eclipse.papyrus.navigator.factory,
+ org.eclipse.papyrus.navigator.filters;uses:="org.eclipse.jface.viewers",
+ org.eclipse.papyrus.navigator.internal;x-internal:=true,
+ org.eclipse.papyrus.navigator.internal.utils;x-internal:=true,
+ org.eclipse.papyrus.navigator.providers,
+ org.eclipse.papyrus.navigator.sorters
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 0.9.0.qualifier
+Bundle-Localization: plugin
+Bundle-Name: %pluginName
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.navigator.internal.Activator
+Bundle-SymbolicName: org.eclipse.papyrus.navigator;singleton:=true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/deprecated/org.eclipse.papyrus.navigator/about.html b/deprecated/org.eclipse.papyrus.navigator/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/about.html
@@ -0,0 +1,28 @@
+
+
+
+
+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/deprecated/org.eclipse.papyrus.navigator/build.properties b/deprecated/org.eclipse.papyrus.navigator/build.properties
new file mode 100644
index 00000000000..8308a1ef92d
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/build.properties
@@ -0,0 +1,7 @@
+#
+#Mon Sep 12 09:29:59 CEST 2011
+bin.includes=META-INF/,.,plugin.xml,icons/,about.html,plugin.properties,schema/
+output..=bin/
+src.includes=about.html,schema/,META-INF/,.,plugin.xml,icons/,plugin.properties
+source..=src/
+bin..=bin/
diff --git a/deprecated/org.eclipse.papyrus.navigator/icons/ModelExplorer.gif b/deprecated/org.eclipse.papyrus.navigator/icons/ModelExplorer.gif
new file mode 100644
index 00000000000..acb63823aa3
Binary files /dev/null and b/deprecated/org.eclipse.papyrus.navigator/icons/ModelExplorer.gif differ
diff --git a/deprecated/org.eclipse.papyrus.navigator/icons/etool16/duplicate.png b/deprecated/org.eclipse.papyrus.navigator/icons/etool16/duplicate.png
new file mode 100644
index 00000000000..195dc6d6c36
Binary files /dev/null and b/deprecated/org.eclipse.papyrus.navigator/icons/etool16/duplicate.png differ
diff --git a/deprecated/org.eclipse.papyrus.navigator/icons/etool16/rename.gif b/deprecated/org.eclipse.papyrus.navigator/icons/etool16/rename.gif
new file mode 100644
index 00000000000..e6f786eca9a
Binary files /dev/null and b/deprecated/org.eclipse.papyrus.navigator/icons/etool16/rename.gif differ
diff --git a/deprecated/org.eclipse.papyrus.navigator/icons/etool16/search.gif b/deprecated/org.eclipse.papyrus.navigator/icons/etool16/search.gif
new file mode 100644
index 00000000000..a75166978d7
Binary files /dev/null and b/deprecated/org.eclipse.papyrus.navigator/icons/etool16/search.gif differ
diff --git a/deprecated/org.eclipse.papyrus.navigator/plugin.properties b/deprecated/org.eclipse.papyrus.navigator/plugin.properties
new file mode 100644
index 00000000000..ff4e6c71189
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/plugin.properties
@@ -0,0 +1,14 @@
+########################################################################################
+#
+# Copyright (c) 2009 Obeo.
+# 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:
+# Obeo - initial API and implementation
+########################################################################################
+pluginName=Papyrus Navigator (Incubation)
+providerName=Eclipse Modeling Project
+
diff --git a/deprecated/org.eclipse.papyrus.navigator/plugin.xml b/deprecated/org.eclipse.papyrus.navigator/plugin.xml
new file mode 100644
index 00000000000..60715ef991d
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/plugin.xml
@@ -0,0 +1,270 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/deprecated/org.eclipse.papyrus.navigator/schema/org.eclipse.papyrus.navigator.actionHandler.exsd b/deprecated/org.eclipse.papyrus.navigator/schema/org.eclipse.papyrus.navigator.actionHandler.exsd
new file mode 100644
index 00000000000..f01f090dfac
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/schema/org.eclipse.papyrus.navigator.actionHandler.exsd
@@ -0,0 +1,135 @@
+
+
+
+
+
+
+
+
+ This extension point allows adding action in the contextual menu of the model explorer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ registered action identifier
+
+
+
+
+
+
+ implement the action handler factory to add your custom actions
+
+
+
+
+
+
+
+
+
+ fill the action id after you want to insert yours
+
+
+
+
+
+
+ Add a separator before your action(s) if needed
+
+
+
+
+
+
+
+
+
+
+
+ [Enter the first release in which this extension point appears.]
+
+
+
+
+
+
+
+
+ org.eclipse.papyrus.navigator.factory.DefaultEMFActionsFactory adds default EMF actions in model explorer.
+See registered extension org.eclipse.papyrus.navigator.actionHandler
+
+
+
+
+
+
+
+
+ The class must implement interface org.eclipse.papyrus.navigator.factory.IActionHandlerFactory
+
+
+
+
+
+
+
+
+ none
+
+
+
+
+
+
+
+
+ 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
+
+
+
+
diff --git a/deprecated/org.eclipse.papyrus.navigator/schema/providerAdapterFactory.exsd b/deprecated/org.eclipse.papyrus.navigator/schema/providerAdapterFactory.exsd
new file mode 100644
index 00000000000..f16405105b2
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/schema/providerAdapterFactory.exsd
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+ This extension provides factories to the navigator which will be used to display informations like labels and images of the EObjects displayed in this navigator.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ An adapter factory
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ UMLComposedAdapterFactory adds a composed factory for UML which used UMLResourceItemProviderAdapterFactory and UMLItemProviderAdapterFactory (from the uml2 plugin) to retrieved labels or images from the UML elements.
+
+
+
+
+
+
+
+
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/ModelNavigator.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/ModelNavigator.java
new file mode 100644
index 00000000000..8dfb4130cc7
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/ModelNavigator.java
@@ -0,0 +1,592 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+
+ * 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:
+ * Obeo - initial API and implementation
+ * Francisco Javier Cano Muñoz (Prodevelop) - bugs solving, features implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator;
+
+import static org.eclipse.papyrus.navigator.internal.Activator.log;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.emf.transaction.ResourceSetChangeEvent;
+import org.eclipse.emf.transaction.ResourceSetListener;
+import org.eclipse.emf.transaction.ResourceSetListenerImpl;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.navigator.actions.GroupChildrenAction;
+import org.eclipse.papyrus.navigator.actions.RemoveTypePrefixAction;
+import org.eclipse.papyrus.navigator.actions.SearchElementAction;
+import org.eclipse.papyrus.navigator.internal.Activator;
+import org.eclipse.papyrus.navigator.internal.utils.NavigatorUtils;
+import org.eclipse.papyrus.navigator.internal.utils.StereotypeApplicationUtils;
+import org.eclipse.papyrus.navigator.providers.IContentProvider;
+import org.eclipse.papyrus.navigator.providers.ToEditorSaveable;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.Saveable;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonActionConstants;
+import org.eclipse.ui.navigator.INavigatorContentExtension;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+/**
+ * This class define a view used to navigate in UML model and resource
+ *
+ * @author Jerome Benois
+ * @author Francisco Javier Cano Muñoz
+ */
+public class ModelNavigator extends CommonNavigator implements IEditingDomainProvider {
+
+ /** ID Of the Navigator. */
+ public static final String ID_MODELNAVIGATOR = "org.eclipse.papyrus.navigator.modelExplorer";
+
+ // //
+ // fjcano #291192 :: type prefix in model explorer
+ // //
+ public static final String PROPERTY_REMOVEPREFIX = "org.eclipse.papyrus.navigator.view.removeTypePrefix";
+
+ public static final int IS_REMOVEPREFIXTYPE_ENABLED_PROPERTY = 16774;
+
+ // //
+ // fjcano #290422 :: grouping children by type
+ // //
+ public static final String PROPERTY_GROUPCHILDS = "org.eclipse.papyrus.navigator.view.groupchilds";
+
+ public static final int IS_GROUPINGCHILDS_ENABLED_PROPERTY = 987;
+
+ // //
+ // fjcano #288599# :: enable linking by default in the model explorer
+ // //
+ private final String LINKING_ENABLED = "CommonNavigator.LINKING_ENABLED"; //$NON-NLS-1$
+
+ private boolean isRemovePrefixTypeEnabled = false;
+
+ private IWorkbenchPage page = null;
+
+ private boolean isGroupingChildsEnabled = false;
+
+ // optimize selection handling
+ private boolean handlingSelectionChanged = false;
+
+ /** {@link TransactionalEditingDomain} used to perform actions and commands. */
+ private TransactionalEditingDomain editingDomain = null;
+
+ /** Active {@link IEditorPart}. */
+ private IEditorPart editorPart = null;
+
+ /**
+ * The {@link IPropertySheetPage} this model exploer will use.
+ */
+ private IPropertySheetPage propertySheetPage = null;
+
+ /**
+ * {@link ResourceSetListener} to listen and react to changes in the resource set.
+ */
+ private final ResourceSetListener resourceSetListener = new ResourceSetListenerImpl() {
+
+ @Override
+ public void resourceSetChanged(ResourceSetChangeEvent event) {
+ super.resourceSetChanged(event);
+ handleResourceSetChanged(event);
+ }
+ };
+
+ // //
+ // fjcano #290424 :: allow saving from the Model Explorer
+ // //
+ private final ToEditorSaveable toEditorSaveable = new ToEditorSaveable(null, this);
+
+ private final Saveable[] toEditorSaveableArray = new Saveable[]{ toEditorSaveable };
+
+ /**
+ * Make the synchronization between the editor and the model explorer active by default.
+ */
+ @Override
+ public void init(IViewSite aSite, IMemento aMemento) throws PartInitException {
+ super.init(aSite, aMemento);
+ // fjcano #288599# :: linking enabled by default
+ if(memento != null) {
+ Integer linkingEnabledInteger = memento.getInteger(LINKING_ENABLED);
+ setLinkingEnabled(((linkingEnabledInteger != null) ? linkingEnabledInteger.intValue() == 1 : true));
+ } else {
+ // fjcano :: linking is enabled by default.
+ setLinkingEnabled(true);
+ }
+ }
+
+ private ToEditorSaveable getToEditorSaveable() {
+ // fjcano #290424 :: allow saving from the Model Explorer
+ return toEditorSaveable;
+ }
+
+ /**
+ * Due to the NavigatorSaveablesService not updating correctly the Saveables available via the
+ * ContentProviders, a new and direct way of getting the Saveables is implemented here.
+ *
+ * @author Francisco Javier Cano Muñoz
+ */
+ @Override
+ public Saveable[] getSaveables() {
+ // fjcano #290424 :: allow saving from the Model Explorer
+ // return a Saveable that targets the doSave action to the Active
+ // Editor.
+ return toEditorSaveableArray;
+ }
+
+ /**
+ * Due to the NavigatorSaveablesService not updating correctly the Saveables available via the
+ * ContentProviders, a new and direct way of getting the Saveables is implemented here.
+ *
+ * @author Francisco Javier Cano Muñoz
+ */
+ @Override
+ public Saveable[] getActiveSaveables() {
+ // fjcano #290424 :: allow saving from the Model Explorer
+ // return a Saveable that targets the doSave action to the Active
+ // Editor.
+ return toEditorSaveableArray;
+ }
+
+ /**
+ * Method to perform all necessary updates.
+ */
+ private void doUpdate() {
+ // fjcano #290424 :: allow saving from the Model Explorer
+ if(getToEditorSaveable() != null) {
+ getToEditorSaveable().setEditor(editorPart);
+ }
+ }
+
+ /**
+ * Sets the grouping of children by type. Fires a property change that makes the model explorer
+ * to refresh.
+ *
+ * @param toGroupChilds
+ */
+ public final void setGroupChildsEnabled(boolean toGroupChilds) {
+ // fjcano :: #290422
+ isGroupingChildsEnabled = toGroupChilds;
+ firePropertyChange(IS_GROUPINGCHILDS_ENABLED_PROPERTY);
+ ISelection sel = this.getCommonViewer().getSelection();
+ if(sel instanceof ITreeSelection && ((ITreeSelection)sel).getFirstElement() != null) {
+ IStructuredSelection s = new StructuredSelection(((ITreeSelection)sel).getFirstElement());
+ this.getCommonViewer().setSelection(s, true);
+ }
+ this.refreshViewer();
+ }
+
+ /**
+ * Retrieves the value of the grouping children flag.
+ *
+ * @return
+ */
+ public boolean isGroupingChildsEnabled() {
+ // fjcano :: #290422
+ return this.isGroupingChildsEnabled;
+ }
+
+ /**
+ * Retrieves the grouping of children action.
+ *
+ * @return
+ */
+ private IAction getGroupChildrenAction() {
+ // fjcano :: #290422
+ IAction groupChildsAction = new GroupChildrenAction(this);
+ ImageDescriptor folderIcon = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
+ groupChildsAction.setImageDescriptor(folderIcon);
+ groupChildsAction.setHoverImageDescriptor(folderIcon);
+ return groupChildsAction;
+ }
+
+ /**
+ * Set the isRemovePrefixTypeEnabled to the given value and fire a property change event.
+ *
+ * @param isRemovePrefixTypeEnabled
+ */
+ public void setRemovePrefixTypeEnabled(boolean isRemovePrefixTypeEnabled) {
+ // fjcano #291192
+ this.isRemovePrefixTypeEnabled = isRemovePrefixTypeEnabled;
+ firePropertyChange(IS_REMOVEPREFIXTYPE_ENABLED_PROPERTY);
+ refreshViewer();
+ }
+
+ /**
+ * Gets whether the removal of prefix types is enabled or not.
+ *
+ * @return
+ */
+ public boolean isRemovePrefixTypeEnabled() {
+ // fjcano #291192
+ return isRemovePrefixTypeEnabled;
+ }
+
+ private IAction getRemoveTypesPrefixAction() {
+ // fjcano #291192
+ IAction removeTypesPrefixAction = new RemoveTypePrefixAction(this);
+ ImageDescriptor clearIcon = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_REMOVE);
+ removeTypesPrefixAction.setImageDescriptor(clearIcon);
+ removeTypesPrefixAction.setHoverImageDescriptor(clearIcon);
+ return removeTypesPrefixAction;
+ }
+
+ private IAction getSearchAction() {
+ // fjcano #290425 :: add search element action to model navigator
+ IAction searchAction = new SearchElementAction(this);
+ ImageDescriptor magnifyingGlassIcon = Activator.getImageDescriptor("icons/etool16/search.gif");
+ searchAction.setImageDescriptor(magnifyingGlassIcon);
+ searchAction.setHoverImageDescriptor(magnifyingGlassIcon);
+ return searchAction;
+ }
+
+ /**
+ * Add the "Group children" action.
+ */
+ @Override
+ public void createPartControl(Composite aParent) {
+ super.createPartControl(aParent);
+ // fjcano #290422 :: add "Group children" action
+ getViewSite().getActionBars().getToolBarManager().add(getGroupChildrenAction());
+ // fjcano #291192
+ getViewSite().getActionBars().getToolBarManager().add(getRemoveTypesPrefixAction());
+ // fjcano #290425 :: add search action to model navigator
+ getViewSite().getActionBars().getToolBarManager().add(getSearchAction());
+ }
+
+ private void handleResourceSetChanged(ResourceSetChangeEvent event) {
+ // Notify all content providers
+ List notifications = event.getNotifications();
+ int i = 0;
+ boolean finish = false;
+ while(!finish && i < notifications.size()) {
+ Object n = notifications.get(i);
+ if(n instanceof Notification) {
+ Notification notification = (Notification)n;
+ Iterator> it = getNavigatorContentService().findRootContentExtensions(notification.getNotifier()).iterator();
+ while(it.hasNext()) {
+ Object obj = it.next();
+ finish = true;
+ if(obj instanceof INavigatorContentExtension) {
+ INavigatorContentExtension nce = (INavigatorContentExtension)obj;
+ if(nce.getContentProvider() instanceof IContentProvider) {
+ IContentProvider provider = (IContentProvider)nce.getContentProvider();
+ provider.resourceSetChanged(event);
+ }
+ }
+ }
+ }
+ i++;
+ }
+ }
+
+ /**
+ * A new {@link IWorkbenchPart} has been activated, refresh.
+ *
+ * @param partRef
+ */
+ private void handlePartActivated(IWorkbenchPartReference partRef) {
+ IWorkbenchPart part = partRef.getPart(false);
+ if(part instanceof IEditorPart) {
+ activate();
+ }
+ }
+
+ /**
+ * An {@link IWorkbenchPart} has been deactivated, refresh.
+ *
+ * @param partRef
+ */
+ private void handlePartDeactivated(IWorkbenchPartReference partRef) {
+ IWorkbenchPart part = partRef.getPart(false);
+ if(editorPart != null && editorPart.equals(part)) {
+ deactivate();
+ }
+ }
+
+ /**
+ * Activate the Model Explorer.
+ */
+ private void activate() {
+ this.editorPart = EditorUtils.getMultiDiagramEditor();
+ this.editingDomain = EditorUtils.getTransactionalEditingDomain();
+ if(editingDomain != null) {
+ editingDomain.addResourceSetListener(resourceSetListener);
+ }
+ refreshViewer();
+ // fjcano #290424 :: allow saving from the Model Explorer
+ doUpdate();
+ }
+
+ /**
+ * Deactivate the Model Explorer.
+ */
+ private void deactivate() {
+ editorPart = null;
+ if(editingDomain != null) {
+ editingDomain.removeResourceSetListener(resourceSetListener);
+ }
+ // if (propertySheet != null) {
+ // propertySheet.dispose();
+ // }
+ refreshViewer();
+ // fjcano #290424 :: allow saving from the Model Explorer
+ doUpdate();
+ }
+
+ /**
+ * Adapts to {@link IPropertySheetPage}. Other adaptations are handled by superclasses.
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object getAdapter(Class adapter) {
+ if(IPropertySheetPage.class.equals(adapter)) {
+ return getPropertySheetPage();
+ }
+ return super.getAdapter(adapter);
+ }
+
+ /**
+ * Forces the viewer to be refreshed.
+ */
+ private void refreshViewer() {
+ CommonViewer viewer = getCommonViewer();
+ if(viewer != null && viewer.getTree().isDisposed() == false) {
+ viewer.refresh();
+ }
+ }
+
+ /**
+ * Adds an {@link IPartListener2} and an {@link ISelectionListener}.
+ */
+ @Override
+ public void init(IViewSite site) throws PartInitException {
+ super.init(site);
+ page = site.getPage();
+ // IPartListener to listen to IWorkbenchParts' life cycle.
+ page.addPartListener(new IPartListener2() {
+
+ public void partActivated(IWorkbenchPartReference partRef) {
+ handlePartActivated(partRef);
+ }
+
+ public void partBroughtToTop(IWorkbenchPartReference partRef) {
+ }
+
+ public void partClosed(IWorkbenchPartReference partRef) {
+ handlePartDeactivated(partRef);
+ }
+
+ public void partDeactivated(IWorkbenchPartReference partRef) {
+ }
+
+ public void partHidden(IWorkbenchPartReference partRef) {
+ }
+
+ public void partInputChanged(IWorkbenchPartReference partRef) {
+ handlePartActivated(partRef);
+ }
+
+ public void partOpened(IWorkbenchPartReference partRef) {
+ handlePartActivated(partRef);
+ }
+
+ public void partVisible(IWorkbenchPartReference partRef) {
+ handlePartActivated(partRef);
+ }
+
+ });
+ // an ISelectionListener to react to workbench selection changes.
+ page.addSelectionListener(new ISelectionListener() {
+
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ handleSelectionChangedFromDiagramEditor(part, selection);
+ }
+ });
+ activate();
+ }
+
+ /**
+ * Retrieves the {@link IPropertySheetPage} that his Model Explorer uses.
+ *
+ * @return
+ */
+ private IPropertySheetPage getPropertySheetPage() {
+ final IMultiDiagramEditor multiDiagramEditor = EditorUtils.getMultiDiagramEditor();
+ if(multiDiagramEditor != null) {
+ if(propertySheetPage == null) {
+ // An 'EEF' properties view
+ if(multiDiagramEditor instanceof ITabbedPropertySheetPageContributor) {
+ ITabbedPropertySheetPageContributor contributor = (ITabbedPropertySheetPageContributor)multiDiagramEditor;
+ this.propertySheetPage = new TabbedPropertySheetPage(contributor);
+ }
+ }
+ return propertySheetPage;
+ }
+ return null;
+ }
+
+ /**
+ * Adds an {@link ISelectionChangedListener} to this Model Explorer's viewer to react to
+ * selection changes in the Model Explorer.
+ */
+ @Override
+ protected CommonViewer createCommonViewer(Composite parent) {
+ CommonViewer commonViewer = super.createCommonViewer(parent);
+ commonViewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleSelectionChangedFromCommonViewer(event);
+ }
+ });
+ return commonViewer;
+ }
+
+ /**
+ * Handle a selection change in the editor.
+ *
+ * @param part
+ * @param selection
+ */
+ private void handleSelectionChangedFromDiagramEditor(IWorkbenchPart part, ISelection selection) {
+ // Handle selection from diagram editor
+ if(isLinkingEnabled() && !handlingSelectionChanged) {
+ this.handlingSelectionChanged = true;
+ if(part instanceof IEditorPart) {
+ ISelection unwrappedSelection = NavigatorUtils.unwrapSelection(selection);
+ if(!unwrappedSelection.isEmpty() && unwrappedSelection instanceof StructuredSelection) {
+ // forward the selection to the stereotyped element if needed
+ EObject firstElement = (EObject)((StructuredSelection)unwrappedSelection).getFirstElement();
+ if(firstElement != null && firstElement.eContainer() == null) {
+ unwrappedSelection = StereotypeApplicationUtils.unwrapStereotypedSelection(unwrappedSelection);
+ }
+ getCommonViewer().setSelection(unwrappedSelection, true);
+ }
+ }
+ this.handlingSelectionChanged = false;
+ }
+ }
+
+ /**
+ * Handle a selection change in the Model Explorer's viewer.
+ *
+ * @param event
+ */
+ private void handleSelectionChangedFromCommonViewer(SelectionChangedEvent event) {
+ // Handle selection from common viewer
+ if(isLinkingEnabled() && !handlingSelectionChanged) {
+ this.handlingSelectionChanged = true;
+ DiagramEditor editor = EditorUtils.lookupActiveDiagramEditor();
+ if(editor != null) {
+ // set editor selection and select the EditParts
+ IDiagramGraphicalViewer diagramGraphicalViewer = editor.getDiagramGraphicalViewer();
+ List> editPartsToSelect = NavigatorUtils.getEditPartsFromSelection(event.getSelection(), diagramGraphicalViewer);
+ if(editPartsToSelect.isEmpty()) {
+ // forward the selection to the stereotype application
+ editPartsToSelect = NavigatorUtils.getEditPartsFromSelection(StereotypeApplicationUtils.getStereotypedSelectionFromCommonViewer(event.getSelection()), diagramGraphicalViewer);
+ }
+ StructuredSelection selectedEditParts = new StructuredSelection(editPartsToSelect);
+ diagramGraphicalViewer.setSelection(selectedEditParts);
+ if(!selectedEditParts.isEmpty()) {
+ EditPart editPart = (EditPart)selectedEditParts.getFirstElement();
+ diagramGraphicalViewer.reveal(editPart);
+ }
+ }
+ this.handlingSelectionChanged = false;
+ }
+ }
+
+ /**
+ * Handle a double click on an element in the Model Explorer
+ */
+ @Override
+ protected void handleDoubleClick(DoubleClickEvent anEvent) {
+ if(log.isDebugEnabled()) {
+ log.debug("Model Navigator got a double click");
+ }
+ IAction openHandler = getViewSite().getActionBars().getGlobalActionHandler(ICommonActionConstants.OPEN);
+ if(openHandler != null) {
+ openHandler.run();
+ } else {
+ IStructuredSelection selection = (IStructuredSelection)anEvent.getSelection();
+ Object element = selection.getFirstElement();
+ if(element instanceof Diagram) {
+ // fjcano #287943 :: handle a double click on a papyrus Diagram
+ handleDoubleClickOnDiagram((Diagram)element);
+ } else if(element instanceof org.eclipse.gmf.runtime.notation.Diagram) {
+ // fjcano #287943 :: handle a double click on a gmf Diagram
+ handleDoubleClickOnDiagram((org.eclipse.gmf.runtime.notation.Diagram)element);
+ } else if(element instanceof EObject) {
+ // Open SWT EEF Properties UI
+ NavigatorUtils.openPropertySheetsView();
+ } else {
+ super.handleDoubleClick(anEvent);
+ }
+ }
+ }
+
+ /**
+ * Handle double click on a GMF Diagram.
+ *
+ * @param diagram
+ */
+ private void handleDoubleClickOnDiagram(Diagram diagram) {
+ // fjcano #287943 :: handle double click on a gmf diagram
+ if(log.isDebugEnabled()) {
+ log.debug("#ModelNavigator-> handleDoubleClickOnDiagram : " + diagram);
+ }
+ if(!EditorUtils.getIPageMngr().isOpen(diagram)) {
+ // open the diagram if not already open
+ EditorUtils.getIPageMngr().openPage(diagram);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @return the EditingDomain used by the properties view
+ */
+ public EditingDomain getEditingDomain() {
+ return editingDomain;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractCommonActionProvider.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractCommonActionProvider.java
new file mode 100644
index 00000000000..9f9023df310
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractCommonActionProvider.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Conselleria de Infraestructuras y Transporte, Generalitat
+ * de la Comunitat Valenciana, Obeo . All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francisco Javier Cano Muñoz (Prodevelop) – Initial API implementation.
+ * Obeo
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.navigator.actions;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.navigator.internal.utils.NavigatorUtils;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.CommonNavigator;
+
+/**
+ * Specialization of to be used as Papyrus action provider.
+ *
+ * @author fjcano
+ * @author Jerome Benois
+ */
+public abstract class AbstractCommonActionProvider extends CommonActionProvider {
+
+ /**
+ * Gets the ID of the this is associated to.
+ *
+ * @return the viewer id
+ */
+ // @unused
+ protected String getViewerID() {
+ return getActionSite().getViewSite().getId();
+ }
+
+ /**
+ * Gets the this is associated with, via
+ * the viewerID.
+ *
+ * @return the common navigator
+ */
+ protected CommonNavigator getCommonNavigator() {
+ IViewPart part = NavigatorUtils.findViewPart(getViewerID());
+ if(part instanceof CommonNavigator) {
+ return ((CommonNavigator)part);
+ }
+ return null;
+ }
+
+ /**
+ * Gets the current context's selection.
+ *
+ * @return the selection
+ */
+ // @unused
+ protected ISelection getSelection() {
+ ActionContext context = getContext();
+ return (context != null) ? context.getSelection() : null;
+ }
+
+ /**
+ * Gets the first element of the current context's selection.
+ *
+ * @return the first selected element
+ */
+ protected Object getFirstSelectedElement() {
+ ISelection selection = getSelection();
+ if(selection instanceof StructuredSelection) {
+ return ((StructuredSelection)selection).getFirstElement();
+ }
+ return null;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractSubmenuActionProvider.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractSubmenuActionProvider.java
new file mode 100644
index 00000000000..60e357744dc
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractSubmenuActionProvider.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Conselleria de Infraestructuras y Transporte, Generalitat
+ * de la Comunitat Valenciana, Obeo. All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francisco Javier Cano Muñoz (Prodevelop) – Initial API implementation.
+ * Obeo
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.navigator.actions;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionManager;
+import org.eclipse.jface.action.MenuManager;
+
+/**
+ * Specialization of to be used in menu and submenu contributions.
+ *
+ * @author fjcano
+ * @author Jerome Benois
+ */
+public abstract class AbstractSubmenuActionProvider extends AbstractCommonActionProvider {
+
+ /**
+ * Organizes the given of .
+ *
+ * @param createActions
+ * of to organize
+ * @param token
+ * that the will use to trim each 's text.
+ *
+ * @return a associating s to s of s.
+ */
+ protected Map> extractSubmenuActions(Collection createActions, String token) {
+ Map> createSubmenuActions = new LinkedHashMap>();
+ if(createActions != null) {
+ for(Iterator actions = createActions.iterator(); actions.hasNext();) {
+ IAction action = actions.next();
+ StringTokenizer st = new StringTokenizer(action.getText(), token);
+ if(st.countTokens() == 2) {
+ String text = st.nextToken().trim();
+ Collection submenuActions = createSubmenuActions.get(text);
+ if(submenuActions == null) {
+ createSubmenuActions.put(text, submenuActions = new ArrayList());
+ }
+ action.setText(st.nextToken().trim());
+ submenuActions.add(action);
+ actions.remove();
+ }
+ }
+ }
+ return createSubmenuActions;
+ }
+
+ /**
+ * Fills a with the given of .
+ *
+ * @param manager
+ * the manager
+ * @param actions
+ * the actions
+ * @param contributionID
+ * the contribution id
+ */
+ protected void populateManager(IContributionManager manager, Collection extends IAction> actions, String contributionID) {
+ if(actions != null) {
+ for(IAction action : actions) {
+ if(contributionID != null) {
+ manager.insertBefore(contributionID, action);
+ } else {
+ manager.add(action);
+ }
+ }
+ }
+ }
+
+ /**
+ * Fills a with two levels of menus, as specified by the of
+ * s to s of s.
+ *
+ * @param manager
+ * the manager
+ * @param submenuActions
+ * the submenu actions
+ * @param contributionID
+ * the contribution id
+ */
+ protected void populateManager(IContributionManager manager, Map> submenuActions, String contributionID) {
+ if(submenuActions != null) {
+ for(Map.Entry> entry : submenuActions.entrySet()) {
+ MenuManager submenuManager = new MenuManager(entry.getKey());
+ if(contributionID != null) {
+ manager.insertBefore(contributionID, submenuManager);
+ } else {
+ manager.add(submenuManager);
+ }
+ populateManager(submenuManager, entry.getValue(), null);
+ }
+ }
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseAllDiagramsAction.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseAllDiagramsAction.java
new file mode 100644
index 00000000000..631c89e6dd5
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseAllDiagramsAction.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Conselleria de Infraestructuras y Transporte, Generalitat
+ * de la Comunitat Valenciana . All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Francisco Javier Cano Muñoz (Prodevelop) - Initial implementation
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.navigator.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Action used to close all open diagrams.
+ *
+ * @author Francisco Javier Cano Muñoz
+ * @see Bug #287948
+ */
+public class CloseAllDiagramsAction extends Action {
+
+ IPageMngr pageMngr;
+
+ protected IPageMngr getPageMngr() {
+ return pageMngr;
+ }
+
+ public CloseAllDiagramsAction(IPageMngr pageMngr) {
+ if(pageMngr == null) {
+ throw new IllegalArgumentException("An IPageMngr must be specified");
+ }
+ this.pageMngr = pageMngr;
+ ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
+ setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
+ setText("Close all diagrams");
+ // this action is enabled when there is at least one diagram open.
+ boolean aDiagramIsOpen = false;
+ for(Object identifier : pageMngr.allPages()) {
+ if(pageMngr.isOpen(identifier)) {
+ aDiagramIsOpen = true;
+ }
+ }
+ setEnabled(aDiagramIsOpen);
+ }
+
+ /**
+ * Delete the given diagram
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ // close all open diagrams
+ for(Object identifier : pageMngr.allPages()) {
+ if(getPageMngr().isOpen(identifier)) {
+ getPageMngr().closePage(identifier);
+ }
+ }
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseDiagramAction.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseDiagramAction.java
new file mode 100644
index 00000000000..f20cc69466d
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseDiagramAction.java
@@ -0,0 +1,44 @@
+/**
+ *
+ */
+
+package org.eclipse.papyrus.navigator.actions;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.action.Action;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Action used to open the given diagram
+ *
+ * @author cedric dumoulin
+ */
+public class CloseDiagramAction extends Action {
+
+ Diagram diagram;
+
+ IPageMngr pageMngr;
+
+ public CloseDiagramAction(IPageMngr pageMngr, Diagram diagram) {
+ this.diagram = diagram;
+ this.pageMngr = pageMngr;
+
+ ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
+ setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
+ setText("Close");
+ setEnabled(pageMngr.isOpen(diagram));
+ }
+
+ /**
+ * Delete the given diagram
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+
+ pageMngr.closePage(diagram);
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateChildActionProvider.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateChildActionProvider.java
new file mode 100644
index 00000000000..ab372d69e51
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateChildActionProvider.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.actions;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.edit.command.CommandParameter;
+import org.eclipse.emf.edit.ui.action.CreateChildAction;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+
+/**
+ * The Class CreateChildActions.
+ *
+ * @author Jerome Benois
+ */
+public class CreateChildActionProvider extends AbstractSubmenuActionProvider {
+
+ protected Collection createChildActions;
+
+ protected Map> createChildSubmenuActions;
+
+ // @unused
+ protected IMenuManager createChildMenuManager;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void init(ICommonActionExtensionSite site) {
+ super.init(site);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void fillContextMenu(IMenuManager menu) {
+ super.fillContextMenu(menu);
+ ISelection selection = getContext().getSelection();
+ Collection> newChildDescriptors = null;
+ Object selectedElement = null;
+ if(selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) {
+ selectedElement = ((IStructuredSelection)selection).getFirstElement();
+
+ TransactionalEditingDomain domain = EditorUtils.getTransactionalEditingDomain();
+ if(domain == null) {
+ return;
+ }
+ newChildDescriptors = domain.getNewChildDescriptors(selectedElement, null);
+ }
+
+ createChildActions = generateCreateChildActions(newChildDescriptors, selection);
+ createChildSubmenuActions = extractSubmenuActions(createChildActions, "|");
+ MenuManager submenuManager = new MenuManager("New Child");
+ populateManager(submenuManager, createChildSubmenuActions, null);
+ populateManager(submenuManager, createChildActions, null);
+ menu.add(submenuManager);
+ }
+
+ /**
+ * Generate create child actions.
+ *
+ * @param descriptors
+ * the descriptors
+ * @param selection
+ * the selection
+ *
+ * @return the collection< i action>
+ */
+ protected Collection generateCreateChildActions(Collection> descriptors, ISelection selection) {
+ List createChildActions = (List)generateCreateChildActionsGen(descriptors, selection);
+
+ Collections. sort(createChildActions, new Comparator() {
+
+ public int compare(IAction a1, IAction a2) {
+ return a1.getText().compareTo(a2.getText());
+ }
+ });
+
+ return createChildActions;
+ }
+
+ /**
+ * Generate create child actions gen.
+ *
+ * @param descriptors
+ * the descriptors
+ * @param selection
+ * the selection
+ *
+ * @return the collection< i action>
+ */
+ protected Collection generateCreateChildActionsGen(Collection> descriptors, ISelection selection) {
+ Collection actions = new ArrayList();
+ if(descriptors != null) {
+ for(Object descriptor : descriptors) {
+ if(descriptor instanceof CommandParameter) {
+ actions.add(new CreateChildAction(EditorUtils.getTransactionalEditingDomain(), selection, descriptor));
+ }
+ }
+ }
+ return actions;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateDiagramAction.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateDiagramAction.java
new file mode 100644
index 00000000000..5aa59176931
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateDiagramAction.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.actions;
+
+import static org.eclipse.papyrus.navigator.internal.Activator.log;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.action.Action;
+import org.eclipse.papyrus.infra.core.extension.NotFoundException;
+import org.eclipse.papyrus.infra.core.extension.commands.CreationCommandDescriptor;
+import org.eclipse.papyrus.infra.core.extension.commands.CreationCommandRegistry;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommandRegistry;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+
+/**
+ * Action used to create a new diagram for given type
+ *
+ * @author Jerome Benois
+ */
+public class CreateDiagramAction extends Action {
+
+ private final EObject container;
+
+ private final CreationCommandDescriptor commandDescriptor;
+
+ /**
+ * Constructor
+ *
+ * @param selectedObject
+ * the selected Element on which the diagram is to be associated
+ */
+ public CreateDiagramAction(EObject selectedElement, CreationCommandDescriptor commandDescriptor) {
+ this.container = selectedElement;
+ this.commandDescriptor = commandDescriptor;
+ setText(commandDescriptor.getLabel());
+ setImageDescriptor(commandDescriptor.getIcon());
+ }
+
+ /**
+ * @see org.eclipse.jface.action.Action#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ return container != null;
+ }
+
+ /**
+ * This methods creates a new Diagram to be associated with the given domain element
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+
+ // Start LOG
+ if(log.isDebugEnabled()) {
+ log.debug("Start - CreateDiagramAction#run"); //$NON-NLS-1$
+ }
+
+ try {
+ ICreationCommand creationCommand = getCreationCommandRegistry().getCommand(commandDescriptor.getCommandId());
+ creationCommand.createDiagram(EditorUtils.getDiResourceSet(), container, null);
+ } catch (NotFoundException e) {
+ log.error(e);
+ }
+
+ // END LOG
+ if(log.isDebugEnabled()) {
+ log.debug("End - CreateDiagramAction#run"); //$NON-NLS-1$
+ }
+ }
+
+ private ICreationCommandRegistry getCreationCommandRegistry() {
+ return CreationCommandRegistry.getInstance(org.eclipse.papyrus.infra.core.Activator.PLUGIN_ID);
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateDiagramActionProvider.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateDiagramActionProvider.java
new file mode 100644
index 00000000000..72d30be62f9
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateDiagramActionProvider.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - add condition to the create command (task #296902)
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.actions;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.papyrus.infra.core.extension.commands.CreationCommandDescriptor;
+import org.eclipse.papyrus.infra.core.extension.commands.CreationCommandRegistry;
+import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommandRegistry;
+
+/**
+ * Provider used to create a new diagram actions
+ *
+ * @author Jerome Benois
+ */
+public class CreateDiagramActionProvider extends AbstractSubmenuActionProvider {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void fillContextMenu(IMenuManager menu) {
+ Object selectedElement = getFirstSelectedElement();
+ if(selectedElement instanceof EObject) {
+ EObject eObject = (EObject)selectedElement;
+ MenuManager newDiagramMenu = new MenuManager("New Diagram");
+ menu.add(newDiagramMenu);
+ for(CreationCommandDescriptor desc : getCreationCommandRegistry().getCommandDescriptors()) {
+ if(desc.getCondition() == null || desc.getCondition().create(eObject)) {
+ CreateDiagramAction createDiagramAction = new CreateDiagramAction(eObject, desc);
+ newDiagramMenu.add(createDiagramAction);
+ }
+ }
+ }
+ }
+
+ private ICreationCommandRegistry getCreationCommandRegistry() {
+ return CreationCommandRegistry.getInstance(org.eclipse.papyrus.infra.core.Activator.PLUGIN_ID);
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/DeleteDiagramAction.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/DeleteDiagramAction.java
new file mode 100644
index 00000000000..78527c5b4bc
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/DeleteDiagramAction.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.actions;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.action.Action;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Action used to delete the given diagram
+ *
+ * @author Jerome Benois
+ * @author cedric dumoulin
+ */
+public class DeleteDiagramAction extends Action {
+
+ Diagram diagram;
+
+ IPageMngr pageMngr;
+
+ public DeleteDiagramAction(IPageMngr pageMngr, Diagram diagram) {
+ this.diagram = diagram;
+ this.pageMngr = pageMngr;
+
+ ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
+ setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+ setText("Delete");
+ setEnabled(true);
+ }
+
+ /**
+ * Delete the given diagram
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ TransactionalEditingDomain editingDomain = EditorUtils.getTransactionalEditingDomain();
+ if(editingDomain != null) {
+
+ // Create a compound command containing removing of the sash and removing from GMF
+ // resource.
+ CompoundCommand command = new CompoundCommand();
+ Command sashRemoveComd = new RecordingCommand(editingDomain) {
+
+ @Override
+ protected void doExecute() {
+ pageMngr.removePage(diagram);
+ }
+ };
+
+ EList diagrams = diagram.eResource().getContents();
+ // TODO : synchronize with Cedric
+ command.append(sashRemoveComd);
+ command.append(new RemoveCommand(editingDomain, diagrams, diagram));
+ editingDomain.getCommandStack().execute(command);
+ }
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/DiagramActionProvider.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/DiagramActionProvider.java
new file mode 100644
index 00000000000..684c834cc04
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/DiagramActionProvider.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.actions;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+
+/**
+ * Provider used to create actions applicable on diagrams
+ *
+ * @author Jerome Benois
+ */
+public class DiagramActionProvider extends AbstractSubmenuActionProvider {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void fillContextMenu(IMenuManager menu) {
+ Object selectedElement = getFirstSelectedElement();
+
+ if(selectedElement instanceof Diagram) {
+ Diagram diagram = (Diagram)selectedElement;
+ // Get the Editor IPageMngr. It should be Transactional.
+ IPageMngr pageMngr = EditorUtils.getIPageMngr();
+
+ // Create Rename Diagram action
+ RenameDiagramAction renameDiagramAction = new RenameDiagramAction(diagram);
+ menu.add(renameDiagramAction);
+
+ // Create Delete Diagram action
+ OpenDiagramAction openDiagramAction = new OpenDiagramAction(pageMngr, diagram);
+ menu.add(openDiagramAction);
+
+ // Create Delete Diagram action
+ CloseDiagramAction closeDiagramAction = new CloseDiagramAction(pageMngr, diagram);
+ menu.add(closeDiagramAction);
+
+ // Create Close all diagrams action
+ // fjcano #287948 :: close all diagrams action
+ CloseAllDiagramsAction closeAllDiagramsAction = new CloseAllDiagramsAction(pageMngr);
+ menu.add(closeAllDiagramsAction);
+
+ // Create Delete Diagram action
+ DeleteDiagramAction deleteDiagramAction = new DeleteDiagramAction(pageMngr, diagram);
+ menu.add(deleteDiagramAction);
+
+ // Create Duplicate Diagram action
+ DuplicateDiagramAction duplicateDiagramAction = new DuplicateDiagramAction(pageMngr, diagram);
+ menu.add(duplicateDiagramAction);
+ }
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/DuplicateDiagramAction.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/DuplicateDiagramAction.java
new file mode 100644
index 00000000000..c7321906772
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/DuplicateDiagramAction.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.actions;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.action.Action;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.navigator.internal.Activator;
+
+/**
+ * Action used to duplicate the given diagram
+ *
+ * @author Jerome Benois
+ */
+public class DuplicateDiagramAction extends Action {
+
+ Diagram diagram;
+
+ IPageMngr pageMngr;
+
+ public DuplicateDiagramAction(IPageMngr pageMngr, Diagram diagram) {
+ this.diagram = diagram;
+ this.pageMngr = pageMngr;
+
+ setImageDescriptor(Activator.getImageDescriptor("icons/etool16/duplicate.png"));
+ setText("Duplicate");
+ setEnabled(true);
+ }
+
+ /**
+ * Duplicate the given diagram
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ TransactionalEditingDomain editingDomain = EditorUtils.getTransactionalEditingDomain();
+ if(editingDomain != null) {
+
+ // Create a compound command containing removing of the sash and removing from GMF
+ // resource.
+ CompoundCommand command = new CompoundCommand();
+
+ // Clone the current diagram
+ final Diagram newDiagram = (Diagram)EcoreUtil.copy(diagram);
+ // Give a new name
+ newDiagram.setName("Copy of " + diagram.getName());
+
+ Command addGmfDiagramCmd = new AddCommand(editingDomain, diagram.eResource().getContents(), newDiagram);
+ // EMFCommandOperation operation = new EMFCommandOperation(editingDomain,
+ // addGmfDiagramCmd);
+
+ Command sashOpenComd = new RecordingCommand(editingDomain) {
+
+ @Override
+ protected void doExecute() {
+ pageMngr.openPage(newDiagram);
+ }
+ };
+
+ // TODO : synchronize with Cedric
+ // command.append(operation.getCommand());
+ command.append(addGmfDiagramCmd);
+ command.append(sashOpenComd);
+ // Execute changes through a Command so that Undo/Redo is supported
+ editingDomain.getCommandStack().execute(command);
+
+ }
+
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/EditingDomainActionProvider.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/EditingDomainActionProvider.java
new file mode 100644
index 00000000000..962722b4446
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/EditingDomainActionProvider.java
@@ -0,0 +1,255 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ * Emilien Perico - use extension point to define dynamically registered actions
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.actions;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.navigator.factory.IActionHandlerFactory;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+
+/**
+ * Provider used to create actions applicable on semantic elements
+ *
+ * @author Jerome Benois
+ * @author Emilien Perico - see extension point org.eclipse.papyrus.navigator.actionHandler to add
+ * specific action
+ */
+public class EditingDomainActionProvider extends AbstractSubmenuActionProvider {
+
+ public static final String ACTION_HANDLER_EXTENSION_POINT_ID = "org.eclipse.papyrus.navigator.actionHandler";
+
+ protected CommonNavigator activeViewPart;
+
+ protected Map actionsFactoriesMap;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void init(ICommonActionExtensionSite site) {
+ super.init(site);
+
+ this.activeViewPart = getCommonNavigator();
+ this.actionsFactoriesMap = new HashMap();
+ TransactionalEditingDomain editingDomain = EditorUtils.getTransactionalEditingDomain();
+
+ IConfigurationElement[] registry = Platform.getExtensionRegistry().getConfigurationElementsFor(ACTION_HANDLER_EXTENSION_POINT_ID);
+ for(IConfigurationElement elt : registry) {
+ try {
+ final String actionId = elt.getAttribute("actionId");
+ final String afterAction = elt.getAttribute("afterAction");
+ boolean needSeparator = Boolean.valueOf(elt.getAttribute("needSeparator"));
+ ActionProperties properties = new ActionProperties(actionId, afterAction, needSeparator);
+
+ IActionHandlerFactory factory = (IActionHandlerFactory)elt.createExecutableExtension("actionHandler");
+ // create registered actions
+ factory.createActions(editingDomain);
+
+ actionsFactoriesMap.put(factory, properties);
+ } catch (CoreException exception) {
+ exception.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void fillActionBars(IActionBars actionBars) {
+ super.fillActionBars(actionBars);
+ for(IActionHandlerFactory factory : actionsFactoriesMap.keySet()) {
+ factory.fillActionBars(actionBars);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void fillContextMenu(IMenuManager menu) {
+ update();
+ // sort factories from "afterAction" property
+ List sortedFactories = sortFactories(actionsFactoriesMap);
+
+ // Add the edit menu actions
+ for(IActionHandlerFactory factory : sortedFactories) {
+ ActionProperties actionProperties = actionsFactoriesMap.get(factory);
+ if(actionProperties != null && actionProperties.isNeedSeparator()) {
+ menu.add(new Separator());
+ }
+ for(Action action : factory.getActions()) {
+ menu.add(new ActionContributionItem(action));
+ }
+ }
+ activate();
+ }
+
+ /**
+ * Update actions
+ */
+ public void update() {
+ ISelection selection = getCommonNavigator().getCommonViewer().getSelection();
+ IStructuredSelection structuredSelection = StructuredSelection.EMPTY;
+ if(selection instanceof IStructuredSelection) {
+ structuredSelection = (IStructuredSelection)selection;
+ }
+
+ for(IActionHandlerFactory factory : actionsFactoriesMap.keySet()) {
+ factory.update(structuredSelection);
+ }
+ }
+
+ /**
+ * Activate actions
+ */
+ public void activate() {
+ for(IActionHandlerFactory factory : actionsFactoriesMap.keySet()) {
+ factory.activate(activeViewPart);
+ }
+ update();
+ }
+
+ /**
+ * Deactivate actions
+ */
+ // @unused
+ public void deactivate() {
+ for(IActionHandlerFactory factory : actionsFactoriesMap.keySet()) {
+ factory.deactivate(activeViewPart);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void updateActionBars() {
+ super.updateActionBars();
+ activate();
+ update();
+ }
+
+ /**
+ * Sort factories.
+ *
+ * @param actionsFactoriesMap
+ * the actions factories map
+ *
+ * @return the sorted list of factories
+ */
+ private List sortFactories(final Map actionsFactoriesMap) {
+
+ List factories = new ArrayList(actionsFactoriesMap.keySet());
+
+ Collections.sort(factories, new Comparator() {
+
+ public int compare(IActionHandlerFactory factory1, IActionHandlerFactory factory2) {
+
+ ActionProperties properties1 = getDefaultForNull(actionsFactoriesMap.get(factory1));
+ ActionProperties properties2 = getDefaultForNull(actionsFactoriesMap.get(factory2));
+ String after1 = properties1.getAfterAction();
+ String after2 = properties2.getAfterAction();
+
+ if(properties1.getActionId().equals(properties2.getActionId())) {
+ return 0;
+ } else if(properties1.getActionId().equals(after2)) {
+ return -1;
+ } else if(properties2.getActionId().equals(after1)) {
+ return 1;
+ } else if(after1 == null) {
+ return -1;
+ } else if(after2 == null) {
+ return 1;
+ }
+ return 0;
+ }
+
+ private ActionProperties getDefaultForNull(ActionProperties actionProperties) {
+ if(actionProperties == null) {
+ actionProperties = new ActionProperties("", "", false);
+ }
+ return actionProperties;
+ }
+ });
+
+ return factories;
+ }
+
+ /**
+ * The Class ActionProperties to store properties for a registered action from extension point
+ * org.eclipse.papyrus.navigator.actionHandler
+ */
+ private class ActionProperties {
+
+ private final String actionId;
+
+ private final String afterAction;
+
+ private final boolean needSeparator;
+
+ /**
+ * @param actionId
+ * @param afterAction
+ * @param needSeparator
+ */
+ // @unused
+ public ActionProperties(String actionId, String afterAction, boolean needSeparator) {
+ super();
+ this.actionId = actionId;
+ this.afterAction = afterAction;
+ this.needSeparator = needSeparator;
+ }
+
+ /**
+ * @return the actionId
+ */
+ public String getActionId() {
+ return actionId;
+ }
+
+ /**
+ * @return the afterAction
+ */
+ public String getAfterAction() {
+ return afterAction;
+ }
+
+ /**
+ * @return the needSeparator
+ */
+ public boolean isNeedSeparator() {
+ return needSeparator;
+ }
+
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GenericTransformAction.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GenericTransformAction.java
new file mode 100644
index 00000000000..c987ab706cc
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GenericTransformAction.java
@@ -0,0 +1,101 @@
+/***************************************************
+ * 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.navigator.actions;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.navigator.dialog.InformationDialog;
+import org.eclipse.papyrus.navigator.internal.Activator;
+import org.eclipse.papyrus.navigator.preferences.INavigatorPreferenceConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * GenericTransformAction is an action which transforms and EObject by changing its eclass.
+ */
+public class GenericTransformAction extends Action {
+
+ /** title of error dialog */
+ private static final String ERROR_TITLE = "Impossible to continue transformation.";
+
+ /** message in error dialog */
+ private static final String ERROR_MESSAGE = "The transformation can not continue.\n" + "Some objects referencing your selection could not be able to reference the result of the transformation.\n" + "For UML and SysML, applied stereotypes could not be applicable on the result of the transformation.\n" + "Before performing the transformation please delete or unapply the elements listed bellow.";
+
+ /** title of error dialog */
+ private static final String WARNING_TITLE = "Warning: transformation command";
+
+ /** WARNING_MESSAGE for transform command execution */
+ private static final String WARNING_MESSAGE = "You are trying to transform an element typed %s into %s.\nThis operation will copy all the common elements between the two eclasses.\nDo you want to continue ?";
+
+ /** The EClass to transform into. */
+ private EClass targetEClass = null;
+
+ /** The element to transform. */
+ private EObject element;
+
+ /**
+ * Constructor for a new action.
+ *
+ * @param transformationEClass
+ * the eclass element must be transformed into
+ * @param adapterFactory
+ * the adapter factory for providing label image
+ * @param elementToTransform
+ * the element to transform
+ */
+ public GenericTransformAction(EClass transformationEClass, AdapterFactory adapterFactory, EObject elementToTransform) {
+ super(transformationEClass.getName());
+ targetEClass = transformationEClass;
+ element = elementToTransform;
+
+ if(adapterFactory != null) {
+ EObject tmpEobject = transformationEClass.getEPackage().getEFactoryInstance().create(transformationEClass);
+ IItemLabelProvider provider = (IItemLabelProvider)adapterFactory.adapt(tmpEobject, IItemLabelProvider.class);
+ setImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(provider.getImage(tmpEobject)));
+ }
+ }
+
+ /**
+ * Transform the element and update referencing diagrams.
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ GenericTransformer transformer = new GenericTransformer(element);
+ MultiStatus messages = transformer.isTransformationPossible(targetEClass);
+ if(messages != null && messages.getChildren().length == 0) {
+ String message = String.format(WARNING_MESSAGE, this.element.eClass().getName(), targetEClass.getName());
+ InformationDialog dialog = new InformationDialog(Display.getDefault().getActiveShell(), WARNING_TITLE, message, Activator.getDefault().getPreferenceStore(), INavigatorPreferenceConstants.PREF_NAVIGATOR_TRANSFORM_INTO_SHOW_POPUP, SWT.YES | SWT.NO, MessageDialog.INFORMATION, new String[]{ IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL });
+ int result = dialog.open();
+ if(result == SWT.YES || result == Window.OK) {
+ transformer.transform(targetEClass);
+ }
+ } else {
+ ErrorDialog errorDialog = new ErrorDialog(Display.getDefault().getActiveShell(), ERROR_TITLE, ERROR_MESSAGE, messages, IStatus.WARNING);
+ errorDialog.open();
+ }
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GenericTransformActionProvider.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GenericTransformActionProvider.java
new file mode 100644
index 00000000000..dab4b79a71f
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GenericTransformActionProvider.java
@@ -0,0 +1,187 @@
+/***************************************************
+ * 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.navigator.actions;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.converter.util.ConverterUtil;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+/**
+ * GenericTransformActionProvider class provides GenericTransformAction actions available for a given element.
+ */
+public class GenericTransformActionProvider extends AbstractSubmenuActionProvider {
+
+ /** Group label */
+ private static final String TRANSFORM_INTO_LABEL = "Transform into";
+
+ /** The factories of appropriate EClass */
+ private Map factories = new HashMap();
+
+ /** The appropriate EClass for element's transformation */
+ private Set eClassifiers = new HashSet();
+
+ /**
+ * Adds all actions to transform an EObject
+ */
+ @Override
+ public void fillContextMenu(IMenuManager menu) {
+ super.fillContextMenu(menu);
+ ISelection selection = getContext().getSelection();
+ if(selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) {
+ Object selectedElement = ((IStructuredSelection)selection).getFirstElement();
+ if(selectedElement instanceof EObject) {
+ fillEClassifiers((EObject)selectedElement);
+ }
+ }
+
+ Collection genericTransformActions = generateTransformActions(selection);
+ MenuManager submenuManager = new MenuManager(TRANSFORM_INTO_LABEL);
+ populateManager(submenuManager, genericTransformActions, null);
+ menu.add(submenuManager);
+ }
+
+ /**
+ * From an EObject we get the epackage corresponding to the resource extension of the file
+ * and get the imported epackage correspondant
+ *
+ * @param selectionEObject
+ */
+ private void fillEClassifiers(EObject selectionEObject) {
+ Resource r = selectionEObject.eResource();
+ URI uri = r.getURI();
+ String extension = uri.fileExtension();
+ for(Object p : EPackage.Registry.INSTANCE.values()) {
+ if(p instanceof EPackage) {
+ EPackage pack = (EPackage)p;
+ if(pack.getNsPrefix() != null && extension.toLowerCase().equals(pack.getNsPrefix().toLowerCase())) {
+ addClassifiers(pack, eClassifiers);
+ factories.put(pack.getNsURI(), GenericTransformer.getFactory(pack.getNsURI()));
+ List packages = ConverterUtil.computeRequiredPackages(pack);
+ for(EPackage pTmp : packages) {
+ addClassifiers(pTmp, eClassifiers);
+ factories.put(pTmp.getNsURI(), GenericTransformer.getFactory(pTmp.getNsURI()));
+ }
+ break;
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Register all classifiers contained in the package
+ *
+ * @param pack
+ * the package
+ * @param result
+ * results at which classifiers must be added
+ */
+ private void addClassifiers(EPackage pack, Set result) {
+ for(EClassifier c : pack.getEClassifiers()) {
+ result.add(c);
+ }
+ }
+
+ /**
+ * Generate the sorted list of transformation actions.
+ *
+ * @param descriptors
+ * the descriptors
+ * @param selection
+ * the selection
+ *
+ * @return the collection< i action>
+ */
+ protected Collection generateTransformActions(ISelection selection) {
+ List transformActions = (List)generateTransformActionsCore(selection);
+
+ Collections. sort(transformActions, new Comparator() {
+
+ public int compare(IAction a1, IAction a2) {
+ return a1.getText().compareTo(a2.getText());
+ }
+ });
+
+ return transformActions;
+ }
+
+ /**
+ * Generate transformation actions.
+ *
+ * @param descriptors
+ * the descriptors
+ * @param selection
+ * the selection
+ *
+ * @return the collection< i action>
+ */
+ protected Collection generateTransformActionsCore(ISelection selection) {
+ Collection actions = new ArrayList();
+ if(eClassifiers != null) {
+ for(EClassifier descriptor : eClassifiers) {
+ Object selected = ((IStructuredSelection)selection).getFirstElement();
+ if(selected instanceof EObject) {
+ final EObject selectedElement = (EObject)selected;
+ if(descriptor instanceof EClass && selectedElement.eContainingFeature() != null) {
+ final EClass eclass = (EClass)descriptor;
+ EStructuralFeature containingFeature = selectedElement.eContainingFeature();
+ // to be candidate an eclass has to have a common parent, to not be the selection
+ // and to not be abstract
+ EClass containgType = (EClass)containingFeature.getEType();
+ if((GenericTransformer.getAllSuperTypes(eclass).contains(containgType) || EcoreUtil.equals(eclass, containgType)) && !eclass.equals(selectedElement.eClass()) && !eclass.isAbstract()) {
+ if(selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) {
+
+ AdapterFactory adapterFactory = factories.get(eclass.getEPackage().getNsURI());
+ Action transformAction = new GenericTransformAction(eclass, adapterFactory, selectedElement);
+ actions.add(transformAction);
+ if(adapterFactory != null) {
+ EObject tmpEobject = eclass.getEPackage().getEFactoryInstance().create(eclass);
+ IItemLabelProvider provider = (IItemLabelProvider)adapterFactory.adapt(tmpEobject, IItemLabelProvider.class);
+ transformAction.setImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(provider.getImage(tmpEobject)));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return actions;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GenericTransformer.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GenericTransformer.java
new file mode 100644
index 00000000000..21d50454651
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GenericTransformer.java
@@ -0,0 +1,437 @@
+/***************************************************
+ * 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.navigator.actions;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CommandStack;
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.eclipse.gef.requests.GroupRequest;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.ui.services.editor.EditorService;
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewRefactorHelper;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramEditDomain;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+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.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.infra.core.utils.PapyrusEcoreUtils;
+import org.eclipse.papyrus.navigator.commands.EObjectInheritanceCopyCommand;
+import org.eclipse.papyrus.navigator.internal.Activator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * The Class GenericTransformer. Permits to transform an eobject of eclass to another eclass
+ */
+public class GenericTransformer {
+
+ /** The factories to create eObjects */
+ private static HashMap factories = new HashMap();
+
+ /** extension to recover factories */
+ private static final String EXT_FACTORIES = "org.eclipse.emf.edit.itemProviderAdapterFactories";
+
+ /** title of the warning dialog */
+ private static final String WARNING_TITLE = "Problems during transformation";
+
+ /** message of the warning dialog */
+ private static final String WARNING_MSG = "It seems the transformation you want to perform can't be executed";
+
+ /** command to execute the whole transformation */
+ private CompositeCommand globalCommand;
+
+ /** element to transform */
+ private EObject element;
+
+ /** views referencing the element */
+ private Set referencingViews = new HashSet();
+
+ /** command to execute the model transformation */
+ private EObjectInheritanceCopyCommand commandModel;
+
+ /** whether the graphical edit parts must also be transformed */
+ private boolean graphCopy = true;
+
+ /** the command to import new graphical edit parts */
+ private ImporterCommand importerCommand;
+
+ /**
+ * Instantiates a new generic transformer.
+ *
+ * @param currentNode
+ * the current node
+ */
+ public GenericTransformer(AbstractGraphicalEditPart currentNode) {
+ this(currentNode, true);
+ }
+
+ /**
+ * Instantiates a new generic transformer. and specify if we have to perform graphical copy
+ *
+ * @param currentNode
+ * the current node
+ * @param graphCopy
+ * the graph copy
+ */
+ public GenericTransformer(AbstractGraphicalEditPart currentNode, boolean graphCopy) {
+ this.graphCopy = graphCopy;
+ if(currentNode != null) {
+ Object model = currentNode.getModel();
+ if(model instanceof View) {
+ this.element = ((View)model).getElement();
+ }
+ }
+ }
+
+ /**
+ * Instantiates a new generic transformer.
+ *
+ * @param currentEobject
+ * the current eobject
+ */
+ public GenericTransformer(EObject currentEobject) {
+ this.element = currentEobject;
+ }
+
+ /**
+ * Transform the element to the given eclass.
+ *
+ * @param eclass
+ * the targeted eclass
+ */
+ public void transform(EClass eclass) {
+
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IEditorPart editor = page.getActiveEditor();
+ CommandStack stack = (CommandStack)editor.getAdapter(CommandStack.class);
+ globalCommand = new CompositeCommand("Generic Transformation");
+
+ if(graphCopy) {
+ if(element != null) {
+ EReference[] features = { NotationPackage.eINSTANCE.getView_Element() };
+ Collection> views = EMFCoreUtil.getReferencers(element, features);
+ for(Object view : views) {
+ if(view instanceof View) {
+ referencingViews.add((View)view);
+ }
+ }
+ }
+ }
+ if(stack != null) {
+ // maybe extension point for stereotypes
+ EObject model = (EObject)AdapterFactoryEditingDomain.unwrap(element);
+ // get mixed editing domain to do transaction
+ TransactionalEditingDomain domain = EditorUtils.getTransactionalEditingDomain();
+ commandModel = new EObjectInheritanceCopyCommand(model, eclass, domain);
+ globalCommand.add(commandModel);
+ if(graphCopy) {
+ importerCommand = new ImporterCommand(domain);
+ if(importerCommand.canExecute()) {
+ globalCommand.add(importerCommand);
+ }
+
+ }
+ if(globalCommand.canExecute()) {
+ try {
+ // drop caches about input element
+ ECrossReferenceAdapter cross = ECrossReferenceAdapter.getCrossReferenceAdapter(element);
+ if(cross != null) {
+ cross.unsetTarget(element);
+ }
+ stack.execute(new ICommandProxy(globalCommand));
+ } catch (Exception e) {
+ MessageDialog.openWarning(Display.getDefault().getActiveShell(), WARNING_TITLE, WARNING_MSG);
+ e.printStackTrace();
+ }
+ } else {
+ MessageDialog.openWarning(Display.getDefault().getActiveShell(), WARNING_TITLE, WARNING_MSG);
+ }
+ }
+ }
+
+ /**
+ * The Class ImporterCommand. permits to add the importer in the compound command
+ */
+ private class ImporterCommand extends AbstractTransactionalCommand {
+
+ /**
+ * Constructor.
+ *
+ * @param domain
+ * transactional editing domain
+ */
+ public ImporterCommand(TransactionalEditingDomain domain) {
+ super(domain, "Import graphical nodes", null);
+ }
+
+ /**
+ * Execute the command
+ *
+ * @param monitor
+ * progress monitor
+ * @param info
+ * the info
+ * @return the command result
+ * @throws ExecutionException
+ */
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ graphCopy(null, commandModel.getResultEobject());
+ return CommandResult.newOKCommandResult();
+ }
+
+ /**
+ * Graph copy, make a drag and drop of the new object on all diagrams
+ *
+ * @param diagramDomain
+ * the mixed domain
+ * @param target
+ * the target
+ * @param globalCommand2
+ * @param graphElement
+ * the graph element
+ * @param oldLocation
+ * the old location
+ * @param editpart
+ * the editpart
+ */
+ private void graphCopy(IDiagramEditDomain domain, EObject target) {
+ for(View graphElement : referencingViews) {
+ View parent = ViewUtil.getContainerView(graphElement);
+ if(parent == null || graphElement.getDiagram() == null) {
+ // this is an orphaned view. Skip it
+ continue;
+ }
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ // Get the edit part of the diagram containing the view.
+ DiagramEditPart diagramEditPart = null;
+ IEditorPart activeEditorPart = page.getActiveEditor();
+ if(activeEditorPart instanceof IDiagramWorkbenchPart) {
+ if(graphElement.getDiagram().equals(((IDiagramWorkbenchPart)activeEditorPart).getDiagram())) {
+ diagramEditPart = ((IDiagramWorkbenchPart)activeEditorPart).getDiagramEditPart();
+ }
+ }
+ if(diagramEditPart == null) {
+ // search in other editor parts than the active one
+ List> editorParts = EditorService.getInstance().getRegisteredEditorParts();
+ for(Object editorPart : editorParts) {
+ if(editorPart instanceof IDiagramWorkbenchPart) {
+ if(graphElement.getDiagram().equals(((IDiagramWorkbenchPart)editorPart).getDiagram())) {
+ diagramEditPart = ((IDiagramWorkbenchPart)editorPart).getDiagramEditPart();
+ }
+ }
+ }
+ }
+
+ if(diagramEditPart != null) {
+ EditPart containerPart = (EditPart)diagramEditPart.getViewer().getEditPartRegistry().get(parent);
+ // create the new transformed view
+ DropObjectsRequest req = new DropObjectsRequest();
+ req.setObjects(Collections.singletonList(target));
+ if(graphElement instanceof Node) {
+ LayoutConstraint constraint = ((Node)graphElement).getLayoutConstraint();
+ if(constraint instanceof Location) {
+ Location location = (Location)constraint;
+ req.setLocation(new Point(location.getX(), location.getY()));
+ }
+ }
+ if(req.getLocation() == null) {
+ req.setLocation(new Point());
+ }
+ Command partCreationCmd = containerPart.getCommand(req);
+ partCreationCmd.execute();
+ View newView = null;
+ if(partCreationCmd instanceof ICommandProxy) {
+ CommandResult res = ((ICommandProxy)partCreationCmd).getICommand().getCommandResult();
+ Object newValue = res.getReturnValue();
+ if(newValue instanceof Collection>) {
+ for(Object value : (Collection>)newValue) {
+ if(value instanceof ViewDescriptor) {
+ newView = (View)((ViewDescriptor)value).getAdapter(View.class);
+ }
+ }
+ } else if(newValue instanceof ViewDescriptor) {
+ newView = (View)((ViewDescriptor)newValue).getAdapter(View.class);
+ }
+ }
+ //with ViewRefactorHelper, copy view properties on the old one
+ if(newView != null) {
+ ViewTransformerHelper helper = new ViewTransformerHelper(diagramEditPart.getDiagramPreferencesHint());
+ helper.copyMixedViewFeatures(graphElement, newView);
+ }
+ // delete the old view
+ GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
+ EditPart oldPart = (EditPart)diagramEditPart.getViewer().getEditPartRegistry().get(graphElement);
+ Command partDeletionCmd = oldPart.getCommand(deleteReq);
+ partDeletionCmd.execute();
+ }
+ }
+
+ }
+
+ }
+
+ /**
+ * ViewTransformerHelper allow to refactor a view to copy properties from another view
+ */
+ private static class ViewTransformerHelper extends ViewRefactorHelper {
+
+ /**
+ * Constructor.
+ *
+ * @param preferencesHint
+ * the diagram preferences hint
+ */
+ public ViewTransformerHelper(PreferencesHint preferencesHint) {
+ super(preferencesHint);
+ }
+
+ /**
+ * Copy common features from a view to another
+ *
+ * @param oldView
+ * the old view to copy from
+ * @param newView
+ * the new view to copy to
+ */
+ public void copyMixedViewFeatures(View oldView, View newView) {
+ if(oldView instanceof Diagram && newView instanceof Diagram) {
+ copyDiagramFeatures((Diagram)oldView, (Diagram)newView);
+ } else if(oldView instanceof Node && newView instanceof Node) {
+ copyNodeFeatures((Node)oldView, (Node)newView);
+ } else if(oldView instanceof Edge && newView instanceof Edge) {
+ copyEdgeFeatures((Edge)oldView, (Edge)newView);
+ } else {
+ copyViewFeatures(oldView, newView);
+ }
+ }
+
+ }
+
+ /**
+ * Gets all the super types.
+ *
+ * @param class1
+ * the class
+ *
+ * @return super types
+ */
+ public static HashSet getAllSuperTypes(EClass class1) {
+ HashSet results = new HashSet();
+ results.addAll(class1.getEAllSuperTypes());
+ return results;
+ }
+
+ /**
+ * Gets the factory from uri.
+ *
+ * @param uri
+ * the uri
+ *
+ * @return the factory
+ */
+ public static AdapterFactory getFactory(String uri) {
+ AdapterFactory factory = factories.get(uri);
+ if(factory == null) {
+ IConfigurationElement[] extensions = Platform.getExtensionRegistry().getConfigurationElementsFor(EXT_FACTORIES);
+ for(IConfigurationElement e : extensions) {
+ if(uri.equals(e.getAttribute("uri"))) {
+ try {
+ factory = (AdapterFactory)e.createExecutableExtension("class");
+ if(factory != null) {
+ factories.put(uri, factory);
+ }
+ } catch (CoreException e1) {
+ // do nothing
+ }
+ }
+ }
+ }
+ return factory;
+ }
+
+ /**
+ * Checks if a transformation is possible.
+ *
+ * @param eclass
+ * the eclass
+ *
+ * @return the multi status
+ */
+ public MultiStatus isTransformationPossible(EClass eclass) {
+ MultiStatus result = new MultiStatus(Activator.PLUGIN_ID, 0, "Type incompatibility", null);
+ if(element != null) {
+ Collection usages = PapyrusEcoreUtils.getUsages(element);
+ if(usages != null) {
+ for(EStructuralFeature.Setting nonNavigableInverseReference : usages) {
+ EStructuralFeature structuralFeature = nonNavigableInverseReference.getEStructuralFeature();
+ if(!(nonNavigableInverseReference.getEObject() instanceof View)) {
+ boolean compatible = EObjectInheritanceCopyCommand.isCompatible(structuralFeature.getEType(), eclass);
+ if(!compatible) {
+ String econtainer = structuralFeature.eContainer() instanceof EClassifier ? ((EClassifier)structuralFeature.eContainer()).getName() + " ( " + nonNavigableInverseReference.getEObject().toString() + " )" : structuralFeature.eContainer().toString();
+ Status s = new Status(Status.WARNING, Activator.PLUGIN_ID, String.format("an element typed %s references your selection, we can not assign instead of your selection an object typed %s", econtainer, eclass.getName()));
+ result.add(s);
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GroupChildrenAction.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GroupChildrenAction.java
new file mode 100644
index 00000000000..176619a9335
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/GroupChildrenAction.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Conselleria de Infraestructuras y Transporte, Generalitat
+ * de la Comunitat Valenciana . All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Francisco Javier Cano Muñoz (Prodevelop) - Initial implementation
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.navigator.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.papyrus.navigator.ModelNavigator;
+import org.eclipse.ui.IPropertyListener;
+
+/**
+ * Action that toggles the grouping of children by type in the Model Explorer.
+ *
+ * @author Francisco Javier Cano Muñoz
+ * @see Bug #290422
+ */
+public class GroupChildrenAction extends Action implements IPropertyListener {
+
+ private final ModelNavigator navigator;
+
+ public GroupChildrenAction(ModelNavigator commonNavigator) {
+ super("Group Childs");
+ this.navigator = commonNavigator;
+ this.setToolTipText("Group Childs");
+ init();
+ }
+
+ private void init() {
+
+ updateGroupingChildsProperty(navigator.isGroupingChildsEnabled());
+ navigator.addPropertyListener(this);
+ }
+
+ @Override
+ public void run() {
+ navigator.setGroupChildsEnabled(!navigator.isGroupingChildsEnabled());
+ }
+
+ public void propertyChanged(Object source, int propId) {
+ switch(propId) {
+ case ModelNavigator.IS_GROUPINGCHILDS_ENABLED_PROPERTY:
+ updateGroupingChildsProperty(((ModelNavigator)source).isGroupingChildsEnabled());
+ }
+
+ }
+
+ private void updateGroupingChildsProperty(boolean groupingChildsEnabled) {
+ setChecked(groupingChildsEnabled);
+
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/OpenDiagramAction.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/OpenDiagramAction.java
new file mode 100644
index 00000000000..950f08f4739
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/OpenDiagramAction.java
@@ -0,0 +1,62 @@
+/**
+ *
+ */
+
+package org.eclipse.papyrus.navigator.actions;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.action.Action;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Action used to open the given diagram. The diagram is open in a new tab, even if it is already
+ * open.
+ *
+ * @author cedric dumoulin
+ */
+public class OpenDiagramAction extends Action {
+
+ private final Diagram diagram;
+
+ private final IPageMngr pageMngr;
+
+ public OpenDiagramAction(IPageMngr pageMngr, Diagram diagram) {
+ this.diagram = diagram;
+ this.pageMngr = pageMngr;
+
+ ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
+ if(pageMngr.isOpen(diagram)) {
+ setText("Open in New Tab");
+ setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD));
+ } else {
+ setText("Open");
+ setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_BACK));
+ }
+
+ setEnabled(true);
+ }
+
+ /**
+ * Delete the given diagram
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+
+ pageMngr.openPage(diagram);
+ // TransactionalEditingDomain editingDomain =
+ // NavigatorUtils.getTransactionalEditingDomain();
+ // if (editingDomain != null) {
+ //
+ //
+ // EList diagrams = diagram.eResource().getContents();
+ // //TODO : synchronize with Cedric
+ // Command command = new RemoveCommand(editingDomain, diagrams,
+ // diagram);
+ // editingDomain.getCommandStack().execute(command);
+ // }
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/RemoveTypePrefixAction.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/RemoveTypePrefixAction.java
new file mode 100644
index 00000000000..f83b547db9e
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/RemoveTypePrefixAction.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Conselleria de Infraestructuras y Transporte, Generalitat
+ * de la Comunitat Valenciana . All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Francisco Javier Cano Muñoz (Prodevelop) – Initial API
+ * implementation.
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.navigator.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.papyrus.navigator.ModelNavigator;
+import org.eclipse.ui.IPropertyListener;
+
+/**
+ * Action that removes the prefix that shows the type of the element.
+ *
+ * @author Francisco Javier Cano Muñoz
+ *
+ */
+// fjcano #291192
+public class RemoveTypePrefixAction extends Action implements IPropertyListener {
+
+ /**
+ * The {@link MOSKittModelNavigator} this action is attached to.
+ */
+ private final ModelNavigator navigator;
+
+ /**
+ * Constructor with {@link MOSKittModelNavigator} parameter.
+ *
+ * @param commonNavigator
+ */
+ public RemoveTypePrefixAction(ModelNavigator commonNavigator) {
+ super("Remove type prefix");
+ this.navigator = commonNavigator;
+ this.setToolTipText("Remove type name prefix");
+ init();
+ }
+
+ /**
+ * Initializing means setting the initial state of the {@link Action} and adding the action as
+ * an {@link IPropertyListener} to the {@link MOSKittModelNavigator}.
+ */
+ private void init() {
+ updateRemovePrefixTypesProperty(navigator.isRemovePrefixTypeEnabled());
+ navigator.addPropertyListener(this);
+ }
+
+ /**
+ * Sets the navigator property to remove the prefix of the types.
+ */
+ @Override
+ public void run() {
+ navigator.setRemovePrefixTypeEnabled(!navigator.isRemovePrefixTypeEnabled());
+ }
+
+ /**
+ * Upon a MOSKittModelNavigator.IS_REMOVEPREFIXTYPE_ENABLED_PROPERTY property change, update the
+ * model explorer.
+ */
+ public void propertyChanged(Object source, int propId) {
+ switch(propId) {
+ case ModelNavigator.IS_REMOVEPREFIXTYPE_ENABLED_PROPERTY:
+ updateRemovePrefixTypesProperty(((ModelNavigator)source).isRemovePrefixTypeEnabled());
+ }
+ }
+
+ /**
+ * Update this model explorer.
+ *
+ * @param removePrefixTypesEnabled
+ */
+ private void updateRemovePrefixTypesProperty(boolean removePrefixTypesEnabled) {
+ setChecked(removePrefixTypesEnabled);
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/RenameDiagramAction.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/RenameDiagramAction.java
new file mode 100644
index 00000000000..c75cbcc7053
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/RenameDiagramAction.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.actions;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.navigator.internal.Activator;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Action used to rename the given diagram
+ *
+ * @author Jerome Benois
+ */
+public class RenameDiagramAction extends Action {
+
+ Diagram diagram;
+
+ public RenameDiagramAction(Diagram diagram) {
+ this.diagram = diagram;
+ setImageDescriptor(Activator.getImageDescriptor("icons/etool16/rename.gif"));
+ setText("Rename...");
+ }
+
+ /**
+ * Rename the given diagram
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ TransactionalEditingDomain editingDomain = EditorUtils.getTransactionalEditingDomain();
+ if(editingDomain != null) {
+ InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Rename an existing diagram", "New name:", diagram.getName(), null);
+ if(dialog.open() == Window.OK) {
+ final String name = dialog.getValue();
+ if(name != null && name.length() > 0) {
+
+ Command command = new RecordingCommand(editingDomain) {
+
+ @Override
+ protected void doExecute() {
+ diagram.setName(name);
+ }
+ };
+
+ editingDomain.getCommandStack().execute(command);
+ }
+ }
+ }
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/RenameNamedElementAction.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/RenameNamedElementAction.java
new file mode 100644
index 00000000000..5fa285e5a3c
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/RenameNamedElementAction.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Conselleria de Infraestructuras y Transporte, Generalitat
+ * de la Comunitat Valenciana . All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Francisco Javier Cano Muñoz (Prodevelop) - Initial implementation
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.navigator.actions;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.emf.edit.ui.action.CommandActionHandler;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.navigator.internal.utils.NavigatorUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.uml2.uml.NamedElement;
+
+/**
+ * Action to rename a {@link NamedElement} in the Model Explorer. This action is binded to the "F2"
+ * key.
+ *
+ * @author Francisco Javier Cano Muñoz
+ * @see Bug #290514
+ */
+public class RenameNamedElementAction extends CommandActionHandler {
+
+ /**
+ * Constructor binds this action to the "F2" key.
+ *
+ * @param editingDomain
+ */
+ public RenameNamedElementAction(EditingDomain editingDomain) {
+ super(editingDomain, "Rename...");
+ setAccelerator(SWT.F2);
+ }
+
+ /**
+ * The selected {@link NamedElement}.
+ */
+ private NamedElement selectedNamedElement = null;
+
+ /**
+ * Get the selected {@link NamedElement}.
+ *
+ * @return
+ */
+ protected NamedElement getSelectedNamedElement() {
+ return selectedNamedElement;
+ }
+
+ /**
+ * Set the selected {@link NamedElement}.
+ *
+ * @param selectedNamedElement
+ */
+ // @notused
+ protected void setSelectedNamedElement(NamedElement selectedNamedElement) {
+ this.selectedNamedElement = selectedNamedElement;
+ }
+
+ /**
+ * Update the selection.
+ *
+ * @return true if this {@link Action} is still enabled after the new selection.
+ */
+ @Override
+ public boolean updateSelection(IStructuredSelection selection) {
+ ISelection unwrappedselection = NavigatorUtils.unwrapSelection(selection);
+ if(unwrappedselection instanceof StructuredSelection) {
+ StructuredSelection structuredSelection = (StructuredSelection)unwrappedselection;
+ if(structuredSelection.size() == 1) {
+ Object selectedObject = structuredSelection.getFirstElement();
+ if(selectedObject instanceof NamedElement) {
+ setSelectedNamedElement((NamedElement)selectedObject);
+ return super.updateSelection(selection);
+ }
+ }
+ }
+ setSelectedNamedElement(null);
+ return super.updateSelection(selection);
+ }
+
+ /**
+ * Create the {@link Command} to execute when this {@link Action} is run.
+ */
+ @Override
+ public Command createCommand(Collection> selection) {
+ TransactionalEditingDomain domain = getTransactionalEditingDomain();
+ if(domain == null) {
+ return null;
+ }
+ return new RecordingCommand(domain) {
+
+ @Override
+ protected void doExecute() {
+ InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Rename an existing diagram", "New name:", getSelectedNamedElement().getName(), null);
+ if(dialog.open() == Window.OK) {
+ final String name = dialog.getValue();
+ getSelectedNamedElement().setName(name);
+ }
+ }
+ };
+ }
+
+ /**
+ * Get the {@link EditingDomain} as a {@link TransactionalEditingDomain}.
+ *
+ * @return
+ */
+ protected TransactionalEditingDomain getTransactionalEditingDomain() {
+ if(getEditingDomain() instanceof TransactionalEditingDomain) {
+ return (TransactionalEditingDomain)getEditingDomain();
+ }
+ return null;
+ }
+
+ /**
+ * Update the active {@link IWorkbenchPart} and the active {@link EditingDomain}.
+ *
+ * @param workbenchPart
+ */
+ public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart) {
+ if(workbenchPart instanceof IEditingDomainProvider) {
+ domain = ((IEditingDomainProvider)workbenchPart).getEditingDomain();
+ }
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/SearchElementAction.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/SearchElementAction.java
new file mode 100644
index 00000000000..c4ca60bf718
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/SearchElementAction.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Conselleria de Infraestructuras y Transporte, Generalitat
+ * de la Comunitat Valenciana . All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Francisco Javier Cano Muñoz (Prodevelop) - initial api implementation
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.navigator.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.papyrus.navigator.ModelNavigator;
+import org.eclipse.papyrus.navigator.dialog.NavigatorSearchDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.navigator.CommonNavigator;
+
+/**
+ * An {@link Action} that allows searching elements in the {@link ModelNavigator} by their name.
+ *
+ * @author alreadyManaged = new LinkedList();
+
+ public EObjectInheritanceCopyCommand(EObject source, EClass target, TransactionalEditingDomain adapterFactoryEditingDomain) {
+ super("Inheritance copy");
+ this.sourceEObject = source;
+ this.targetEObject = target.getEPackage().getEFactoryInstance().create(target);
+ this.editingDomain = adapterFactoryEditingDomain;
+ if(sourceEObject == null || targetEObject == null || editingDomain == null) {
+ throw new IllegalArgumentException("Please provide non null arguments");
+ }
+ init();
+ if(sourceEObject.eContainingFeature().isMany()) {
+ replace(sourceEObject.eContainer(), sourceEObject, targetEObject, sourceEObject.eContainingFeature());
+ } else {
+ add(new CustomSetCommand(editingDomain, sourceEObject.eContainer(), sourceEObject.eContainingFeature(), targetEObject, sourceEObject, sourceEObject.eContainingFeature()));
+ add(new DestroyElementCommand(new DestroyElementRequest(editingDomain, sourceEObject, false)));
+ }
+ }
+
+ private void init() {
+ modelCopy(sourceEObject, targetEObject);
+ crossReference(sourceEObject, targetEObject);
+ }
+
+ /**
+ * Model copy, copy the eobject source attributes to target's
+ *
+ * @param mixedDomain
+ * the mixed domain
+ * @param source
+ * the source
+ * @param target
+ * the target
+ */
+ private void modelCopy(EObject source, EObject target) {
+ EClass eclass = source.eClass();
+ if(eclass != null) {
+ EList eAllStructuralFeatures = eclass.getEAllStructuralFeatures();
+ for(EStructuralFeature e : eAllStructuralFeatures) {
+ if(contains(target.eClass(), e) && isCompatible(e.getEType(), target.eClass().getEStructuralFeature(e.getName()).getEType())) {
+ manageFeature(source, target, e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Contains. check if the target eclass contains a estructuralfeature with the same name less rigorous can work for
+ * many cases
+ *
+ * @param target
+ * the target
+ * @param e
+ * the e
+ *
+ * @return true, if successful
+ */
+ private boolean contains(EClass target, EStructuralFeature e) {
+ EList features = target.getEAllStructuralFeatures();
+ for(EStructuralFeature f : features) {
+ if(f.getName().equals(e.getName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Manage feature for cross.
+ *
+ * @param mixedDomain
+ * the mixed domain
+ * @param theObjectWithCross
+ * the the object with cross
+ * @param source
+ * the source
+ * @param target
+ * the target
+ * @param structuralFeature
+ * the structural feature
+ */
+ private void manageFeatureForCross(EObject theObjectWithCross, EObject source, EObject target, EStructuralFeature structuralFeature) {
+ boolean compatible = isCompatible(structuralFeature.getEType(), target.eClass());
+
+ if(compatible && structuralFeature.isChangeable() && !structuralFeature.isDerived()) {
+ if(structuralFeature.isMany()) {
+ replace(theObjectWithCross, source, target, structuralFeature);
+ } else {
+ add(new SetValueCommand(new SetRequest(editingDomain, theObjectWithCross, structuralFeature, target)));
+ }
+ } else if(!compatible) {
+ if(structuralFeature.isMany()) {
+ remove(theObjectWithCross, source, structuralFeature);
+ } else {
+ add(new SetValueCommand(new SetRequest(editingDomain, theObjectWithCross, structuralFeature, null)));
+ }
+ }
+
+ }
+
+ private void remove(EObject owner, Object source, EStructuralFeature structuralFeature) {
+ if(!alreadyManaged.contains(source)) {
+
+ if(owner == null && structuralFeature == null) {
+ if(source instanceof EObject) {
+ add(new DestroyElementCommand(new DestroyElementRequest(editingDomain, (EObject)source, false)));
+ }
+ } else {
+ Object value = owner.eGet(structuralFeature);
+ if(value instanceof Collection>) {
+ List newList = new ArrayList((Collection>)value);
+ newList.remove(source);
+ add(new SetValueCommand(new SetRequest(editingDomain, owner, structuralFeature, newList)));
+ } else if(source.equals(value)) {
+ add(new SetValueCommand(new SetRequest(editingDomain, owner, structuralFeature, null)));
+ } else {
+ add(new SetValueCommand(new SetRequest(editingDomain, owner, structuralFeature, null)));
+ }
+ }
+ alreadyManaged.add(source);
+ }
+ }
+
+ private void replace(EObject owner, Object source, Object target, EStructuralFeature structuralFeature) {
+ if(!alreadyManaged.contains(source)) {
+
+ if(owner == null && structuralFeature == null) {
+ if(source instanceof EObject) {
+ add(new DestroyElementCommand(new DestroyElementRequest(editingDomain, (EObject)source, false)));
+ }
+ } else {
+ Object value = owner.eGet(structuralFeature);
+ if(value instanceof Collection>) {
+ List newList = new ArrayList((Collection>)value);
+ int index = newList.indexOf(source);
+ if(index >= 0) {
+ newList.remove(index);
+ newList.add(index, target);
+ add(new SetValueCommand(new SetRequest(editingDomain, owner, structuralFeature, newList)));
+ }
+ } else if(source.equals(value)) {
+ add(new SetValueCommand(new SetRequest(editingDomain, owner, structuralFeature, target)));
+ } else {
+ add(new SetValueCommand(new SetRequest(editingDomain, owner, structuralFeature, target)));
+ }
+ }
+ alreadyManaged.add(source);
+ }
+ }
+
+ @Override
+ public IStatus undo(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ return super.undo(progressMonitor, info);
+ }
+
+ /**
+ * Cross reference. Manage eobjects referencing the source eobject
+ *
+ * @param mixedDomain
+ * the mixed domain
+ * @param source
+ * the source eobject
+ * @param target
+ * the target eobject
+ */
+ private void crossReference(EObject source, EObject target) {
+ Collection collection = PapyrusEcoreUtils.getUsages(source);
+ if(collection != null) {
+ for(EStructuralFeature.Setting nonNavigableInverseReference : collection) {
+ EStructuralFeature structuralFeature = nonNavigableInverseReference.getEStructuralFeature();
+ if(!(nonNavigableInverseReference.getEObject() instanceof View)) {
+ manageFeatureForCross(nonNavigableInverseReference.getEObject(), source, target, structuralFeature);
+ } else if(nonNavigableInverseReference.getEObject() instanceof Diagram) {
+ Diagram di = (Diagram)nonNavigableInverseReference.getEObject();
+ remove(null, di, null);
+ }
+ }
+ }
+ }
+
+ /**
+ * Checks if a type is compatible to another.
+ *
+ * @param type
+ * the type
+ * @param target
+ * the target
+ *
+ * @return true, if is compatible
+ */
+ public static boolean isCompatible(EClassifier type, EClassifier target) {
+ Collection types = new LinkedList();
+ if(target instanceof EClass) {
+ EClass eclass = (EClass)target;
+ types.addAll(eclass.getEAllSuperTypes());
+ }
+ if(!types.contains(target)) {
+ types.add(target);
+ }
+ return types.contains(type);
+ }
+
+ /**
+ * Manage a feature for the attribute's copy.
+ *
+ * @param mixedDomain
+ * the mixed domain
+ * @param source
+ * the source
+ * @param target
+ * the target
+ * @param feature
+ * the e
+ */
+ @SuppressWarnings("unchecked")
+ private void manageFeature(EObject source, EObject target, EStructuralFeature feature) {
+ EStructuralFeature targetFeature = getFeature(target, feature.getName());
+
+ if(feature.getUpperBound() <= targetFeature.getUpperBound() && feature.getLowerBound() >= targetFeature.getLowerBound()) {
+ if(feature.isChangeable() && !feature.isDerived()) {
+ Object value = source.eGet(feature);
+ if(feature.isMany() && targetFeature.isMany()) {
+ Collection list = (Collection)value;
+ if(list != null && !list.isEmpty()) {
+ Collection newList = new LinkedList();
+ newList.addAll(list);
+ if(feature instanceof EReference && !((EReference)feature).isContainment()) {
+ add(new SetValueCommand(new SetRequest(editingDomain, target, targetFeature, newList)));
+ } else if(feature instanceof EReference && ((EReference)feature).isContainment()) {
+ Collection toTreat = new LinkedList();
+ for(Object o : newList) {
+ if(!alreadyManaged.contains(o)) {
+ toTreat.add(o);
+ alreadyManaged.add(o);
+ }
+ }
+ add(new CustomAddCommand(editingDomain, target, targetFeature, newList, source, feature));
+ }
+ }
+ } else if(!feature.isMany() && !targetFeature.isMany()) {
+ if(value != null) {
+ if(!alreadyManaged.contains(value)) {
+ alreadyManaged.add(value);
+ add(new CustomSetCommand(editingDomain, target, targetFeature, value, source, feature));
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Gets a feature from a name
+ *
+ * @param eobject
+ * the eobject
+ * @param name
+ * the name
+ *
+ * @return the feature
+ */
+ private EStructuralFeature getFeature(EObject eobject, String name) {
+ return eobject.eClass().getEStructuralFeature(name);
+ }
+
+ /**
+ * Gets the result eobject.
+ *
+ * @return the result eobject
+ */
+ public EObject getResultEobject() {
+ return targetEObject;
+ }
+
+ /**
+ * The Class CustomSetCommand. permits to change a value from an eobject to eanother
+ */
+ private class CustomSetCommand extends SetValueCommand {
+
+ private EObject oldObject = null;
+
+ private EStructuralFeature oldFeature = null;
+
+ private Object oldValue = null;
+
+ public CustomSetCommand(TransactionalEditingDomain domain, EObject owner, EStructuralFeature feature, Object value, EObject old, EStructuralFeature structuralFeature) {
+ super(new SetRequest(domain, owner, feature, value));
+ oldObject = old;
+ oldFeature = structuralFeature;
+ oldValue = value;
+ }
+
+ @Override
+ protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ IStatus result = super.doUndo(monitor, info);
+ oldObject.eSet(oldFeature, oldValue);
+ return result;
+ }
+
+ }
+
+ /**
+ * The Class CustomSetCommand. permits to change a value from an eobject to eanother
+ */
+ private class CustomAddCommand extends SetValueCommand {
+
+ private EObject oldObject = null;
+
+ private EStructuralFeature oldFeature;
+
+ private EStructuralFeature newFeature;
+
+ public CustomAddCommand(TransactionalEditingDomain editingDomain, EObject target, EStructuralFeature targetFeature, Collection newList, EObject source, EStructuralFeature e) {
+ super(new SetRequest(editingDomain, target, targetFeature, newList));
+ oldObject = source;
+ oldFeature = e;
+ newFeature = targetFeature;
+ }
+
+ @Override
+ protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Object values = getElementToEdit().eGet(newFeature);
+ IStatus result = super.doUndo(monitor, info);
+ // this test permit to avoid modification from other command
+ // if getOwner list is empty it will perform error we avoid it
+ if(values instanceof Collection> && !((Collection>)values).isEmpty()) {
+ Collection> collection = (Collection>)values;
+ Collection collecOldObject = (Collection)oldObject.eGet(oldFeature);
+ for(Object o : collection) {
+ if(!collecOldObject.contains(o)) {
+ collecOldObject.add(o);
+ }
+ }
+ }
+ return result;
+ }
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dialog/InformationDialog.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dialog/InformationDialog.java
new file mode 100644
index 00000000000..868b4310bda
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dialog/InformationDialog.java
@@ -0,0 +1,124 @@
+/*****************************************************************************
+ * 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:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigator.dialog;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * A JFace dialog used to show information to the end user.
+ * This dialog is able to store the user choice into a preference store.
+ *
+ */
+public class InformationDialog extends MessageDialog {
+
+ private IPreferenceStore ps;
+
+ private String preference;
+
+ private Button rememberChoice;
+
+ /**
+ * The Constructor.
+ *
+ * @param parentShell
+ * the parent shell
+ * @param dialogTitle
+ * the dialog title
+ * @param message
+ * the message
+ * @param pso
+ * the preference store
+ * @param preference
+ * the preference
+ */
+ public InformationDialog(Shell parentShell, String dialogTitle, String message, IPreferenceStore ps, String preference) {
+ this(parentShell, dialogTitle, message, ps, preference, SWT.OK, MessageDialog.INFORMATION, new String[]{ IDialogConstants.OK_LABEL });
+ }
+
+ /**
+ * The Constructor.
+ *
+ * @param parentShell
+ * the parent shell
+ * @param dialogTitle
+ * the dialog title
+ * @param message
+ * the message
+ * @param ps
+ * the ps the preference store
+ * @param preference
+ * the preference string to store the choice
+ * @param style
+ * the style for buttons : SWT.OK, SWT.YES
+ * @param messageDialogType
+ * : MessageDialog.INFORMATION, MessageDialog.WARNING
+ * @param labels
+ * the labels, for example IDialogConstants.OK_LABEL
+ */
+ public InformationDialog(Shell parentShell, String dialogTitle, String message, IPreferenceStore ps, String preference, int style, int messageDialogType, String[] labels) {
+ super(parentShell, dialogTitle, null, message, messageDialogType, labels, style);
+ this.ps = ps;
+ this.preference = preference;
+ }
+
+ /**
+ * @see org.eclipse.jface.dialogs.MessageDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea(Composite parent) {
+ Composite container = (Composite)super.createDialogArea(parent);
+
+ if(ps != null && preference != null && preference.length() > 0) {
+ rememberChoice = new Button(container, SWT.CHECK);
+ rememberChoice.setText("Do not show again");
+ }
+ return container;
+ }
+
+ /**
+ * @see org.eclipse.jface.window.Window#open()
+ * return Window.OK if it's valid
+ */
+ public int open() {
+ // Do not open the dialog if the preference is true
+ if(ps != null && preference != null && preference.length() > 0) {
+ if(ps.getBoolean(preference)) {
+ return Window.OK;
+ }
+ }
+ return super.open();
+ }
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+ */
+ protected void buttonPressed(int buttonId) {
+ // OK pressed
+ if(buttonId == Window.OK && rememberChoice.getSelection()) {
+ if(ps != null && preference != null && preference.length() > 0) {
+ // Store the preference
+ ps.setValue(preference, true);
+ }
+ }
+ super.buttonPressed(buttonId);
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dialog/NavigatorSearchDialog.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dialog/NavigatorSearchDialog.java
new file mode 100644
index 00000000000..67d28b937ed
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dialog/NavigatorSearchDialog.java
@@ -0,0 +1,274 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Conselleria de Infraestructuras y Transporte, Generalitat
+ * de la Comunitat Valenciana . All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Francisco Javier Cano Muñoz (Prodevelop) - initial api contribution
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.navigator.dialog;
+
+import java.util.ArrayList;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.navigator.CommonNavigator;
+
+/**
+ * A dialog that allows searching elements in the Model navigator by name.
+ *
+ * @author Francisco Javier Cano Muñoz
+ */
+public class NavigatorSearchDialog extends TrayDialog {
+
+ private ITreeContentProvider contentProvider = null;
+
+ private ILabelProvider labelProvider = null;
+
+ private Object root = null;
+
+ private Viewer viewer = null;
+
+ private List matchedObjects = Collections.emptyList();
+
+ private Label matchesLabel;
+
+ private Text searchText;
+
+ private Button backButton;
+
+ private Button nextButton;
+
+ private Button caseButton;
+
+ public NavigatorSearchDialog(Shell shell, CommonNavigator modelNavigator) {
+ super(shell);
+ IContentProvider cprovider = modelNavigator.getCommonViewer().getContentProvider();
+ if(cprovider instanceof ITreeContentProvider) {
+ contentProvider = (ITreeContentProvider)cprovider;
+ }
+ root = modelNavigator.getCommonViewer().getInput();
+ viewer = modelNavigator.getCommonViewer();
+ labelProvider = (ILabelProvider)modelNavigator.getCommonViewer().getLabelProvider();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets .Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite background = new Composite(parent, SWT.None);
+ GridData bgData = new GridData(GridData.FILL_BOTH);
+ bgData.minimumWidth = 300;
+ background.setLayoutData(bgData);
+ GridLayout bgLayout = new GridLayout();
+ bgLayout.numColumns = 2;
+ background.setLayout(bgLayout);
+
+ createSearchTextComposite(background);
+ return background;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse
+ * .swt.widgets.Composite)
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+
+ backButton = createButton(parent, IDialogConstants.BACK_ID, IDialogConstants.BACK_LABEL, false);
+ nextButton = createButton(parent, IDialogConstants.NEXT_ID, IDialogConstants.NEXT_LABEL, false);
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+
+ backButton.setEnabled(false);
+ nextButton.setEnabled(false);
+
+ nextButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ ISelection sel = viewer.getSelection();
+ if(!(sel instanceof StructuredSelection)) {
+ return;
+ }
+ StructuredSelection ssel = (StructuredSelection)sel;
+
+ int index = matchedObjects.lastIndexOf(ssel.getFirstElement());
+ if(index == matchedObjects.size() - 1) {
+ index = -1;
+ }
+ index++;
+ viewer.setSelection(new StructuredSelection(matchedObjects.get(index)), true);
+ }
+
+ });
+
+ backButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ ISelection sel = viewer.getSelection();
+ if(!(sel instanceof StructuredSelection)) {
+ return;
+ }
+ StructuredSelection ssel = (StructuredSelection)sel;
+
+ int index = matchedObjects.lastIndexOf(ssel.getFirstElement());
+ if(index == 0) {
+ index = matchedObjects.size() - 1;
+ }
+ index--;
+ viewer.setSelection(new StructuredSelection(matchedObjects.get(index)), true);
+ }
+
+ });
+ }
+
+ private void createSearchTextComposite(Composite background) {
+ Label searchLabel = new Label(background, SWT.None);
+ searchLabel.setText("Search:");
+ searchLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
+
+ searchText = new Text(background, SWT.SEARCH);
+ searchText.setFocus();
+ searchText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ searchText.addKeyListener(getKeyListener());
+
+ caseButton = new Button(background, SWT.CHECK);
+ caseButton.setText("Case sensitive?");
+ GridData caseButtonData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ caseButtonData.horizontalSpan = 2;
+ caseButton.setSelection(false);
+ caseButton.setLayoutData(caseButtonData);
+ caseButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ updateMatches();
+ }
+
+ });
+
+ Label resultsLabel = new Label(background, SWT.None);
+ resultsLabel.setText("Results:");
+ resultsLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
+
+ matchesLabel = new Label(background, SWT.None);
+ matchesLabel.setText("No matchings.");
+ matchesLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL));
+
+ }
+
+ private void updateMatches() {
+ if(contentProvider == null && labelProvider == null) {
+ return;
+ }
+
+ String pattern = searchText.getText();
+ if(pattern.length() == 0) {
+ matchedObjects = Collections.emptyList();
+ backButton.setEnabled(false);
+ nextButton.setEnabled(false);
+ matchesLabel.setText("No matchings.");
+ return;
+ }
+
+ if(!caseButton.getSelection()) {
+ pattern = pattern.toUpperCase();
+ }
+
+ matchedObjects = searchPattern(pattern, Arrays.asList(contentProvider.getElements(root)));
+
+ // Update matches label
+ matchesLabel.setText(matchedObjects.size() + " matches found");
+
+ // Select first match and update buttons
+ if(!matchedObjects.isEmpty()) {
+ viewer.setSelection(new StructuredSelection(matchedObjects.get(0)), true);
+ nextButton.setEnabled(true);
+ backButton.setEnabled(true);
+ } else {
+ nextButton.setEnabled(false);
+ backButton.setEnabled(false);
+ }
+
+ }
+
+ private List searchPattern(String pattern, List objects) {
+ List matches = new ArrayList();
+
+ List childs = new ArrayList();
+ String objectLabel;
+ boolean caseSensitive = caseButton.getSelection();
+ for(Object o : objects) {
+ // Search matches in this level
+ objectLabel = caseSensitive ? labelProvider.getText(o) : labelProvider.getText(o).toUpperCase();
+
+ if(objectLabel.contains(pattern)) {
+ matches.add(o);
+ }
+
+ // Find childs
+ childs.addAll(Arrays.asList(contentProvider.getChildren(o)));
+ }
+
+ if(!childs.isEmpty()) {
+ matches.addAll(searchPattern(pattern, childs));
+ }
+
+ return matches;
+ }
+
+ protected KeyListener getKeyListener() {
+ return new KeyListener() {
+
+ public void keyPressed(KeyEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void keyReleased(KeyEvent e) {
+ updateMatches();
+
+ }
+
+ };
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dnd/CommonDragAdapterAssistant.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dnd/CommonDragAdapterAssistant.java
new file mode 100644
index 00000000000..c24af5a46f7
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dnd/CommonDragAdapterAssistant.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.dnd;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
+import org.eclipse.uml2.uml.PackageableElement;
+
+/**
+ * This class handle Drag events in ModelExplorer view.
+ *
+ * @author Jerome Benois
+ */
+public class CommonDragAdapterAssistant extends org.eclipse.ui.navigator.CommonDragAdapterAssistant {
+
+ public CommonDragAdapterAssistant() {
+ }
+
+ @Override
+ public Transfer[] getSupportedTransferTypes() {
+ Transfer[] transfer = new Transfer[]{ LocalSelectionTransfer.getInstance() };
+ return transfer;
+ }
+
+ @Override
+ public boolean setDragData(DragSourceEvent anEvent, IStructuredSelection selection) {
+ Object o = selection.getFirstElement();
+ if(o instanceof PackageableElement) {
+ anEvent.data = o;
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dnd/CommonDropAdapterAssistant.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dnd/CommonDropAdapterAssistant.java
new file mode 100644
index 00000000000..f8a17f5850a
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/dnd/CommonDropAdapterAssistant.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.dnd;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
+import org.eclipse.uml2.common.edit.command.ChangeCommand;
+import org.eclipse.uml2.uml.Namespace;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PackageableElement;
+
+/**
+ * This class handle Drop events in ModelExplorer view.
+ *
+ * @author Jerome Benois
+ */
+public class CommonDropAdapterAssistant extends org.eclipse.ui.navigator.CommonDropAdapterAssistant {
+
+ public CommonDropAdapterAssistant() {
+ }
+
+ @Override
+ public IStatus handleDrop(CommonDropAdapter dropAdapter, DropTargetEvent dropTargetEvent, Object dropTarget) {
+ Package targetElement = (Package)dropTarget;
+ if(LocalSelectionTransfer.getInstance().isSupportedType(dropAdapter.getCurrentTransfer())) {
+ switch(dropAdapter.getCurrentOperation()) {
+ case DND.DROP_MOVE:
+ handleDropMove(targetElement);
+ break;
+ // case DND.DROP_COPY:
+ // break;
+ }
+
+ }
+ return null;
+ }
+
+ @Override
+ public IStatus validateDrop(Object target, int operation, TransferData transferType) {
+ if(target instanceof Package) {
+ return Status.OK_STATUS;
+ }
+ return Status.CANCEL_STATUS;
+ }
+
+ private void handleDropMove(final Package target) {
+ ISelection s = LocalSelectionTransfer.getInstance().getSelection();
+ if(s instanceof IStructuredSelection) {
+ List> selectedElements = ((IStructuredSelection)s).toList();
+ for(Object o : selectedElements) {
+ if(o instanceof PackageableElement) {
+ PackageableElement element = (PackageableElement)o;
+ moveElementTo(element, target);
+ }
+ }
+ }
+ }
+
+ private void moveElementTo(final PackageableElement element, final Package target) {
+ TransactionalEditingDomain editingDomain = getEditingDomain();
+ if(editingDomain != null && (element.getNamespace() instanceof Package)) {
+ ChangeCommand changeCommand = new ChangeCommand(editingDomain, new Runnable() {
+
+ public void run() {
+ Namespace oldOwner = element.getNamespace();
+ if(oldOwner instanceof Package) {
+ // Remove from the old package
+ Package pkg = (Package)oldOwner;
+ pkg.getPackagedElements().remove(element);
+
+ // Add to the new package
+ target.getPackagedElements().add(element);
+ }
+ }
+ }, "Move " + element.getName() + " to " + target.getName());
+
+ if(changeCommand.canExecute()) {
+ editingDomain.getCommandStack().execute(changeCommand);
+ }
+ }
+ }
+
+ private TransactionalEditingDomain getEditingDomain() {
+ return EditorUtils.getTransactionalEditingDomain();
+ }
+
+ private IMultiDiagramEditor getMultiDiagramEditor() {
+ IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if(editorPart instanceof IMultiDiagramEditor) {
+ return (IMultiDiagramEditor)editorPart;
+ }
+ return null;
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/DefaultEMFActionsFactory.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/DefaultEMFActionsFactory.java
new file mode 100644
index 00000000000..58075317f4f
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/DefaultEMFActionsFactory.java
@@ -0,0 +1,180 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigator.factory;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.ui.action.CopyAction;
+import org.eclipse.emf.edit.ui.action.CutAction;
+import org.eclipse.emf.edit.ui.action.DeleteAction;
+import org.eclipse.emf.edit.ui.action.LoadResourceAction;
+import org.eclipse.emf.edit.ui.action.PasteAction;
+import org.eclipse.emf.edit.ui.action.RedoAction;
+import org.eclipse.emf.edit.ui.action.UndoAction;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.navigator.CommonNavigator;
+
+/**
+ * The Class DefaultEMFActionsFactory for creating a default action from EMF. Undefined actions are
+ * not still in use or might be overridden
+ *
+ * @author Emilien Perico
+ */
+public class DefaultEMFActionsFactory implements IActionHandlerFactory {
+
+ protected List actions = new LinkedList();
+
+ protected DeleteAction deleteAction;
+
+ protected CutAction cutAction;
+
+ protected CopyAction copyAction;
+
+ protected PasteAction pasteAction;
+
+ protected UndoAction undoAction;
+
+ protected RedoAction redoAction;
+
+ protected LoadResourceAction loadResourceAction;
+
+ // protected ValidateAction validateAction;
+
+ /**
+ * {@inheritDoc}
+ */
+ public List createActions(EditingDomain editingDomain) {
+ ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
+
+ // Create Cut action
+ this.cutAction = new CutAction(editingDomain);
+ this.cutAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
+ actions.add(cutAction);
+
+ // Create Copy action
+ this.copyAction = new CopyAction(editingDomain);
+ this.copyAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
+ actions.add(copyAction);
+
+ // Create Paste action
+ this.pasteAction = new PasteAction(editingDomain);
+ this.pasteAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
+ actions.add(pasteAction);
+
+ // Create Delete action
+ this.deleteAction = new DeleteAction(editingDomain, true);
+ this.deleteAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+ this.deleteAction.setDisabledImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
+ actions.add(deleteAction);
+
+ // Undo action
+ this.undoAction = new UndoAction();
+ this.undoAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_UNDO));
+ actions.add(undoAction);
+
+ // Redo action
+ this.redoAction = new RedoAction();
+ this.redoAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_REDO));
+ actions.add(redoAction);
+
+ // Load Resource action
+ this.loadResourceAction = new LoadResourceAction(editingDomain);
+ actions.add(loadResourceAction);
+
+ return actions;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void activate(CommonNavigator activeViewPart) {
+ deleteAction.setActiveWorkbenchPart(activeViewPart);
+ cutAction.setActiveWorkbenchPart(activeViewPart);
+ copyAction.setActiveWorkbenchPart(activeViewPart);
+ pasteAction.setActiveWorkbenchPart(activeViewPart);
+ undoAction.setActiveWorkbenchPart(activeViewPart);
+ redoAction.setActiveWorkbenchPart(activeViewPart);
+ loadResourceAction.setActiveWorkbenchPart(activeViewPart);
+
+ ISelectionProvider selectionProvider = null;
+ if(activeViewPart.getCommonViewer() instanceof ISelectionProvider) {
+ selectionProvider = activeViewPart.getCommonViewer();
+ selectionProvider.addSelectionChangedListener(deleteAction);
+ selectionProvider.addSelectionChangedListener(cutAction);
+ selectionProvider.addSelectionChangedListener(copyAction);
+ selectionProvider.addSelectionChangedListener(pasteAction);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void deactivate(CommonNavigator activeViewPart) {
+ deleteAction.setActiveWorkbenchPart(null);
+ cutAction.setActiveWorkbenchPart(null);
+ copyAction.setActiveWorkbenchPart(null);
+ pasteAction.setActiveWorkbenchPart(null);
+ undoAction.setActiveWorkbenchPart(null);
+ redoAction.setActiveWorkbenchPart(null);
+ loadResourceAction.setActiveWorkbenchPart(null);
+
+ ISelectionProvider selectionProvider = null;
+ if(activeViewPart.getCommonViewer() instanceof ISelectionProvider) {
+ selectionProvider = activeViewPart.getCommonViewer();
+ selectionProvider.removeSelectionChangedListener(deleteAction);
+ selectionProvider.removeSelectionChangedListener(cutAction);
+ selectionProvider.removeSelectionChangedListener(copyAction);
+ selectionProvider.removeSelectionChangedListener(pasteAction);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void fillActionBars(IActionBars actionBars) {
+ actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
+ actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), cutAction);
+ actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
+ actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);
+ actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction);
+ actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void update(IStructuredSelection structuredSelection) {
+ deleteAction.updateSelection(structuredSelection);
+ cutAction.updateSelection(structuredSelection);
+ copyAction.updateSelection(structuredSelection);
+ pasteAction.updateSelection(structuredSelection);
+ loadResourceAction.update();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getActions() {
+ return actions;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/GroupableAdapterFactory.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/GroupableAdapterFactory.java
new file mode 100644
index 00000000000..1b73e0b8fbc
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/GroupableAdapterFactory.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Conselleria de Infraestructuras y Transporte, Generalitat
+ * de la Comunitat Valenciana . All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Javier Muñoz (Integranova) - Initial implementation
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.navigator.factory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.navigator.providers.GroupableTreeArrayContentProvider;
+import org.eclipse.papyrus.navigator.providers.PackagingNode;
+
+/**
+ * @author Francisco Javier Cano Muñoz
+ */
+public class GroupableAdapterFactory extends AdapterFactoryImpl {
+
+ /** The supported types. */
+ private final Collection supportedTypes = new ArrayList();
+
+ private final AdapterFactory wrappedAdapterFactory;
+
+ public GroupableAdapterFactory(AdapterFactory factory) {
+ wrappedAdapterFactory = factory;
+ supportedTypes.add(IStructuredItemContentProvider.class);
+ supportedTypes.add(ITreeItemContentProvider.class);
+ supportedTypes.add(IItemPropertySource.class);
+ supportedTypes.add(IEditingDomainItemProvider.class);
+ supportedTypes.add(IItemLabelProvider.class);
+ supportedTypes.add(ITableItemLabelProvider.class);
+ }
+
+ @Override
+ public Object adapt(Object target, Object type) {
+ if((target instanceof EObject) || (target instanceof PackagingNode)) {
+ return new GroupableTreeArrayContentProvider(this, wrappedAdapterFactory);
+ } else {
+ return this.wrappedAdapterFactory.adapt(target, type);
+ }
+ }
+
+ @Override
+ public Adapter adapt(Notifier target, Object type) {
+
+ return (Adapter)adapt((Object)target, type);
+ }
+
+ @Override
+ public boolean isFactoryForType(Object type) {
+ return (((type instanceof EObject) || (type instanceof PackagingNode) || supportedTypes.contains(type)) && (!(type instanceof View))) || this.wrappedAdapterFactory.isFactoryForType(type);
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/IActionHandlerFactory.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/IActionHandlerFactory.java
new file mode 100644
index 00000000000..ab6f0610e5c
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/IActionHandlerFactory.java
@@ -0,0 +1,82 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigator.factory;
+
+import java.util.List;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.navigator.CommonNavigator;
+
+/**
+ * A factory for creating Action objects from org.eclipse.jface.action
+ */
+public interface IActionHandlerFactory {
+
+ /**
+ * Creates a new IActionHandler object.
+ *
+ * @param editingDomain
+ * the editing domain
+ *
+ * @return the list of created actions
+ */
+ List createActions(EditingDomain editingDomain);
+
+ /**
+ * Gets the actions.
+ *
+ * @return the actions list
+ */
+ List getActions();
+
+ /**
+ * Activate the action.
+ *
+ * @param activeViewPart
+ * the active view part
+ */
+ void activate(CommonNavigator activeViewPart);
+
+ /**
+ * Deactivate the action.
+ *
+ * @param activeViewPart
+ * the active view part
+ */
+ void deactivate(CommonNavigator activeViewPart);
+
+ /**
+ * Update action from the selection
+ *
+ * @param structuredSelection
+ * the structured selection
+ */
+ void update(IStructuredSelection structuredSelection);
+
+ /**
+ * Adds the applicable actions to a part's action bars, including setting any global action
+ * handlers.
+ *
+ * The default implementation does nothing.
+ *
+ *
+ * @param actionBars
+ * the part's action bars
+ */
+ void fillActionBars(IActionBars actionBars);
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/RenameActionFactory.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/RenameActionFactory.java
new file mode 100644
index 00000000000..4531ebb3b01
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/factory/RenameActionFactory.java
@@ -0,0 +1,100 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigator.factory;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.navigator.actions.RenameNamedElementAction;
+import org.eclipse.papyrus.navigator.internal.Activator;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.navigator.CommonNavigator;
+
+/**
+ * The Class RenameActionFactory for creating a rename action for named element
+ *
+ * @author Emilien Perico
+ */
+public class RenameActionFactory implements IActionHandlerFactory {
+
+ protected List actions = new LinkedList();
+
+ protected RenameNamedElementAction renameNamedElementAction;
+
+ /**
+ * {@inheritDoc}
+ */
+ public List createActions(EditingDomain editingDomain) {
+ // Rename NamedElement action
+ // fjcano #290514 :: command to rename elements in the model explorer
+ this.renameNamedElementAction = new RenameNamedElementAction(editingDomain);
+ this.renameNamedElementAction.setImageDescriptor(Activator.getImageDescriptor("icons/etool16/rename.gif"));
+ actions.add(renameNamedElementAction);
+
+ return actions;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void activate(CommonNavigator activeViewPart) {
+ this.renameNamedElementAction.setActiveWorkbenchPart(activeViewPart);
+
+ ISelectionProvider selectionProvider = null;
+ if(activeViewPart.getCommonViewer() instanceof ISelectionProvider) {
+ selectionProvider = activeViewPart.getCommonViewer();
+ selectionProvider.addSelectionChangedListener(renameNamedElementAction);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void deactivate(CommonNavigator activeViewPart) {
+ this.renameNamedElementAction.setActiveWorkbenchPart(null);
+
+ ISelectionProvider selectionProvider = null;
+ if(activeViewPart.getCommonViewer() instanceof ISelectionProvider) {
+ selectionProvider = activeViewPart.getCommonViewer();
+ selectionProvider.removeSelectionChangedListener(renameNamedElementAction);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void fillActionBars(IActionBars actionBars) {
+ actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameNamedElementAction);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void update(IStructuredSelection structuredSelection) {
+ this.renameNamedElementAction.updateSelection(structuredSelection);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getActions() {
+ return actions;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/DiResourceFilter.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/DiResourceFilter.java
new file mode 100644
index 00000000000..171f5a9bc01
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/DiResourceFilter.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.navigator.filters;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.papyrus.infra.core.resource.notation.NotationModel;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
+import org.eclipse.papyrus.infra.core.utils.DiResourceSet;
+
+/**
+ * Filter that hides/shows the di/uml/notation.
+ *
+ * @author Thomas Szadel
+ */
+public class DiResourceFilter extends ViewerFilter {
+
+ /**
+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if(element instanceof IFile) {
+ IFile file = ((IFile)element);
+ String ext = file.getFileExtension();
+ if(NotationModel.NOTATION_FILE_EXTENSION.equalsIgnoreCase(ext)) {
+ // Let see if the .di exists
+ String name = file.getName().substring(0, file.getName().lastIndexOf('.'));
+ if(file.getParent().findMember(name + "." + DiModel.DI_FILE_EXTENSION) != null) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideAdditionalResourcesViewerFilter.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideAdditionalResourcesViewerFilter.java
new file mode 100644
index 00000000000..46c7f128f19
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideAdditionalResourcesViewerFilter.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.filters;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.papyrus.navigator.internal.AdditionalResources;
+
+/**
+ * Filter Additional Resources in navigator in order to hide.
+ *
+ * @author Jerome Benois
+ */
+public class HideAdditionalResourcesViewerFilter extends ViewerFilter {
+
+ /**
+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if(element instanceof AdditionalResources) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideDiagramsViewerFilter.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideDiagramsViewerFilter.java
new file mode 100644
index 00000000000..54e626b5ae6
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideDiagramsViewerFilter.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.filters;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+/**
+ * Filter diagrams elements in navigator in order to hide.
+ *
+ * @author Jerome Benois
+ */
+public class HideDiagramsViewerFilter extends ViewerFilter {
+
+ /**
+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if(element instanceof Diagram) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideEAnnotationsViewerFilter.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideEAnnotationsViewerFilter.java
new file mode 100644
index 00000000000..43d8ad6e963
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideEAnnotationsViewerFilter.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.filters;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+/**
+ * Filter EAnnotation elements in navigator in order to hide.
+ *
+ * @author Jerome Benois
+ */
+public class HideEAnnotationsViewerFilter extends ViewerFilter {
+
+ /**
+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if(element instanceof EAnnotation) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideProfileApplicationsViewerFilter.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideProfileApplicationsViewerFilter.java
new file mode 100644
index 00000000000..8ae30164b33
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/filters/HideProfileApplicationsViewerFilter.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.filters;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.uml2.uml.ProfileApplication;
+
+/**
+ * Filter Profile Application elements in navigator in order to hide.
+ *
+ * @author Jerome Benois
+ */
+public class HideProfileApplicationsViewerFilter extends ViewerFilter {
+
+ /**
+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if(element instanceof ProfileApplication) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/Activator.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/Activator.java
new file mode 100644
index 00000000000..8d50db27444
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/Activator.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.internal;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ *
+ * @author Jerome Benois
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.navigator";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /** The shared log helper. */
+ public static LogHelper log;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(plugin);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ 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;
+ }
+
+ /**
+ * get the image descriptor from a string path
+ *
+ * @param pathString
+ * path of the image
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String pathString) {
+
+ IPath path = new Path(pathString);
+ URL uri = FileLocator.find(Activator.plugin.getBundle(), path, null);
+ if(uri == null) {
+ return null;
+ }
+ return ImageDescriptor.createFromURL(uri);
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/AdditionalResources.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/AdditionalResources.java
new file mode 100644
index 00000000000..d64cb69a56a
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/AdditionalResources.java
@@ -0,0 +1,51 @@
+/***********************************************************************
+ * Copyright (c) 2007-2009 Anyware Technologies, Obeo
+ *
+ * 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:
+ * Anyware Technologies - initial API and implementation
+ * Obeo
+ *
+ **********************************************************************/
+package org.eclipse.papyrus.navigator.internal;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.papyrus.infra.core.utils.DiResourceSet;
+
+/**
+ * This object computes all the loaded resources from a resource set.
+ *
+ * @author David Sciamma
+ * @author Jacques Lescot
+ * @author Jerome Benois
+ * @author Thomas Szadel
+ */
+public class AdditionalResources {
+
+ private DiResourceSet diResourceSet;
+
+ /**
+ * Constructor
+ *
+ * @param rSet
+ * the ResourceSet to be used to load these Additional Resources
+ */
+ public AdditionalResources(DiResourceSet diResourceSet) {
+ this.diResourceSet = diResourceSet;
+ }
+
+ /**
+ * Returns all the resources without the DI and the domain resources
+ *
+ * @return the list of additional resources
+ */
+ public List getResources() {
+ return diResourceSet.getAdditionalResources();
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/DeleteModelParticipant.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/DeleteModelParticipant.java
new file mode 100644
index 00000000000..e054c1390c5
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/DeleteModelParticipant.java
@@ -0,0 +1,143 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Thomas Szadel - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigator.internal.ltk;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.NullChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.DeleteParticipant;
+import org.eclipse.ltk.core.refactoring.resource.DeleteResourceChange;
+
+/**
+ * The participant that is aware of file deletion.
+ *
+ * @author Thomas Szadel
+ *
+ */
+public class DeleteModelParticipant extends DeleteParticipant {
+
+ private Set filesToRemove;
+
+ /**
+ * Overrides checkConditions.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
+ */
+ @Override
+ public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) throws OperationCanceledException {
+ return new RefactoringStatus();
+ }
+
+ /**
+ * Overrides createChange.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ List changes = new ArrayList(filesToRemove.size());
+ for(IResource file : filesToRemove) {
+ if(file.exists()) {
+ changes.add(new InternalDeleteResourceChange(file.getFullPath(), true));
+ }
+ }
+ if(changes.isEmpty()) {
+ return new NullChange();
+ } else {
+ return new CompositeChange(getName(), changes.toArray(new Change[changes.size()]));
+ }
+ }
+
+ /**
+ * Overrides getName.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName()
+ */
+ @Override
+ public String getName() {
+ return "Papyrus Model Deletion";
+ }
+
+ /**
+ * Overrides initialize.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object)
+ */
+ @Override
+ protected boolean initialize(Object element) {
+ if(!(element instanceof IFile)) {
+ return false;
+ }
+ IFile file = (IFile)element;
+
+ filesToRemove = ModelParticipantHelpers.getRelatedFiles(file);
+ return filesToRemove.size() > 0;
+ }
+
+
+
+ private class InternalDeleteResourceChange extends DeleteResourceChange {
+
+ /**
+ * Constructor.
+ *
+ * @param resourcePath
+ * The file to delete.
+ * @param forceOutOfSync
+ * Delete even if out of sync
+ */
+ public InternalDeleteResourceChange(IPath resourcePath, boolean forceOutOfSync) {
+ super(resourcePath, forceOutOfSync);
+ }
+
+ /**
+ * @see org.eclipse.ltk.core.refactoring.resource.DeleteResourceChange#perform(org.eclipse.core.runtime.IProgressMonitor)
+ *
+ * @param pm
+ * @return
+ * @throws CoreException
+ */
+
+ @Override
+ public Change perform(IProgressMonitor pm) throws CoreException {
+ IResource resource = getModifiedResource();
+ // If the user selects the 3 resources, the delete fails.
+ if(resource == null || !resource.exists()) {
+ return new NullChange();
+ }
+ return super.perform(pm);
+ }
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/DirtyEditorChange.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/DirtyEditorChange.java
new file mode 100644
index 00000000000..2c6e66f72ae
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/DirtyEditorChange.java
@@ -0,0 +1,146 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Thomas Szadel - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigator.internal.ltk;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * A change that checks if an editor is actually editing the model and if it must be save.
+ *
+ * @author tszadel
+ *
+ */
+public class DirtyEditorChange extends Change {
+
+ private final IFile oldFile;
+
+ private final IFile newFile;
+
+ /**
+ * Constructor.
+ *
+ * @param resourceSet
+ * The resource set being changed.
+ * @param oldFile
+ * The old file.
+ * @param newFile
+ * The new file.
+ */
+ public DirtyEditorChange(IFile oldFile, IFile newFile) {
+ this.oldFile = oldFile;
+ this.newFile = newFile;
+ }
+
+ /**
+ * @see org.eclipse.ltk.core.refactoring.Change#getModifiedElement()
+ *
+ * @return
+ */
+
+ @Override
+ public Object getModifiedElement() {
+ return oldFile;
+ }
+
+ /**
+ * @see org.eclipse.ltk.core.refactoring.Change#getName()
+ *
+ * @return
+ */
+
+ @Override
+ public String getName() {
+ return "Check opened editors";
+ }
+
+ /**
+ * @see org.eclipse.ltk.core.refactoring.Change#initializeValidationData(org.eclipse.core.runtime.IProgressMonitor)
+ *
+ * @param pm
+ */
+
+ @Override
+ public void initializeValidationData(IProgressMonitor pm) {
+ // Nothing
+ }
+
+
+ private boolean hasDirtyEditors() {
+ IMultiDiagramEditor[] list = EditorUtils.getRelatedEditors(oldFile);
+ if(list != null && list.length > 0) {
+ for(IMultiDiagramEditor editor : list) {
+ if(editor.isDirty()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.ltk.core.refactoring.Change#isValid(org.eclipse.core.runtime.IProgressMonitor)
+ *
+ * @param pm
+ * The progress monitor.
+ * @return The status.
+ * @throws CoreException
+ * Error.
+ * @throws OperationCanceledException
+ * Operation canceled.
+ */
+
+ @Override
+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ final RefactoringStatus status = new RefactoringStatus();
+ // We need to get the current workbench... so we have to use the UI-Thread!
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ if(hasDirtyEditors()) {
+ if(!MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Confirm saving", "The related editor(s) must be saved to continue.")) {
+ status.addFatalError("User doesn't want to save the related editor(s)");
+ }
+ }
+ }
+ });
+
+ return status;
+ }
+
+ /**
+ * @see org.eclipse.ltk.core.refactoring.Change#perform(org.eclipse.core.runtime.IProgressMonitor)
+ *
+ * @param pm
+ * The progress monitor.
+ * @return The change used to undo.
+ * @throws CoreException
+ * Error.
+ */
+
+ @Override
+ public Change perform(IProgressMonitor pm) throws CoreException {
+ // Nothing to do
+ return new DirtyEditorChange(newFile, oldFile);
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/ModelParticipantHelpers.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/ModelParticipantHelpers.java
new file mode 100644
index 00000000000..af604365233
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/ModelParticipantHelpers.java
@@ -0,0 +1,128 @@
+/*****************************************************************************
+ * 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:
+ * Thomas Szadel - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigator.internal.ltk;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.papyrus.infra.core.resource.notation.NotationModel;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
+import org.eclipse.papyrus.infra.core.utils.DiResourceSet;
+
+public class ModelParticipantHelpers {
+
+ /**
+ * get the files related the initialFile which need to be modified/deleted
+ * if initialFile is modified/deleted
+ *
+ * @param initialFile
+ * @return a list of related files. Does not include initialFile.
+ */
+ public static Set getRelatedFiles(IFile initialFile) {
+
+ Set relatedFiles = new HashSet();
+
+ IContainer parent = initialFile.getParent();
+ IPath initialPath = initialFile.getFullPath();
+
+ IPath diPath = null;
+
+ if(DiModel.DI_FILE_EXTENSION.equalsIgnoreCase(initialPath.getFileExtension())) {
+ diPath = initialPath;
+ } else {
+ // try to find a di file with the same name
+ try {
+ for(IResource r : parent.members()) {
+ IPath p = r.getFullPath();
+ if(DiModel.DI_FILE_EXTENSION.equalsIgnoreCase(p.getFileExtension()) && p.removeFileExtension().equals(initialPath.removeFileExtension())) {
+ diPath = p;
+ break;
+ }
+ }
+ } catch (CoreException e) {
+ }
+ }
+
+ if(diPath != null) {
+ IFile diFile = parent.getFile(diPath.makeRelativeTo(parent.getFullPath()));
+
+ if(diFile.exists()) {
+ relatedFiles.add(diFile);
+
+ // add the notation file
+ IPath notationPath = initialPath.removeFileExtension().addFileExtension(NotationModel.NOTATION_FILE_EXTENSION);
+ IFile notationFile = parent.getFile(notationPath.makeRelativeTo(parent.getFullPath()));
+
+ if(notationFile.exists()) {
+ relatedFiles.add(notationFile);
+
+ // find the related model files referenced in the notation file
+ URI notationURI = URI.createPlatformResourceURI(notationPath.toString(), true);
+ ResourceSet rs = new ResourceSetImpl();
+ Resource notationResource = rs.getResource(notationURI, true);
+
+ if(notationResource != null) {
+ relatedFiles.addAll(getModelFilesFromNotationResource(notationResource));
+ }
+ }
+ }
+ }
+
+ // If the initialFile is contained in the list, we remove it
+ if(relatedFiles.contains(initialFile)) {
+ relatedFiles.remove(initialFile);
+ }
+
+ return relatedFiles;
+ }
+
+ private static List getModelFilesFromNotationResource(Resource notationResource) {
+ List modelFiles = new ArrayList();
+
+ // look for a model associated with a diagram in notation
+ for(EObject eObject : notationResource.getContents()) {
+ if(eObject instanceof Diagram) {
+ Diagram diagram = (Diagram)eObject;
+ InternalEObject element = (InternalEObject)diagram.eGet(NotationPackage.Literals.VIEW__ELEMENT, false);
+ if(element != null && element.eIsProxy()) {
+ URI modelURI = element.eProxyURI().trimFragment();
+ if(modelURI.isPlatform()) {
+ IResource modelFile = ResourcesPlugin.getWorkspace().getRoot().findMember(modelURI.toPlatformString(true));
+ if(modelFile != null) {
+ modelFiles.add(modelFile);
+ }
+ }
+ }
+ }
+ }
+
+ return modelFiles;
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/MoveModelParticipant.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/MoveModelParticipant.java
new file mode 100644
index 00000000000..950297318d8
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/MoveModelParticipant.java
@@ -0,0 +1,112 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Thomas Szadel - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigator.internal.ltk;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.NullChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.MoveParticipant;
+import org.eclipse.ltk.core.refactoring.resource.MoveResourceChange;
+
+/**
+ * Participant that is aware of model deletion.
+ *
+ * @author Thomas Szadel
+ *
+ */
+public class MoveModelParticipant extends MoveParticipant {
+
+ private Set filesToMove = new HashSet();
+
+ private IContainer destination;
+
+ /**
+ * Overrides checkConditions.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
+ */
+ @Override
+ public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) throws OperationCanceledException {
+ return new RefactoringStatus();
+ }
+
+ /**
+ * Overrides createChange.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ List changes = new ArrayList(filesToMove.size());
+
+ for(IResource path : filesToMove) {
+ if(path.exists()) {
+ changes.add(new MoveResourceChange(path, destination));
+ }
+ }
+ if(changes.isEmpty()) {
+ return new NullChange();
+ } else {
+ return new CompositeChange(getName(), changes.toArray(new Change[changes.size()]));
+ }
+ }
+
+ /**
+ * Overrides getName.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName()
+ */
+ @Override
+ public String getName() {
+ return "Papyrus Model Move";
+ }
+
+ /**
+ * Overrides initialize.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object)
+ */
+ @Override
+ protected boolean initialize(Object element) {
+ if(!(element instanceof IFile)) {
+ return false;
+ }
+ IFile file = (IFile)element;
+
+ filesToMove = ModelParticipantHelpers.getRelatedFiles(file);
+ return filesToMove.size() > 0;
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/RenameModelChange.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/RenameModelChange.java
new file mode 100644
index 00000000000..b7150018632
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/RenameModelChange.java
@@ -0,0 +1,272 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Thomas Szadel - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigator.internal.ltk;
+
+import static org.eclipse.papyrus.navigator.internal.Activator.log;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.resource.RenameResourceChange;
+import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModelUtils;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.DiResourceSet;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * Rename the model.
+ * Note : That change should be called inside a rename operation as it assumes that a {@link RenameResourceChange} occured.
+ *
+ * @author tszadel
+ *
+ */
+public class RenameModelChange extends Change {
+
+ private final Map uriMap = new HashMap();
+
+ private final IFile oldFile;
+
+ private final IFile newFile;
+
+ private final Set relatedFiles;
+
+ /**
+ * Constructor.
+ *
+ * @param resourceSet
+ * The resource set being changed.
+ * @param oldFile
+ * The old file.
+ * @param newFile
+ * The new file.
+ */
+ public RenameModelChange(IFile oldFile, IFile newFile) {
+ this.oldFile = oldFile;
+ this.newFile = newFile;
+
+ IPath newPathWithoutExt = newFile.getFullPath().removeFileExtension();
+
+ // Create the map of URI that are being modified in the resource set
+ relatedFiles = ModelParticipantHelpers.getRelatedFiles(oldFile);
+ relatedFiles.add(oldFile);
+ for(IResource file : relatedFiles) {
+ IPath path = file.getFullPath();
+ URI oldURI = getPlatformURI(path);
+ URI newURI = getPlatformURI(newPathWithoutExt.addFileExtension(path.getFileExtension()));
+ uriMap.put(oldURI, newURI);
+ }
+ }
+
+ /**
+ * Overrides getModifiedElement.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.Change#getModifiedElement()
+ */
+ @Override
+ public Object getModifiedElement() {
+ return oldFile;
+ }
+
+ /**
+ * Overrides getName.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.Change#getName()
+ */
+ @Override
+ public String getName() {
+ return "Update all resources related to " + oldFile.getName();
+ }
+
+ /**
+ * Overrides initializeValidationData.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.Change#initializeValidationData(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void initializeValidationData(IProgressMonitor pm) {
+ // Nothing
+ }
+
+ /**
+ * Overrides isValid.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.Change#isValid(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ return new RefactoringStatus();
+ }
+
+ /**
+ * Get a platform resource URI of the given path
+ *
+ * @param path
+ * the path
+ * @return the uri
+ */
+ private URI getPlatformURI(IPath path) {
+ return URI.createPlatformResourceURI(path.toString(), true);
+ }
+
+
+ /**
+ * Overrides perform.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.Change#perform(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public Change perform(IProgressMonitor pm) throws CoreException {
+ String lMsg = "Rename " + oldFile.getName() + " to " + newFile.getName();
+ log.info(lMsg);
+ pm.beginTask(lMsg, 30);
+ try {
+ // That change assumes that the model resource has already been renamed
+ // So, the first thing to do is to get the new file, to restore it in order
+ // to change all the resources.
+ pm.subTask("Loading EMF model into memory");
+
+ boolean isUndoOperation = oldFile.exists() && !newFile.exists();
+ if(!isUndoOperation) {
+ newFile.move(oldFile.getFullPath(), true, new SubProgressMonitor(pm, 1));
+ }
+
+ pm.subTask("Saving dirty editors");
+ // We need to get the current workbench... so we have to use the UI-Thread!
+ final List openedEditors = new ArrayList();
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ IMultiDiagramEditor[] multiEditors = EditorUtils.getRelatedEditors(oldFile);
+ if(multiEditors != null) {
+ for(IMultiDiagramEditor editor : multiEditors) {
+ if(editor.isDirty()) {
+ editor.doSave(new NullProgressMonitor());
+ }
+ openedEditors.add(editor);
+ }
+ }
+ }
+ });
+ pm.worked(10);
+
+ // Then, we can load the resource set as the file structure is now correct
+ DiResourceSet resourceSet = new DiResourceSet();
+ resourceSet.loadResources(oldFile);
+ // Force EMF resolve and load all the resources
+ EcoreUtil.resolveAll(resourceSet);
+ pm.worked(4);
+
+ // Change the URIs of modified resources
+ pm.subTask("Modifying resources' URI");
+ for(Resource res : resourceSet.getResources()) {
+ URI newURI = uriMap.get(res.getURI());
+ if(newURI != null) {
+ if(log.isDebugEnabled()) {
+ log.debug("Changing URI " + res.getURI() + " into " + newURI);
+ }
+ res.setURI(newURI);
+ }
+ }
+ pm.worked(5);
+
+ // Now, save all the resources
+ pm.subTask("Saving resources");
+ for(Resource res : resourceSet.getResources()) {
+ try {
+ res.save(null);
+ } catch (IOException e) {
+ log.error("Error while loading resource " + res.getURI(), e);
+ }
+ }
+ pm.worked(5);
+
+ // Do not forget to unload all the resources to avoid memory leak
+ pm.subTask("Unloading model");
+ resourceSet.unload();
+ pm.worked(1);
+
+ // Now, notify the editor of the change
+ if(!openedEditors.isEmpty()) {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ // Get the DI file as the rename could occur on any model's file.
+ IFile newDiFile = DiModelUtils.getRelatedDiFile(newFile);
+ for(IMultiDiagramEditor editor : openedEditors) {
+ try {
+ DiResourceSet diRes = editor.getServicesRegistry().getService(DiResourceSet.class);
+ if(diRes != null) {
+ diRes.saveAs(newFile.getFullPath());
+ }
+ editor.setEditorInput(new FileEditorInput(newDiFile));
+
+ } catch (ServiceException e) {
+ log.error(e);
+ } catch (IOException e) {
+ log.error(e);
+ }
+ }
+ }
+ });
+ }
+
+ // Then, remove the old model files
+ pm.subTask("Removing old files");
+ for(IResource file : relatedFiles) {
+ if(file.exists()) {
+ file.delete(true, new NullProgressMonitor());
+ }
+ }
+ pm.worked(4);
+
+ if(isUndoOperation) {
+ newFile.move(oldFile.getFullPath(), true, new SubProgressMonitor(pm, 1));
+ }
+
+ return new RenameModelChange(newFile, oldFile);
+ } finally {
+ pm.done();
+ }
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/RenameModelParticipant.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/RenameModelParticipant.java
new file mode 100644
index 00000000000..40bb076bcb8
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/ltk/RenameModelParticipant.java
@@ -0,0 +1,137 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Thomas Szadel - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigator.internal.ltk;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
+
+/**
+ * Participant that is aware of the renaming of a model.
+ *
+ * @author Thomas Szadel
+ *
+ */
+public class RenameModelParticipant extends RenameParticipant {
+
+ private IFile fileToRename;
+
+ private IFile newFile;
+
+ /**
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createPreChange(org.eclipse.core.runtime.IProgressMonitor)
+ *
+ * @param pm
+ * The progress monitor.
+ * @return The change.
+ * @throws CoreException
+ * @throws OperationCanceledException
+ */
+
+ @Override
+ public Change createPreChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ return new DirtyEditorChange(fileToRename, newFile);
+ }
+
+ /**
+ * Overrides checkConditions.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
+ */
+ @Override
+ public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) throws OperationCanceledException {
+ return new RefactoringStatus();
+ }
+
+ /**
+ * Overrides createChange.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ return new RenameModelChange(fileToRename, newFile);
+ }
+
+ /**
+ * Overrides getName.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName()
+ */
+ @Override
+ public String getName() {
+ return "Papyrus Model Renaming";
+ }
+
+ /**
+ * Overrides initialize.
+ *
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object)
+ */
+ @Override
+ protected boolean initialize(Object element) {
+ if(!(element instanceof IFile)) {
+ return false;
+ }
+ fileToRename = (IFile)element;
+ String ext = fileToRename.getFileExtension();
+
+ IContainer parent = fileToRename.getParent();
+ String newName = getArguments().getNewName();
+ int idx = newName.lastIndexOf('.');
+ if(idx > 0) {
+ newName = newName.substring(0, idx);
+ } else {
+ newName = newName + '.' + ext; // Always append the extension
+ }
+
+ boolean otherFiles = false;
+ for(IResource file : ModelParticipantHelpers.getRelatedFiles(fileToRename)) {
+ IPath path = file.getFullPath();
+ // Only add the change if the resource exists
+ IFile renFile = parent.getFile(path.makeRelativeTo(parent.getFullPath()));
+ if(!path.equals(fileToRename.getFullPath()) && renFile.exists()) {
+ otherFiles = true;
+ break;
+ }
+ }
+ if(otherFiles) {
+ // Get the new file
+ IPath newDiPath = fileToRename.getFullPath().removeLastSegments(1);
+ newDiPath = newDiPath.append(newName).addFileExtension(ext);
+ newFile = parent.getFile(newDiPath.makeRelativeTo(parent.getFullPath()));
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/utils/NavigatorUtils.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/utils/NavigatorUtils.java
new file mode 100644
index 00000000000..f87140becce
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/utils/NavigatorUtils.java
@@ -0,0 +1,262 @@
+package org.eclipse.papyrus.navigator.internal.utils;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer;
+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Utility method for Model Navigator.
+ *
+ * @author Jerome Benois
+ * @author Francisco Javier Cano Muñoz
+ * @author Thomas Szadel : Remove Backbone
+ * dependency
+ **/
+public class NavigatorUtils {
+
+ /**
+ * Find a by it's id string.
+ *
+ * @param viewID
+ * the view id
+ *
+ * @return the i view part
+ */
+ public static IViewPart findViewPart(String viewID) {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if(page == null) {
+ return null;
+ }
+ IViewReference reference = page.findViewReference(viewID);
+ if(reference == null) {
+ return null;
+ }
+ IWorkbenchPart part = reference.getPart(false);
+ if(part instanceof IViewPart) {
+ return (IViewPart)part;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Unwraps selection. Gets s from s, from s or from s
+ *
+ * @param selection
+ * the selection
+ *
+ * @return the i selection
+ */
+ public static ISelection unwrapSelection(ISelection selection) {
+ if(selection instanceof StructuredSelection && !selection.isEmpty()) {
+ List selectionList = new ArrayList();
+ StructuredSelection structuredSelection = (StructuredSelection)selection;
+ for(Iterator> iterator = structuredSelection.iterator(); iterator.hasNext();) {
+ Object next = iterator.next();
+ if(next instanceof EditPart) {
+ Object model = ((EditPart)next).getModel();
+ EObject element = null;
+ if(model instanceof View) {
+ element = ((View)model).getElement();
+ } else if(model instanceof EObject) {
+ element = (EObject)model;
+ }
+ if(element != null) {
+ selectionList.add(element);
+ }
+ } else if(next instanceof View) {
+ EObject element = ((View)next).getElement();
+ if(element != null) {
+ selectionList.add(element);
+ }
+ } else if(next instanceof EObject) {
+ selectionList.add((EObject)next);
+ }
+ }
+ return new StructuredSelection(selectionList);
+ } else {
+ return selection;
+ }
+ }
+
+ /**
+ * Finds the s for the s in the selection.
+ *
+ * @param selection
+ * the selection
+ * @param viewer
+ * the viewer
+ *
+ * @return the edits the parts from selection
+ */
+ public static List getEditPartsFromSelection(ISelection selection, IDiagramGraphicalViewer viewer) {
+ if(selection instanceof StructuredSelection && !selection.isEmpty()) {
+ StructuredSelection structuredSelection = (StructuredSelection)selection;
+ // look for Views of the EObjects in the selection
+ List views = new ArrayList();
+ for(Object o : structuredSelection.toList()) {
+ if(o instanceof EObject) {
+ List referencerViews = getEObjectViews((EObject)o);
+ for(Object ro : referencerViews) {
+ if(ro instanceof View) {
+ views.add((View)ro);
+ }
+ }
+ }
+ }
+ if(!views.isEmpty()) {
+ List editParts = new ArrayList();
+ for(View view : views) {
+ Object ep = viewer.getEditPartRegistry().get(view);
+ if(ep instanceof EditPart) {
+ editParts.add((EditPart)ep);
+ }
+ }
+ if(!editParts.isEmpty()) {
+ return editParts;
+ }
+ }
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * Gets the given views.
+ *
+ * @param element
+ * the element
+ *
+ * @return the e object views
+ */
+ // @unused
+ public static List getEObjectViews(EObject element) {
+ List views = new ArrayList();
+ if(element != null) {
+ EReference[] features = { NotationPackage.eINSTANCE.getView_Element() };
+ Collection> referencers = EMFCoreUtil.getReferencers(element, features);
+ views.addAll(referencers);
+ }
+ return views;
+ }
+
+ // //
+ // get an object name
+ // //
+
+ /**
+ * Gets the object name or empty string.
+ *
+ * @param object
+ * the object
+ *
+ * @return the object name or empty string
+ */
+ // @unused
+ public static String getObjectNameOrEmptyString(Object object) {
+ String name = getObjectName(object);
+ return name == null ? "" : name;
+ }
+
+ /** The Constant getNameNames. */
+ private static final String[] getNameNames = { "getName", "getname" };
+
+ /**
+ * Gets the object name.
+ *
+ * @param object
+ * the object
+ *
+ * @return the object name
+ */
+ // @unused
+ public static String getObjectName(Object object) {
+ if(object == null) {
+ return null;
+ }
+ Method method = null;
+ Object o = null;
+ for(String methodName : getNameNames) {
+ try {
+ method = object.getClass().getMethod(methodName, (Class[])null);
+ } catch (NoSuchMethodException e) {
+ method = null;
+ }
+ if(method != null) {
+ break;
+ }
+ }
+ if(method != null) {
+ try {
+ o = method.invoke(object, (Object[])null);
+ } catch (IllegalAccessException ex) {
+ return null;
+ } catch (InvocationTargetException ex) {
+ return null;
+ }
+ if(o instanceof String) {
+ return (String)o;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Opens a {@link Diagram} in the sash editor.
+ *
+ * @param diagram
+ */
+ // @unused
+ public static void openDiagram(Diagram diagram) {
+ IPageMngr pageManager = EditorUtils.getIPageMngr();
+ if(pageManager != null) {
+ pageManager.openPage(diagram);
+ }
+ }
+
+ /**
+ * Opens a view part in the workbench with the specified ID.
+ *
+ * @param viewPartID
+ */
+ // @unused
+ public static void openViewPart(String viewPartID) {
+ if(viewPartID == null) {
+ return;
+ }
+ try {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(viewPartID);
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Opens the property sheets view.
+ */
+ public static void openPropertySheetsView() {
+ openViewPart("org.eclipse.ui.views.PropertySheet");
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/utils/StereotypeApplicationUtils.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/utils/StereotypeApplicationUtils.java
new file mode 100644
index 00000000000..13475430434
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/internal/utils/StereotypeApplicationUtils.java
@@ -0,0 +1,128 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigator.internal.utils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.uml2.common.util.CacheAdapter;
+
+/**
+ * Class that manages stereotyped element between model explorer and diagram for profile diagram
+ * based
+ */
+public class StereotypeApplicationUtils {
+
+ /**
+ * Unwraps selection. Gets base element from EObject
+ *
+ * @param selection
+ * the selection
+ *
+ * @return the i selection
+ */
+ public static ISelection unwrapStereotypedSelection(ISelection selection) {
+ if(selection instanceof StructuredSelection && !selection.isEmpty()) {
+ StructuredSelection structuredSelection = (StructuredSelection)selection;
+ List selectionList = new ArrayList();
+ for(Iterator> iterator = structuredSelection.iterator(); iterator.hasNext();) {
+ Object next = iterator.next();
+ if(next instanceof EObject) {
+ EObject element = getBaseElement((EObject)next);
+ if(element != null) {
+ selectionList.add(element);
+ }
+ }
+ }
+ if(!selectionList.isEmpty()) {
+ return new StructuredSelection(selectionList);
+ }
+ }
+ return selection;
+ }
+
+ /**
+ * Gets the stereotype application selection of a stereotyped element from common viewer.
+ *
+ * @param selection
+ * the selection
+ *
+ * @return the stereotype application selection
+ */
+ public static ISelection getStereotypedSelectionFromCommonViewer(ISelection selection) {
+ if(selection instanceof TreeSelection) {
+ TreeSelection treeSelectionEvent = (TreeSelection)selection;
+ Object firstElement = treeSelectionEvent.getFirstElement();
+ if(firstElement instanceof EObject) {
+ List stereotypedApplications = StereotypeApplicationUtils.getStereotypedApplications((EObject)firstElement);
+ return new StructuredSelection(stereotypedApplications);
+ }
+ }
+ return selection;
+ }
+
+ /**
+ * Gets the stereotyped applications for an eObject
+ *
+ * @param eObject
+ * the eObject
+ *
+ * @return the stereotyped applications
+ */
+ public static List getStereotypedApplications(EObject eObject) {
+ List references = new ArrayList();
+ if(eObject != null) {
+ Collection inverseReferences = CacheAdapter.INSTANCE.getNonNavigableInverseReferences(eObject);
+ for(Setting ref : inverseReferences) {
+ EObject extension = ref.getEObject();
+ EObject baseElement = getBaseElement(extension);
+ if(eObject.equals(baseElement)) {
+ references.add(extension);
+ }
+ }
+ }
+ return references;
+ }
+
+ /**
+ * Gets the base element of an eObject
+ *
+ * @param eObject
+ * the eObject
+ *
+ * @return the base element
+ */
+ private static EObject getBaseElement(EObject eObject) {
+ if(eObject != null) {
+ for(EStructuralFeature f : eObject.eClass().getEAllStructuralFeatures()) {
+ if(f.getName().startsWith("base_")) {
+ Object b = eObject.eGet(f);
+ if(b instanceof EObject && b != null) {
+ return (EObject)b;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/INavigatorPreferenceConstants.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/INavigatorPreferenceConstants.java
new file mode 100644
index 00000000000..6e44dd018a2
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/INavigatorPreferenceConstants.java
@@ -0,0 +1,27 @@
+/*****************************************************************************
+ * 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:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigator.preferences;
+
+/**
+ * Defines specific preference constants for papyrus navigator.
+ *
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface INavigatorPreferenceConstants {
+
+ /**
+ * the preference for displaying the warning popup when element will be transform into another one
+ */
+ public static final String PREF_NAVIGATOR_TRANSFORM_INTO_SHOW_POPUP = "org.eclipse.papyrus.navigator.TransformInto.showPopupDialog"; //$NON-NLS-1$
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/NavigatorPreferenceInitializer.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/NavigatorPreferenceInitializer.java
new file mode 100644
index 00000000000..57af0e3e7a8
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/NavigatorPreferenceInitializer.java
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * 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:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigator.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.navigator.internal.Activator;
+
+/**
+ * This preference initializer initializes diagram preferences specific to the activity diagram.
+ */
+public class NavigatorPreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /**
+ * Initialize default preferences specific to the activity diagram
+ */
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = getPreferenceStore();
+
+ // preference for showing popup dialog when transform element command is performed
+ store.setDefault(INavigatorPreferenceConstants.PREF_NAVIGATOR_TRANSFORM_INTO_SHOW_POPUP, false);
+ }
+
+ /**
+ * Get the preference store
+ */
+ protected IPreferenceStore getPreferenceStore() {
+ return Activator.getDefault().getPreferenceStore();
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/NavigatorPreferencePage.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/NavigatorPreferencePage.java
new file mode 100644
index 00000000000..71b49416688
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/NavigatorPreferencePage.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * 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:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigator.preferences;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.pages.AbstractPapyrusNodePreferencePage;
+import org.eclipse.papyrus.navigator.internal.Activator;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class NavigatorPreferencePage extends AbstractPapyrusNodePreferencePage {
+
+ /**
+ * @generated
+ */
+ @Override
+ protected String getBundleId() {
+ return Activator.PLUGIN_ID;
+ }
+
+ /**
+ * @generated
+ */
+ public static void initDefaults(IPreferenceStore store) {
+
+ // String elementName = "Model Explorer";
+ // PreferenceConverter.setDefault(store, PreferenceConstantHelper.getElementConstant(elementName, PreferenceConstantHelper.COLOR_FILL), new org.eclipse.swt.graphics.RGB(255, 255, 255));
+ // PreferenceConverter.setDefault(store, PreferenceConstantHelper.getElementConstant(elementName, PreferenceConstantHelper.COLOR_LINE), new org.eclipse.swt.graphics.RGB(0, 0, 0));
+ //
+ // // Set the default for the gradient
+ // store.setDefault(PreferenceConstantHelper.getElementConstant(elementName, PreferenceConstantHelper.GRADIENT_POLICY), false);
+ // GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(new org.eclipse.swt.graphics.RGB(255, 255, 255), new org.eclipse.swt.graphics.RGB(0, 0, 0), 0, 0);
+ // store.setDefault(PreferenceConstantHelper.getElementConstant(elementName, PreferenceConstantHelper.COLOR_GRADIENT), gradientPreferenceConverter.getPreferenceValue());
+
+ }
+
+ @Override
+ protected void createPageContents(Composite parent) {
+ //super.createPageContents(parent);
+
+ // show popup dialog
+ TransformCommandShowPopupDialogGroup groupComposite = new TransformCommandShowPopupDialogGroup(parent, getTitle(), this);
+ addAbstractGroup(groupComposite);
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/TransformCommandShowPopupDialogGroup.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/TransformCommandShowPopupDialogGroup.java
new file mode 100644
index 00000000000..0511eff786d
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/preferences/TransformCommandShowPopupDialogGroup.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * 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:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigator.preferences;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.AbstractGroup;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+
+public class TransformCommandShowPopupDialogGroup extends AbstractGroup {
+
+ private static final String SHOW_POPUP_DIALOG_GROUP_TITLE = "Transform into Action";
+
+ private static final String SHOW_POPUP_DIALOG_GROUP_MESSAGE = "Do not show popup dialog when transform command is performed";
+
+ /** Editor for deciding to show the warning popup */
+ private BooleanFieldEditor showPopupDialogBooleanFieldEditor;
+
+ /**
+ * Creation of an ActivityEdgeLabelVisibilityGroup Composite.
+ *
+ * @param parent
+ * the parent of the composite
+ * @param dialogPage
+ * to set the page in field editor
+ * @param title
+ * the title
+ */
+ public TransformCommandShowPopupDialogGroup(Composite parent, String title, DialogPage dialogPage) {
+ super(parent, title, dialogPage);
+ createContent(parent);
+ }
+
+ /**
+ * Creates the content.
+ *
+ * @param parent
+ * the parent
+ */
+ public void createContent(Composite parent) {
+ Group visibilityGroup = new Group(parent, SWT.SCROLL_PAGE);
+ visibilityGroup.setLayout(new GridLayout());
+ visibilityGroup.setText(SHOW_POPUP_DIALOG_GROUP_TITLE);
+
+ // field for name label visibility
+ showPopupDialogBooleanFieldEditor = new BooleanFieldEditor(INavigatorPreferenceConstants.PREF_NAVIGATOR_TRANSFORM_INTO_SHOW_POPUP, SHOW_POPUP_DIALOG_GROUP_MESSAGE, visibilityGroup);
+ showPopupDialogBooleanFieldEditor.setPage(dialogPage);
+
+ addFieldEditor(showPopupDialogBooleanFieldEditor);
+
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/EObjectPackagingNode.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/EObjectPackagingNode.java
new file mode 100644
index 00000000000..34b6740b962
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/EObjectPackagingNode.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Conselleria de Infraestructuras y Transporte, Generalitat
+ * de la Comunitat Valenciana . All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Francisco Javier Cano Muñoz (Prodevelop) - Initial implementation
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.navigator.providers;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.uml2.uml.PackageImport;
+import org.eclipse.uml2.uml.PackageableElement;
+
+/**
+ * A {@link PackagingNode} for {@link EObject}s. Children are obtained by
+ * looking {@link EObject}'s contents and selecting those elements that match
+ * the {@link EClass}
+ *
+ * @author Francisco Javier Cano Muñoz
+ * @see Bug
+ * #290422
+ *
+ */
+public class EObjectPackagingNode extends PackagingNode {
+
+ /**
+ * {@link EClass} to filter children element in contents.
+ */
+ private final EClass eClass;
+
+ public EObjectPackagingNode(EClass eClass, EObject parent) {
+ super(eClass.getName(), parent);
+ if(eClass == null || parent == null) {
+ throw new IllegalArgumentException("No EClass or EObject provided");
+ }
+ this.eClass = eClass;
+ }
+
+ /**
+ * Parent as {@link EObject}.
+ *
+ * @return
+ */
+ public EObject getEObjectParent() {
+ if(getParent() instanceof EObject) {
+ return (EObject)getParent();
+ }
+ return null;
+ }
+
+ /**
+ * The {@link EClass} to filter contents.
+ *
+ * @return
+ */
+ public EClass getEClass() {
+ return eClass;
+ }
+
+ /**
+ * Adds an element to the contained collection.
+ */
+ @Override
+ public void addContainedNode(Object o) {
+ super.getContainedNodes().add(o);
+ }
+
+ @Override
+ public Collection getContainedNodes() {
+ Collection elements = findContainedEClassElements();
+ elements.addAll(super.getContainedNodes());
+ return elements;
+ }
+
+ private Collection findContainedEClassElements() {
+ EObject parent = getEObjectParent();
+ if(parent == null) {
+ return Collections.EMPTY_SET;
+ }
+ Collection elements = new ArrayList();
+ List contents = null;
+ if(parent instanceof PackageImport) {
+ // fjcano #297372 : show PackageImport's imported Package's children
+ contents = new ArrayList();
+ for(PackageableElement element : ((PackageImport)parent).getImportedPackage().getPackagedElements()) {
+ contents.add(element);
+ }
+ } else {
+ contents = parent.eContents();
+ }
+ for(EObject content : contents) {
+ if(content != null && content.eClass() != null && content.eClass().getName() != null) {
+ if(content.eClass().getName().equals(getEClass().getName())) {
+ elements.add(content);
+ }
+ }
+ }
+ return elements;
+ }
+
+ /**
+ * True if parent and eClass match.
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if(obj instanceof EObjectPackagingNode) {
+ EObjectPackagingNode other = (EObjectPackagingNode)obj;
+ if(other.getEClass() != null && other.getEClass().equals(getEClass()) && other.getEObjectParent() != null && other.getEObjectParent().equals(getEObjectParent())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/GroupableLabelProvider.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/GroupableLabelProvider.java
new file mode 100644
index 00000000000..4282502539b
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/GroupableLabelProvider.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Conselleria de Infraestructuras y Transporte, Generalitat
+ * de la Comunitat Valenciana . All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Francisco Javier Cano Muñoz (Prodevelop) - Initial implementation
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.navigator.providers;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ *
+ * @author Francisco Javier Cano Muñoz
+ * @see Bug #290422
+ */
+public class GroupableLabelProvider extends LabelProvider {
+
+ @Override
+ public Image getImage(Object element) {
+ if(element instanceof PackagingNode) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
+ }
+ return super.getImage(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if(element instanceof PackagingNode) {
+ return "<" + ((PackagingNode)element).getName() + ">";
+ }
+ return super.getText(element);
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/GroupableTreeArrayContentProvider.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/GroupableTreeArrayContentProvider.java
new file mode 100644
index 00000000000..ed5983ee2b1
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/GroupableTreeArrayContentProvider.java
@@ -0,0 +1,278 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Conselleria de Infraestructuras y Transporte, Generalitat
+ * de la Comunitat Valenciana . All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Francisco Javier Cano Muñoz (Prodevelop) - initial api implementation
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.navigator.providers;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.provider.EObjectItemProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.uml2.uml.PackageImport;
+
+/**
+ * A provider that takes envelopes children in groups by type. EObjecs are
+ * grouped by their {@link EClass}. {@link Object}s are grouped by their first
+ * Interface.
+ *
+ * @author Francisco Javier Cano Muñoz
+ * @see Bug
+ * #290422
+ *
+ */
+public class GroupableTreeArrayContentProvider extends EObjectItemProvider {
+
+ /**
+ * A from to containing .
+ */
+ private static Map parentNodes = null;
+
+ /**
+ * A from to contained .
+ */
+ private static Map> virtualSuperNodes = null;
+
+ synchronized protected static Map getParentNodes() {
+ if(parentNodes == null) {
+ parentNodes = new HashMap();
+ }
+ return parentNodes;
+ }
+
+ synchronized protected static Map> getVirtualSuperNodes() {
+ if(virtualSuperNodes == null) {
+ virtualSuperNodes = new HashMap>();
+ }
+ return virtualSuperNodes;
+ }
+
+ AdapterFactory helperAdapterFactory;
+
+ public GroupableTreeArrayContentProvider(AdapterFactory adapterFactory, AdapterFactory helper) {
+ super(adapterFactory);
+ helperAdapterFactory = helper;
+ }
+
+ @Override
+ public Collection> getChildren(Object parentElement) {
+ if(parentElement instanceof PackagingNode) {
+ return ((PackagingNode)parentElement).getContainedNodes();
+ } else if(getVirtualSuperNodes().containsKey(parentElement)) {
+ updateElementChildren(parentElement);
+ return getVirtualSuperNodes().get(parentElement);
+ } else {
+ Collection> children = getVirtualSupernodes(parentElement);
+ getVirtualSuperNodes().put(parentElement, children);
+ return children;
+ }
+ }
+
+ public Object getParent(Object element) {
+ if(element instanceof PackagingNode) {
+ return ((PackagingNode)element).getParent();
+ } else if(getParentNodes().containsKey(element)) {
+ return getParentNodes().get(element);
+ } else if(element instanceof EObject && element instanceof View == false) {
+ createVirtualSuperNodesTilParent((EObject)element);
+ if(getParentNodes().containsKey(element)) {
+ return getParentNodes().get(element);
+ }
+ }
+ Object adapter = helperAdapterFactory.adapt(element, ITreeItemContentProvider.class);
+ if(adapter instanceof ITreeItemContentProvider) {
+ return ((ITreeItemContentProvider)adapter).getParent(element);
+ } else
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ if(element instanceof PackagingNode) {
+ return true;
+ } else {
+ if(element instanceof PackageImport) {
+ return ((PackageImport)element).getImportedPackage().getPackagedElements().size() > 0;
+ }
+ Object adapter = helperAdapterFactory.adapt(element, ITreeItemContentProvider.class);
+ if(adapter instanceof ITreeItemContentProvider) {
+ return ((ITreeItemContentProvider)adapter).hasChildren(element);
+ } else
+ return false;
+ }
+ }
+
+ @Override
+ public Collection> getElements(Object inputElement) {
+
+ return getVirtualSupernodes(inputElement);
+ }
+
+ private String getKey(Object o) {
+ if(o instanceof EObject) {
+ return ((EObject)o).eClass().getName();
+ } else {
+ return o.getClass().getInterfaces()[0].getSimpleName();
+ }
+ }
+
+ private Collection> getVirtualSupernodes(Collection> node) {
+ Object[] nodes = node != null ? node.toArray(new Object[node.size()]) : new Object[0];
+ return getVirtualSupernodes(nodes);
+ }
+
+ private Collection> getVirtualSupernodes(Object[] node) {
+ Map superNodes = new HashMap();
+ Object[] nodeList = node != null ? node : new Object[0];
+
+ for(int i = 0; i < nodeList.length; i++) {
+ if(nodeList[i] instanceof View) {
+ superNodes.put(nodeList[i].toString(), nodeList[i]);
+ } else {
+ String key = getKey(nodeList[i]);
+ PackagingNode ghostNode = null;
+ if(!superNodes.containsKey(key)) {
+ ghostNode = new PackagingNode(key, super.getParent(nodeList[i]));
+ superNodes.put(key, ghostNode);
+ } else {
+ ghostNode = superNodes.get(key) instanceof PackagingNode ? (PackagingNode)superNodes.get(key) : null;
+ }
+ if(ghostNode != null) {
+ ghostNode.getContainedNodes().add(nodeList[i]);
+ getParentNodes().put(nodeList[i], ghostNode);
+ }
+ }
+ }
+ return superNodes.values();
+ }
+
+ private Collection> getVirtualSupernodes(Object parent) {
+ Collection> children = null;
+ if(parent instanceof PackageImport) {
+ // fjcano #297372 : show PackageImport's imported Package's children
+ children = ((PackageImport)parent).getImportedPackage().getPackagedElements();
+ } else {
+ Object adapter = helperAdapterFactory.adapt(parent, ITreeItemContentProvider.class);
+ if(adapter instanceof ITreeItemContentProvider) {
+ children = ((ITreeItemContentProvider)adapter).getChildren(parent);
+ }
+ }
+ if(parent instanceof EObject && children != null) {
+ // Map> superNodes = getVirtualSuperNodes();
+ // collection of EClass nodes to create
+ Collection eClasses = new ArrayList();
+ // collection of other elements to add as children
+ Collection othersToAdd = new ArrayList();
+ for(Object child : children) {
+ if(child instanceof EObject && !(child instanceof Diagram || child instanceof EAnnotation)) {
+ // for each child EObject we'll find its EClass and add it
+ // as a node to create
+ EClass eClass = ((EObject)child).eClass();
+ if(!eClasses.contains(eClass)) {
+ eClasses.add(eClass);
+ }
+ } else {
+ // if not an EObject it will be added as a child as is
+ othersToAdd.add(child);
+ }
+ }
+ // final collection of actual children to show in the tree for this
+ // parent element
+ Collection superNodes = new ArrayList();
+ // EObjectPackagingNodes for EObjects
+ for(EClass eClass : eClasses) {
+ EObjectPackagingNode node = new EObjectPackagingNode(eClass, (EObject)parent);
+ superNodes.add(node);
+ // add to the parentNodes collection these newly created
+ // elements
+ for(Object o : node.getContainedNodes()) {
+ getParentNodes().put(o, node);
+ }
+ }
+ // other Objects that are children
+ for(Object object : othersToAdd) {
+ superNodes.add(object);
+ }
+ return superNodes;
+ } else {
+ return getVirtualSupernodes(children);
+ }
+ }
+
+ protected void updateElementChildren(Object parent) {
+ if(getVirtualSuperNodes().containsKey(parent)) {
+ Collection oldCollection = (Collection)getVirtualSuperNodes().get(parent);
+ Collection newCollection = (Collection)getVirtualSupernodes(parent);
+ mergeCollections(oldCollection, newCollection);
+ } else {
+ return;
+ }
+ }
+
+ /**
+ * Adds to oldC the new elements in newC. Removes from oldC the elements
+ * that don't appear in newC.
+ *
+ * @param oldC
+ * @param newC
+ */
+ protected void mergeCollections(Collection oldC, Collection newC) {
+ if(oldC == null || newC == null || (oldC.size() == 0 && newC.size() == 0)) {
+ return;
+ }
+ // elements to remove from oldC
+ Collection toRemove = new ArrayList();
+ for(Object o : oldC) {
+ if(!newC.contains(o)) {
+ toRemove.add(o);
+ }
+ }
+ // elements to add to oldC
+ Collection toAdd = new ArrayList();
+ for(Object o : newC) {
+ if(!oldC.contains(o)) {
+ toAdd.add(o);
+ }
+ }
+ // remove elements
+ for(Object o : toRemove) {
+ oldC.remove(o);
+ }
+ // add elements
+ for(Object o : toAdd) {
+ oldC.add(o);
+ }
+ }
+
+ protected void createVirtualSuperNodesTilParent(EObject element) {
+ if(getVirtualSuperNodes().containsKey(element)) {
+ return;
+ }
+ if(element.eContainer() != null) {
+ createVirtualSuperNodesTilParent(element.eContainer());
+ }
+ getChildren(element);
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/IContentProvider.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/IContentProvider.java
new file mode 100644
index 00000000000..f847eea32b3
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/IContentProvider.java
@@ -0,0 +1,12 @@
+package org.eclipse.papyrus.navigator.providers;
+
+import org.eclipse.emf.transaction.ResourceSetChangeEvent;
+import org.eclipse.ui.navigator.ICommonContentProvider;
+
+/**
+ * @author Jerome Benois
+ **/
+public interface IContentProvider extends ICommonContentProvider {
+
+ public void resourceSetChanged(ResourceSetChangeEvent event);
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/NavigatorComposedAdapterFactory.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/NavigatorComposedAdapterFactory.java
new file mode 100644
index 00000000000..828d5f65f49
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/NavigatorComposedAdapterFactory.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.providers;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
+import org.eclipse.papyrus.infra.core.Activator;
+import org.eclipse.papyrus.infra.core.extension.ExtensionException;
+
+/**
+ * @author Jerome Benois
+ */
+public class NavigatorComposedAdapterFactory extends ComposedAdapterFactory {
+
+ /** ID of the editor extension (schema filename) */
+ private static final String ID = "providerAdapterFactory";
+
+
+ /** Namespace where to look for the extension points. */
+ private static final String NAMESPACE = "org.eclipse.papyrus.navigator";
+
+ private static ComposedAdapterFactory navCompAdapterFactory;
+
+ public final static ComposedAdapterFactory getAdapterFactory() {
+ if(navCompAdapterFactory == null)
+ navCompAdapterFactory = new ComposedAdapterFactory(createFactoryList());
+ return navCompAdapterFactory;
+ }
+
+ private NavigatorComposedAdapterFactory() {
+ super(createFactoryList());
+ }
+
+ private final static ArrayList createFactoryList() {
+ // Common factories
+ ArrayList factories = new ArrayList();
+ factories.add(new ResourceItemProviderAdapterFactory());
+ factories.add(new EcoreItemProviderAdapterFactory());
+
+ IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(NAMESPACE, ID);
+ ProviderAdapterFactoryReader adapterFactoryReader = new ProviderAdapterFactoryReader();
+
+ for(IConfigurationElement ele : configElements) {
+ try {
+ factories.add(adapterFactoryReader.createProviderAdapterFactory(ele));
+ } catch (ExtensionException e) {
+ Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage(), e));
+ }
+
+ }
+
+ return factories;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/NoTypePrefixLabelDecorator.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/NoTypePrefixLabelDecorator.java
new file mode 100644
index 00000000000..129b736977a
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/NoTypePrefixLabelDecorator.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Conselleria de Infraestructuras y Transporte, Generalitat
+ * de la Comunitat Valenciana . All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Francisco Javier Cano Muñoz (Prodevelop) – Initial API
+ * implementation.
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.navigator.providers;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.IDecorationContext;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.LabelDecorator;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * A {@link LabelDecorator} that removes the type prefix that appears with some label providers.
+ *
+ * @author Francisco Javier Cano Muñoz
+ *
+ */
+// fjcano #291192
+public class NoTypePrefixLabelDecorator extends LabelDecorator {
+
+ @Override
+ public Image decorateImage(Image image, Object element, IDecorationContext context) {
+ return image;
+ }
+
+ @Override
+ public String decorateText(String text, Object element, IDecorationContext context) {
+ return removeTypeName(element, text);
+ }
+
+ private static String prefixTypeReplacement = "";
+
+ protected String removeTypeName(Object element, String label) {
+ if(element != null && label != null) {
+ String typePrefix = getTypePrefix(element);
+ if(typePrefix != null) {
+ label = label.replaceAll(typePrefix, prefixTypeReplacement);
+ label = label.trim();
+ }
+ }
+ return label;
+ }
+
+ protected String getTypePrefix(Object element) {
+ String typeName = getTypeName(element);
+ return typeName != null ? "<" + typeName + ">" : null;
+ }
+
+ protected String getTypeName(Object element) {
+ if(element instanceof EObject) {
+ EObject eObject = (EObject)element;
+ if(eObject.eClass() != null) {
+ if(eObject.eClass().getName() != null) {
+ return convertNameToDisplayName(eObject.eClass().getName());
+ }
+ }
+ }
+ return null;
+ }
+
+ protected String convertNameToDisplayName(String name) {
+ if(name == null) {
+ return name;
+ }
+ StringBuilder displayNameBuilder = new StringBuilder(name.length() + 5);
+ char character = 'a';
+ for(int index = 0; index < name.length(); index++) {
+ character = name.charAt(index);
+ if(Character.isUpperCase(character) && index > 0) {
+ displayNameBuilder.append(" ");
+ displayNameBuilder.append(character);
+ } else {
+ displayNameBuilder.append(character);
+ }
+ }
+ return displayNameBuilder.toString();
+ }
+
+ @Override
+ public boolean prepareDecoration(Object element, String originalText, IDecorationContext context) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Image decorateImage(Image image, Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String decorateText(String text, Object element) {
+ return removeTypeName(element, text);
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/PackagingNode.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/PackagingNode.java
new file mode 100644
index 00000000000..294b80fc996
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/PackagingNode.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Conselleria de Infraestructuras y Transporte, Generalitat
+ * de la Comunitat Valenciana . All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Francisco Javier Cano Muñoz (Prodevelop) - initial api implementation
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.navigator.providers;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * An intermediate node for children grouping by type.
+ *
+ * @author Francisco Javier Cano Muñoz
+ * @see Bug #290422
+ */
+public class PackagingNode {
+
+ private String name;
+
+ private Object parent;
+
+ private Collection containedNodes = null;
+
+ public PackagingNode(String key, Object parent) {
+ this.name = key;
+ this.parent = parent;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void addContainedNode(Object o) {
+ getContainedNodes().add(o);
+ }
+
+ public Collection getContainedNodes() {
+ if(containedNodes == null) {
+ containedNodes = new ArrayList();
+ }
+ return containedNodes;
+ }
+
+ public Object getParent() {
+ return parent;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/ProviderAdapterFactoryReader.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/ProviderAdapterFactoryReader.java
new file mode 100644
index 00000000000..5520d68a93c
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/ProviderAdapterFactoryReader.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * 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.navigator.providers;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.papyrus.infra.core.extension.ExtensionException;
+import org.eclipse.papyrus.infra.core.extension.ExtensionUtils;
+
+public class ProviderAdapterFactoryReader extends ExtensionUtils {
+
+ /** singleton eINSTANCE of this class */
+ public final static ProviderAdapterFactoryReader eINSTANCE = new ProviderAdapterFactoryReader();
+
+ public final static String PROVIDER_ADAPTER_FACTORY_EXTENSIONPOINT = "providerAdapterFactory";
+
+ public final static String ADAPTER_FACTORY_CLASS_ATTR = "adapterFactoryClass";
+
+ /**
+ * @return the eINSTANCE
+ */
+ public static ProviderAdapterFactoryReader getInstance() {
+ return eINSTANCE;
+ }
+
+ /**
+ * Create a factory instance corresponding to the ConfigurationElement.
+ *
+ * @param element
+ * an {@link IConfigurationElement} see eclipse extension point
+ * @return an instance of the factory
+ * @throws ExtensionException
+ **/
+ @SuppressWarnings("unchecked")
+ public AdapterFactory createProviderAdapterFactory(IConfigurationElement element) throws ExtensionException {
+ checkTagName(element, PROVIDER_ADAPTER_FACTORY_EXTENSIONPOINT);
+
+ Class adapterFactoryClass = (Class)parseClass(element, ADAPTER_FACTORY_CLASS_ATTR,
+ PROVIDER_ADAPTER_FACTORY_EXTENSIONPOINT);
+ try {
+ return adapterFactoryClass.newInstance();
+ } catch (Exception e) {
+ throw new ExtensionException(e.getLocalizedMessage());
+ }
+ }
+}
\ No newline at end of file
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/ToEditorSaveable.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/ToEditorSaveable.java
new file mode 100644
index 00000000000..ccfd1e5124e
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/ToEditorSaveable.java
@@ -0,0 +1,116 @@
+/***************************************************************************
+
+ * Copyright (c) 2008 Conselleria de Infraestructuras y Transporte,
+ * Generalitat de la Comunitat Valenciana . All rights reserved. This program
+ * and the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Francisco Javier Cano Muñoz (Prodevelop) – initial api implementation
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.navigator.providers;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.Saveable;
+
+/**
+ * A {@link Saveable} that targets the {@link Saveable#doSave(IProgressMonitor)} action to the
+ * active {@link IEditorPart}.
+ *
+ * @author Francisco Javier Cano Muñoz
+ * @see Bug 290424
+ *
+ */
+public class ToEditorSaveable extends Saveable {
+
+ private IEditorPart editor = null;
+
+ private IWorkbenchPart part = null;
+
+ public ToEditorSaveable(IEditorPart editor, IWorkbenchPart part) {
+ this.editor = editor;
+ this.part = part;
+ }
+
+ @Override
+ public void doSave(IProgressMonitor monitor) throws CoreException {
+ if(editor != null) {
+ editor.doSave(monitor);
+ }
+ }
+
+ public IEditorPart getEditor() {
+ return editor;
+ }
+
+ public void setEditor(IEditorPart editor) {
+ this.editor = editor;
+ }
+
+ public IWorkbenchPart getPart() {
+ return part;
+ }
+
+ protected IEditorInput getEditorInput() {
+ if(getEditor() != null && getEditor().getEditorInput() != null) {
+ return getEditor().getEditorInput();
+ }
+ return null;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if(this == object) {
+ return true;
+ }
+ if(getPart() != null && object instanceof ToEditorSaveable) {
+ return getPart().equals(((ToEditorSaveable)object).getPart());
+ }
+ return false;
+ }
+
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ if(getEditor() != null) {
+ return getEditor().getEditorInput().getName();
+ }
+ return null;
+ }
+
+ @Override
+ public String getToolTipText() {
+ if(getEditor() != null) {
+ return "Save " + getName() + " contents";
+ }
+ return null;
+ }
+
+ @Override
+ public int hashCode() {
+ if(getPart() != null) {
+ return part.hashCode();
+ }
+ return 0x0;
+ }
+
+ @Override
+ public boolean isDirty() {
+ if(getEditor() != null) {
+ return getEditor().isDirty();
+ }
+ return false;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/UMLContentProvider.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/UMLContentProvider.java
new file mode 100644
index 00000000000..8198584e1e2
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/UMLContentProvider.java
@@ -0,0 +1,271 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ * Francisco Javier Cano Muñoz (Prodevelop) - solve bug #290422
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.providers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.FeatureMap;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.IWrapperItemProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.transaction.ResourceSetChangeEvent;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.utils.DiResourceSet;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.navigator.ModelNavigator;
+import org.eclipse.papyrus.navigator.factory.GroupableAdapterFactory;
+import org.eclipse.papyrus.navigator.internal.AdditionalResources;
+import org.eclipse.papyrus.navigator.internal.utils.NavigatorUtils;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.uml2.uml.PackageImport;
+
+/**
+ * @author Jerome Benois
+ * @author Francisco Javier Cano Muñoz
+ * @see Bug #290422
+ */
+public class UMLContentProvider extends AdapterFactoryContentProvider implements IContentProvider {
+
+ private static final Object[] EMPTY_ARRAY = new Object[0];
+
+ protected DiResourceSet diResourceSet;
+
+ /** The list of open pages (diagrams) */
+ protected IPageMngr pageMngr;
+
+ /** {@link ICommonContentExtensionSite} as given in initialization. */
+ protected ICommonContentExtensionSite contentExtensionSite = null;
+
+ /**
+ * {@link ComposedAdapterFactory} used to get the adapters to content providers.
+ */
+ protected static ComposedAdapterFactory umlComposedAdapterFactory = NavigatorComposedAdapterFactory.getAdapterFactory();
+
+ /**
+ * Factory to adapt children grouping elements
+ */
+ protected static GroupableAdapterFactory groupableFactory = new GroupableAdapterFactory(umlComposedAdapterFactory);
+
+ public UMLContentProvider() {
+ super(umlComposedAdapterFactory);
+ }
+
+ public void init(ICommonContentExtensionSite config) {
+ this.contentExtensionSite = config;
+ }
+
+ public void restoreState(IMemento memento) {
+ // TODO
+ }
+
+ public void saveState(IMemento memento) {
+ // TODO
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean hasChildren(Object element) {
+ if(element instanceof Diagram) {
+ return false;
+ }
+ if(element instanceof PackageImport) {
+ return ((PackageImport)element).getImportedPackage().getPackagedElements().size() > 0;
+
+ }
+ return getChildren(element).length > 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ // Only display diagram (no graphNodes or graphEdges)
+ if(parentElement instanceof Diagram) {
+ return EMPTY_ARRAY;
+ }
+ if(parentElement instanceof AdditionalResources) {
+ return ((AdditionalResources)parentElement).getResources().toArray();
+ }
+
+ // fjcano #290422 :: add "Group children" action.
+ // if grouping is enabled, return the children in a folder organization
+ if(getModelNavigator() != null && getModelNavigator().isGroupingChildsEnabled() && groupableFactory.isFactoryForType(ITreeItemContentProvider.class)) {
+ ITreeItemContentProvider provider = (ITreeItemContentProvider)groupableFactory.adapt(parentElement, ITreeItemContentProvider.class);
+ return provider == null ? null : provider.getChildren(parentElement).toArray();
+ }
+
+ // In the case of a domain element :
+ List children = new ArrayList();
+
+ // 1. Retrieve children elements
+ Object[] modelChildren = super.getChildren(parentElement);
+ for(Object child : modelChildren) {
+ children.add(child);
+ }
+ if(parentElement instanceof PackageImport) {
+ Object[] importedChildren = super.getChildren(((PackageImport)parentElement).getImportedPackage());
+ for(Object child : importedChildren) {
+ children.add(child);
+ }
+ }
+
+ // 2. and associated diagrams
+ if(parentElement instanceof EObject || parentElement instanceof IWrapperItemProvider || parentElement instanceof FeatureMap.Entry) {
+ Object object = AdapterFactoryEditingDomain.unwrap(parentElement);
+ if(object instanceof EObject) {
+ EObject owner = (EObject)object;
+ if(owner != null) {
+ children.addAll(findAllExistingDiagrams(owner));
+ }
+ }
+ }
+ return children.toArray();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Object getParent(Object element) {
+ /*
+ * if (object instanceof IFile) return ((IResource) object).getParent(); return
+ * super.getParent(object);
+ */
+ if(getModelNavigator() != null && getModelNavigator().isGroupingChildsEnabled() && groupableFactory.isFactoryForType(ITreeItemContentProvider.class)) {
+ ITreeItemContentProvider provider = (ITreeItemContentProvider)groupableFactory.adapt(element, ITreeItemContentProvider.class);
+ return provider == null ? null : provider.getParent(element);
+ }
+
+ // Delegates
+ if(element instanceof IWrapperItemProvider || element instanceof FeatureMap.Entry || element instanceof EObject) {
+ return super.getParent(element);
+ }
+
+ return null;
+ }
+
+ @Override
+ public Object[] getElements(Object object) {
+
+ if(canPopulateModelNavigator()) {
+ this.diResourceSet = getDiResourceSet();
+ pageMngr = EditorUtils.getIPageMngr(diResourceSet.getDiResource());
+
+ Resource modelResource = diResourceSet.getModelResource();
+ List children = new ArrayList(modelResource.getContents());
+ AdditionalResources resources = new AdditionalResources(diResourceSet);
+ children.add(resources);
+ // hookListeners();
+ return children.toArray();
+ }
+ // TODO check //WorkspaceRoot for physical representation
+ return EMPTY_ARRAY;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void dispose() {
+ // Dispose objects
+ super.dispose();
+ }
+
+ /**
+ * @param owner
+ * the owner of the diagrams
+ * @return the list of diagrams contained by the given owner
+ */
+ private List findAllExistingDiagrams(EObject owner) {
+ ArrayList diagrams = new ArrayList();
+
+ // Walk on page (Diagram) references
+ for(Object page : pageMngr.allPages()) {
+ if(!(page instanceof Diagram)) {
+ continue;
+ }
+ // We have a GMF Diagram
+ Diagram diagram = (Diagram)page;
+ if(diagram.getElement()!=null){
+ if(owner.equals(diagram.getElement())) {
+ diagrams.add(diagram);
+ }
+ }
+ }
+
+ return diagrams;
+ }
+
+ private boolean canPopulateModelNavigator() {
+ return (EditorUtils.getMultiDiagramEditor() != null);
+ }
+
+ private DiResourceSet getDiResourceSet() {
+ return EditorUtils.getDiResourceSet();
+ }
+
+ /**
+ * Override this method if you want to execute additional actions when the resource is modified
+ *
+ * @param event
+ */
+ public void resourceSetChanged(ResourceSetChangeEvent event) {
+ for(Object o : event.getNotifications()) {
+ if(o instanceof Notification) {
+ Notification n = (Notification)o;
+ if(n.getEventType() == Notification.ADD) {
+ if(getCommonNavigator() != null) {
+ getCommonNavigator().getCommonViewer().setSelection(new StructuredSelection(n.getNewValue()));
+ }
+ }
+ }
+
+ }
+ }
+
+ /**
+ * Gets the . This content provider is associated to, via the viewer ID.
+ *
+ * @return the common navigator
+ */
+ protected CommonNavigator getCommonNavigator() {
+ IViewPart part = NavigatorUtils.findViewPart(getViewerID());
+ if(part instanceof CommonNavigator) {
+ return ((CommonNavigator)part);
+ }
+ return null;
+ }
+
+ protected ModelNavigator getModelNavigator() {
+ CommonNavigator nav = getCommonNavigator();
+ return nav instanceof ModelNavigator ? (ModelNavigator)nav : null;
+ }
+
+ protected String getViewerID() {
+ return contentExtensionSite.getExtensionStateModel().getViewerId();
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/UMLLabelProvider.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/UMLLabelProvider.java
new file mode 100644
index 00000000000..40dc8712de0
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/providers/UMLLabelProvider.java
@@ -0,0 +1,227 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ * Francisco Javier Cano Muñoz (Prodevelop) - bug #290422
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.providers;
+
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
+import org.eclipse.papyrus.infra.core.editorsfactory.PageIconsRegistry;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.navigator.ModelNavigator;
+import org.eclipse.papyrus.navigator.internal.AdditionalResources;
+import org.eclipse.papyrus.navigator.internal.utils.NavigatorUtils;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonLabelProvider;
+
+/**
+ * An {@link ICommonLabelProvider} for the Papyrus Model Explorer-
+ *
+ * @author Jerome Benois
+ * @author Francisco Javier Cano Muñoz
+ * @see Bug #290422
+ */
+public class UMLLabelProvider extends AdapterFactoryLabelProvider implements ICommonLabelProvider/*
+ * ,
+ * IFontProvider
+ */{
+
+ /** Registry to store editor factories */
+ private IPageIconsRegistry editorRegistry;
+
+ /** as given in initialization. */
+ protected ICommonContentExtensionSite contentExtensionSite = null;
+
+ // private Font diagramFont = null;
+
+ protected ILabelDecorator removePrefixLabelDecorator = null;
+
+ protected ILabelDecorator getRemovePrefixLabelDecorator() {
+ if(removePrefixLabelDecorator == null) {
+ removePrefixLabelDecorator = new NoTypePrefixLabelDecorator();
+ }
+ return removePrefixLabelDecorator;
+ }
+
+ public UMLLabelProvider() {
+ super(NavigatorComposedAdapterFactory.getAdapterFactory());
+ }
+
+ public void init(ICommonContentExtensionSite config) {
+ this.contentExtensionSite = config;
+ }
+
+ public void restoreState(IMemento memento) {
+ // TODO Auto-generated method stub
+ }
+
+ public void saveState(IMemento memento) {
+ // TODO Auto-generated method stub
+ }
+
+ public String getDescription(Object anElement) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * Returns the platform icon for a file. You can replace with your own icon If not a IFile, then
+ * passes to the regular EMF.Edit providers
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public Image getImage(Object element) {
+ if(element instanceof Diagram) {
+ return getEditorRegistry().getEditorIcon(element);
+ }
+ // fjcano #290422 :: grouping of children by type
+ if(element instanceof PackagingNode) {
+ return new GroupableLabelProvider().getImage(element);
+ }
+ return super.getImage(element);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getText(Object element) {
+ String text = null;
+ if(element instanceof AdditionalResources) {
+ text = "Additional Resources";
+ }
+
+ // if (object instanceof IFile)
+ // return ((IFile) object).getName();
+
+ else if(element instanceof Diagram) {
+ Diagram diagram = (Diagram)element;
+ text = super.getText(diagram);
+
+ // if (diagram.getSemanticModel() instanceof
+ // CoreSemanticModelBridge) {
+ // CoreSemanticModelBridge coreSemanticModelBridge =
+ // (CoreSemanticModelBridge)
+ // diagram.getSemanticModel();
+ // return super.getText(coreSemanticModelBridge.getElement());
+ // }
+ }
+
+ // fjcano #290422 :: grouping of children by type
+ else if(element instanceof PackagingNode) {
+ text = new GroupableLabelProvider().getText(element);
+ }
+
+ else {
+ text = super.getText(element);
+ }
+
+ if(getModelNavigator() != null && getModelNavigator().isRemovePrefixTypeEnabled()) {
+ text = getRemovePrefixLabelDecorator().decorateText(text, element);
+ }
+
+ return text;
+ }
+
+ /**
+ * Get the EditorRegistry used to create editor instances. This default implementation return
+ * the singleton eINSTANCE. This method can be subclassed to return another registry.
+ *
+ * @return the singleton eINSTANCE of editor registry
+ * @throws ServiceException
+ */
+ protected IPageIconsRegistry getEditorRegistry() {
+ if(editorRegistry == null) {
+ editorRegistry = createEditorRegistry();
+ }
+ return editorRegistry;
+ }
+
+ /**
+ * Return the EditorRegistry for nested editor descriptors. Subclass should implements this
+ * method in order to return the registry associated to the extension point namespace.
+ *
+ * @return the EditorRegistry for nested editor descriptors
+ * @throws ServiceException
+ */
+ protected IPageIconsRegistry createEditorRegistry() {
+ try {
+ return EditorUtils.getServiceRegistry().getService(IPageIconsRegistry.class);
+ } catch (ServiceException e) {
+ // Not found, return an empty one which return null for each request.
+ return new PageIconsRegistry();
+ }
+ }
+
+ // @Override
+ // public Font getFont(Object element) {
+ // if (element instanceof Diagram) {
+ // return getDiagramFont();
+ // }
+ // return JFaceResources.getFontRegistry().defaultFont();
+ // //return null;
+ // }
+ // private Font getDiagramFont()
+ // {
+ // if (this.diagramFont == null){
+ // //Display display = getSite().getShell().getDisplay();
+ // //Display display = Display.getCurrent();
+ // //FontData[] datas =
+ // currentViewer.getControl().getFont().getFontData().clone();
+ // //FontData[] datas = getDefaultFont().getFontData().clone();
+ // //datas[0].setStyle(SWT.BOLD);
+ // //this.diagramFont = new Font(display, datas);
+ // this.diagramFont =
+ // JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
+ // }
+ // return this.diagramFont;
+ // }
+ //
+ //
+ // @Override
+ // public void dispose() {
+ // if(diagramFont!=null){
+ // diagramFont.dispose();
+ // diagramFont=null;
+ // }
+ // super.dispose();
+ // }
+
+ /**
+ * Gets the . This content provider is associated to, via the viewer ID.
+ *
+ * @return the common navigator
+ */
+ protected CommonNavigator getCommonNavigator() {
+ IViewPart part = NavigatorUtils.findViewPart(getViewerID());
+ if(part instanceof CommonNavigator) {
+ return ((CommonNavigator)part);
+ }
+ return null;
+ }
+
+ protected ModelNavigator getModelNavigator() {
+ CommonNavigator nav = getCommonNavigator();
+ return nav instanceof ModelNavigator ? (ModelNavigator)nav : null;
+ }
+
+ protected String getViewerID() {
+ return contentExtensionSite.getExtensionStateModel().getViewerId();
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/sorters/UMLViewerSorter.java b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/sorters/UMLViewerSorter.java
new file mode 100644
index 00000000000..b7d971796a1
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/sorters/UMLViewerSorter.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.navigator.sorters;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+
+/**
+ * This class sort elements in Model Navigator.
+ *
+ * @author Jerome Benois
+ **/
+public class UMLViewerSorter extends ViewerSorter {
+
+ @Override
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ // Add diagram at first position
+ if(e1 instanceof Diagram || e2 instanceof Diagram) {
+ if(e1 instanceof Diagram && e2 instanceof Diagram) {
+ return super.compare(viewer, e1, e2);
+ } else {
+ return 1;
+ }
+ }
+ return super.compare(viewer, e1, e2);
+ }
+
+}
diff --git a/plugins/others/org.eclipse.papyrus.navigator/.classpath b/plugins/others/org.eclipse.papyrus.navigator/.classpath
deleted file mode 100644
index 64c5e31b7a2..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/plugins/others/org.eclipse.papyrus.navigator/.project b/plugins/others/org.eclipse.papyrus.navigator/.project
deleted file mode 100644
index 80f0f97e73b..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- org.eclipse.papyrus.navigator
-
-
-
-
-
- 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/others/org.eclipse.papyrus.navigator/.settings/org.eclipse.jdt.core.prefs b/plugins/others/org.eclipse.papyrus.navigator/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 66cb186456f..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-#Wed Feb 04 16:43:43 GMT+01:00 2009
-eclipse.preferences.version=1
-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/others/org.eclipse.papyrus.navigator/META-INF/MANIFEST.MF b/plugins/others/org.eclipse.papyrus.navigator/META-INF/MANIFEST.MF
deleted file mode 100644
index 546bd9bf6b3..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,33 +0,0 @@
-Manifest-Version: 1.0
-Require-Bundle: org.eclipse.ui.navigator;bundle-version="3.3.101",
- org.eclipse.emf.ecore.editor;bundle-version="2.4.0",
- org.eclipse.uml2.uml.editor;bundle-version="2.2.0",
- org.eclipse.papyrus.infra.core;bundle-version="0.9.0";visibility:=reexport,
- org.eclipse.papyrus.infra.core.sasheditor.di;bundle-version="0.9.0";visibility:=reexport,
- org.eclipse.ltk.core.refactoring;bundle-version="3.5.0",
- org.eclipse.emf.converter;bundle-version="2.5.0",
- org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="0.9.0",
- org.eclipse.emf.transaction;bundle-version="1.4.0",
- org.eclipse.gmf.runtime.notation;bundle-version="1.5.0",
- org.eclipse.gef;bundle-version="3.7.1",
- org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0"
-Export-Package: org.eclipse.papyrus.navigator,
- org.eclipse.papyrus.navigator.actions,
- org.eclipse.papyrus.navigator.dialog,
- org.eclipse.papyrus.navigator.dnd,
- org.eclipse.papyrus.navigator.factory,
- org.eclipse.papyrus.navigator.filters;uses:="org.eclipse.jface.viewers",
- org.eclipse.papyrus.navigator.internal;x-internal:=true,
- org.eclipse.papyrus.navigator.internal.utils;x-internal:=true,
- org.eclipse.papyrus.navigator.providers,
- org.eclipse.papyrus.navigator.sorters
-Bundle-Vendor: %providerName
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 0.9.0.qualifier
-Bundle-Localization: plugin
-Bundle-Name: %pluginName
-Bundle-ManifestVersion: 2
-Bundle-Activator: org.eclipse.papyrus.navigator.internal.Activator
-Bundle-SymbolicName: org.eclipse.papyrus.navigator;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-
diff --git a/plugins/others/org.eclipse.papyrus.navigator/about.html b/plugins/others/org.eclipse.papyrus.navigator/about.html
deleted file mode 100644
index 82d49bf5f81..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/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/others/org.eclipse.papyrus.navigator/build.properties b/plugins/others/org.eclipse.papyrus.navigator/build.properties
deleted file mode 100644
index 8308a1ef92d..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/build.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-#
-#Mon Sep 12 09:29:59 CEST 2011
-bin.includes=META-INF/,.,plugin.xml,icons/,about.html,plugin.properties,schema/
-output..=bin/
-src.includes=about.html,schema/,META-INF/,.,plugin.xml,icons/,plugin.properties
-source..=src/
-bin..=bin/
diff --git a/plugins/others/org.eclipse.papyrus.navigator/icons/ModelExplorer.gif b/plugins/others/org.eclipse.papyrus.navigator/icons/ModelExplorer.gif
deleted file mode 100644
index acb63823aa3..00000000000
Binary files a/plugins/others/org.eclipse.papyrus.navigator/icons/ModelExplorer.gif and /dev/null differ
diff --git a/plugins/others/org.eclipse.papyrus.navigator/icons/etool16/duplicate.png b/plugins/others/org.eclipse.papyrus.navigator/icons/etool16/duplicate.png
deleted file mode 100644
index 195dc6d6c36..00000000000
Binary files a/plugins/others/org.eclipse.papyrus.navigator/icons/etool16/duplicate.png and /dev/null differ
diff --git a/plugins/others/org.eclipse.papyrus.navigator/icons/etool16/rename.gif b/plugins/others/org.eclipse.papyrus.navigator/icons/etool16/rename.gif
deleted file mode 100644
index e6f786eca9a..00000000000
Binary files a/plugins/others/org.eclipse.papyrus.navigator/icons/etool16/rename.gif and /dev/null differ
diff --git a/plugins/others/org.eclipse.papyrus.navigator/icons/etool16/search.gif b/plugins/others/org.eclipse.papyrus.navigator/icons/etool16/search.gif
deleted file mode 100644
index a75166978d7..00000000000
Binary files a/plugins/others/org.eclipse.papyrus.navigator/icons/etool16/search.gif and /dev/null differ
diff --git a/plugins/others/org.eclipse.papyrus.navigator/plugin.properties b/plugins/others/org.eclipse.papyrus.navigator/plugin.properties
deleted file mode 100644
index ff4e6c71189..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/plugin.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-########################################################################################
-#
-# Copyright (c) 2009 Obeo.
-# 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:
-# Obeo - initial API and implementation
-########################################################################################
-pluginName=Papyrus Navigator (Incubation)
-providerName=Eclipse Modeling Project
-
diff --git a/plugins/others/org.eclipse.papyrus.navigator/plugin.xml b/plugins/others/org.eclipse.papyrus.navigator/plugin.xml
deleted file mode 100644
index 60715ef991d..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/plugin.xml
+++ /dev/null
@@ -1,270 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/others/org.eclipse.papyrus.navigator/schema/org.eclipse.papyrus.navigator.actionHandler.exsd b/plugins/others/org.eclipse.papyrus.navigator/schema/org.eclipse.papyrus.navigator.actionHandler.exsd
deleted file mode 100644
index f01f090dfac..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/schema/org.eclipse.papyrus.navigator.actionHandler.exsd
+++ /dev/null
@@ -1,135 +0,0 @@
-
-
-
-
-
-
-
-
- This extension point allows adding action in the contextual menu of the model explorer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- registered action identifier
-
-
-
-
-
-
- implement the action handler factory to add your custom actions
-
-
-
-
-
-
-
-
-
- fill the action id after you want to insert yours
-
-
-
-
-
-
- Add a separator before your action(s) if needed
-
-
-
-
-
-
-
-
-
-
-
- [Enter the first release in which this extension point appears.]
-
-
-
-
-
-
-
-
- org.eclipse.papyrus.navigator.factory.DefaultEMFActionsFactory adds default EMF actions in model explorer.
-See registered extension org.eclipse.papyrus.navigator.actionHandler
-
-
-
-
-
-
-
-
- The class must implement interface org.eclipse.papyrus.navigator.factory.IActionHandlerFactory
-
-
-
-
-
-
-
-
- none
-
-
-
-
-
-
-
-
- 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
-
-
-
-
diff --git a/plugins/others/org.eclipse.papyrus.navigator/schema/providerAdapterFactory.exsd b/plugins/others/org.eclipse.papyrus.navigator/schema/providerAdapterFactory.exsd
deleted file mode 100644
index f16405105b2..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/schema/providerAdapterFactory.exsd
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-
-
-
-
-
-
- This extension provides factories to the navigator which will be used to display informations like labels and images of the EObjects displayed in this navigator.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- An adapter factory
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- UMLComposedAdapterFactory adds a composed factory for UML which used UMLResourceItemProviderAdapterFactory and UMLItemProviderAdapterFactory (from the uml2 plugin) to retrieved labels or images from the UML elements.
-
-
-
-
-
-
-
-
diff --git a/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/ModelNavigator.java b/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/ModelNavigator.java
deleted file mode 100644
index 8dfb4130cc7..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/ModelNavigator.java
+++ /dev/null
@@ -1,592 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Obeo.
-
- * 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:
- * Obeo - initial API and implementation
- * Francisco Javier Cano Muñoz (Prodevelop) - bugs solving, features implementation
- *******************************************************************************/
-package org.eclipse.papyrus.navigator;
-
-import static org.eclipse.papyrus.navigator.internal.Activator.log;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.emf.transaction.ResourceSetChangeEvent;
-import org.eclipse.emf.transaction.ResourceSetListener;
-import org.eclipse.emf.transaction.ResourceSetListenerImpl;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
-import org.eclipse.papyrus.infra.core.utils.EditorUtils;
-import org.eclipse.papyrus.navigator.actions.GroupChildrenAction;
-import org.eclipse.papyrus.navigator.actions.RemoveTypePrefixAction;
-import org.eclipse.papyrus.navigator.actions.SearchElementAction;
-import org.eclipse.papyrus.navigator.internal.Activator;
-import org.eclipse.papyrus.navigator.internal.utils.NavigatorUtils;
-import org.eclipse.papyrus.navigator.internal.utils.StereotypeApplicationUtils;
-import org.eclipse.papyrus.navigator.providers.IContentProvider;
-import org.eclipse.papyrus.navigator.providers.ToEditorSaveable;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.Saveable;
-import org.eclipse.ui.navigator.CommonNavigator;
-import org.eclipse.ui.navigator.CommonViewer;
-import org.eclipse.ui.navigator.ICommonActionConstants;
-import org.eclipse.ui.navigator.INavigatorContentExtension;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
-
-/**
- * This class define a view used to navigate in UML model and resource
- *
- * @author Jerome Benois
- * @author Francisco Javier Cano Muñoz
- */
-public class ModelNavigator extends CommonNavigator implements IEditingDomainProvider {
-
- /** ID Of the Navigator. */
- public static final String ID_MODELNAVIGATOR = "org.eclipse.papyrus.navigator.modelExplorer";
-
- // //
- // fjcano #291192 :: type prefix in model explorer
- // //
- public static final String PROPERTY_REMOVEPREFIX = "org.eclipse.papyrus.navigator.view.removeTypePrefix";
-
- public static final int IS_REMOVEPREFIXTYPE_ENABLED_PROPERTY = 16774;
-
- // //
- // fjcano #290422 :: grouping children by type
- // //
- public static final String PROPERTY_GROUPCHILDS = "org.eclipse.papyrus.navigator.view.groupchilds";
-
- public static final int IS_GROUPINGCHILDS_ENABLED_PROPERTY = 987;
-
- // //
- // fjcano #288599# :: enable linking by default in the model explorer
- // //
- private final String LINKING_ENABLED = "CommonNavigator.LINKING_ENABLED"; //$NON-NLS-1$
-
- private boolean isRemovePrefixTypeEnabled = false;
-
- private IWorkbenchPage page = null;
-
- private boolean isGroupingChildsEnabled = false;
-
- // optimize selection handling
- private boolean handlingSelectionChanged = false;
-
- /** {@link TransactionalEditingDomain} used to perform actions and commands. */
- private TransactionalEditingDomain editingDomain = null;
-
- /** Active {@link IEditorPart}. */
- private IEditorPart editorPart = null;
-
- /**
- * The {@link IPropertySheetPage} this model exploer will use.
- */
- private IPropertySheetPage propertySheetPage = null;
-
- /**
- * {@link ResourceSetListener} to listen and react to changes in the resource set.
- */
- private final ResourceSetListener resourceSetListener = new ResourceSetListenerImpl() {
-
- @Override
- public void resourceSetChanged(ResourceSetChangeEvent event) {
- super.resourceSetChanged(event);
- handleResourceSetChanged(event);
- }
- };
-
- // //
- // fjcano #290424 :: allow saving from the Model Explorer
- // //
- private final ToEditorSaveable toEditorSaveable = new ToEditorSaveable(null, this);
-
- private final Saveable[] toEditorSaveableArray = new Saveable[]{ toEditorSaveable };
-
- /**
- * Make the synchronization between the editor and the model explorer active by default.
- */
- @Override
- public void init(IViewSite aSite, IMemento aMemento) throws PartInitException {
- super.init(aSite, aMemento);
- // fjcano #288599# :: linking enabled by default
- if(memento != null) {
- Integer linkingEnabledInteger = memento.getInteger(LINKING_ENABLED);
- setLinkingEnabled(((linkingEnabledInteger != null) ? linkingEnabledInteger.intValue() == 1 : true));
- } else {
- // fjcano :: linking is enabled by default.
- setLinkingEnabled(true);
- }
- }
-
- private ToEditorSaveable getToEditorSaveable() {
- // fjcano #290424 :: allow saving from the Model Explorer
- return toEditorSaveable;
- }
-
- /**
- * Due to the NavigatorSaveablesService not updating correctly the Saveables available via the
- * ContentProviders, a new and direct way of getting the Saveables is implemented here.
- *
- * @author Francisco Javier Cano Muñoz
- */
- @Override
- public Saveable[] getSaveables() {
- // fjcano #290424 :: allow saving from the Model Explorer
- // return a Saveable that targets the doSave action to the Active
- // Editor.
- return toEditorSaveableArray;
- }
-
- /**
- * Due to the NavigatorSaveablesService not updating correctly the Saveables available via the
- * ContentProviders, a new and direct way of getting the Saveables is implemented here.
- *
- * @author Francisco Javier Cano Muñoz
- */
- @Override
- public Saveable[] getActiveSaveables() {
- // fjcano #290424 :: allow saving from the Model Explorer
- // return a Saveable that targets the doSave action to the Active
- // Editor.
- return toEditorSaveableArray;
- }
-
- /**
- * Method to perform all necessary updates.
- */
- private void doUpdate() {
- // fjcano #290424 :: allow saving from the Model Explorer
- if(getToEditorSaveable() != null) {
- getToEditorSaveable().setEditor(editorPart);
- }
- }
-
- /**
- * Sets the grouping of children by type. Fires a property change that makes the model explorer
- * to refresh.
- *
- * @param toGroupChilds
- */
- public final void setGroupChildsEnabled(boolean toGroupChilds) {
- // fjcano :: #290422
- isGroupingChildsEnabled = toGroupChilds;
- firePropertyChange(IS_GROUPINGCHILDS_ENABLED_PROPERTY);
- ISelection sel = this.getCommonViewer().getSelection();
- if(sel instanceof ITreeSelection && ((ITreeSelection)sel).getFirstElement() != null) {
- IStructuredSelection s = new StructuredSelection(((ITreeSelection)sel).getFirstElement());
- this.getCommonViewer().setSelection(s, true);
- }
- this.refreshViewer();
- }
-
- /**
- * Retrieves the value of the grouping children flag.
- *
- * @return
- */
- public boolean isGroupingChildsEnabled() {
- // fjcano :: #290422
- return this.isGroupingChildsEnabled;
- }
-
- /**
- * Retrieves the grouping of children action.
- *
- * @return
- */
- private IAction getGroupChildrenAction() {
- // fjcano :: #290422
- IAction groupChildsAction = new GroupChildrenAction(this);
- ImageDescriptor folderIcon = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
- groupChildsAction.setImageDescriptor(folderIcon);
- groupChildsAction.setHoverImageDescriptor(folderIcon);
- return groupChildsAction;
- }
-
- /**
- * Set the isRemovePrefixTypeEnabled to the given value and fire a property change event.
- *
- * @param isRemovePrefixTypeEnabled
- */
- public void setRemovePrefixTypeEnabled(boolean isRemovePrefixTypeEnabled) {
- // fjcano #291192
- this.isRemovePrefixTypeEnabled = isRemovePrefixTypeEnabled;
- firePropertyChange(IS_REMOVEPREFIXTYPE_ENABLED_PROPERTY);
- refreshViewer();
- }
-
- /**
- * Gets whether the removal of prefix types is enabled or not.
- *
- * @return
- */
- public boolean isRemovePrefixTypeEnabled() {
- // fjcano #291192
- return isRemovePrefixTypeEnabled;
- }
-
- private IAction getRemoveTypesPrefixAction() {
- // fjcano #291192
- IAction removeTypesPrefixAction = new RemoveTypePrefixAction(this);
- ImageDescriptor clearIcon = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_REMOVE);
- removeTypesPrefixAction.setImageDescriptor(clearIcon);
- removeTypesPrefixAction.setHoverImageDescriptor(clearIcon);
- return removeTypesPrefixAction;
- }
-
- private IAction getSearchAction() {
- // fjcano #290425 :: add search element action to model navigator
- IAction searchAction = new SearchElementAction(this);
- ImageDescriptor magnifyingGlassIcon = Activator.getImageDescriptor("icons/etool16/search.gif");
- searchAction.setImageDescriptor(magnifyingGlassIcon);
- searchAction.setHoverImageDescriptor(magnifyingGlassIcon);
- return searchAction;
- }
-
- /**
- * Add the "Group children" action.
- */
- @Override
- public void createPartControl(Composite aParent) {
- super.createPartControl(aParent);
- // fjcano #290422 :: add "Group children" action
- getViewSite().getActionBars().getToolBarManager().add(getGroupChildrenAction());
- // fjcano #291192
- getViewSite().getActionBars().getToolBarManager().add(getRemoveTypesPrefixAction());
- // fjcano #290425 :: add search action to model navigator
- getViewSite().getActionBars().getToolBarManager().add(getSearchAction());
- }
-
- private void handleResourceSetChanged(ResourceSetChangeEvent event) {
- // Notify all content providers
- List notifications = event.getNotifications();
- int i = 0;
- boolean finish = false;
- while(!finish && i < notifications.size()) {
- Object n = notifications.get(i);
- if(n instanceof Notification) {
- Notification notification = (Notification)n;
- Iterator> it = getNavigatorContentService().findRootContentExtensions(notification.getNotifier()).iterator();
- while(it.hasNext()) {
- Object obj = it.next();
- finish = true;
- if(obj instanceof INavigatorContentExtension) {
- INavigatorContentExtension nce = (INavigatorContentExtension)obj;
- if(nce.getContentProvider() instanceof IContentProvider) {
- IContentProvider provider = (IContentProvider)nce.getContentProvider();
- provider.resourceSetChanged(event);
- }
- }
- }
- }
- i++;
- }
- }
-
- /**
- * A new {@link IWorkbenchPart} has been activated, refresh.
- *
- * @param partRef
- */
- private void handlePartActivated(IWorkbenchPartReference partRef) {
- IWorkbenchPart part = partRef.getPart(false);
- if(part instanceof IEditorPart) {
- activate();
- }
- }
-
- /**
- * An {@link IWorkbenchPart} has been deactivated, refresh.
- *
- * @param partRef
- */
- private void handlePartDeactivated(IWorkbenchPartReference partRef) {
- IWorkbenchPart part = partRef.getPart(false);
- if(editorPart != null && editorPart.equals(part)) {
- deactivate();
- }
- }
-
- /**
- * Activate the Model Explorer.
- */
- private void activate() {
- this.editorPart = EditorUtils.getMultiDiagramEditor();
- this.editingDomain = EditorUtils.getTransactionalEditingDomain();
- if(editingDomain != null) {
- editingDomain.addResourceSetListener(resourceSetListener);
- }
- refreshViewer();
- // fjcano #290424 :: allow saving from the Model Explorer
- doUpdate();
- }
-
- /**
- * Deactivate the Model Explorer.
- */
- private void deactivate() {
- editorPart = null;
- if(editingDomain != null) {
- editingDomain.removeResourceSetListener(resourceSetListener);
- }
- // if (propertySheet != null) {
- // propertySheet.dispose();
- // }
- refreshViewer();
- // fjcano #290424 :: allow saving from the Model Explorer
- doUpdate();
- }
-
- /**
- * Adapts to {@link IPropertySheetPage}. Other adaptations are handled by superclasses.
- */
- @SuppressWarnings("unchecked")
- @Override
- public Object getAdapter(Class adapter) {
- if(IPropertySheetPage.class.equals(adapter)) {
- return getPropertySheetPage();
- }
- return super.getAdapter(adapter);
- }
-
- /**
- * Forces the viewer to be refreshed.
- */
- private void refreshViewer() {
- CommonViewer viewer = getCommonViewer();
- if(viewer != null && viewer.getTree().isDisposed() == false) {
- viewer.refresh();
- }
- }
-
- /**
- * Adds an {@link IPartListener2} and an {@link ISelectionListener}.
- */
- @Override
- public void init(IViewSite site) throws PartInitException {
- super.init(site);
- page = site.getPage();
- // IPartListener to listen to IWorkbenchParts' life cycle.
- page.addPartListener(new IPartListener2() {
-
- public void partActivated(IWorkbenchPartReference partRef) {
- handlePartActivated(partRef);
- }
-
- public void partBroughtToTop(IWorkbenchPartReference partRef) {
- }
-
- public void partClosed(IWorkbenchPartReference partRef) {
- handlePartDeactivated(partRef);
- }
-
- public void partDeactivated(IWorkbenchPartReference partRef) {
- }
-
- public void partHidden(IWorkbenchPartReference partRef) {
- }
-
- public void partInputChanged(IWorkbenchPartReference partRef) {
- handlePartActivated(partRef);
- }
-
- public void partOpened(IWorkbenchPartReference partRef) {
- handlePartActivated(partRef);
- }
-
- public void partVisible(IWorkbenchPartReference partRef) {
- handlePartActivated(partRef);
- }
-
- });
- // an ISelectionListener to react to workbench selection changes.
- page.addSelectionListener(new ISelectionListener() {
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- handleSelectionChangedFromDiagramEditor(part, selection);
- }
- });
- activate();
- }
-
- /**
- * Retrieves the {@link IPropertySheetPage} that his Model Explorer uses.
- *
- * @return
- */
- private IPropertySheetPage getPropertySheetPage() {
- final IMultiDiagramEditor multiDiagramEditor = EditorUtils.getMultiDiagramEditor();
- if(multiDiagramEditor != null) {
- if(propertySheetPage == null) {
- // An 'EEF' properties view
- if(multiDiagramEditor instanceof ITabbedPropertySheetPageContributor) {
- ITabbedPropertySheetPageContributor contributor = (ITabbedPropertySheetPageContributor)multiDiagramEditor;
- this.propertySheetPage = new TabbedPropertySheetPage(contributor);
- }
- }
- return propertySheetPage;
- }
- return null;
- }
-
- /**
- * Adds an {@link ISelectionChangedListener} to this Model Explorer's viewer to react to
- * selection changes in the Model Explorer.
- */
- @Override
- protected CommonViewer createCommonViewer(Composite parent) {
- CommonViewer commonViewer = super.createCommonViewer(parent);
- commonViewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- handleSelectionChangedFromCommonViewer(event);
- }
- });
- return commonViewer;
- }
-
- /**
- * Handle a selection change in the editor.
- *
- * @param part
- * @param selection
- */
- private void handleSelectionChangedFromDiagramEditor(IWorkbenchPart part, ISelection selection) {
- // Handle selection from diagram editor
- if(isLinkingEnabled() && !handlingSelectionChanged) {
- this.handlingSelectionChanged = true;
- if(part instanceof IEditorPart) {
- ISelection unwrappedSelection = NavigatorUtils.unwrapSelection(selection);
- if(!unwrappedSelection.isEmpty() && unwrappedSelection instanceof StructuredSelection) {
- // forward the selection to the stereotyped element if needed
- EObject firstElement = (EObject)((StructuredSelection)unwrappedSelection).getFirstElement();
- if(firstElement != null && firstElement.eContainer() == null) {
- unwrappedSelection = StereotypeApplicationUtils.unwrapStereotypedSelection(unwrappedSelection);
- }
- getCommonViewer().setSelection(unwrappedSelection, true);
- }
- }
- this.handlingSelectionChanged = false;
- }
- }
-
- /**
- * Handle a selection change in the Model Explorer's viewer.
- *
- * @param event
- */
- private void handleSelectionChangedFromCommonViewer(SelectionChangedEvent event) {
- // Handle selection from common viewer
- if(isLinkingEnabled() && !handlingSelectionChanged) {
- this.handlingSelectionChanged = true;
- DiagramEditor editor = EditorUtils.lookupActiveDiagramEditor();
- if(editor != null) {
- // set editor selection and select the EditParts
- IDiagramGraphicalViewer diagramGraphicalViewer = editor.getDiagramGraphicalViewer();
- List> editPartsToSelect = NavigatorUtils.getEditPartsFromSelection(event.getSelection(), diagramGraphicalViewer);
- if(editPartsToSelect.isEmpty()) {
- // forward the selection to the stereotype application
- editPartsToSelect = NavigatorUtils.getEditPartsFromSelection(StereotypeApplicationUtils.getStereotypedSelectionFromCommonViewer(event.getSelection()), diagramGraphicalViewer);
- }
- StructuredSelection selectedEditParts = new StructuredSelection(editPartsToSelect);
- diagramGraphicalViewer.setSelection(selectedEditParts);
- if(!selectedEditParts.isEmpty()) {
- EditPart editPart = (EditPart)selectedEditParts.getFirstElement();
- diagramGraphicalViewer.reveal(editPart);
- }
- }
- this.handlingSelectionChanged = false;
- }
- }
-
- /**
- * Handle a double click on an element in the Model Explorer
- */
- @Override
- protected void handleDoubleClick(DoubleClickEvent anEvent) {
- if(log.isDebugEnabled()) {
- log.debug("Model Navigator got a double click");
- }
- IAction openHandler = getViewSite().getActionBars().getGlobalActionHandler(ICommonActionConstants.OPEN);
- if(openHandler != null) {
- openHandler.run();
- } else {
- IStructuredSelection selection = (IStructuredSelection)anEvent.getSelection();
- Object element = selection.getFirstElement();
- if(element instanceof Diagram) {
- // fjcano #287943 :: handle a double click on a papyrus Diagram
- handleDoubleClickOnDiagram((Diagram)element);
- } else if(element instanceof org.eclipse.gmf.runtime.notation.Diagram) {
- // fjcano #287943 :: handle a double click on a gmf Diagram
- handleDoubleClickOnDiagram((org.eclipse.gmf.runtime.notation.Diagram)element);
- } else if(element instanceof EObject) {
- // Open SWT EEF Properties UI
- NavigatorUtils.openPropertySheetsView();
- } else {
- super.handleDoubleClick(anEvent);
- }
- }
- }
-
- /**
- * Handle double click on a GMF Diagram.
- *
- * @param diagram
- */
- private void handleDoubleClickOnDiagram(Diagram diagram) {
- // fjcano #287943 :: handle double click on a gmf diagram
- if(log.isDebugEnabled()) {
- log.debug("#ModelNavigator-> handleDoubleClickOnDiagram : " + diagram);
- }
- if(!EditorUtils.getIPageMngr().isOpen(diagram)) {
- // open the diagram if not already open
- EditorUtils.getIPageMngr().openPage(diagram);
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @return the EditingDomain used by the properties view
- */
- public EditingDomain getEditingDomain() {
- return editingDomain;
- }
-
-}
diff --git a/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractCommonActionProvider.java b/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractCommonActionProvider.java
deleted file mode 100644
index 9f9023df310..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractCommonActionProvider.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Conselleria de Infraestructuras y Transporte, Generalitat
- * de la Comunitat Valenciana, Obeo . All rights reserved. This program
- * and the accompanying materials are made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francisco Javier Cano Muñoz (Prodevelop) – Initial API implementation.
- * Obeo
- *
- ******************************************************************************/
-package org.eclipse.papyrus.navigator.actions;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.papyrus.navigator.internal.utils.NavigatorUtils;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.navigator.CommonActionProvider;
-import org.eclipse.ui.navigator.CommonNavigator;
-
-/**
- * Specialization of to be used as Papyrus action provider.
- *
- * @author fjcano
- * @author Jerome Benois
- */
-public abstract class AbstractCommonActionProvider extends CommonActionProvider {
-
- /**
- * Gets the ID of the this is associated to.
- *
- * @return the viewer id
- */
- // @unused
- protected String getViewerID() {
- return getActionSite().getViewSite().getId();
- }
-
- /**
- * Gets the this is associated with, via
- * the viewerID.
- *
- * @return the common navigator
- */
- protected CommonNavigator getCommonNavigator() {
- IViewPart part = NavigatorUtils.findViewPart(getViewerID());
- if(part instanceof CommonNavigator) {
- return ((CommonNavigator)part);
- }
- return null;
- }
-
- /**
- * Gets the current context's selection.
- *
- * @return the selection
- */
- // @unused
- protected ISelection getSelection() {
- ActionContext context = getContext();
- return (context != null) ? context.getSelection() : null;
- }
-
- /**
- * Gets the first element of the current context's selection.
- *
- * @return the first selected element
- */
- protected Object getFirstSelectedElement() {
- ISelection selection = getSelection();
- if(selection instanceof StructuredSelection) {
- return ((StructuredSelection)selection).getFirstElement();
- }
- return null;
- }
-
-}
diff --git a/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractSubmenuActionProvider.java b/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractSubmenuActionProvider.java
deleted file mode 100644
index 60e357744dc..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/AbstractSubmenuActionProvider.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Conselleria de Infraestructuras y Transporte, Generalitat
- * de la Comunitat Valenciana, Obeo. All rights reserved. This program
- * and the accompanying materials are made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francisco Javier Cano Muñoz (Prodevelop) – Initial API implementation.
- * Obeo
- *
- ******************************************************************************/
-package org.eclipse.papyrus.navigator.actions;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionManager;
-import org.eclipse.jface.action.MenuManager;
-
-/**
- * Specialization of to be used in menu and submenu contributions.
- *
- * @author fjcano
- * @author Jerome Benois
- */
-public abstract class AbstractSubmenuActionProvider extends AbstractCommonActionProvider {
-
- /**
- * Organizes the given of .
- *
- * @param createActions
- * of to organize
- * @param token
- * that the will use to trim each 's text.
- *
- * @return a associating s to s of s.
- */
- protected Map> extractSubmenuActions(Collection createActions, String token) {
- Map> createSubmenuActions = new LinkedHashMap>();
- if(createActions != null) {
- for(Iterator actions = createActions.iterator(); actions.hasNext();) {
- IAction action = actions.next();
- StringTokenizer st = new StringTokenizer(action.getText(), token);
- if(st.countTokens() == 2) {
- String text = st.nextToken().trim();
- Collection submenuActions = createSubmenuActions.get(text);
- if(submenuActions == null) {
- createSubmenuActions.put(text, submenuActions = new ArrayList());
- }
- action.setText(st.nextToken().trim());
- submenuActions.add(action);
- actions.remove();
- }
- }
- }
- return createSubmenuActions;
- }
-
- /**
- * Fills a with the given of .
- *
- * @param manager
- * the manager
- * @param actions
- * the actions
- * @param contributionID
- * the contribution id
- */
- protected void populateManager(IContributionManager manager, Collection extends IAction> actions, String contributionID) {
- if(actions != null) {
- for(IAction action : actions) {
- if(contributionID != null) {
- manager.insertBefore(contributionID, action);
- } else {
- manager.add(action);
- }
- }
- }
- }
-
- /**
- * Fills a with two levels of menus, as specified by the of
- * s to s of s.
- *
- * @param manager
- * the manager
- * @param submenuActions
- * the submenu actions
- * @param contributionID
- * the contribution id
- */
- protected void populateManager(IContributionManager manager, Map> submenuActions, String contributionID) {
- if(submenuActions != null) {
- for(Map.Entry> entry : submenuActions.entrySet()) {
- MenuManager submenuManager = new MenuManager(entry.getKey());
- if(contributionID != null) {
- manager.insertBefore(contributionID, submenuManager);
- } else {
- manager.add(submenuManager);
- }
- populateManager(submenuManager, entry.getValue(), null);
- }
- }
- }
-
-}
diff --git a/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseAllDiagramsAction.java b/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseAllDiagramsAction.java
deleted file mode 100644
index 631c89e6dd5..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseAllDiagramsAction.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Conselleria de Infraestructuras y Transporte, Generalitat
- * de la Comunitat Valenciana . All rights reserved. This program
- * and the accompanying materials are made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Francisco Javier Cano Muñoz (Prodevelop) - Initial implementation
- *
- ******************************************************************************/
-package org.eclipse.papyrus.navigator.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Action used to close all open diagrams.
- *
- * @author Francisco Javier Cano Muñoz
- * @see Bug #287948
- */
-public class CloseAllDiagramsAction extends Action {
-
- IPageMngr pageMngr;
-
- protected IPageMngr getPageMngr() {
- return pageMngr;
- }
-
- public CloseAllDiagramsAction(IPageMngr pageMngr) {
- if(pageMngr == null) {
- throw new IllegalArgumentException("An IPageMngr must be specified");
- }
- this.pageMngr = pageMngr;
- ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
- setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
- setText("Close all diagrams");
- // this action is enabled when there is at least one diagram open.
- boolean aDiagramIsOpen = false;
- for(Object identifier : pageMngr.allPages()) {
- if(pageMngr.isOpen(identifier)) {
- aDiagramIsOpen = true;
- }
- }
- setEnabled(aDiagramIsOpen);
- }
-
- /**
- * Delete the given diagram
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
- // close all open diagrams
- for(Object identifier : pageMngr.allPages()) {
- if(getPageMngr().isOpen(identifier)) {
- getPageMngr().closePage(identifier);
- }
- }
- }
-
-}
diff --git a/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseDiagramAction.java b/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseDiagramAction.java
deleted file mode 100644
index f20cc69466d..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CloseDiagramAction.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- *
- */
-
-package org.eclipse.papyrus.navigator.actions;
-
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.jface.action.Action;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Action used to open the given diagram
- *
- * @author cedric dumoulin
- */
-public class CloseDiagramAction extends Action {
-
- Diagram diagram;
-
- IPageMngr pageMngr;
-
- public CloseDiagramAction(IPageMngr pageMngr, Diagram diagram) {
- this.diagram = diagram;
- this.pageMngr = pageMngr;
-
- ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
- setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
- setText("Close");
- setEnabled(pageMngr.isOpen(diagram));
- }
-
- /**
- * Delete the given diagram
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
-
- pageMngr.closePage(diagram);
- }
-}
diff --git a/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateChildActionProvider.java b/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateChildActionProvider.java
deleted file mode 100644
index ab372d69e51..00000000000
--- a/plugins/others/org.eclipse.papyrus.navigator/src/org/eclipse/papyrus/navigator/actions/CreateChildActionProvider.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Obeo.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.papyrus.navigator.actions;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.edit.command.CommandParameter;
-import org.eclipse.emf.edit.ui.action.CreateChildAction;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.core.utils.EditorUtils;
-import org.eclipse.ui.navigator.ICommonActionExtensionSite;
-
-/**
- * The Class CreateChildActions.
- *
- * @author Jerome Benois
- */
-public class CreateChildActionProvider extends AbstractSubmenuActionProvider {
-
- protected Collection createChildActions;
-
- protected Map