From 7386d7af54782ebc5ce195f3210fd3d80d0c1add Mon Sep 17 00:00:00 2001 From: cletavernie Date: Wed, 9 Nov 2011 15:23:42 +0000 Subject: 362162: [Architecture - Refactoring] The plug-ins should be renamed to match their layer's qualified name https://bugs.eclipse.org/bugs/show_bug.cgi?id=362162 --- .../META-INF/MANIFEST.MF | 3 +- .../plugin.xml | 4 +- ...se.papyrus.editor.perspectiveconfiguration.exsd | 232 ++++ ...clipse.papyrus.ui.perspectiveconfiguration.exsd | 232 ---- .../editor/perspectiveconfiguration/Activator.java | 75 ++ .../perspectiveconfiguration/Configuration.java | 104 ++ .../ConfigurationService.java | 121 ++ .../CustomizeActionBars.java | 177 +++ .../PapyrusPerspectiveListener.java | 314 +++++ .../PerspectiveConfigurator.java | 38 + .../ui/perspectiveconfiguration/Activator.java | 75 -- .../ui/perspectiveconfiguration/Configuration.java | 104 -- .../ConfigurationService.java | 121 -- .../CustomizeActionBars.java | 177 --- .../PapyrusPerspectiveListener.java | 314 ----- .../PerspectiveConfigurator.java | 38 - .../editor/org.eclipse.papyrus.editor/plugin.xml | 4 +- .../editor/PapyrusActionBarContributor.java | 4 +- .../papyrus/editor/PapyrusMultiDiagramEditor.java | 2 +- .../editor/commands/RenameNestedEditorCommand.java | 10 +- .../META-INF/MANIFEST.MF | 4 +- .../papyrus/core/adaptor/emf/Activator.java | 67 - .../core/adaptor/emf/CreateDiagramHandler.java | 103 -- .../papyrus/infra/core/adaptor/emf/Activator.java | 67 + .../core/adaptor/emf/CreateDiagramHandler.java | 103 ++ .../META-INF/MANIFEST.MF | 4 +- .../plugin.xml | 4 +- .../schema/nestedEditor.exsd | 6 +- ...tractPapyrusGmfCreateDiagramCommandHandler.java | 355 ------ .../papyrus/core/adaptor/gmf/Activator.java | 278 ---- .../papyrus/core/adaptor/gmf/DiagramsUtil.java | 75 -- .../papyrus/core/adaptor/gmf/GmfEditorFactory.java | 219 ---- .../gmf/GmfMultiDiagramDocumentProvider.java | 1133 ---------------- .../eclipse/papyrus/core/adaptor/gmf/Messages.java | 80 -- .../core/adaptor/gmf/ModelManagerEditor.java | 594 --------- .../core/adaptor/gmf/SemanticFromGMFElement.java | 44 - .../gmf/SynchronizableGmfDiagramEditor.java | 101 -- .../core/adaptor/gmf/UMLDiagramEditorUtil.java | 37 - ...tractPapyrusGmfCreateDiagramCommandHandler.java | 355 ++++++ .../papyrus/infra/core/adaptor/gmf/Activator.java | 278 ++++ .../infra/core/adaptor/gmf/DiagramsUtil.java | 75 ++ .../infra/core/adaptor/gmf/GmfEditorFactory.java | 219 ++++ .../gmf/GmfMultiDiagramDocumentProvider.java | 1133 ++++++++++++++++ .../papyrus/infra/core/adaptor/gmf/Messages.java | 80 ++ .../infra/core/adaptor/gmf/ModelManagerEditor.java | 594 +++++++++ .../core/adaptor/gmf/SemanticFromGMFElement.java | 44 + .../gmf/SynchronizableGmfDiagramEditor.java | 101 ++ .../core/adaptor/gmf/UMLDiagramEditorUtil.java | 37 + .../META-INF/MANIFEST.MF | 4 +- .../eclipse/papyrus/infra/core/log/LogHelper.java | 171 +++ .../papyrus/infra/core/log/internal/Activator.java | 64 + .../src/org/eclipse/papyrus/log/LogHelper.java | 171 --- .../eclipse/papyrus/log/internal/Activator.java | 64 - .../.project | 2 +- .../META-INF/MANIFEST.MF | 18 +- .../antBuild.xml | 2 +- .../di/contentprovider/DiSashModelMngr.java | 235 ++++ .../di/contentprovider/IPageModelFactory.java | 40 + .../TransactionalDiSashModelMngr.java | 132 ++ .../commands/CloseAllDiagramsCommand.java | 77 ++ .../commands/CloseDiagramCommand.java | 72 ++ .../commands/CloseOtherDiagramsCommand.java | 70 + .../internal/ContentChangedEventProvider.java | 198 +++ .../internal/DiContentProvider.java | 288 +++++ .../di/contentprovider/internal/PageMngrImpl.java | 373 ++++++ .../contentprovider/internal/SashPanelModel.java | 82 ++ .../contentprovider/internal/TabFolderModel.java | 81 ++ .../internal/TransactionalDiContentProvider.java | 264 ++++ .../internal/TransactionalPageMngrImpl.java | 317 +++++ .../di/contentprovider/utils/IPageUtils.java | 50 + .../contentprovider/di/DiSashModelMngr.java | 235 ---- .../contentprovider/di/IPageModelFactory.java | 40 - .../di/TransactionalDiSashModelMngr.java | 132 -- .../di/commands/CloseAllDiagramsCommand.java | 77 -- .../di/commands/CloseDiagramCommand.java | 72 -- .../di/commands/CloseOtherDiagramsCommand.java | 70 - .../di/internal/ContentChangedEventProvider.java | 198 --- .../di/internal/DiContentProvider.java | 288 ----- .../contentprovider/di/internal/PageMngrImpl.java | 373 ------ .../di/internal/SashPanelModel.java | 82 -- .../di/internal/TabFolderModel.java | 81 -- .../internal/TransactionalDiContentProvider.java | 264 ---- .../di/internal/TransactionalPageMngrImpl.java | 317 ----- .../contentprovider/di/utils/IPageUtils.java | 50 - .../model/sashwindowsdi.genmodel | 4 +- .../model/sashwindowsdi.uml | 2 +- .../plugin.xml | 2 +- .../papyrus/sashwindows/di/impl/PageListImpl.java | 12 +- .../papyrus/sashwindows/di/impl/PageRefImpl.java | 12 +- .../papyrus/sashwindows/di/impl/SashModelImpl.java | 32 +- .../papyrus/sashwindows/di/impl/SashPanelImpl.java | 16 +- .../papyrus/sashwindows/di/impl/TabFolderImpl.java | 14 +- .../papyrus/sashwindows/di/impl/WindowImpl.java | 18 +- .../papyrus/sashwindows/di/util/DiUtils.java | 14 +- .../infra/core/sashwindows/di/AbstractPage.java | 58 + .../infra/core/sashwindows/di/AbstractPanel.java | 57 + .../infra/core/sashwindows/di/DiFactory.java | 127 ++ .../infra/core/sashwindows/di/DiPackage.java | 1349 ++++++++++++++++++++ .../infra/core/sashwindows/di/PageList.java | 65 + .../papyrus/infra/core/sashwindows/di/PageRef.java | 160 +++ .../infra/core/sashwindows/di/PanelParent.java | 59 + .../infra/core/sashwindows/di/Position.java | 83 ++ .../infra/core/sashwindows/di/SashModel.java | 195 +++ .../infra/core/sashwindows/di/SashPanel.java | 100 ++ .../infra/core/sashwindows/di/SashWindowsMngr.java | 88 ++ .../papyrus/infra/core/sashwindows/di/Size.java | 84 ++ .../infra/core/sashwindows/di/TabFolder.java | 74 ++ .../papyrus/infra/core/sashwindows/di/Window.java | 107 ++ .../di/exception/SashEditorException.java | 53 + .../core/sashwindows/di/impl/AbstractPageImpl.java | 168 +++ .../sashwindows/di/impl/AbstractPanelImpl.java | 198 +++ .../core/sashwindows/di/impl/DiFactoryImpl.java | 331 +++++ .../core/sashwindows/di/impl/DiPackageImpl.java | 815 ++++++++++++ .../core/sashwindows/di/impl/PageListImpl.java | 182 +++ .../core/sashwindows/di/impl/PageRefImpl.java | 406 ++++++ .../core/sashwindows/di/impl/PanelParentImpl.java | 178 +++ .../core/sashwindows/di/impl/PositionImpl.java | 218 ++++ .../core/sashwindows/di/impl/SashModelImpl.java | 587 +++++++++ .../core/sashwindows/di/impl/SashPanelImpl.java | 389 ++++++ .../sashwindows/di/impl/SashWindowsMngrImpl.java | 253 ++++ .../infra/core/sashwindows/di/impl/SizeImpl.java | 218 ++++ .../core/sashwindows/di/impl/TabFolderImpl.java | 212 +++ .../infra/core/sashwindows/di/impl/WindowImpl.java | 280 ++++ .../core/sashwindows/di/util/DiAdapterFactory.java | 347 +++++ .../sashwindows/di/util/DiResourceFactoryImpl.java | 48 + .../core/sashwindows/di/util/DiResourceImpl.java | 34 + .../infra/core/sashwindows/di/util/DiSwitch.java | 401 ++++++ .../infra/core/sashwindows/di/util/DiUtils.java | 188 +++ .../papyrus/sashwindows/di/AbstractPage.java | 58 - .../papyrus/sashwindows/di/AbstractPanel.java | 57 - .../eclipse/papyrus/sashwindows/di/DiFactory.java | 127 -- .../eclipse/papyrus/sashwindows/di/DiPackage.java | 1349 -------------------- .../eclipse/papyrus/sashwindows/di/PageList.java | 65 - .../eclipse/papyrus/sashwindows/di/PageRef.java | 160 --- .../papyrus/sashwindows/di/PanelParent.java | 59 - .../eclipse/papyrus/sashwindows/di/Position.java | 83 -- .../eclipse/papyrus/sashwindows/di/SashModel.java | 195 --- .../eclipse/papyrus/sashwindows/di/SashPanel.java | 100 -- .../papyrus/sashwindows/di/SashWindowsMngr.java | 88 -- .../org/eclipse/papyrus/sashwindows/di/Size.java | 84 -- .../eclipse/papyrus/sashwindows/di/TabFolder.java | 74 -- .../org/eclipse/papyrus/sashwindows/di/Window.java | 107 -- .../di/exception/SashEditorException.java | 53 - .../sashwindows/di/impl/AbstractPageImpl.java | 168 --- .../sashwindows/di/impl/AbstractPanelImpl.java | 198 --- .../papyrus/sashwindows/di/impl/DiFactoryImpl.java | 331 ----- .../papyrus/sashwindows/di/impl/DiPackageImpl.java | 815 ------------ .../papyrus/sashwindows/di/impl/PageListImpl.java | 182 --- .../papyrus/sashwindows/di/impl/PageRefImpl.java | 406 ------ .../sashwindows/di/impl/PanelParentImpl.java | 178 --- .../papyrus/sashwindows/di/impl/PositionImpl.java | 218 ---- .../papyrus/sashwindows/di/impl/SashModelImpl.java | 587 --------- .../papyrus/sashwindows/di/impl/SashPanelImpl.java | 389 ------ .../sashwindows/di/impl/SashWindowsMngrImpl.java | 253 ---- .../papyrus/sashwindows/di/impl/SizeImpl.java | 218 ---- .../papyrus/sashwindows/di/impl/TabFolderImpl.java | 212 --- .../papyrus/sashwindows/di/impl/WindowImpl.java | 280 ---- .../sashwindows/di/util/DiAdapterFactory.java | 347 ----- .../sashwindows/di/util/DiResourceFactoryImpl.java | 48 - .../sashwindows/di/util/DiResourceImpl.java | 34 - .../papyrus/sashwindows/di/util/DiSwitch.java | 401 ------ .../papyrus/sashwindows/di/util/DiUtils.java | 188 --- .../.project | 2 +- .../META-INF/MANIFEST.MF | 18 +- .../plugin.xml | 6 +- .../schema/nestedEditor.exsd | 10 +- .../papyrus/infra/core/sasheditor/Activator.java | 69 + .../contentprovider/IAbstractPanelModel.java | 15 + .../contentprovider/IComponentModel.java | 25 + .../contentprovider/IContentChangedListener.java | 79 ++ .../contentprovider/IContentChangedProvider.java | 28 + .../sasheditor/contentprovider/IEditorModel.java | 44 + .../core/sasheditor/contentprovider/IPageMngr.java | 141 ++ .../sasheditor/contentprovider/IPageModel.java | 41 + .../contentprovider/ISashPanelModel.java | 38 + .../ISashWindowsContentProvider.java | 132 ++ .../contentprovider/ITabFolderModel.java | 34 + .../contentprovider/simple/AbstractModel.java | 42 + .../contentprovider/simple/AbstractPanelModel.java | 63 + .../contentprovider/simple/RootModel.java | 79 ++ .../contentprovider/simple/SashPanelModel.java | 153 +++ .../simple/SimpleSashWindowsContentProvider.java | 500 ++++++++ .../contentprovider/simple/TabFolderModel.java | 233 ++++ .../singlefolder/SingleFolderContentProvider.java | 262 ++++ .../singlefolder/SingleFolderModel.java | 139 ++ .../editor/AbstractMultiPageSashEditor.java | 323 +++++ .../core/sasheditor/editor/IComponentPage.java | 17 + .../infra/core/sasheditor/editor/IEditorPage.java | 26 + .../sasheditor/editor/IMultiEditorManager.java | 74 ++ .../sasheditor/editor/IMultiPageEditorPart.java | 48 + .../infra/core/sasheditor/editor/IPage.java | 47 + .../sasheditor/editor/IPageChangedListener.java | 20 + .../core/sasheditor/editor/IPageImageUtils.java | 63 + .../infra/core/sasheditor/editor/IPageVisitor.java | 28 + .../sasheditor/editor/ISashWindowsContainer.java | 98 ++ .../ISashWindowsContainerChangedListener.java | 19 + .../editor/SashContainerEventsListener.java | 58 + .../editor/SashTabDecorationSynchronizer.java | 211 +++ .../sasheditor/editor/SashWindowsContainer.java | 1024 +++++++++++++++ .../editor/SashWindowsEventsProvider.java | 432 +++++++ .../ComposedActionBarContributor.java | 155 +++ .../IMultiPageEditorActionBarContributor.java | 46 + .../MultiPageEditorActionBarContributor.java | 65 + .../editor/gef/MultiDiagramEditorGefDelegate.java | 108 ++ .../sasheditor/internal/AbstractPanelPart.java | 170 +++ .../core/sasheditor/internal/AbstractPart.java | 101 ++ .../internal/ActiveEditorServicesSwitcher.java | 270 ++++ .../sasheditor/internal/ActivePageTracker.java | 182 +++ .../core/sasheditor/internal/ComponentPart.java | 274 ++++ .../infra/core/sasheditor/internal/Copyright.java | 22 + .../infra/core/sasheditor/internal/EditorPart.java | 624 +++++++++ .../core/sasheditor/internal/IPanelParent.java | 43 + .../core/sasheditor/internal/IPartVisitor.java | 80 ++ .../sasheditor/internal/ImageToolTipManager.java | 346 +++++ .../LookupFolderPartByRawModelVisitor.java | 59 + .../internal/LookupIPageByIEditorPartVisitor.java | 62 + .../internal/LookupModelPageVisitor.java | 73 ++ .../sasheditor/internal/NotFoundException.java | 60 + .../infra/core/sasheditor/internal/PTabFolder.java | 495 +++++++ .../infra/core/sasheditor/internal/PagePart.java | 209 +++ .../sasheditor/internal/PageVisitorWrapper.java | 48 + .../infra/core/sasheditor/internal/PartLists.java | 155 +++ .../core/sasheditor/internal/PartVisitor.java | 167 +++ .../sasheditor/internal/ReplaceableSashForm.java | 71 ++ .../infra/core/sasheditor/internal/RootPart.java | 324 +++++ .../internal/SashContainerEventsProvider.java | 118 ++ .../core/sasheditor/internal/SashPanelPart.java | 480 +++++++ .../sasheditor/internal/SashWindowsException.java | 56 + .../sasheditor/internal/ShowPartStatusVisitor.java | 115 ++ .../core/sasheditor/internal/TabFolderPart.java | 1230 ++++++++++++++++++ .../core/sasheditor/internal/TabItemPart.java | 279 ++++ .../eclipsecopy/AbstractTabFolderPart.java | 501 ++++++++ .../internal/eclipsecopy/MultiPageEditorSite.java | 554 ++++++++ .../eclipsecopy/MultiPageSelectionProvider.java | 176 +++ .../preferences/ITabTooltipPreferences.java | 52 + .../preferences/ShowPreferencesHandler.java | 60 + .../TabTooltipPreferenceInitializer.java | 38 + .../preferences/TabTooltipPreferencePage.java | 78 ++ .../preferences/TabTooltipPreferences.java | 103 ++ .../multipage/editor/MultiPageEditor.java | 381 ++++++ .../org/eclipse/papyrus/sasheditor/Activator.java | 69 - .../contentprovider/IAbstractPanelModel.java | 15 - .../contentprovider/IComponentModel.java | 25 - .../contentprovider/IContentChangedListener.java | 79 -- .../contentprovider/IContentChangedProvider.java | 28 - .../sasheditor/contentprovider/IEditorModel.java | 44 - .../sasheditor/contentprovider/IPageMngr.java | 141 -- .../sasheditor/contentprovider/IPageModel.java | 41 - .../contentprovider/ISashPanelModel.java | 38 - .../ISashWindowsContentProvider.java | 132 -- .../contentprovider/ITabFolderModel.java | 34 - .../contentprovider/simple/AbstractModel.java | 42 - .../contentprovider/simple/AbstractPanelModel.java | 63 - .../contentprovider/simple/RootModel.java | 79 -- .../contentprovider/simple/SashPanelModel.java | 153 --- .../simple/SimpleSashWindowsContentProvider.java | 500 -------- .../contentprovider/simple/TabFolderModel.java | 233 ---- .../singlefolder/SingleFolderContentProvider.java | 262 ---- .../singlefolder/SingleFolderModel.java | 139 -- .../editor/AbstractMultiPageSashEditor.java | 323 ----- .../papyrus/sasheditor/editor/IComponentPage.java | 17 - .../papyrus/sasheditor/editor/IEditorPage.java | 26 - .../sasheditor/editor/IMultiEditorManager.java | 74 -- .../sasheditor/editor/IMultiPageEditorPart.java | 48 - .../eclipse/papyrus/sasheditor/editor/IPage.java | 47 - .../sasheditor/editor/IPageChangedListener.java | 20 - .../papyrus/sasheditor/editor/IPageImageUtils.java | 63 - .../papyrus/sasheditor/editor/IPageVisitor.java | 28 - .../sasheditor/editor/ISashWindowsContainer.java | 98 -- .../ISashWindowsContainerChangedListener.java | 19 - .../editor/SashContainerEventsListener.java | 58 - .../editor/SashTabDecorationSynchronizer.java | 211 --- .../sasheditor/editor/SashWindowsContainer.java | 1024 --------------- .../editor/SashWindowsEventsProvider.java | 432 ------- .../ComposedActionBarContributor.java | 155 --- .../IMultiPageEditorActionBarContributor.java | 46 - .../MultiPageEditorActionBarContributor.java | 65 - .../editor/gef/MultiDiagramEditorGefDelegate.java | 108 -- .../sasheditor/internal/AbstractPanelPart.java | 170 --- .../papyrus/sasheditor/internal/AbstractPart.java | 101 -- .../internal/ActiveEditorServicesSwitcher.java | 270 ---- .../sasheditor/internal/ActivePageTracker.java | 182 --- .../papyrus/sasheditor/internal/ComponentPart.java | 274 ---- .../papyrus/sasheditor/internal/Copyright.java | 22 - .../papyrus/sasheditor/internal/EditorPart.java | 624 --------- .../papyrus/sasheditor/internal/IPanelParent.java | 43 - .../papyrus/sasheditor/internal/IPartVisitor.java | 80 -- .../sasheditor/internal/ImageToolTipManager.java | 346 ----- .../LookupFolderPartByRawModelVisitor.java | 59 - .../internal/LookupIPageByIEditorPartVisitor.java | 62 - .../internal/LookupModelPageVisitor.java | 73 -- .../sasheditor/internal/NotFoundException.java | 60 - .../papyrus/sasheditor/internal/PTabFolder.java | 495 ------- .../papyrus/sasheditor/internal/PagePart.java | 209 --- .../sasheditor/internal/PageVisitorWrapper.java | 48 - .../papyrus/sasheditor/internal/PartLists.java | 155 --- .../papyrus/sasheditor/internal/PartVisitor.java | 167 --- .../sasheditor/internal/ReplaceableSashForm.java | 71 -- .../papyrus/sasheditor/internal/RootPart.java | 324 ----- .../internal/SashContainerEventsProvider.java | 118 -- .../papyrus/sasheditor/internal/SashPanelPart.java | 480 ------- .../sasheditor/internal/SashWindowsException.java | 56 - .../sasheditor/internal/ShowPartStatusVisitor.java | 115 -- .../papyrus/sasheditor/internal/TabFolderPart.java | 1230 ------------------ .../papyrus/sasheditor/internal/TabItemPart.java | 279 ---- .../eclipsecopy/AbstractTabFolderPart.java | 501 -------- .../internal/eclipsecopy/MultiPageEditorSite.java | 554 -------- .../eclipsecopy/MultiPageSelectionProvider.java | 176 --- .../preferences/ITabTooltipPreferences.java | 52 - .../preferences/ShowPreferencesHandler.java | 60 - .../TabTooltipPreferenceInitializer.java | 38 - .../preferences/TabTooltipPreferencePage.java | 78 -- .../preferences/TabTooltipPreferences.java | 103 -- .../multipage/editor/MultiPageEditor.java | 381 ------ .../core/org.eclipse.papyrus.infra.core/.options | 6 +- .../META-INF/MANIFEST.MF | 44 +- .../core/org.eclipse.papyrus.infra.core/plugin.xml | 112 +- .../schema/contentOutline.exsd | 8 +- .../schema/model.exsd | 10 +- .../schema/modelListener.exsd | 6 +- .../schema/papyrusDiagram.exsd | 38 +- .../schema/service.exsd | 8 +- .../schema/transactionalEditingDomainProvider.exsd | 6 +- .../src/org/eclipse/papyrus/core/Activator.java | 78 -- .../eclipse/papyrus/core/IElementWithSemantic.java | 34 - .../contentoutline/ContentOutlineRegistry.java | 256 ---- .../contentoutline/IPapyrusContentOutlinePage.java | 34 - .../papyrus/core/editor/BackboneException.java | 71 -- .../core/editor/ContentProviderServiceFactory.java | 64 - .../core/editor/CoreMultiDiagramEditor.java | 809 ------------ .../core/editor/DiResourceSetServiceFactory.java | 63 - .../core/editor/DiSashModelMngrServiceFactory.java | 97 -- .../papyrus/core/editor/IMultiDiagramEditor.java | 91 -- .../core/editor/ModelSetServiceFactory.java | 64 - .../editor/PageIconRegistryServiceFactory.java | 65 - .../core/editor/PageMngrServiceFactory.java | 65 - .../core/editorsfactory/IEditorFactory.java | 39 - .../core/editorsfactory/IEditorIconFactory.java | 59 - .../editorsfactory/IEditorIconFactoryExtended.java | 30 - .../core/editorsfactory/IPageIconsRegistry.java | 35 - .../editorsfactory/IPageIconsRegistryExtended.java | 32 - .../core/editorsfactory/PageIconsRegistry.java | 108 -- .../editorsfactory/PageModelFactoryRegistry.java | 89 -- .../core/extension/BadClassNameException.java | 86 -- .../core/extension/BadNameExtensionException.java | 70 - .../papyrus/core/extension/ExtensionException.java | 86 -- .../papyrus/core/extension/ExtensionUtils.java | 92 -- .../papyrus/core/extension/NotFoundException.java | 70 - .../commands/CreationCommandDescriptor.java | 102 -- .../commands/CreationCommandExtensionFactory.java | 101 -- .../commands/CreationCommandRegistry.java | 142 --- .../core/extension/commands/ICreationCommand.java | 70 - .../commands/ICreationCommandRegistry.java | 41 - .../extension/commands/ICreationCondition.java | 36 - .../extension/commands/IModelCreationCommand.java | 31 - .../commands/ModelCreationCommandBase.java | 126 -- .../commands/PerspectiveContextDependence.java | 51 - .../diagrameditor/AbstractEditorFactory.java | 109 -- .../extension/diagrameditor/EditorDescriptor.java | 152 --- .../EditorDescriptorExtensionFactory.java | 82 -- .../diagrameditor/EditorFactoryProxy.java | 105 -- .../extension/diagrameditor/EditorIconFactory.java | 135 -- .../diagrameditor/EditorNotFoundException.java | 53 - .../diagrameditor/IPluggableEditorFactory.java | 39 - .../diagrameditor/MultiDiagramException.java | 53 - .../PluggableEditorFactoryReader.java | 140 -- .../papyrus/core/lifecycleevents/DoSaveEvent.java | 47 - .../IEditorInputChangedListener.java | 41 - .../lifecycleevents/ILifeCycleEventsProvider.java | 57 - .../core/lifecycleevents/ISaveAndDirtyService.java | 56 - .../core/lifecycleevents/ISaveEventListener.java | 27 - .../lifecycleevents/LifeCycleEventsProvider.java | 272 ---- .../LifeCycleEventsProviderServiceFactory.java | 76 -- .../core/lifecycleevents/SaveAndDirtyService.java | 491 ------- .../core/listenerservice/IPapyrusListener.java | 30 - .../core/listenerservice/ModelListenerManager.java | 126 -- .../papyrus/core/modelsetquery/ModelSetQuery.java | 43 - .../modelsetquery/impl/IModelSetQueryAdapter.java | 39 - .../modelsetquery/impl/ModelSetQueryAdapter.java | 485 ------- .../impl/ModelSetQueryInitializer.java | 66 - .../ActionBarContributorDescriptor.java | 71 -- .../ActionBarContributorExtensionFactory.java | 72 -- .../ActionBarContributorRegistry.java | 172 --- .../CoreComposedActionBarContributor.java | 117 -- .../IActionBarContributorFactory.java | 25 - .../papyrus/core/services/BadStateException.java | 37 - .../papyrus/core/services/ComposedService.java | 93 -- .../papyrus/core/services/ComposedServicePart.java | 75 -- .../core/services/ExtensionServicesRegistry.java | 196 --- .../eclipse/papyrus/core/services/IService.java | 42 - .../papyrus/core/services/IServiceFactory.java | 28 - .../papyrus/core/services/ServiceDescriptor.java | 301 ----- .../papyrus/core/services/ServiceException.java | 57 - .../core/services/ServiceMultiException.java | 139 -- .../core/services/ServiceNotFoundException.java | 51 - .../papyrus/core/services/ServiceStartKind.java | 18 - .../papyrus/core/services/ServiceState.java | 14 - .../papyrus/core/services/ServicesRegistry.java | 1042 --------------- .../services/internal/ErrorServiceTypeEntry.java | 98 -- .../core/services/internal/LazyStartupEntry.java | 96 -- .../core/services/internal/PojoServiceEntry.java | 118 -- .../core/services/internal/ServiceEntry.java | 160 --- .../services/internal/ServiceFactoryEntry.java | 171 --- .../services/internal/ServiceStartupEntry.java | 127 -- .../core/services/internal/ServiceTypeEntry.java | 201 --- .../core/services/internal/StartStartupEntry.java | 84 -- .../papyrus/core/ui/IRevealSemanticElement.java | 34 - .../papyrus/core/utils/AbstractServiceUtils.java | 121 -- .../papyrus/core/utils/BusinessModelResolver.java | 102 -- .../eclipse/papyrus/core/utils/DiResourceSet.java | 339 ----- .../eclipse/papyrus/core/utils/DisplayUtils.java | 44 - .../eclipse/papyrus/core/utils/EditorUtils.java | 652 ---------- .../papyrus/core/utils/FilteredCollectionView.java | 217 ---- .../utils/FilteredCollectionViewFromIterator.java | 255 ---- .../papyrus/core/utils/FilteredListView.java | 376 ------ .../papyrus/core/utils/GMFtoEMFCommandWrapper.java | 32 - .../eclipse/papyrus/core/utils/IDebugChannel.java | 30 - .../org/eclipse/papyrus/core/utils/IFilter.java | 30 - .../papyrus/core/utils/OpenDiagramCommand.java | 96 -- .../papyrus/core/utils/PapyrusEcoreUtils.java | 86 -- .../papyrus/core/utils/PapyrusImageUtils.java | 67 - .../eclipse/papyrus/core/utils/PapyrusTrace.java | 107 -- .../eclipse/papyrus/core/utils/ServiceUtils.java | 49 - .../core/utils/ServiceUtilsForActionHandlers.java | 148 --- .../org/eclipse/papyrus/infra/core/Activator.java | 78 ++ .../papyrus/infra/core/IElementWithSemantic.java | 34 + .../contentoutline/ContentOutlineRegistry.java | 256 ++++ .../contentoutline/IPapyrusContentOutlinePage.java | 34 + .../infra/core/editor/BackboneException.java | 71 ++ .../core/editor/ContentProviderServiceFactory.java | 64 + .../infra/core/editor/CoreMultiDiagramEditor.java | 809 ++++++++++++ .../core/editor/DiResourceSetServiceFactory.java | 63 + .../core/editor/DiSashModelMngrServiceFactory.java | 97 ++ .../infra/core/editor/IMultiDiagramEditor.java | 91 ++ .../infra/core/editor/ModelSetServiceFactory.java | 64 + .../editor/PageIconRegistryServiceFactory.java | 65 + .../infra/core/editor/PageMngrServiceFactory.java | 65 + .../infra/core/editorsfactory/IEditorFactory.java | 39 + .../core/editorsfactory/IEditorIconFactory.java | 59 + .../editorsfactory/IEditorIconFactoryExtended.java | 30 + .../core/editorsfactory/IPageIconsRegistry.java | 35 + .../editorsfactory/IPageIconsRegistryExtended.java | 32 + .../core/editorsfactory/PageIconsRegistry.java | 108 ++ .../editorsfactory/PageModelFactoryRegistry.java | 89 ++ .../core/extension/BadClassNameException.java | 86 ++ .../core/extension/BadNameExtensionException.java | 70 + .../infra/core/extension/ExtensionException.java | 86 ++ .../infra/core/extension/ExtensionUtils.java | 92 ++ .../infra/core/extension/NotFoundException.java | 70 + .../commands/CreationCommandDescriptor.java | 102 ++ .../commands/CreationCommandExtensionFactory.java | 101 ++ .../commands/CreationCommandRegistry.java | 142 +++ .../core/extension/commands/ICreationCommand.java | 70 + .../commands/ICreationCommandRegistry.java | 41 + .../extension/commands/ICreationCondition.java | 36 + .../extension/commands/IModelCreationCommand.java | 31 + .../commands/ModelCreationCommandBase.java | 126 ++ .../commands/PerspectiveContextDependence.java | 51 + .../diagrameditor/AbstractEditorFactory.java | 109 ++ .../extension/diagrameditor/EditorDescriptor.java | 152 +++ .../EditorDescriptorExtensionFactory.java | 82 ++ .../diagrameditor/EditorFactoryProxy.java | 105 ++ .../extension/diagrameditor/EditorIconFactory.java | 135 ++ .../diagrameditor/EditorNotFoundException.java | 53 + .../diagrameditor/IPluggableEditorFactory.java | 39 + .../diagrameditor/MultiDiagramException.java | 53 + .../PluggableEditorFactoryReader.java | 140 ++ .../infra/core/lifecycleevents/DoSaveEvent.java | 47 + .../IEditorInputChangedListener.java | 41 + .../lifecycleevents/ILifeCycleEventsProvider.java | 57 + .../core/lifecycleevents/ISaveAndDirtyService.java | 56 + .../core/lifecycleevents/ISaveEventListener.java | 27 + .../lifecycleevents/LifeCycleEventsProvider.java | 272 ++++ .../LifeCycleEventsProviderServiceFactory.java | 76 ++ .../core/lifecycleevents/SaveAndDirtyService.java | 491 +++++++ .../core/listenerservice/IPapyrusListener.java | 30 + .../core/listenerservice/ModelListenerManager.java | 126 ++ .../infra/core/modelsetquery/ModelSetQuery.java | 43 + .../modelsetquery/impl/IModelSetQueryAdapter.java | 39 + .../modelsetquery/impl/ModelSetQueryAdapter.java | 485 +++++++ .../impl/ModelSetQueryInitializer.java | 66 + .../ActionBarContributorDescriptor.java | 71 ++ .../ActionBarContributorExtensionFactory.java | 72 ++ .../ActionBarContributorRegistry.java | 172 +++ .../CoreComposedActionBarContributor.java | 117 ++ .../IActionBarContributorFactory.java | 25 + .../infra/core/resource/AbstractBaseModel.java | 221 ++++ .../resource/AbstractModelWithSharedResource.java | 184 +++ .../infra/core/resource/BadStateException.java | 60 + .../core/resource/EditingDomainServiceFactory.java | 59 + .../papyrus/infra/core/resource/IModel.java | 94 ++ .../infra/core/resource/IModelSetSnippet.java | 32 + .../papyrus/infra/core/resource/IModelSnippet.java | 32 + .../ITransactionalEditingDomainProvider.java | 8 + .../infra/core/resource/ModelException.java | 54 + .../infra/core/resource/ModelIdentifiers.java | 28 + .../infra/core/resource/ModelMultiException.java | 137 ++ .../papyrus/infra/core/resource/ModelSet.java | 511 ++++++++ .../infra/core/resource/ModelSnippetList.java | 47 + .../papyrus/infra/core/resource/ModelUtils.java | 85 ++ .../papyrus/infra/core/resource/ModelsReader.java | 232 ++++ .../infra/core/resource/NotFoundException.java | 54 + .../TransactionalEditingDomainManager.java | 85 ++ .../additional/AdditionalResourcesModel.java | 114 ++ .../core/resource/notation/NotationModel.java | 80 ++ .../core/resource/notation/NotationUtils.java | 176 +++ .../infra/core/resource/sasheditor/DiModel.java | 54 + .../core/resource/sasheditor/DiModelUtils.java | 41 + .../infra/core/resource/sasheditor/SashModel.java | 71 ++ .../core/resource/sasheditor/SashModelUtils.java | 118 ++ .../infra/core/resource/uml/ExtendedUmlModel.java | 56 + .../papyrus/infra/core/resource/uml/UmlModel.java | 93 ++ .../infra/core/resource/uml/UmlSnippet.java | 51 + .../papyrus/infra/core/resource/uml/UmlUtils.java | 99 ++ .../infra/core/services/BadStateException.java | 37 + .../infra/core/services/ComposedService.java | 93 ++ .../infra/core/services/ComposedServicePart.java | 75 ++ .../core/services/ExtensionServicesRegistry.java | 196 +++ .../papyrus/infra/core/services/IService.java | 42 + .../infra/core/services/IServiceFactory.java | 28 + .../infra/core/services/ServiceDescriptor.java | 301 +++++ .../infra/core/services/ServiceException.java | 57 + .../infra/core/services/ServiceMultiException.java | 139 ++ .../core/services/ServiceNotFoundException.java | 51 + .../infra/core/services/ServiceStartKind.java | 18 + .../papyrus/infra/core/services/ServiceState.java | 14 + .../infra/core/services/ServicesRegistry.java | 1042 +++++++++++++++ .../services/internal/ErrorServiceTypeEntry.java | 98 ++ .../core/services/internal/LazyStartupEntry.java | 96 ++ .../core/services/internal/PojoServiceEntry.java | 118 ++ .../infra/core/services/internal/ServiceEntry.java | 160 +++ .../services/internal/ServiceFactoryEntry.java | 171 +++ .../services/internal/ServiceStartupEntry.java | 127 ++ .../core/services/internal/ServiceTypeEntry.java | 201 +++ .../core/services/internal/StartStartupEntry.java | 84 ++ .../infra/core/ui/IRevealSemanticElement.java | 34 + .../infra/core/utils/AbstractServiceUtils.java | 121 ++ .../infra/core/utils/BusinessModelResolver.java | 102 ++ .../papyrus/infra/core/utils/DiResourceSet.java | 339 +++++ .../papyrus/infra/core/utils/DisplayUtils.java | 44 + .../papyrus/infra/core/utils/EditorUtils.java | 652 ++++++++++ .../infra/core/utils/FilteredCollectionView.java | 217 ++++ .../utils/FilteredCollectionViewFromIterator.java | 255 ++++ .../papyrus/infra/core/utils/FilteredListView.java | 376 ++++++ .../infra/core/utils/GMFtoEMFCommandWrapper.java | 32 + .../papyrus/infra/core/utils/IDebugChannel.java | 30 + .../eclipse/papyrus/infra/core/utils/IFilter.java | 30 + .../infra/core/utils/OpenDiagramCommand.java | 96 ++ .../infra/core/utils/PapyrusEcoreUtils.java | 86 ++ .../infra/core/utils/PapyrusImageUtils.java | 67 + .../papyrus/infra/core/utils/PapyrusTrace.java | 107 ++ .../papyrus/infra/core/utils/ServiceUtils.java | 49 + .../core/utils/ServiceUtilsForActionHandlers.java | 148 +++ .../papyrus/resource/AbstractBaseModel.java | 221 ---- .../resource/AbstractModelWithSharedResource.java | 184 --- .../papyrus/resource/BadStateException.java | 60 - .../resource/EditingDomainServiceFactory.java | 59 - .../src/org/eclipse/papyrus/resource/IModel.java | 94 -- .../eclipse/papyrus/resource/IModelSetSnippet.java | 32 - .../eclipse/papyrus/resource/IModelSnippet.java | 32 - .../ITransactionalEditingDomainProvider.java | 8 - .../eclipse/papyrus/resource/ModelException.java | 54 - .../eclipse/papyrus/resource/ModelIdentifiers.java | 28 - .../papyrus/resource/ModelMultiException.java | 137 -- .../src/org/eclipse/papyrus/resource/ModelSet.java | 511 -------- .../eclipse/papyrus/resource/ModelSnippetList.java | 47 - .../org/eclipse/papyrus/resource/ModelUtils.java | 85 -- .../org/eclipse/papyrus/resource/ModelsReader.java | 232 ---- .../papyrus/resource/NotFoundException.java | 54 - .../TransactionalEditingDomainManager.java | 85 -- .../additional/AdditionalResourcesModel.java | 114 -- .../papyrus/resource/notation/NotationModel.java | 80 -- .../papyrus/resource/notation/NotationUtils.java | 176 --- .../papyrus/resource/sasheditor/DiModel.java | 54 - .../papyrus/resource/sasheditor/DiModelUtils.java | 41 - .../papyrus/resource/sasheditor/SashModel.java | 71 -- .../resource/sasheditor/SashModelUtils.java | 118 -- .../papyrus/resource/uml/ExtendedUmlModel.java | 56 - .../org/eclipse/papyrus/resource/uml/UmlModel.java | 93 -- .../eclipse/papyrus/resource/uml/UmlSnippet.java | 51 - .../org/eclipse/papyrus/resource/uml/UmlUtils.java | 99 -- .../META-INF/MANIFEST.MF | 4 +- .../org.eclipse.papyrus.infra.export/plugin.xml | 12 +- .../eclipse/papyrus/export/ExportAllDiagrams.java | 417 ------ .../eclipse/papyrus/export/ExportException.java | 61 - .../src/org/eclipse/papyrus/export/Messages.java | 73 -- .../org/eclipse/papyrus/export/PropertyTester.java | 25 - .../export/actions/ExportAllDiagramsAction.java | 95 -- .../export/actions/ExportAllDiagramsDialog.java | 68 - .../papyrus/export/actions/ExportComposite.java | 199 --- .../eclipse/papyrus/export/actions/Messages.java | 36 - .../papyrus/export/actions/messages.properties | 5 - .../eclipse/papyrus/export/internal/Activator.java | 205 --- .../org/eclipse/papyrus/export/messages.properties | 24 - .../papyrus/export/wizard/ExportAllWizard.java | 131 -- .../export/wizard/ExportDiagramsErrorPage.java | 44 - .../papyrus/export/wizard/ExportDiagramsPage.java | 54 - .../eclipse/papyrus/export/wizard/Messages.java | 38 - .../papyrus/export/wizard/messages.properties | 6 - .../papyrus/infra/export/ExportAllDiagrams.java | 417 ++++++ .../papyrus/infra/export/ExportException.java | 61 + .../org/eclipse/papyrus/infra/export/Messages.java | 73 ++ .../papyrus/infra/export/PropertyTester.java | 25 + .../export/actions/ExportAllDiagramsAction.java | 95 ++ .../export/actions/ExportAllDiagramsDialog.java | 68 + .../infra/export/actions/ExportComposite.java | 199 +++ .../papyrus/infra/export/actions/Messages.java | 36 + .../infra/export/actions/messages.properties | 5 + .../papyrus/infra/export/internal/Activator.java | 205 +++ .../papyrus/infra/export/messages.properties | 24 + .../infra/export/wizard/ExportAllWizard.java | 131 ++ .../export/wizard/ExportDiagramsErrorPage.java | 44 + .../infra/export/wizard/ExportDiagramsPage.java | 54 + .../papyrus/infra/export/wizard/Messages.java | 38 + .../infra/export/wizard/messages.properties | 6 + .../META-INF/MANIFEST.MF | 12 +- .../ModifySemanticValuesActionConfiguration.ecore | 4 +- ...difySemanticValuesActionConfiguration.ecorediag | 4 +- ...odifySemanticValuesActionConfiguration.genmodel | 12 +- .../plugin.xml | 12 +- .../ConstantValue.java | 54 - .../DynamicValue.java | 21 - .../FeatureToSet.java | 81 -- .../FeatureValue.java | 22 - .../ListValue.java | 44 - .../ModifySemanticValuesActionConfiguration.java | 46 - ...fySemanticValuesActionConfigurationFactory.java | 91 -- ...fySemanticValuesActionConfigurationPackage.java | 548 -------- .../QueryExecutionValue.java | 54 - .../impl/ConstantValueImpl.java | 180 --- .../impl/DynamicValueImpl.java | 43 - .../impl/FeatureToSetImpl.java | 248 ---- .../impl/FeatureValueImpl.java | 45 - .../impl/ListValueImpl.java | 136 -- ...manticValuesActionConfigurationFactoryImpl.java | 154 --- ...odifySemanticValuesActionConfigurationImpl.java | 156 --- ...manticValuesActionConfigurationPackageImpl.java | 384 ------ .../impl/QueryExecutionValueImpl.java | 161 --- ...ticValuesActionConfigurationAdapterFactory.java | 271 ---- ...luesActionConfigurationResourceFactoryImpl.java | 56 - ...anticValuesActionConfigurationResourceImpl.java | 32 - ...ifySemanticValuesActionConfigurationSwitch.java | 279 ---- ...anticValuesActionConfigurationXMLProcessor.java | 54 - .../ConstantValue.java | 54 + .../DynamicValue.java | 21 + .../FeatureToSet.java | 81 ++ .../FeatureValue.java | 22 + .../ListValue.java | 44 + .../ModifySemanticValuesActionConfiguration.java | 46 + ...fySemanticValuesActionConfigurationFactory.java | 91 ++ ...fySemanticValuesActionConfigurationPackage.java | 548 ++++++++ .../QueryExecutionValue.java | 54 + .../impl/ConstantValueImpl.java | 180 +++ .../impl/DynamicValueImpl.java | 43 + .../impl/FeatureToSetImpl.java | 248 ++++ .../impl/FeatureValueImpl.java | 45 + .../impl/ListValueImpl.java | 136 ++ ...manticValuesActionConfigurationFactoryImpl.java | 154 +++ ...odifySemanticValuesActionConfigurationImpl.java | 156 +++ ...manticValuesActionConfigurationPackageImpl.java | 384 ++++++ .../impl/QueryExecutionValueImpl.java | 161 +++ ...ticValuesActionConfigurationAdapterFactory.java | 271 ++++ ...luesActionConfigurationResourceFactoryImpl.java | 56 + ...anticValuesActionConfigurationResourceImpl.java | 32 + ...ifySemanticValuesActionConfigurationSwitch.java | 279 ++++ ...anticValuesActionConfigurationXMLProcessor.java | 54 + .../papyrus/extendedtypes/emf/Activator.java | 58 - .../ModifySemanticValuesActionProvider.java | 186 --- .../papyrus/infra/extendedtypes/emf/Activator.java | 58 + .../ModifySemanticValuesActionProvider.java | 186 +++ .../META-INF/MANIFEST.MF | 16 +- .../model/ExtendedTypes.ecore | 2 +- .../model/ExtendedTypes.ecorediag | 2 +- .../model/ExtendedTypes.genmodel | 10 +- .../plugin.xml | 8 +- .../schema/extendedElementTypeActionProvider.exsd | 8 +- .../schema/extendedTypesSetConfiguration.exsd | 4 +- .../papyrus/extendedtypes/ActionConfiguration.java | 81 -- .../ExtendedElementTypeConfiguration.java | 236 ---- .../extendedtypes/ExtendedElementTypeSet.java | 73 -- .../extendedtypes/ExtendedtypesFactory.java | 64 - .../extendedtypes/ExtendedtypesPackage.java | 777 ----------- .../eclipse/papyrus/extendedtypes/IconEntry.java | 81 -- .../extendedtypes/PostActionConfiguration.java | 21 - .../extendedtypes/PreActionConfiguration.java | 21 - .../impl/ActionConfigurationImpl.java | 221 ---- .../impl/ExtendedElementTypeConfigurationImpl.java | 566 -------- .../impl/ExtendedElementTypeSetImpl.java | 226 ---- .../impl/ExtendedtypesFactoryImpl.java | 121 -- .../impl/ExtendedtypesPackageImpl.java | 453 ------- .../papyrus/extendedtypes/impl/IconEntryImpl.java | 221 ---- .../impl/PostActionConfigurationImpl.java | 43 - .../impl/PreActionConfigurationImpl.java | 43 - .../util/ExtendedtypesAdapterFactory.java | 214 ---- .../util/ExtendedtypesResourceFactoryImpl.java | 56 - .../util/ExtendedtypesResourceImpl.java | 32 - .../extendedtypes/util/ExtendedtypesSwitch.java | 237 ---- .../util/ExtendedtypesXMLProcessor.java | 54 - .../infra/extendedtypes/ActionConfiguration.java | 81 ++ .../ExtendedElementTypeConfiguration.java | 236 ++++ .../extendedtypes/ExtendedElementTypeSet.java | 73 ++ .../infra/extendedtypes/ExtendedtypesFactory.java | 64 + .../infra/extendedtypes/ExtendedtypesPackage.java | 777 +++++++++++ .../papyrus/infra/extendedtypes/IconEntry.java | 81 ++ .../extendedtypes/PostActionConfiguration.java | 21 + .../extendedtypes/PreActionConfiguration.java | 21 + .../impl/ActionConfigurationImpl.java | 221 ++++ .../impl/ExtendedElementTypeConfigurationImpl.java | 566 ++++++++ .../impl/ExtendedElementTypeSetImpl.java | 226 ++++ .../impl/ExtendedtypesFactoryImpl.java | 121 ++ .../impl/ExtendedtypesPackageImpl.java | 453 +++++++ .../infra/extendedtypes/impl/IconEntryImpl.java | 221 ++++ .../impl/PostActionConfigurationImpl.java | 43 + .../impl/PreActionConfigurationImpl.java | 43 + .../util/ExtendedtypesAdapterFactory.java | 214 ++++ .../util/ExtendedtypesResourceFactoryImpl.java | 56 + .../util/ExtendedtypesResourceImpl.java | 32 + .../extendedtypes/util/ExtendedtypesSwitch.java | 237 ++++ .../util/ExtendedtypesXMLProcessor.java | 54 + .../eclipse/papyrus/extendedtypes/Activator.java | 58 - .../extendedtypes/ExtendedEditHelperAdvice.java | 108 -- .../ExtendedSemanticTypeDescriptor.java | 136 -- .../extendedtypes/ExtendedTypesRegistry.java | 270 ---- .../extendedtypes/IExtendedTypeExtensionPoint.java | 40 - .../advices/ExtendedTypesOwnerAdvice.java | 102 -- .../preferences/ExtendedTypesPreferences.java | 197 --- .../ExtendedElementTypeActionService.java | 198 --- ...ntedElementTypeActionProviderConfiguration.java | 82 -- ...xtendedElementTypeActionProvidersOperation.java | 48 - ...ExtendedElementTypeActionProviderOperation.java | 53 - .../IExtendedElementTypeActionProvider.java | 61 - .../providers/ProviderNotFoundException.java | 36 - .../types/ExtendedHintedTypeFactory.java | 125 -- .../types/IExtendedHintedElementType.java | 31 - .../extendedtypes/util/ElementTypeUtils.java | 156 --- .../papyrus/infra/extendedtypes/Activator.java | 58 + .../extendedtypes/ExtendedEditHelperAdvice.java | 108 ++ .../ExtendedSemanticTypeDescriptor.java | 136 ++ .../infra/extendedtypes/ExtendedTypesRegistry.java | 272 ++++ .../extendedtypes/IExtendedTypeExtensionPoint.java | 40 + .../advices/ExtendedTypesOwnerAdvice.java | 102 ++ .../preferences/ExtendedTypesPreferences.java | 197 +++ .../ExtendedElementTypeActionService.java | 198 +++ ...ntedElementTypeActionProviderConfiguration.java | 82 ++ ...xtendedElementTypeActionProvidersOperation.java | 48 + ...ExtendedElementTypeActionProviderOperation.java | 53 + .../IExtendedElementTypeActionProvider.java | 61 + .../providers/ProviderNotFoundException.java | 36 + .../types/ExtendedHintedTypeFactory.java | 125 ++ .../types/IExtendedHintedElementType.java | 31 + .../infra/extendedtypes/util/ElementTypeUtils.java | 156 +++ .../META-INF/MANIFEST.MF | 6 +- .../org.eclipse.papyrus.infra.onefile/plugin.xml | 92 +- .../schema/modelFactory.exsd | 6 +- .../eclipse/papyrus/infra/onefile/Activator.java | 69 + .../infra/onefile/matcher/OnlyDiFilter.java | 55 + .../infra/onefile/model/IPapyrusElement.java | 34 + .../papyrus/infra/onefile/model/IPapyrusFile.java | 56 + .../infra/onefile/model/IPapyrusModelFactory.java | 50 + .../infra/onefile/model/ISubResourceFile.java | 30 + .../infra/onefile/model/PapyrusModelHelper.java | 111 ++ .../model/adapters/ModelAdapterFactory.java | 63 + .../PapyrusCommonDropAdapterAssistant.java | 81 ++ .../onefile/model/adapters/PapyrusLinkHelper.java | 75 ++ .../PapyrusModelContributorResourceAdapter.java | 38 + .../model/adapters/SubResourceAdapterFactory.java | 56 + .../infra/onefile/model/impl/PapyrusFile.java | 103 ++ .../onefile/model/impl/PapyrusModelFactory.java | 35 + .../infra/onefile/model/impl/SubResourceFile.java | 74 ++ .../model/mapping/PapyrusResourceMapping.java | 84 ++ .../onefile/model/mapping/SubResourceMapping.java | 71 ++ .../providers/ISubresourceFileActionProvider.java | 76 ++ .../infra/onefile/providers/OneFileDecorator.java | 173 +++ .../onefile/providers/OneFileModelProvider.java | 62 + .../onefile/providers/PapyrusContentProvider.java | 268 ++++ .../onefile/providers/PapyrusLabelProvider.java | 67 + .../providers/PapyrusModelActionProvider.java | 316 +++++ .../onefile/providers/PapyrusViewerSorter.java | 54 + .../papyrus/infra/onefile/utils/OneFileUtils.java | 343 +++++ .../src/org/eclipse/papyrus/onefile/Activator.java | 69 - .../papyrus/onefile/matcher/OnlyDiFilter.java | 55 - .../papyrus/onefile/model/IPapyrusElement.java | 34 - .../papyrus/onefile/model/IPapyrusFile.java | 56 - .../onefile/model/IPapyrusModelFactory.java | 50 - .../papyrus/onefile/model/ISubResourceFile.java | 30 - .../papyrus/onefile/model/PapyrusModelHelper.java | 111 -- .../model/adapters/ModelAdapterFactory.java | 63 - .../PapyrusCommonDropAdapterAssistant.java | 81 -- .../onefile/model/adapters/PapyrusLinkHelper.java | 75 -- .../PapyrusModelContributorResourceAdapter.java | 38 - .../model/adapters/SubResourceAdapterFactory.java | 56 - .../papyrus/onefile/model/impl/PapyrusFile.java | 103 -- .../onefile/model/impl/PapyrusModelFactory.java | 35 - .../onefile/model/impl/SubResourceFile.java | 74 -- .../model/mapping/PapyrusResourceMapping.java | 84 -- .../onefile/model/mapping/SubResourceMapping.java | 71 -- .../providers/ISubresourceFileActionProvider.java | 76 -- .../onefile/providers/OneFileDecorator.java | 173 --- .../onefile/providers/OneFileModelProvider.java | 62 - .../onefile/providers/PapyrusContentProvider.java | 268 ---- .../onefile/providers/PapyrusLabelProvider.java | 67 - .../providers/PapyrusModelActionProvider.java | 316 ----- .../onefile/providers/PapyrusViewerSorter.java | 54 - .../papyrus/onefile/utils/OneFileUtils.java | 343 ----- .../META-INF/MANIFEST.MF | 2 +- .../OSGI-INF/l10n/bundle.properties | 2 +- .../build.properties | 20 +- .../plugin.xml | 6 +- .../papyrus/infra/ui/resources/Activator.java | 72 ++ .../refactoring/DeleteModelParticipant.java | 147 +++ .../resources/refactoring/DirtyEditorChange.java | 146 +++ .../infra/ui/resources/refactoring/Messages.java | 66 + .../refactoring/ModelParticipantHelpers.java | 152 +++ .../refactoring/MoveModelParticipant.java | 117 ++ .../resources/refactoring/RenameModelChange.java | 443 +++++++ .../refactoring/RenameModelParticipant.java | 142 +++ .../ui/resources/refactoring/messages.properties | 19 + .../ui/resources/refactoring/ui/IScopeChooser.java | 50 + .../ui/resources/refactoring/ui/Messages.java | 35 + .../refactoring/ui/RenameParticipantsDialog.java | 246 ++++ .../ui/resources/refactoring/ui/ScopeChooser.java | 99 ++ .../resources/refactoring/ui/messages.properties | 10 + .../eclipse/papyrus/ui/resources/Activator.java | 72 -- .../refactoring/DeleteModelParticipant.java | 147 --- .../resources/refactoring/DirtyEditorChange.java | 146 --- .../papyrus/ui/resources/refactoring/Messages.java | 66 - .../refactoring/ModelParticipantHelpers.java | 152 --- .../refactoring/MoveModelParticipant.java | 117 -- .../resources/refactoring/RenameModelChange.java | 443 ------- .../refactoring/RenameModelParticipant.java | 142 --- .../ui/resources/refactoring/messages.properties | 19 - .../ui/resources/refactoring/ui/IScopeChooser.java | 50 - .../ui/resources/refactoring/ui/Messages.java | 35 - .../refactoring/ui/RenameParticipantsDialog.java | 246 ---- .../ui/resources/refactoring/ui/ScopeChooser.java | 99 -- .../resources/refactoring/ui/messages.properties | 10 - 836 files changed, 58067 insertions(+), 58050 deletions(-) create mode 100644 plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/schema/org.eclipse.papyrus.editor.perspectiveconfiguration.exsd delete mode 100644 plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/schema/org.eclipse.papyrus.ui.perspectiveconfiguration.exsd create mode 100644 plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/Activator.java create mode 100644 plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/Configuration.java create mode 100644 plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/ConfigurationService.java create mode 100644 plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/CustomizeActionBars.java create mode 100644 plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/PapyrusPerspectiveListener.java create mode 100644 plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/PerspectiveConfigurator.java delete mode 100644 plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/Activator.java delete mode 100644 plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/Configuration.java delete mode 100644 plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/ConfigurationService.java delete mode 100644 plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/CustomizeActionBars.java delete mode 100644 plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/PapyrusPerspectiveListener.java delete mode 100644 plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/PerspectiveConfigurator.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/core/adaptor/emf/Activator.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/core/adaptor/emf/CreateDiagramHandler.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/infra/core/adaptor/emf/Activator.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/infra/core/adaptor/emf/CreateDiagramHandler.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/AbstractPapyrusGmfCreateDiagramCommandHandler.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/Activator.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/DiagramsUtil.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/GmfEditorFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/GmfMultiDiagramDocumentProvider.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/Messages.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/ModelManagerEditor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/SemanticFromGMFElement.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/SynchronizableGmfDiagramEditor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/UMLDiagramEditorUtil.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/AbstractPapyrusGmfCreateDiagramCommandHandler.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/Activator.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/DiagramsUtil.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/GmfEditorFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/GmfMultiDiagramDocumentProvider.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/Messages.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/ModelManagerEditor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/SemanticFromGMFElement.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/SynchronizableGmfDiagramEditor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/UMLDiagramEditorUtil.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/infra/core/log/LogHelper.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/infra/core/log/internal/Activator.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/log/LogHelper.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/log/internal/Activator.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/DiSashModelMngr.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/IPageModelFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/TransactionalDiSashModelMngr.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseAllDiagramsCommand.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseDiagramCommand.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseOtherDiagramsCommand.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/ContentChangedEventProvider.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/DiContentProvider.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageMngrImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/SashPanelModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TabFolderModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalDiContentProvider.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalPageMngrImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/utils/IPageUtils.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/DiSashModelMngr.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/IPageModelFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/TransactionalDiSashModelMngr.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/commands/CloseAllDiagramsCommand.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/commands/CloseDiagramCommand.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/commands/CloseOtherDiagramsCommand.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/ContentChangedEventProvider.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/DiContentProvider.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/PageMngrImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/SashPanelModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/TabFolderModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/TransactionalDiContentProvider.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/TransactionalPageMngrImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/utils/IPageUtils.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/AbstractPage.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/AbstractPanel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/DiFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/DiPackage.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/PageList.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/PageRef.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/PanelParent.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/Position.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/SashModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/SashPanel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/SashWindowsMngr.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/Size.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/TabFolder.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/Window.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/exception/SashEditorException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/AbstractPageImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/AbstractPanelImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/DiFactoryImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/DiPackageImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PageListImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PageRefImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PanelParentImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PositionImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SashModelImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SashPanelImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SashWindowsMngrImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SizeImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/TabFolderImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/WindowImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiAdapterFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiResourceFactoryImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiResourceImpl.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiSwitch.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiUtils.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/AbstractPage.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/AbstractPanel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/DiFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/DiPackage.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/PageList.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/PageRef.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/PanelParent.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/Position.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/SashModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/SashPanel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/SashWindowsMngr.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/Size.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/TabFolder.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/Window.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/exception/SashEditorException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/AbstractPageImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/AbstractPanelImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/DiFactoryImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/DiPackageImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PageListImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PageRefImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PanelParentImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PositionImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SashModelImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SashPanelImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SashWindowsMngrImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SizeImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/TabFolderImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/WindowImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiAdapterFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiResourceFactoryImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiResourceImpl.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiSwitch.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiUtils.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/Activator.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IAbstractPanelModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IComponentModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedListener.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedProvider.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IEditorModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageMngr.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashPanelModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashWindowsContentProvider.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ITabFolderModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractPanelModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/RootModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SashPanelModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SimpleSashWindowsContentProvider.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/TabFolderModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderContentProvider.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IComponentPage.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IEditorPage.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IMultiEditorManager.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IMultiPageEditorPart.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPage.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageChangedListener.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageImageUtils.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageVisitor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainer.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainerChangedListener.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashContainerEventsListener.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashTabDecorationSynchronizer.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashWindowsContainer.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashWindowsEventsProvider.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/IMultiPageEditorActionBarContributor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/MultiPageEditorActionBarContributor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/gef/MultiDiagramEditorGefDelegate.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPanelPart.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPart.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActiveEditorServicesSwitcher.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActivePageTracker.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ComponentPart.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/Copyright.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/EditorPart.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPanelParent.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPartVisitor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ImageToolTipManager.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupFolderPartByRawModelVisitor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupIPageByIEditorPartVisitor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupModelPageVisitor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/NotFoundException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PTabFolder.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PagePart.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PageVisitorWrapper.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartLists.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartVisitor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ReplaceableSashForm.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/RootPart.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashContainerEventsProvider.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashPanelPart.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ShowPartStatusVisitor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabItemPart.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/AbstractTabFolderPart.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageSelectionProvider.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/ITabTooltipPreferences.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/ShowPreferencesHandler.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/TabTooltipPreferenceInitializer.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/TabTooltipPreferencePage.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/TabTooltipPreferences.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/multipage/editor/MultiPageEditor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/Activator.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IAbstractPanelModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IComponentModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IContentChangedListener.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IContentChangedProvider.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IEditorModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IPageMngr.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IPageModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/ISashPanelModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/ISashWindowsContentProvider.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/ITabFolderModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/AbstractModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/AbstractPanelModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/RootModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/SashPanelModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/SimpleSashWindowsContentProvider.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/TabFolderModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/singlefolder/SingleFolderContentProvider.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/singlefolder/SingleFolderModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/AbstractMultiPageSashEditor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IComponentPage.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IEditorPage.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IMultiEditorManager.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IMultiPageEditorPart.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPage.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPageChangedListener.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPageImageUtils.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPageVisitor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/ISashWindowsContainer.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/ISashWindowsContainerChangedListener.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashContainerEventsListener.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashTabDecorationSynchronizer.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashWindowsContainer.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashWindowsEventsProvider.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/actionbarcontributor/IMultiPageEditorActionBarContributor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/actionbarcontributor/MultiPageEditorActionBarContributor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/gef/MultiDiagramEditorGefDelegate.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/AbstractPanelPart.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/AbstractPart.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ActiveEditorServicesSwitcher.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ActivePageTracker.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ComponentPart.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/Copyright.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/EditorPart.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/IPanelParent.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/IPartVisitor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ImageToolTipManager.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/LookupFolderPartByRawModelVisitor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/LookupIPageByIEditorPartVisitor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/LookupModelPageVisitor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/NotFoundException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PTabFolder.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PagePart.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PageVisitorWrapper.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PartLists.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PartVisitor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ReplaceableSashForm.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/RootPart.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/SashContainerEventsProvider.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/SashPanelPart.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/SashWindowsException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ShowPartStatusVisitor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/TabFolderPart.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/TabItemPart.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/eclipsecopy/AbstractTabFolderPart.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/eclipsecopy/MultiPageSelectionProvider.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/ITabTooltipPreferences.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/ShowPreferencesHandler.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/TabTooltipPreferenceInitializer.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/TabTooltipPreferencePage.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/TabTooltipPreferences.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/multipage/editor/MultiPageEditor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/Activator.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/IElementWithSemantic.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/contentoutline/ContentOutlineRegistry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/contentoutline/IPapyrusContentOutlinePage.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/BackboneException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/ContentProviderServiceFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/CoreMultiDiagramEditor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/DiResourceSetServiceFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/DiSashModelMngrServiceFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/IMultiDiagramEditor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/ModelSetServiceFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/PageIconRegistryServiceFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/PageMngrServiceFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IEditorFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IEditorIconFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IEditorIconFactoryExtended.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IPageIconsRegistry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IPageIconsRegistryExtended.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/PageIconsRegistry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/PageModelFactoryRegistry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/BadClassNameException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/BadNameExtensionException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/ExtensionException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/ExtensionUtils.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/NotFoundException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/CreationCommandDescriptor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/CreationCommandExtensionFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/CreationCommandRegistry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ICreationCommand.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ICreationCommandRegistry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ICreationCondition.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/IModelCreationCommand.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ModelCreationCommandBase.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/PerspectiveContextDependence.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/AbstractEditorFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorDescriptor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorDescriptorExtensionFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorFactoryProxy.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorIconFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorNotFoundException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/IPluggableEditorFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/MultiDiagramException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/PluggableEditorFactoryReader.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/DoSaveEvent.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/IEditorInputChangedListener.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/ILifeCycleEventsProvider.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/ISaveAndDirtyService.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/ISaveEventListener.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/LifeCycleEventsProvider.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/LifeCycleEventsProviderServiceFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/SaveAndDirtyService.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/listenerservice/IPapyrusListener.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/listenerservice/ModelListenerManager.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/ModelSetQuery.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/impl/IModelSetQueryAdapter.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/impl/ModelSetQueryAdapter.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/impl/ModelSetQueryInitializer.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/ActionBarContributorDescriptor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/ActionBarContributorExtensionFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/ActionBarContributorRegistry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/IActionBarContributorFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/BadStateException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ComposedService.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ComposedServicePart.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ExtensionServicesRegistry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/IService.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/IServiceFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceDescriptor.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceMultiException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceNotFoundException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceStartKind.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceState.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServicesRegistry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ErrorServiceTypeEntry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/LazyStartupEntry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/PojoServiceEntry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceEntry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceFactoryEntry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceStartupEntry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceTypeEntry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/StartStartupEntry.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/ui/IRevealSemanticElement.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/AbstractServiceUtils.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/BusinessModelResolver.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/DiResourceSet.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/DisplayUtils.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/EditorUtils.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/FilteredCollectionView.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/FilteredCollectionViewFromIterator.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/FilteredListView.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/GMFtoEMFCommandWrapper.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/IDebugChannel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/IFilter.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/OpenDiagramCommand.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/PapyrusEcoreUtils.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/PapyrusImageUtils.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/PapyrusTrace.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/ServiceUtils.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/ServiceUtilsForActionHandlers.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/Activator.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/IElementWithSemantic.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/contentoutline/ContentOutlineRegistry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/contentoutline/IPapyrusContentOutlinePage.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/BackboneException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/ContentProviderServiceFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/DiResourceSetServiceFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/DiSashModelMngrServiceFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/IMultiDiagramEditor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/ModelSetServiceFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/PageIconRegistryServiceFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/PageMngrServiceFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IEditorFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IEditorIconFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IEditorIconFactoryExtended.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IPageIconsRegistry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IPageIconsRegistryExtended.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/PageIconsRegistry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/PageModelFactoryRegistry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/BadClassNameException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/BadNameExtensionException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/ExtensionException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/ExtensionUtils.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/NotFoundException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/CreationCommandDescriptor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/CreationCommandExtensionFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/CreationCommandRegistry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ICreationCommand.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ICreationCommandRegistry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ICreationCondition.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/IModelCreationCommand.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ModelCreationCommandBase.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/PerspectiveContextDependence.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/AbstractEditorFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorDescriptor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorDescriptorExtensionFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorFactoryProxy.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorIconFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorNotFoundException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/IPluggableEditorFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/MultiDiagramException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/PluggableEditorFactoryReader.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/DoSaveEvent.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/IEditorInputChangedListener.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/ILifeCycleEventsProvider.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/ISaveAndDirtyService.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/ISaveEventListener.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/LifeCycleEventsProvider.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/LifeCycleEventsProviderServiceFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/SaveAndDirtyService.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/listenerservice/IPapyrusListener.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/listenerservice/ModelListenerManager.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/ModelSetQuery.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/IModelSetQueryAdapter.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/ModelSetQueryAdapter.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/ModelSetQueryInitializer.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/ActionBarContributorDescriptor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/ActionBarContributorExtensionFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/ActionBarContributorRegistry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/IActionBarContributorFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractBaseModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/BadStateException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/EditingDomainServiceFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IModelSetSnippet.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IModelSnippet.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ITransactionalEditingDomainProvider.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelIdentifiers.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelMultiException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSnippetList.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelUtils.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelsReader.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/NotFoundException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/TransactionalEditingDomainManager.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/additional/AdditionalResourcesModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/notation/NotationModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/notation/NotationUtils.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/DiModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/DiModelUtils.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModelUtils.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/ExtendedUmlModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/UmlModel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/UmlSnippet.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/UmlUtils.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/BadStateException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ComposedService.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ComposedServicePart.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ExtensionServicesRegistry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/IService.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/IServiceFactory.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceDescriptor.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceMultiException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceNotFoundException.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceStartKind.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceState.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ErrorServiceTypeEntry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/LazyStartupEntry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/PojoServiceEntry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceEntry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceFactoryEntry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceStartupEntry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceTypeEntry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/StartStartupEntry.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/ui/IRevealSemanticElement.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/AbstractServiceUtils.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/BusinessModelResolver.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/DiResourceSet.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/DisplayUtils.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/EditorUtils.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/FilteredCollectionView.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/FilteredCollectionViewFromIterator.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/FilteredListView.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/GMFtoEMFCommandWrapper.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/IDebugChannel.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/IFilter.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/OpenDiagramCommand.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/PapyrusEcoreUtils.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/PapyrusImageUtils.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/PapyrusTrace.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtils.java create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtilsForActionHandlers.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/AbstractBaseModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/AbstractModelWithSharedResource.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/BadStateException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/EditingDomainServiceFactory.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/IModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/IModelSetSnippet.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/IModelSnippet.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ITransactionalEditingDomainProvider.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelIdentifiers.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelMultiException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelSet.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelSnippetList.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelUtils.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelsReader.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/NotFoundException.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/TransactionalEditingDomainManager.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/additional/AdditionalResourcesModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/notation/NotationModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/notation/NotationUtils.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/DiModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/DiModelUtils.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/SashModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/SashModelUtils.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/ExtendedUmlModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/UmlModel.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/UmlSnippet.java delete mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/UmlUtils.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/ExportAllDiagrams.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/ExportException.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/Messages.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/PropertyTester.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/ExportAllDiagramsAction.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/ExportAllDiagramsDialog.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/ExportComposite.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/Messages.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/messages.properties delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/internal/Activator.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/messages.properties delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/ExportAllWizard.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/ExportDiagramsErrorPage.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/ExportDiagramsPage.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/Messages.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/messages.properties create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/ExportAllDiagrams.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/ExportException.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/Messages.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/PropertyTester.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/ExportAllDiagramsAction.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/ExportAllDiagramsDialog.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/ExportComposite.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/Messages.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/messages.properties create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/internal/Activator.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/messages.properties create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/ExportAllWizard.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/ExportDiagramsErrorPage.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/ExportDiagramsPage.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/Messages.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/messages.properties delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ConstantValue.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/DynamicValue.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureToSet.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureValue.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ListValue.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfiguration.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationFactory.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationPackage.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/QueryExecutionValue.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ConstantValueImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/DynamicValueImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureToSetImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureValueImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ListValueImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationFactoryImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationPackageImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/QueryExecutionValueImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationAdapterFactory.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceFactoryImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationSwitch.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationXMLProcessor.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ConstantValue.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/DynamicValue.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureToSet.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureValue.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ListValue.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfiguration.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationFactory.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationPackage.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/QueryExecutionValue.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ConstantValueImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/DynamicValueImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureToSetImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureValueImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ListValueImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationFactoryImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationPackageImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/QueryExecutionValueImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationAdapterFactory.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceFactoryImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationSwitch.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationXMLProcessor.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/extendedtypes/emf/Activator.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/extendedtypes/emf/providers/ModifySemanticValuesActionProvider.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/infra/extendedtypes/emf/Activator.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/infra/extendedtypes/emf/providers/ModifySemanticValuesActionProvider.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ActionConfiguration.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedElementTypeConfiguration.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedElementTypeSet.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedtypesFactory.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedtypesPackage.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/IconEntry.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/PostActionConfiguration.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/PreActionConfiguration.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ActionConfigurationImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedElementTypeConfigurationImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedElementTypeSetImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedtypesFactoryImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedtypesPackageImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/IconEntryImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/PostActionConfigurationImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/PreActionConfigurationImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesAdapterFactory.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesResourceFactoryImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesResourceImpl.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesSwitch.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesXMLProcessor.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ActionConfiguration.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedElementTypeConfiguration.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedElementTypeSet.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedtypesFactory.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedtypesPackage.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/IconEntry.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/PostActionConfiguration.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/PreActionConfiguration.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ActionConfigurationImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedElementTypeConfigurationImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedElementTypeSetImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedtypesFactoryImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedtypesPackageImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/IconEntryImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/PostActionConfigurationImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/PreActionConfigurationImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesAdapterFactory.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesResourceFactoryImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesResourceImpl.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesSwitch.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesXMLProcessor.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/Activator.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/ExtendedEditHelperAdvice.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/ExtendedSemanticTypeDescriptor.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/ExtendedTypesRegistry.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/IExtendedTypeExtensionPoint.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/advices/ExtendedTypesOwnerAdvice.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/preferences/ExtendedTypesPreferences.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/ExtendedElementTypeActionService.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/ExtentedElementTypeActionProviderConfiguration.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/GetAllExtendedElementTypeActionProvidersOperation.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/GetExtendedElementTypeActionProviderOperation.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/IExtendedElementTypeActionProvider.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/ProviderNotFoundException.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/types/ExtendedHintedTypeFactory.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/types/IExtendedHintedElementType.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/util/ElementTypeUtils.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/Activator.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedEditHelperAdvice.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedSemanticTypeDescriptor.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedTypesRegistry.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/IExtendedTypeExtensionPoint.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/advices/ExtendedTypesOwnerAdvice.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/preferences/ExtendedTypesPreferences.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtendedElementTypeActionService.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtentedElementTypeActionProviderConfiguration.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetAllExtendedElementTypeActionProvidersOperation.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetExtendedElementTypeActionProviderOperation.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/IExtendedElementTypeActionProvider.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ProviderNotFoundException.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/types/ExtendedHintedTypeFactory.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/types/IExtendedHintedElementType.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/util/ElementTypeUtils.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/Activator.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/matcher/OnlyDiFilter.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/IPapyrusElement.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/IPapyrusFile.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/IPapyrusModelFactory.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/ISubResourceFile.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/PapyrusModelHelper.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/ModelAdapterFactory.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/PapyrusCommonDropAdapterAssistant.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/PapyrusLinkHelper.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/PapyrusModelContributorResourceAdapter.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/SubResourceAdapterFactory.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/PapyrusFile.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/PapyrusModelFactory.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/SubResourceFile.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/mapping/PapyrusResourceMapping.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/mapping/SubResourceMapping.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/ISubresourceFileActionProvider.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/OneFileDecorator.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/OneFileModelProvider.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusContentProvider.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusLabelProvider.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusModelActionProvider.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusViewerSorter.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/utils/OneFileUtils.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/Activator.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/matcher/OnlyDiFilter.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusElement.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusFile.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusModelFactory.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/ISubResourceFile.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/PapyrusModelHelper.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/ModelAdapterFactory.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusCommonDropAdapterAssistant.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusLinkHelper.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusModelContributorResourceAdapter.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/SubResourceAdapterFactory.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusFile.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusModelFactory.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/impl/SubResourceFile.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/mapping/PapyrusResourceMapping.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/mapping/SubResourceMapping.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/ISubresourceFileActionProvider.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/OneFileDecorator.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/OneFileModelProvider.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusContentProvider.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusLabelProvider.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusModelActionProvider.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusViewerSorter.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/utils/OneFileUtils.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/Activator.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/DeleteModelParticipant.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/DirtyEditorChange.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/Messages.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ModelParticipantHelpers.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/MoveModelParticipant.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/RenameModelChange.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/RenameModelParticipant.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/messages.properties create mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/IScopeChooser.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/Messages.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/RenameParticipantsDialog.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/ScopeChooser.java create mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/messages.properties delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/Activator.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/DeleteModelParticipant.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/DirtyEditorChange.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/Messages.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ModelParticipantHelpers.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/MoveModelParticipant.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/RenameModelChange.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/RenameModelParticipant.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/messages.properties delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/IScopeChooser.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/Messages.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/RenameParticipantsDialog.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/ScopeChooser.java delete mode 100644 plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/messages.properties (limited to 'plugins') diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/META-INF/MANIFEST.MF b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/META-INF/MANIFEST.MF index 97b5ab9538e..cad713c0eae 100644 --- a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/META-INF/MANIFEST.MF +++ b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/META-INF/MANIFEST.MF @@ -8,8 +8,7 @@ Bundle-Version: 0.9.0.qualifier Bundle-Name: %pluginName Bundle-Localization: plugin Bundle-ManifestVersion: 2 -Bundle-Activator: org.eclipse.papyrus.ui.perspectiveconfiguration.Acti - vator +Bundle-Activator: org.eclipse.papyrus.editor.perspectiveconfiguration.Activator Bundle-SymbolicName: org.eclipse.papyrus.editor.perspectiveconfiguration;singleton:=true Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/plugin.xml b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/plugin.xml index df4c9f12d28..1cb93c47ee8 100644 --- a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/plugin.xml +++ b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/plugin.xml @@ -1,11 +1,11 @@ - + + class="org.eclipse.papyrus.editor.perspectiveconfiguration.PerspectiveConfigurator"> diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/schema/org.eclipse.papyrus.editor.perspectiveconfiguration.exsd b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/schema/org.eclipse.papyrus.editor.perspectiveconfiguration.exsd new file mode 100644 index 00000000000..1948179b2b8 --- /dev/null +++ b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/schema/org.eclipse.papyrus.editor.perspectiveconfiguration.exsd @@ -0,0 +1,232 @@ + + + + + + + + + This extension point is used to configure a set of perpsectives. +For each perspective, only given action set, menu or category can be shown. It is only possible to configure the menu preference that can be seen for a perspective. +I is also possible to set if a perspective can be customize by the the eclipse dialog box. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + this is a configuration for a perspective + + + + + + + + + + + + + + + this the is of the perpective that will be configured. + + + + + + + + + + + + + This is the list of action Set that will be displayed + + + + + + + Id of the action Set to display + + + + + + + + + + + + + + + the id of the menu that we want to display + + + + + + + + + + + + + + + the id of the tool bar that we want to display + + + + + + + + + + + + + + + the id of the preference page that we want to display + + + + + + + + + + + + + + + this is the id of the category (a set of commands) that we want to display. + + + + + + + + + + + + + + + this is the ID of a command that we want to display + + + + + + + + + + + + + + + 0.7.0 + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + + + + + /***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ + + + + diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/schema/org.eclipse.papyrus.ui.perspectiveconfiguration.exsd b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/schema/org.eclipse.papyrus.ui.perspectiveconfiguration.exsd deleted file mode 100644 index 4ba61db09a0..00000000000 --- a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/schema/org.eclipse.papyrus.ui.perspectiveconfiguration.exsd +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - - - - This extension point is used to configure a set of perpsectives. -For each perspective, only given action set, menu or category can be shown. It is only possible to configure the menu preference that can be seen for a perspective. -I is also possible to set if a perspective can be customize by the the eclipse dialog box. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - this is a configuration for a perspective - - - - - - - - - - - - - - - this the is of the perpective that will be configured. - - - - - - - - - - - - - This is the list of action Set that will be displayed - - - - - - - Id of the action Set to display - - - - - - - - - - - - - - - the id of the menu that we want to display - - - - - - - - - - - - - - - the id of the tool bar that we want to display - - - - - - - - - - - - - - - the id of the preference page that we want to display - - - - - - - - - - - - - - - this is the id of the category (a set of commands) that we want to display. - - - - - - - - - - - - - - - this is the ID of a command that we want to display - - - - - - - - - - - - - - - 0.7.0 - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - - - - - /***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - - - - diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/Activator.java b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/Activator.java new file mode 100644 index 00000000000..4511fa27aab --- /dev/null +++ b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/Activator.java @@ -0,0 +1,75 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.editor.perspectiveconfiguration; + +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 + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.papyrus.editor.perspectiveconfiguration"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** Logging 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; + // register the login helper + 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; + } + +} diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/Configuration.java b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/Configuration.java new file mode 100644 index 00000000000..ebb17bcc304 --- /dev/null +++ b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/Configuration.java @@ -0,0 +1,104 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.editor.perspectiveconfiguration; + +import java.util.ArrayList; + +/** + * this class is a structure that contains a configuration + * + */ +public class Configuration { + + protected String perspectiveID = null; + + protected ArrayList actionSetIDList = new ArrayList(); + + protected ArrayList menuIDList = new ArrayList(); + + protected ArrayList toolBarIDList = new ArrayList(); + + protected ArrayList preferenceIDList = new ArrayList(); + + protected ArrayList categoryIDList = new ArrayList(); + + protected ArrayList commandIDList = new ArrayList(); + + public ArrayList getCategoryIDList() { + return categoryIDList; + } + + + public void addCategory(String id) { + categoryIDList.add(id); + } + + public void addCommandID(String id) { + commandIDList.add(id); + } + + public ArrayList getCommandIDList() { + return commandIDList; + } + + public ArrayList getActionSetIDList() { + return actionSetIDList; + } + + public void addActionSet(String id) { + actionSetIDList.add(id); + } + + public void addMenu(String id) { + menuIDList.add(id); + } + + public void addtoolBar(String id) { + toolBarIDList.add(id); + } + + public void addPreference(String id) { + preferenceIDList.add(id); + } + + public ArrayList getMenuIDList() { + return menuIDList; + } + + public ArrayList getToolBarID() { + return toolBarIDList; + } + + public ArrayList getPreferenceID() { + return preferenceIDList; + } + + public String getPerspectiveID() { + return perspectiveID; + } + + public void setPerspectiveID(String perspectiveID) { + this.perspectiveID = perspectiveID; + } + + /** + * constructor of a perspective + * + * @param perspectiveName + */ + public Configuration(String perspectiveName) { + setPerspectiveID(perspectiveName); + } + +} diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/ConfigurationService.java b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/ConfigurationService.java new file mode 100644 index 00000000000..753a00cfe1f --- /dev/null +++ b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/ConfigurationService.java @@ -0,0 +1,121 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.editor.perspectiveconfiguration; + +import java.util.HashMap; +import java.util.Set; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; + +/** + * Take information form the extension point in order to configure Papyrus. + */ +public class ConfigurationService { + + public static String PERSPECTIVE_CONFIGURATION_EXTENSION_POINT_ID = "org.eclipse.papyrus.editor.perspectiveconfiguration"; + + public static String PERPSECTIVE_ID = "perspectiveID"; + + public static String ACTION_SET = "actionSet"; + + public static String ACTION_SET_ID = "actionSetID"; + + public static String MENU = "menu"; + + public static String MENU_ID = "menuID"; + + public static String TOOLBAR = "toolbar"; + + public static String TOOLBAR_ID = "toolbarID"; + + public static String PREFERENCEPAGE = "preferencePage"; + + public static String PREFERENCEPAGEID = "preferencepageID"; + + public static String CATEGORY = "category"; + + public static String CATEGORYID = "categoryID"; + + public static String COMMAND = "command"; + + public static String COMMANDID = "commandID"; + + + protected HashMap configurationMap = new HashMap(); + + public ConfigurationService() { + IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(PERSPECTIVE_CONFIGURATION_EXTENSION_POINT_ID); + for(int i = 0; i < configElements.length; i++) { + constructAConfiguation(configElements[i]); + } + } + + protected void constructAConfiguation(IConfigurationElement iConfigurationElement) { + try { + String configName = (String)iConfigurationElement.getAttribute(PERPSECTIVE_ID); + if(!configurationMap.containsKey(configName) || configurationMap.get(configName) == null) { + configurationMap.put(configName, new Configuration(configName)); + } + Configuration configuration = configurationMap.get(configName); + + IConfigurationElement[] element = iConfigurationElement.getChildren(ACTION_SET); + for(int i = 0; i < element.length; i++) { + configuration.addActionSet(element[i].getAttribute(ACTION_SET_ID)); + } + element = iConfigurationElement.getChildren(MENU); + for(int i = 0; i < element.length; i++) { + configuration.addMenu(element[i].getAttribute(MENU_ID)); + } + element = iConfigurationElement.getChildren(TOOLBAR); + for(int i = 0; i < element.length; i++) { + configuration.addtoolBar(element[i].getAttribute(TOOLBAR_ID)); + } + element = iConfigurationElement.getChildren(PREFERENCEPAGE); + for(int i = 0; i < element.length; i++) { + configuration.addPreference(element[i].getAttribute(PREFERENCEPAGEID)); + } + element = iConfigurationElement.getChildren(CATEGORY); + for(int i = 0; i < element.length; i++) { + configuration.addCategory(element[i].getAttribute(CATEGORYID)); + } + + element = iConfigurationElement.getChildren(COMMAND); + for(int i = 0; i < element.length; i++) { + configuration.addCommandID(element[i].getAttribute(COMMANDID)); + } + } catch (Exception e) { + Activator.log.error("- " + iConfigurationElement + " can not be loaded ", e); + } + } + + /** + * + * @return a set of perspective id that has a configuration + */ + protected Set getPerspectiveList() { + return configurationMap.keySet(); + } + + /** + * get a configuration from a perspective ID + * + * @param perspectiveID + * @return a configuration or null if a configuration is not defined for the given perspective ID + */ + protected Configuration getConfiguration(String perspectiveID) { + return configurationMap.get(perspectiveID); + } +} diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/CustomizeActionBars.java b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/CustomizeActionBars.java new file mode 100644 index 00000000000..a4ec4050da0 --- /dev/null +++ b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/CustomizeActionBars.java @@ -0,0 +1,177 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.editor.perspectiveconfiguration; + +import java.util.List; + +import org.eclipse.jface.action.CoolBarManager; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.ICoolBarManager; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IStatusLineManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.StatusLineManager; +import org.eclipse.jface.action.ToolBarManager; +import org.eclipse.jface.internal.provisional.action.IToolBarContributionItem; +import org.eclipse.jface.internal.provisional.action.ToolBarContributionItem2; +import org.eclipse.ui.IActionBars2; +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.internal.provisional.application.IActionBarConfigurer2; +import org.eclipse.ui.internal.registry.IActionSetDescriptor; +import org.eclipse.ui.services.IServiceLocator; + + +/** + * this class is used to collection all information about menu, cool bar, statusline... + * + */ +public class CustomizeActionBars implements IActionBarConfigurer2, IActionBars2 { + + protected List actionSet = null; + + + /** + * get the list of action set + * + * @return + */ + public List getActionSet() { + return actionSet; + } + + /** + * set the list of action Set + * + * @param actionSet + */ + public void setActionSet(List actionSet) { + this.actionSet = actionSet; + } + + protected MenuManager menuManager = new MenuManager(); + + protected CoolBarManager coolBarManager = new CoolBarManager(); + + protected StatusLineManager statusLineManager = new StatusLineManager(); + + protected ToolBarManager toolBarManager = new ToolBarManager(); + + /** + * Create a new instance of this class. + * + * @param configurer + * the configurer + */ + public CustomizeActionBars(IWorkbenchWindowConfigurer configurer) { + } + + /** + * do not call this method + */ + public IWorkbenchWindowConfigurer getWindowConfigurer() { + return null; + } + + /** + * get the manager in charge to display all menu + */ + + public IMenuManager getMenuManager() { + return menuManager; + } + + /** + * the manager in charge to display the status line + */ + public IStatusLineManager getStatusLineManager() { + return statusLineManager; + } + + /** + * the manager in charge to display the cool bar, this also the tool bar in eclipse + */ + public ICoolBarManager getCoolBarManager() { + return coolBarManager; + } + + /** + * see the getCoolBarManager + */ + public IToolBarManager getToolBarManager() { + return toolBarManager; + } + + /** + * {@inheritDoc} + */ + public void setGlobalActionHandler(String actionID, IAction handler) { + } + + /** + * {@inheritDoc} + */ + public void updateActionBars() { + } + + /** + * {@inheritDoc} + */ + public void clearGlobalActionHandlers() { + } + + /** + * {@inheritDoc} + */ + public IAction getGlobalActionHandler(String actionId) { + return null; + } + + public void registerGlobalAction(IAction action) { + } + + /** + * Clean up the action bars. + */ + public void dispose() { + coolBarManager.dispose(); + menuManager.dispose(); + statusLineManager.dispose(); + toolBarManager.dispose(); + } + + /** + * {@inheritDoc} + */ + public final IServiceLocator getServiceLocator() { + return null; + } + + /** + * {@inheritDoc} + */ + public IToolBarManager createToolBarManager() { + return toolBarManager; + } + + /** + * {@inheritDoc} + */ + public IToolBarContributionItem createToolBarContributionItem(IToolBarManager toolBarManager, String id) { + return new ToolBarContributionItem2(toolBarManager, id); + } + + + +} diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/PapyrusPerspectiveListener.java b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/PapyrusPerspectiveListener.java new file mode 100644 index 00000000000..56fcf4bddff --- /dev/null +++ b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/PapyrusPerspectiveListener.java @@ -0,0 +1,314 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.editor.perspectiveconfiguration; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.internal.jobs.Worker; +import org.eclipse.jface.action.ContributionManager; +import org.eclipse.jface.action.IContributionItem; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.preference.IPreferenceNode; +import org.eclipse.jface.preference.PreferenceNode; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.IPerspectiveDescriptor; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PerspectiveAdapter; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.commands.ICommandService; +import org.eclipse.ui.internal.Perspective; +import org.eclipse.ui.internal.WorkbenchPage; +import org.eclipse.ui.internal.WorkbenchPlugin; +import org.eclipse.ui.internal.WorkbenchWindow; +import org.eclipse.ui.internal.registry.ActionSetDescriptor; +import org.eclipse.ui.internal.registry.ActionSetRegistry; +import org.eclipse.ui.internal.registry.IActionSetDescriptor; +import org.eclipse.ui.internal.registry.PerspectiveRegistry; +import org.eclipse.ui.menus.IMenuService; +import org.eclipse.ui.menus.MenuUtil; + +/** + * this is a listener hat has in charge to configure a perspective when it is openend etc.. + * + */ +public class PapyrusPerspectiveListener extends PerspectiveAdapter { + + private IWorkbenchWindow window; + + protected ConfigurationService configurationservice; + + protected ArrayList hiddenRootPref = new ArrayList(); + + + /** + * creation of the listener + * + * @param window + */ + public PapyrusPerspectiveListener(IWorkbenchWindow window) { + this.window = window; + this.configurationservice = new ConfigurationService(); + + //this is the lauch of eclipse, so we look for which perspective is opened + if(window.getActivePage() != null) { + IPerspectiveDescriptor openedPerspectiveDescriptor = window.getActivePage().getPerspective(); + if(configurationservice.getConfiguration(openedPerspectiveDescriptor.getId()) != null) { + //it is the frist time? + if(!isAlreadySave(openedPerspectiveDescriptor.getId())) { + //Activator.log.debug("First time to open it"); + updateTooling(openedPerspectiveDescriptor); + window.getActivePage().savePerspective(); + } + + } + updatePreferencePage(openedPerspectiveDescriptor); + } + } + + /** + * return yes id it exist a file that custom a given perspective + * + * @param perspectiveID + * the id of the perspective + * @return yes it find a file,if not no + */ + public boolean isAlreadySave(String perspectiveID) { + PerspectiveRegistry perspRegistry = (PerspectiveRegistry)WorkbenchPlugin.getDefault().getPerspectiveRegistry(); + try { + IMemento memento = perspRegistry.getCustomPersp(perspectiveID); + //Activator.log.debug(""+memento); + return true; + } catch (Exception e) { + return false; + } + } + + @Override + public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspectivedescriptor) { + //Activator.log.debug("perspectiveActivated "+perspectivedescriptor.getId()); + super.perspectiveActivated(page, perspectivedescriptor); + + + //test is we are interesting by the current perspective + if(configurationservice.getConfiguration(perspectivedescriptor.getId()) != null) { + if(!isAlreadySave(perspectivedescriptor.getId())) { + updateTooling(perspectivedescriptor); + page.savePerspective(); + } + + + } + updatePreferencePage(perspectivedescriptor); + Perspective perspective = ((WorkbenchPage)page).findPerspective(perspectivedescriptor); + + //due to a bug on the refresh, we need to call explicitly this method. + //to remove, when the origin is found. + if( perspective!=null){ + perspective.updateActionBars(); + } + } + + protected void updatePreferencePage(IPerspectiveDescriptor perspectivedescriptor) { + //test is we are interesting by the current perspective + if(configurationservice.getConfiguration(perspectivedescriptor.getId()) != null) { + + Configuration configuration = configurationservice.getConfiguration(perspectivedescriptor.getId()); + IPreferenceNode[] preferencepagelist = window.getWorkbench().getPreferenceManager().getRootSubNodes(); + + // take in account the preferences + for(int i = 0; i < preferencepagelist.length; i++) { + if(preferencepagelist[i] instanceof PreferenceNode) { + PreferenceNode node = (PreferenceNode)preferencepagelist[i]; + if(!configuration.getPreferenceID().contains(node.getId())) { + hiddenRootPref.add(node); + } + } + } + Iterator iteratorpreftoremove = hiddenRootPref.iterator(); + while(iteratorpreftoremove.hasNext()) { + window.getWorkbench().getPreferenceManager().remove(iteratorpreftoremove.next()); + } + } else { + //this is not an interesting perspective + Iterator iteratorpreftoremove = hiddenRootPref.iterator(); + while(iteratorpreftoremove.hasNext()) { + window.getWorkbench().getPreferenceManager().addToRoot(iteratorpreftoremove.next()); + } + hiddenRootPref.clear(); + } + + } + + /** + * this method hide menu, tool bar and action hat are not interesting + * + * @param perspectivedescriptor + */ + protected void updateTooling(IPerspectiveDescriptor perspectivedescriptor) { + + CustomizeActionBars customizeActionBars = loadData(); + + if(configurationservice.getConfiguration(perspectivedescriptor.getId()) != null) { + Configuration configuration = configurationservice.getConfiguration(perspectivedescriptor.getId()); + //Activator.log.debug("Update tooling"); + //Load all information about menus.... + WorkbenchPage worbenchPage = (WorkbenchPage)window.getActivePage(); + // Get the perspective + Perspective perspective = worbenchPage.findPerspective(perspectivedescriptor); + + ICommandService cmdService = (ICommandService)worbenchPage.getActivePart().getSite().getService(ICommandService.class); + + + ArrayList commandIdToRemove = new ArrayList(); + + try { + + //put all commands that not reference to the given category + for(int i = 0; i < cmdService.getDefinedCommands().length; i++) { + if(!configuration.getCategoryIDList().contains(cmdService.getDefinedCommands()[i].getCategory().getId())) { + commandIdToRemove.add(cmdService.getDefinedCommands()[i].getId()); + } + // else{System.err.println("keep "+cmdService.getDefinedCommands()[i].getId());} + } + + //then verify for each command by taking account its id. + for(int i = 0; i < cmdService.getDefinedCommands().length; i++) { + //put the commands in the list to hide, theis command are not referenced in the given list of command id and are not in the given list of category + if(!configuration.getCommandIDList().contains(cmdService.getDefinedCommands()[i].getId())) { + if(!configuration.getCategoryIDList().contains(cmdService.getDefinedCommands()[i].getCategory().getId())) { + if(!commandIdToRemove.contains(cmdService.getDefinedCommands()[i].getId())) { + commandIdToRemove.add(cmdService.getDefinedCommands()[i].getId()); + } + } + } else {//may be the id that we want to keep was in already in the list because of the filter on category + if(commandIdToRemove.contains(cmdService.getDefinedCommands()[i].getId())) { + commandIdToRemove.remove(cmdService.getDefinedCommands()[i].getId()); + } + } + } + } catch (Exception e) { + System.err.println(e); + } + + + perspective.getHiddenMenuItems().clear(); + perspective.getHiddenToolbarItems().clear(); + + //look for all actionSet + ArrayList actionSetToRemove = new ArrayList(); + Iterator iteratorActionSet = customizeActionBars.getActionSet().iterator(); + while(iteratorActionSet.hasNext()) { + IActionSetDescriptor currentActionSetDescriptor = iteratorActionSet.next(); + //test if the configuationSet contains the id + if(!configuration.getActionSetIDList().contains(currentActionSetDescriptor.getId())) { + actionSetToRemove.add(currentActionSetDescriptor); + } + } + + + + // look for all menu + ArrayList menuToRemove = new ArrayList(); + + for(int i = 0; i < customizeActionBars.getMenuManager().getItems().length; i++) { + if(!configuration.getMenuIDList().contains(customizeActionBars.getMenuManager().getItems()[i].getId())) { + menuToRemove.add(customizeActionBars.getMenuManager().getItems()[i].getId()); + } + } + + //look for all toolbar + ArrayList toolbarToRemove = new ArrayList(); + for(int i = 0; i < customizeActionBars.getToolBarManager().getItems().length; i++) { + + if(!configuration.getToolBarID().contains(customizeActionBars.getToolBarManager().getItems()[i].getId())) { + toolbarToRemove.add(customizeActionBars.getToolBarManager().getItems()[i].getId()); + } + } + + perspective.getHiddenMenuItems().addAll(commandIdToRemove); + perspective.getHiddenToolbarItems().addAll(commandIdToRemove); + //hide elements + perspective.turnOffActionSets((IActionSetDescriptor[])actionSetToRemove.toArray(new IActionSetDescriptor[actionSetToRemove.size()])); + perspective.getHiddenMenuItems().addAll(menuToRemove); + perspective.getHiddenToolbarItems().addAll(toolbarToRemove); + perspective.updateActionBars(); + + } + + } + + /** + * this method search all identifier of menu toolbar and actionSet that are loaded in eclipse + * + * @return a structure that contains all references of the toolbar, menu, and actionSet.. + */ + protected CustomizeActionBars loadData() { + + + CustomizeActionBars ownedActionBar = new CustomizeActionBars(null); + //actionSet + // Just get the action sets at this point. Do not load the action set + // until it is actually selected in the dialog. + ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry(); + IActionSetDescriptor[] sets = reg.getActionSets(); + IActionSetDescriptor[] actionSetDescriptors = ((WorkbenchPage)window.getActivePage()).getActionSets(); + List initiallyAvailableActionSets = Arrays.asList(actionSetDescriptors); + ownedActionBar.setActionSet(initiallyAvailableActionSets); + + + + // Fill fake action bars with static menu information. + ((WorkbenchWindow)window).fillActionBars(ownedActionBar, ActionBarAdvisor.FILL_PROXY | ActionBarAdvisor.FILL_MENU_BAR | ActionBarAdvisor.FILL_COOL_BAR); + // Activator.log.debug("\n+-> ActionSetDescriptor"); + for(int i = 0; i < sets.length; i++) { + ActionSetDescriptor actionSetDesc = (ActionSetDescriptor)sets[i]; + // Activator.log.debug("+--->" + actionSetDesc.getId()); + + } + + final IMenuService menuService = (IMenuService)window.getService(IMenuService.class); + menuService.populateContributionManager((ContributionManager)ownedActionBar.getMenuManager(), MenuUtil.MAIN_MENU); + //Activator.log.debug("\n+-> Menu " + ownedActionBar.getMenuManager().getItems().length); + for(int i = 0; i < ownedActionBar.getMenuManager().getItems().length; i++) { + IContributionItem item = ownedActionBar.getMenuManager().getItems()[i]; + // Activator.log.debug("+--->" + item.getId()); + } + + + IToolBarManager toolBarManager = ownedActionBar.getToolBarManager(); + menuService.populateContributionManager((ContributionManager)toolBarManager, MenuUtil.MAIN_TOOLBAR); + //Activator.log.debug("\n+-> toolbar " + ownedActionBar.getToolBarManager() + " " + ownedActionBar.getToolBarManager().getItems().length); + for(int i = 0; i < ownedActionBar.getToolBarManager().getItems().length; i++) { + IContributionItem item = toolBarManager.getItems()[i]; + //Activator.log.debug("+--->" + item.getId()); + } + + return ownedActionBar; + } + + /** + * {@inheritDoc} + */ + + public void perspectiveDeactivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) { + //in the case of reset this method is called. + //Activator.log.debug("perspectiveDeactivated "+perspective.getId()); + //updateTooling(perspective); + //page.savePerspective(); + } +} diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/PerspectiveConfigurator.java b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/PerspectiveConfigurator.java new file mode 100644 index 00000000000..f47aa37e685 --- /dev/null +++ b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/editor/perspectiveconfiguration/PerspectiveConfigurator.java @@ -0,0 +1,38 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.editor.perspectiveconfiguration; + +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IStartup; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * this class is used to hide unuseful menu and action Set + * + */ +public class PerspectiveConfigurator implements IStartup { + + public void earlyStartup() { + Display.getDefault().asyncExec(new Runnable() { + + public void run() { + final IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + //a perspective listener is added + workbenchWindow.addPerspectiveListener(new PapyrusPerspectiveListener(workbenchWindow)); + } + }); + } + +} diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/Activator.java b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/Activator.java deleted file mode 100644 index c46282bfcbe..00000000000 --- a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/Activator.java +++ /dev/null @@ -1,75 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.ui.perspectiveconfiguration; - -import org.eclipse.papyrus.log.LogHelper; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.papyrus.editor.perspectiveconfiguration"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** Logging 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; - // register the login helper - 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; - } - -} diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/Configuration.java b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/Configuration.java deleted file mode 100644 index eda2b88e057..00000000000 --- a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/Configuration.java +++ /dev/null @@ -1,104 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.ui.perspectiveconfiguration; - -import java.util.ArrayList; - -/** - * this class is a structure that contains a configuration - * - */ -public class Configuration { - - protected String perspectiveID = null; - - protected ArrayList actionSetIDList = new ArrayList(); - - protected ArrayList menuIDList = new ArrayList(); - - protected ArrayList toolBarIDList = new ArrayList(); - - protected ArrayList preferenceIDList = new ArrayList(); - - protected ArrayList categoryIDList = new ArrayList(); - - protected ArrayList commandIDList = new ArrayList(); - - public ArrayList getCategoryIDList() { - return categoryIDList; - } - - - public void addCategory(String id) { - categoryIDList.add(id); - } - - public void addCommandID(String id) { - commandIDList.add(id); - } - - public ArrayList getCommandIDList() { - return commandIDList; - } - - public ArrayList getActionSetIDList() { - return actionSetIDList; - } - - public void addActionSet(String id) { - actionSetIDList.add(id); - } - - public void addMenu(String id) { - menuIDList.add(id); - } - - public void addtoolBar(String id) { - toolBarIDList.add(id); - } - - public void addPreference(String id) { - preferenceIDList.add(id); - } - - public ArrayList getMenuIDList() { - return menuIDList; - } - - public ArrayList getToolBarID() { - return toolBarIDList; - } - - public ArrayList getPreferenceID() { - return preferenceIDList; - } - - public String getPerspectiveID() { - return perspectiveID; - } - - public void setPerspectiveID(String perspectiveID) { - this.perspectiveID = perspectiveID; - } - - /** - * constructor of a perspective - * - * @param perspectiveName - */ - public Configuration(String perspectiveName) { - setPerspectiveID(perspectiveName); - } - -} diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/ConfigurationService.java b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/ConfigurationService.java deleted file mode 100644 index aa9d5b20e78..00000000000 --- a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/ConfigurationService.java +++ /dev/null @@ -1,121 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.ui.perspectiveconfiguration; - -import java.util.HashMap; -import java.util.Set; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; - -/** - * Take information form the extension point in order to configure Papyrus. - */ -public class ConfigurationService { - - public static String PERSPECTIVE_CONFIGURATION_EXTENSION_POINT_ID = "org.eclipse.papyrus.ui.perspectiveconfiguration"; - - public static String PERPSECTIVE_ID = "perspectiveID"; - - public static String ACTION_SET = "actionSet"; - - public static String ACTION_SET_ID = "actionSetID"; - - public static String MENU = "menu"; - - public static String MENU_ID = "menuID"; - - public static String TOOLBAR = "toolbar"; - - public static String TOOLBAR_ID = "toolbarID"; - - public static String PREFERENCEPAGE = "preferencePage"; - - public static String PREFERENCEPAGEID = "preferencepageID"; - - public static String CATEGORY = "category"; - - public static String CATEGORYID = "categoryID"; - - public static String COMMAND = "command"; - - public static String COMMANDID = "commandID"; - - - protected HashMap configurationMap = new HashMap(); - - public ConfigurationService() { - IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(PERSPECTIVE_CONFIGURATION_EXTENSION_POINT_ID); - for(int i = 0; i < configElements.length; i++) { - constructAConfiguation(configElements[i]); - } - } - - protected void constructAConfiguation(IConfigurationElement iConfigurationElement) { - try { - String configName = (String)iConfigurationElement.getAttribute(PERPSECTIVE_ID); - if(!configurationMap.containsKey(configName) || configurationMap.get(configName) == null) { - configurationMap.put(configName, new Configuration(configName)); - } - Configuration configuration = configurationMap.get(configName); - - IConfigurationElement[] element = iConfigurationElement.getChildren(ACTION_SET); - for(int i = 0; i < element.length; i++) { - configuration.addActionSet(element[i].getAttribute(ACTION_SET_ID)); - } - element = iConfigurationElement.getChildren(MENU); - for(int i = 0; i < element.length; i++) { - configuration.addMenu(element[i].getAttribute(MENU_ID)); - } - element = iConfigurationElement.getChildren(TOOLBAR); - for(int i = 0; i < element.length; i++) { - configuration.addtoolBar(element[i].getAttribute(TOOLBAR_ID)); - } - element = iConfigurationElement.getChildren(PREFERENCEPAGE); - for(int i = 0; i < element.length; i++) { - configuration.addPreference(element[i].getAttribute(PREFERENCEPAGEID)); - } - element = iConfigurationElement.getChildren(CATEGORY); - for(int i = 0; i < element.length; i++) { - configuration.addCategory(element[i].getAttribute(CATEGORYID)); - } - - element = iConfigurationElement.getChildren(COMMAND); - for(int i = 0; i < element.length; i++) { - configuration.addCommandID(element[i].getAttribute(COMMANDID)); - } - } catch (Exception e) { - Activator.log.error("- " + iConfigurationElement + " can not be loaded ", e); - } - } - - /** - * - * @return a set of perspective id that has a configuration - */ - protected Set getPerspectiveList() { - return configurationMap.keySet(); - } - - /** - * get a configuration from a perspective ID - * - * @param perspectiveID - * @return a configuration or null if a configuration is not defined for the given perspective ID - */ - protected Configuration getConfiguration(String perspectiveID) { - return configurationMap.get(perspectiveID); - } -} diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/CustomizeActionBars.java b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/CustomizeActionBars.java deleted file mode 100644 index ca12176ce63..00000000000 --- a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/CustomizeActionBars.java +++ /dev/null @@ -1,177 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.ui.perspectiveconfiguration; - -import java.util.List; - -import org.eclipse.jface.action.CoolBarManager; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.ICoolBarManager; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.StatusLineManager; -import org.eclipse.jface.action.ToolBarManager; -import org.eclipse.jface.internal.provisional.action.IToolBarContributionItem; -import org.eclipse.jface.internal.provisional.action.ToolBarContributionItem2; -import org.eclipse.ui.IActionBars2; -import org.eclipse.ui.application.IWorkbenchWindowConfigurer; -import org.eclipse.ui.internal.provisional.application.IActionBarConfigurer2; -import org.eclipse.ui.internal.registry.IActionSetDescriptor; -import org.eclipse.ui.services.IServiceLocator; - - -/** - * this class is used to collection all information about menu, cool bar, statusline... - * - */ -public class CustomizeActionBars implements IActionBarConfigurer2, IActionBars2 { - - protected List actionSet = null; - - - /** - * get the list of action set - * - * @return - */ - public List getActionSet() { - return actionSet; - } - - /** - * set the list of action Set - * - * @param actionSet - */ - public void setActionSet(List actionSet) { - this.actionSet = actionSet; - } - - protected MenuManager menuManager = new MenuManager(); - - protected CoolBarManager coolBarManager = new CoolBarManager(); - - protected StatusLineManager statusLineManager = new StatusLineManager(); - - protected ToolBarManager toolBarManager = new ToolBarManager(); - - /** - * Create a new instance of this class. - * - * @param configurer - * the configurer - */ - public CustomizeActionBars(IWorkbenchWindowConfigurer configurer) { - } - - /** - * do not call this method - */ - public IWorkbenchWindowConfigurer getWindowConfigurer() { - return null; - } - - /** - * get the manager in charge to display all menu - */ - - public IMenuManager getMenuManager() { - return menuManager; - } - - /** - * the manager in charge to display the status line - */ - public IStatusLineManager getStatusLineManager() { - return statusLineManager; - } - - /** - * the manager in charge to display the cool bar, this also the tool bar in eclipse - */ - public ICoolBarManager getCoolBarManager() { - return coolBarManager; - } - - /** - * see the getCoolBarManager - */ - public IToolBarManager getToolBarManager() { - return toolBarManager; - } - - /** - * {@inheritDoc} - */ - public void setGlobalActionHandler(String actionID, IAction handler) { - } - - /** - * {@inheritDoc} - */ - public void updateActionBars() { - } - - /** - * {@inheritDoc} - */ - public void clearGlobalActionHandlers() { - } - - /** - * {@inheritDoc} - */ - public IAction getGlobalActionHandler(String actionId) { - return null; - } - - public void registerGlobalAction(IAction action) { - } - - /** - * Clean up the action bars. - */ - public void dispose() { - coolBarManager.dispose(); - menuManager.dispose(); - statusLineManager.dispose(); - toolBarManager.dispose(); - } - - /** - * {@inheritDoc} - */ - public final IServiceLocator getServiceLocator() { - return null; - } - - /** - * {@inheritDoc} - */ - public IToolBarManager createToolBarManager() { - return toolBarManager; - } - - /** - * {@inheritDoc} - */ - public IToolBarContributionItem createToolBarContributionItem(IToolBarManager toolBarManager, String id) { - return new ToolBarContributionItem2(toolBarManager, id); - } - - - -} diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/PapyrusPerspectiveListener.java b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/PapyrusPerspectiveListener.java deleted file mode 100644 index d2b07159eec..00000000000 --- a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/PapyrusPerspectiveListener.java +++ /dev/null @@ -1,314 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.ui.perspectiveconfiguration; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.internal.jobs.Worker; -import org.eclipse.jface.action.ContributionManager; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.preference.IPreferenceNode; -import org.eclipse.jface.preference.PreferenceNode; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.IPerspectiveDescriptor; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PerspectiveAdapter; -import org.eclipse.ui.application.ActionBarAdvisor; -import org.eclipse.ui.commands.ICommandService; -import org.eclipse.ui.internal.Perspective; -import org.eclipse.ui.internal.WorkbenchPage; -import org.eclipse.ui.internal.WorkbenchPlugin; -import org.eclipse.ui.internal.WorkbenchWindow; -import org.eclipse.ui.internal.registry.ActionSetDescriptor; -import org.eclipse.ui.internal.registry.ActionSetRegistry; -import org.eclipse.ui.internal.registry.IActionSetDescriptor; -import org.eclipse.ui.internal.registry.PerspectiveRegistry; -import org.eclipse.ui.menus.IMenuService; -import org.eclipse.ui.menus.MenuUtil; - -/** - * this is a listener hat has in charge to configure a perspective when it is openend etc.. - * - */ -public class PapyrusPerspectiveListener extends PerspectiveAdapter { - - private IWorkbenchWindow window; - - protected ConfigurationService configurationservice; - - protected ArrayList hiddenRootPref = new ArrayList(); - - - /** - * creation of the listener - * - * @param window - */ - public PapyrusPerspectiveListener(IWorkbenchWindow window) { - this.window = window; - this.configurationservice = new ConfigurationService(); - - //this is the lauch of eclipse, so we look for which perspective is opened - if(window.getActivePage() != null) { - IPerspectiveDescriptor openedPerspectiveDescriptor = window.getActivePage().getPerspective(); - if(configurationservice.getConfiguration(openedPerspectiveDescriptor.getId()) != null) { - //it is the frist time? - if(!isAlreadySave(openedPerspectiveDescriptor.getId())) { - //Activator.log.debug("First time to open it"); - updateTooling(openedPerspectiveDescriptor); - window.getActivePage().savePerspective(); - } - - } - updatePreferencePage(openedPerspectiveDescriptor); - } - } - - /** - * return yes id it exist a file that custom a given perspective - * - * @param perspectiveID - * the id of the perspective - * @return yes it find a file,if not no - */ - public boolean isAlreadySave(String perspectiveID) { - PerspectiveRegistry perspRegistry = (PerspectiveRegistry)WorkbenchPlugin.getDefault().getPerspectiveRegistry(); - try { - IMemento memento = perspRegistry.getCustomPersp(perspectiveID); - //Activator.log.debug(""+memento); - return true; - } catch (Exception e) { - return false; - } - } - - @Override - public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspectivedescriptor) { - //Activator.log.debug("perspectiveActivated "+perspectivedescriptor.getId()); - super.perspectiveActivated(page, perspectivedescriptor); - - - //test is we are interesting by the current perspective - if(configurationservice.getConfiguration(perspectivedescriptor.getId()) != null) { - if(!isAlreadySave(perspectivedescriptor.getId())) { - updateTooling(perspectivedescriptor); - page.savePerspective(); - } - - - } - updatePreferencePage(perspectivedescriptor); - Perspective perspective = ((WorkbenchPage)page).findPerspective(perspectivedescriptor); - - //due to a bug on the refresh, we need to call explicitly this method. - //to remove, when the origin is found. - if( perspective!=null){ - perspective.updateActionBars(); - } - } - - protected void updatePreferencePage(IPerspectiveDescriptor perspectivedescriptor) { - //test is we are interesting by the current perspective - if(configurationservice.getConfiguration(perspectivedescriptor.getId()) != null) { - - Configuration configuration = configurationservice.getConfiguration(perspectivedescriptor.getId()); - IPreferenceNode[] preferencepagelist = window.getWorkbench().getPreferenceManager().getRootSubNodes(); - - // take in account the preferences - for(int i = 0; i < preferencepagelist.length; i++) { - if(preferencepagelist[i] instanceof PreferenceNode) { - PreferenceNode node = (PreferenceNode)preferencepagelist[i]; - if(!configuration.getPreferenceID().contains(node.getId())) { - hiddenRootPref.add(node); - } - } - } - Iterator iteratorpreftoremove = hiddenRootPref.iterator(); - while(iteratorpreftoremove.hasNext()) { - window.getWorkbench().getPreferenceManager().remove(iteratorpreftoremove.next()); - } - } else { - //this is not an interesting perspective - Iterator iteratorpreftoremove = hiddenRootPref.iterator(); - while(iteratorpreftoremove.hasNext()) { - window.getWorkbench().getPreferenceManager().addToRoot(iteratorpreftoremove.next()); - } - hiddenRootPref.clear(); - } - - } - - /** - * this method hide menu, tool bar and action hat are not interesting - * - * @param perspectivedescriptor - */ - protected void updateTooling(IPerspectiveDescriptor perspectivedescriptor) { - - CustomizeActionBars customizeActionBars = loadData(); - - if(configurationservice.getConfiguration(perspectivedescriptor.getId()) != null) { - Configuration configuration = configurationservice.getConfiguration(perspectivedescriptor.getId()); - //Activator.log.debug("Update tooling"); - //Load all information about menus.... - WorkbenchPage worbenchPage = (WorkbenchPage)window.getActivePage(); - // Get the perspective - Perspective perspective = worbenchPage.findPerspective(perspectivedescriptor); - - ICommandService cmdService = (ICommandService)worbenchPage.getActivePart().getSite().getService(ICommandService.class); - - - ArrayList commandIdToRemove = new ArrayList(); - - try { - - //put all commands that not reference to the given category - for(int i = 0; i < cmdService.getDefinedCommands().length; i++) { - if(!configuration.getCategoryIDList().contains(cmdService.getDefinedCommands()[i].getCategory().getId())) { - commandIdToRemove.add(cmdService.getDefinedCommands()[i].getId()); - } - // else{System.err.println("keep "+cmdService.getDefinedCommands()[i].getId());} - } - - //then verify for each command by taking account its id. - for(int i = 0; i < cmdService.getDefinedCommands().length; i++) { - //put the commands in the list to hide, theis command are not referenced in the given list of command id and are not in the given list of category - if(!configuration.getCommandIDList().contains(cmdService.getDefinedCommands()[i].getId())) { - if(!configuration.getCategoryIDList().contains(cmdService.getDefinedCommands()[i].getCategory().getId())) { - if(!commandIdToRemove.contains(cmdService.getDefinedCommands()[i].getId())) { - commandIdToRemove.add(cmdService.getDefinedCommands()[i].getId()); - } - } - } else {//may be the id that we want to keep was in already in the list because of the filter on category - if(commandIdToRemove.contains(cmdService.getDefinedCommands()[i].getId())) { - commandIdToRemove.remove(cmdService.getDefinedCommands()[i].getId()); - } - } - } - } catch (Exception e) { - System.err.println(e); - } - - - perspective.getHiddenMenuItems().clear(); - perspective.getHiddenToolbarItems().clear(); - - //look for all actionSet - ArrayList actionSetToRemove = new ArrayList(); - Iterator iteratorActionSet = customizeActionBars.getActionSet().iterator(); - while(iteratorActionSet.hasNext()) { - IActionSetDescriptor currentActionSetDescriptor = iteratorActionSet.next(); - //test if the configuationSet contains the id - if(!configuration.getActionSetIDList().contains(currentActionSetDescriptor.getId())) { - actionSetToRemove.add(currentActionSetDescriptor); - } - } - - - - // look for all menu - ArrayList menuToRemove = new ArrayList(); - - for(int i = 0; i < customizeActionBars.getMenuManager().getItems().length; i++) { - if(!configuration.getMenuIDList().contains(customizeActionBars.getMenuManager().getItems()[i].getId())) { - menuToRemove.add(customizeActionBars.getMenuManager().getItems()[i].getId()); - } - } - - //look for all toolbar - ArrayList toolbarToRemove = new ArrayList(); - for(int i = 0; i < customizeActionBars.getToolBarManager().getItems().length; i++) { - - if(!configuration.getToolBarID().contains(customizeActionBars.getToolBarManager().getItems()[i].getId())) { - toolbarToRemove.add(customizeActionBars.getToolBarManager().getItems()[i].getId()); - } - } - - perspective.getHiddenMenuItems().addAll(commandIdToRemove); - perspective.getHiddenToolbarItems().addAll(commandIdToRemove); - //hide elements - perspective.turnOffActionSets((IActionSetDescriptor[])actionSetToRemove.toArray(new IActionSetDescriptor[actionSetToRemove.size()])); - perspective.getHiddenMenuItems().addAll(menuToRemove); - perspective.getHiddenToolbarItems().addAll(toolbarToRemove); - perspective.updateActionBars(); - - } - - } - - /** - * this method search all identifier of menu toolbar and actionSet that are loaded in eclipse - * - * @return a structure that contains all references of the toolbar, menu, and actionSet.. - */ - protected CustomizeActionBars loadData() { - - - CustomizeActionBars ownedActionBar = new CustomizeActionBars(null); - //actionSet - // Just get the action sets at this point. Do not load the action set - // until it is actually selected in the dialog. - ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry(); - IActionSetDescriptor[] sets = reg.getActionSets(); - IActionSetDescriptor[] actionSetDescriptors = ((WorkbenchPage)window.getActivePage()).getActionSets(); - List initiallyAvailableActionSets = Arrays.asList(actionSetDescriptors); - ownedActionBar.setActionSet(initiallyAvailableActionSets); - - - - // Fill fake action bars with static menu information. - ((WorkbenchWindow)window).fillActionBars(ownedActionBar, ActionBarAdvisor.FILL_PROXY | ActionBarAdvisor.FILL_MENU_BAR | ActionBarAdvisor.FILL_COOL_BAR); - // Activator.log.debug("\n+-> ActionSetDescriptor"); - for(int i = 0; i < sets.length; i++) { - ActionSetDescriptor actionSetDesc = (ActionSetDescriptor)sets[i]; - // Activator.log.debug("+--->" + actionSetDesc.getId()); - - } - - final IMenuService menuService = (IMenuService)window.getService(IMenuService.class); - menuService.populateContributionManager((ContributionManager)ownedActionBar.getMenuManager(), MenuUtil.MAIN_MENU); - //Activator.log.debug("\n+-> Menu " + ownedActionBar.getMenuManager().getItems().length); - for(int i = 0; i < ownedActionBar.getMenuManager().getItems().length; i++) { - IContributionItem item = ownedActionBar.getMenuManager().getItems()[i]; - // Activator.log.debug("+--->" + item.getId()); - } - - - IToolBarManager toolBarManager = ownedActionBar.getToolBarManager(); - menuService.populateContributionManager((ContributionManager)toolBarManager, MenuUtil.MAIN_TOOLBAR); - //Activator.log.debug("\n+-> toolbar " + ownedActionBar.getToolBarManager() + " " + ownedActionBar.getToolBarManager().getItems().length); - for(int i = 0; i < ownedActionBar.getToolBarManager().getItems().length; i++) { - IContributionItem item = toolBarManager.getItems()[i]; - //Activator.log.debug("+--->" + item.getId()); - } - - return ownedActionBar; - } - - /** - * {@inheritDoc} - */ - - public void perspectiveDeactivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) { - //in the case of reset this method is called. - //Activator.log.debug("perspectiveDeactivated "+perspective.getId()); - //updateTooling(perspective); - //page.savePerspective(); - } -} diff --git a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/PerspectiveConfigurator.java b/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/PerspectiveConfigurator.java deleted file mode 100644 index 9aa5d1e5a60..00000000000 --- a/plugins/editor/org.eclipse.papyrus.editor.perspectiveconfiguration/src/org/eclipse/papyrus/ui/perspectiveconfiguration/PerspectiveConfigurator.java +++ /dev/null @@ -1,38 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.ui.perspectiveconfiguration; - -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IStartup; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * this class is used to hide unuseful menu and action Set - * - */ -public class PerspectiveConfigurator implements IStartup { - - public void earlyStartup() { - Display.getDefault().asyncExec(new Runnable() { - - public void run() { - final IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - //a perspective listener is added - workbenchWindow.addPerspectiveListener(new PapyrusPerspectiveListener(workbenchWindow)); - } - }); - } - -} diff --git a/plugins/editor/org.eclipse.papyrus.editor/plugin.xml b/plugins/editor/org.eclipse.papyrus.editor/plugin.xml index 439a0f9d84b..7c29634428c 100644 --- a/plugins/editor/org.eclipse.papyrus.editor/plugin.xml +++ b/plugins/editor/org.eclipse.papyrus.editor/plugin.xml @@ -8,7 +8,7 @@ default="true" extensions="di" icon="icons/papyrus/Papyrus_16x16.gif" - id="org.eclipse.papyrus.core.papyrusEditor" + id="org.eclipse.papyrus.infra.core.papyrusEditor" matchingStrategy="org.eclipse.papyrus.editor.PapyrusMatchingStrategy" name="Papyrus Editor Core"> @@ -25,7 +25,7 @@ + value="org.eclipse.papyrus.infra.core.papyrusEditor"> diff --git a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/PapyrusActionBarContributor.java b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/PapyrusActionBarContributor.java index c59de63d7b0..a5c9c48e702 100644 --- a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/PapyrusActionBarContributor.java +++ b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/PapyrusActionBarContributor.java @@ -16,8 +16,8 @@ package org.eclipse.papyrus.editor; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; -import org.eclipse.papyrus.core.editor.BackboneException; -import org.eclipse.papyrus.core.multidiagram.actionbarcontributor.CoreComposedActionBarContributor; +import org.eclipse.papyrus.infra.core.editor.BackboneException; +import org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor.CoreComposedActionBarContributor; import org.eclipse.ui.IEditorActionBarContributor; diff --git a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/PapyrusMultiDiagramEditor.java b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/PapyrusMultiDiagramEditor.java index 13a1d84cfd5..55efa092d01 100644 --- a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/PapyrusMultiDiagramEditor.java +++ b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/PapyrusMultiDiagramEditor.java @@ -14,7 +14,7 @@ package org.eclipse.papyrus.editor; -import org.eclipse.papyrus.core.editor.CoreMultiDiagramEditor; +import org.eclipse.papyrus.infra.core.editor.CoreMultiDiagramEditor; /** diff --git a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/commands/RenameNestedEditorCommand.java b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/commands/RenameNestedEditorCommand.java index 1f614ee06c6..2371edf7dcd 100644 --- a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/commands/RenameNestedEditorCommand.java +++ b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/commands/RenameNestedEditorCommand.java @@ -12,11 +12,11 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.core.utils.EditorUtils; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; -import org.eclipse.papyrus.sasheditor.editor.IEditorPage; -import org.eclipse.papyrus.sasheditor.editor.IPage; -import org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.papyrus.infra.core.sasheditor.editor.IEditorPage; +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage; +import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer; +import org.eclipse.papyrus.infra.core.utils.EditorUtils; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.handlers.HandlerUtil; diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/META-INF/MANIFEST.MF index 95a9de41e6e..8563734c045 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/META-INF/MANIFEST.MF +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/META-INF/MANIFEST.MF @@ -1,13 +1,13 @@ Manifest-Version: 1.0 Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="0.9.0" -Export-Package: org.eclipse.papyrus.core.adaptor.emf +Export-Package: org.eclipse.papyrus.infra.core.adaptor.emf 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.core.adaptor.emf.Activator +Bundle-Activator: org.eclipse.papyrus.infra.core.adaptor.emf.Activator Bundle-SymbolicName: org.eclipse.papyrus.infra.core.adaptor.emf;singleton:=true Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/core/adaptor/emf/Activator.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/core/adaptor/emf/Activator.java deleted file mode 100644 index e40eedda638..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/core/adaptor/emf/Activator.java +++ /dev/null @@ -1,67 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.adaptor.emf; - -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.core.adaptor.emf"; - - // The shared instance - private static Activator plugin; - - /** - * 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; - } - - /* - * (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; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/core/adaptor/emf/CreateDiagramHandler.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/core/adaptor/emf/CreateDiagramHandler.java deleted file mode 100644 index 8b059add2d1..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/core/adaptor/emf/CreateDiagramHandler.java +++ /dev/null @@ -1,103 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.adaptor.emf; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.IHandler; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.NotationFactory; -import org.eclipse.papyrus.core.extension.diagrameditor.IPluggableEditorFactory; -import org.eclipse.papyrus.core.utils.EditorUtils; -import org.eclipse.papyrus.resource.notation.NotationUtils; - -/** - * Base class for create diagram Handlers. - * - * @author cedric dumoulin - * - */ -public abstract class CreateDiagramHandler extends AbstractHandler implements IHandler { - - /** - * - * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) - * - * @param event - * @return - * @throws ExecutionException - */ - public Object execute(ExecutionEvent event) throws ExecutionException { - - TransactionalEditingDomain editingDomain = getEditingDomain(); - RecordingCommand command = new RecordingCommand(editingDomain, "Create EMF Diagram") { - - @Override - protected void doExecute() { - addNewDiagram(); - } - - }; - - editingDomain.getCommandStack().execute(command); - return null; - } - - /** - * Subclasses should implements this method. - */ - protected abstract void addNewDiagram(); - - /** - * Add a new Diagram to the graphical model. - * - * @param diagram - * The diagram to add to graphical model. This will be the diagram provided to - * {@link IPluggableEditorFactory#createIPageModel(Object, org.eclipse.papyrus.core.services.ServicesRegistry)} - */ - protected void addNewDiagram(String name, String type, EObject diagram) { - - // TODO Create a special node inside the sash model (di) instead of introducing - // a dependence on notation. - // This implies to change the factory also. - // The special node creation should be done by methods from sash - // create di2node - Diagram di2Diagram = NotationFactory.eINSTANCE.createDiagram(); - di2Diagram.setVisible(true); - di2Diagram.setType(type); - if(name != null) - di2Diagram.setName(name); - - // Add it to resource, so that it will be saved. -// NotationUtils.getNotationResource().getContents().add(di2Diagram); - NotationUtils.getNotationModel().addDiagram(di2Diagram); - - // Attach to sash in order to show it - // Add the diagram as a page to the current sash folder - EditorUtils.getISashWindowsContentProvider().addPage(di2Diagram); - } - - /** - * Get the main editing doamin. - * - * @return - */ - protected TransactionalEditingDomain getEditingDomain() { - return EditorUtils.getTransactionalEditingDomain(); - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/infra/core/adaptor/emf/Activator.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/infra/core/adaptor/emf/Activator.java new file mode 100644 index 00000000000..a4af36f15be --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/infra/core/adaptor/emf/Activator.java @@ -0,0 +1,67 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.adaptor.emf; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.core.adaptor.emf"; + + // The shared instance + private static Activator plugin; + + /** + * 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; + } + + /* + * (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; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/infra/core/adaptor/emf/CreateDiagramHandler.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/infra/core/adaptor/emf/CreateDiagramHandler.java new file mode 100644 index 00000000000..5391a7d49f5 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.emf/src/org/eclipse/papyrus/infra/core/adaptor/emf/CreateDiagramHandler.java @@ -0,0 +1,103 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.adaptor.emf; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.gmf.runtime.notation.NotationFactory; +import org.eclipse.papyrus.infra.core.extension.diagrameditor.IPluggableEditorFactory; +import org.eclipse.papyrus.infra.core.resource.notation.NotationUtils; +import org.eclipse.papyrus.infra.core.utils.EditorUtils; + +/** + * Base class for create diagram Handlers. + * + * @author cedric dumoulin + * + */ +public abstract class CreateDiagramHandler extends AbstractHandler implements IHandler { + + /** + * + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + * + * @param event + * @return + * @throws ExecutionException + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + + TransactionalEditingDomain editingDomain = getEditingDomain(); + RecordingCommand command = new RecordingCommand(editingDomain, "Create EMF Diagram") { + + @Override + protected void doExecute() { + addNewDiagram(); + } + + }; + + editingDomain.getCommandStack().execute(command); + return null; + } + + /** + * Subclasses should implements this method. + */ + protected abstract void addNewDiagram(); + + /** + * Add a new Diagram to the graphical model. + * + * @param diagram + * The diagram to add to graphical model. This will be the diagram provided to + * {@link IPluggableEditorFactory#createIPageModel(Object, org.eclipse.papyrus.infra.core.services.ServicesRegistry)} + */ + protected void addNewDiagram(String name, String type, EObject diagram) { + + // TODO Create a special node inside the sash model (di) instead of introducing + // a dependence on notation. + // This implies to change the factory also. + // The special node creation should be done by methods from sash + // create di2node + Diagram di2Diagram = NotationFactory.eINSTANCE.createDiagram(); + di2Diagram.setVisible(true); + di2Diagram.setType(type); + if(name != null) + di2Diagram.setName(name); + + // Add it to resource, so that it will be saved. +// NotationUtils.getNotationResource().getContents().add(di2Diagram); + NotationUtils.getNotationModel().addDiagram(di2Diagram); + + // Attach to sash in order to show it + // Add the diagram as a page to the current sash folder + EditorUtils.getISashWindowsContentProvider().addPage(di2Diagram); + } + + /** + * Get the main editing doamin. + * + * @return + */ + protected TransactionalEditingDomain getEditingDomain() { + return EditorUtils.getTransactionalEditingDomain(); + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/META-INF/MANIFEST.MF index da0af266390..e24a81c4974 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/META-INF/MANIFEST.MF +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/META-INF/MANIFEST.MF @@ -1,5 +1,5 @@ Manifest-Version: 1.0 -Export-Package: org.eclipse.papyrus.core.adaptor.gmf +Export-Package: org.eclipse.papyrus.infra.core.adaptor.gmf Bundle-ActivationPolicy: lazy Bundle-ClassPath: . Bundle-Name: %pluginName @@ -12,6 +12,6 @@ Require-Bundle: org.eclipse.emf.edit.ui;bundle-version="2.5.0", Bundle-Vendor: %providerName Bundle-Version: 0.9.0.qualifier Bundle-ManifestVersion: 2 -Bundle-Activator: org.eclipse.papyrus.core.adaptor.gmf.Activator +Bundle-Activator: org.eclipse.papyrus.infra.core.adaptor.gmf.Activator Bundle-SymbolicName: org.eclipse.papyrus.infra.core.adaptor.gmf;singleton:=true diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/plugin.xml b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/plugin.xml index 962dbda9e85..2d5eb997b99 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/plugin.xml +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/plugin.xml @@ -22,9 +22,9 @@ + point="org.eclipse.papyrus.infra.core.papyrusDiagram"> diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/schema/nestedEditor.exsd b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/schema/nestedEditor.exsd index 31387a1a217..542d08cb1c9 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/schema/nestedEditor.exsd +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/schema/nestedEditor.exsd @@ -62,10 +62,10 @@ Define a nested editor descriptor. This descriptor is used to add instance of th The factory used to create an instance of the editor. -The factory must implements org.eclipse.papyrus.core.adaptor.gmf.extension.IEditorFactory +The factory must implements org.eclipse.papyrus.infra.core.adaptor.gmf.extension.IEditorFactory - + @@ -129,7 +129,7 @@ The factory must implements org.eclipse.papyrus.core.adaptor.gmf.extension.IEdit The action class implementing the creation of the root object. - + diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/AbstractPapyrusGmfCreateDiagramCommandHandler.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/AbstractPapyrusGmfCreateDiagramCommandHandler.java deleted file mode 100644 index 9761aba8bfd..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/AbstractPapyrusGmfCreateDiagramCommandHandler.java +++ /dev/null @@ -1,355 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.adaptor.gmf; - -import java.util.ArrayList; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.IHandler; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; -import org.eclipse.gmf.runtime.diagram.core.services.ViewService; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; -import org.eclipse.papyrus.core.editor.IMultiDiagramEditor; -import org.eclipse.papyrus.core.extension.commands.ICreationCommand; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.core.utils.BusinessModelResolver; -import org.eclipse.papyrus.core.utils.DiResourceSet; -import org.eclipse.papyrus.core.utils.EditorUtils; -import org.eclipse.papyrus.core.utils.OpenDiagramCommand; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PlatformUI; - -/** - * Command creating a new GMF diagram in Papyrus. This command is intended to be used in eclipse - * extensions. - * - * Commands to create a GMF Diagram can subclass this class. There is two kinds of commands: - - * Eclipse handlers issuing commands (toolbar, menu, ...). This commands can find the active editor - * by using the Worbench.getActivePArt(). The entry point is {@link #execute(ExecutionEvent)}. - - * Commands called during editor initializing (like wizard). This commands require the diResourceSet - * to work. The entry point is {@link #createDiagram(DiResourceSet, EObject, String)} - * - * @author cedric dumoulin - * @author Jerome Benois - */ -public abstract class AbstractPapyrusGmfCreateDiagramCommandHandler extends AbstractHandler implements IHandler, ICreationCommand { - - /** - * Method called when the command is invoked. - */ - public Object execute(ExecutionEvent event) throws ExecutionException { - - EObject container = null; - // if editor is open and active - if(getMultiDiagramEditor() != null) { - container = getSelectedElement(); - } - runAsTransaction(container); - return null; - } - - /** - * Create a new class diagram - * - * @param sharedObjects - * @param container - * The uml element to which the diagram should be attached, if possible. - * @throws ExecutionException - */ - protected void runAsTransaction(EObject container) throws ExecutionException { - - DiResourceSet diResourceSet; - try { - diResourceSet = EditorUtils.getServiceRegistry().getService(DiResourceSet.class); - } catch (ServiceException e) { - throw new ExecutionException("Can't get diResourceSet", e); - } - - runAsTransaction(diResourceSet, container, null); - } - - /** - * Create a new gmf diagram - * - * @param sharedObjects - * @param container - * The eObject to which the diagram should be attached, if possible. - */ - protected void runAsTransaction(final DiResourceSet diResourceSet, final EObject container, String name) { - TransactionalEditingDomain dom = diResourceSet.getTransactionalEditingDomain(); - CompositeCommand cmd = new CompositeCommand("Create diagram"); - ICommand createCmd = getCreateDiagramCommand(diResourceSet, container, name); - cmd.add(createCmd); - cmd.add(new OpenDiagramCommand(dom, createCmd)); - - dom.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd)); - } - - /** - * Get the root element associated with canvas. - */ - protected EObject getRootElement(Resource modelResource) { - EObject rootElement = null; - if(modelResource != null && modelResource.getContents() != null && modelResource.getContents().size() > 0) { - Object root = modelResource.getContents().get(0); - if(root instanceof EObject) { - rootElement = (EObject)root; - } - } - - return rootElement; - } - - /** - * Store model element in the resource. - */ - protected void attachModelToResource(EObject root, Resource resource) { - resource.getContents().add(root); - } - - /** - * Get the type of the diagram to create. - * - * @return diagram type - */ - public String getCreatedDiagramType() { - return getDiagramNotationID(); - } - - /** - * @return - */ - abstract protected String getDiagramNotationID(); - - /** - * @return - */ - abstract protected PreferencesHint getPreferenceHint(); - - /** - * Get the name used for diagram. - * - * @return - */ - abstract protected String getDefaultDiagramName(); - - /** - * Get currently selected element. - * - * @return The currently selected element, or null if any. - */ - protected EObject getSelectedElement() { - EObject eObject = null; - Object selection = getCurrentSelection(); - if(selection != null) { - Object businessObject = BusinessModelResolver.getInstance().getBusinessModel(selection); - if(businessObject instanceof EObject) { - eObject = (EObject)businessObject; - } - } - return eObject; - } - - /** - * Get current selection first element. - * - * @return the selected element or null. - */ - private Object getCurrentSelection() { - ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); - if(selection instanceof IStructuredSelection) { - IStructuredSelection structuredSelection = (IStructuredSelection)selection; - return structuredSelection.getFirstElement(); - } - - return null; - } - - /** - * Create a diagram. - * - * @param diagramResource - * the diagram resource - * @param owner - * the diagram container - * @param name - * the diagram name - * @return - */ - protected Diagram createDiagram(Resource diagramResource, EObject owner, String name) { - // create diagram - Diagram diagram = ViewService.createDiagram(owner, getDiagramNotationID(), getPreferenceHint()); - if(diagram != null) { - diagram.setName(name); - diagram.setElement(owner); - initializeDiagram(diagram); - diagramResource.getContents().add(diagram); - } - return diagram; - } - - protected void initializeDiagram(EObject diagram) { - }; - - /** - * Get the current MultiDiagramEditor. - * - * @return - */ - protected IMultiDiagramEditor getMultiDiagramEditor() { - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - IEditorPart editorPart = page.getActiveEditor(); - return (IMultiDiagramEditor)editorPart; - } - - /** - * Open popup to enter the new diagram name - * - * @param defaultValue - * the default value - * @return the entered diagram name - */ - protected String openDiagramNameDialog(String defaultValue) { - if(defaultValue == null) { - defaultValue = ""; - } - - InputDialog inputDialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.AbstractPapyrusGmfCreateDiagramCommandHandler_SelectNewDiagramName, Messages.AbstractPapyrusGmfCreateDiagramCommandHandler_NewDiagramName, defaultValue, null); - int result = inputDialog.open(); - - if(result == Window.OK) { - String name = inputDialog.getValue(); - if(name == null || name.length() == 0) { - name = defaultValue; - } - return name; - } - return null; - } - - /** - * {@inheritDoc} - */ - public void createDiagram(final DiResourceSet diResourceSet, final EObject container, final String diagramName) { - TransactionalEditingDomain transactionalEditingDomain = diResourceSet.getTransactionalEditingDomain(); - RecordingCommand command = new RecordingCommand(transactionalEditingDomain) { - - @Override - protected void doExecute() { - runAsTransaction(diResourceSet, container, diagramName); - } - }; - transactionalEditingDomain.getCommandStack().execute(command); - } - - /** - * {@inheritDoc} - */ - public ICommand getCreateDiagramCommand(final DiResourceSet diResourceSet, final EObject container, final String diagramName) { - final Resource modelResource = diResourceSet.getAssociatedModelResource(container); - final Resource notationResource = diResourceSet.getAssociatedNotationResource(container); - final Resource diResource = diResourceSet.getAssociatedDiResource(container); - - ArrayList modifiedFiles = new ArrayList(); - modifiedFiles.add(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(modelResource.getURI().toPlatformString(true)))); - modifiedFiles.add(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(notationResource.getURI().toPlatformString(true)))); - modifiedFiles.add(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(diResource.getURI().toPlatformString(true)))); - - return new AbstractTransactionalCommand(diResourceSet.getTransactionalEditingDomain(), Messages.AbstractPapyrusGmfCreateDiagramCommandHandler_CreateDiagramCommandLabel, modifiedFiles) { - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - - String name = diagramName; - if(name == null) { - name = openDiagramNameDialog(getDefaultDiagramName()); - } - // canceled - if(name == null) { - return CommandResult.newCancelledCommandResult(); - } - - EObject model = container; - if(model == null) { - model = getRootElement(modelResource); - attachModelToResource(model, modelResource); - } - - Diagram diagram = createDiagram(notationResource, model, name); - - if(diagram != null) { - IPageMngr pageMngr = EditorUtils.getIPageMngr(diResource); - pageMngr.addPage(diagram); - return CommandResult.newOKCommandResult(diagram); - } - return CommandResult.newErrorCommandResult("Error during diagram creation"); - } - }; - } - - /** - * Get the ServiceRegistry of the main editor. - * - * @return - */ - protected ServicesRegistry getServiceRegistry() { - return EditorUtils.getServiceRegistry(); - } - - /** - * Get the ISashWindowsContentProvider from the main editor. - * - * @return - */ - protected ISashWindowsContentProvider getISashWindowsContentProvider() { - return EditorUtils.getISashWindowsContentProvider(); - - } - - /** - * Check if the creation of this diagram is strongly attached to its parent or if it can be reassigned after creation. - * - * @return true if parent can be reassigned - */ - public boolean isParentReassignable() { - // yes by default - return true; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/Activator.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/Activator.java deleted file mode 100644 index 7d72f2f1fa6..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/Activator.java +++ /dev/null @@ -1,278 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.adaptor.gmf; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -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.IItemLabelProvider; -import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; -import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; -import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; -import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.papyrus.log.LogHelper; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * @generated - */ -public class Activator extends AbstractUIPlugin { - - /** - * @generated - */ - public static final String ID = "org.eclipse.papyrus.infra.core.adaptor.gmf"; //$NON-NLS-1$ - - /** - * @generated - */ - public static final PreferencesHint DIAGRAM_PREFERENCES_HINT = new PreferencesHint(ID); - - /** - * @generated - */ - private static Activator instance; - - /** - * @generated - */ - private ComposedAdapterFactory adapterFactory; - - /** - * @generated - */ - public Activator() { - } - - /** Logging helper */ - public static LogHelper log; - - /** - * @generated - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - instance = this; - // register the login helper - log = new LogHelper(this); - PreferencesHint.registerPreferenceStore(DIAGRAM_PREFERENCES_HINT, getPreferenceStore()); - adapterFactory = createAdapterFactory(); - } - - /** - * @generated - */ - @Override - public void stop(BundleContext context) throws Exception { - adapterFactory.dispose(); - adapterFactory = null; - log = null; - instance = null; - super.stop(context); - } - - /** - * @generated - */ - public static Activator getInstance() { - return instance; - } - - /** - * @generated - */ - protected ComposedAdapterFactory createAdapterFactory() { - List factories = new ArrayList(); - // fillItemProviderFactories(factories); - return new ComposedAdapterFactory(factories); - } - - /** - * @generated - */ - protected void fillItemProviderFactoriesGen(List factories) { - factories.add(new EcoreItemProviderAdapterFactory()); - factories.add(new ResourceItemProviderAdapterFactory()); - factories.add(new ReflectiveItemProviderAdapterFactory()); - } - - /** - * Use alternative UMLItemProviderAdapterFactory insteadof UMLItemProviderAdapterFactory - * - * @see org.eclipse.emf.edit.provider.ComposedAdapterFactory#getFactoryForTypes(java.util.Collection) - * @generated NOT - */ - // protected void fillItemProviderFactories(List factories) { - // factories.add(new AlternativeUMLItemProviderAdapterFactory(getPreferenceStore())); - // fillItemProviderFactoriesGen(factories); - // } - - /** - * @generated - */ - public AdapterFactory getItemProvidersAdapterFactory() { - return adapterFactory; - } - - /** - * @generated - */ - public ImageDescriptor getItemImageDescriptor(Object item) { - IItemLabelProvider labelProvider = (IItemLabelProvider)adapterFactory.adapt(item, IItemLabelProvider.class); - if(labelProvider != null) { - return ExtendedImageRegistry.getInstance().getImageDescriptor(labelProvider.getImage(item)); - } - return null; - } - - /** - * Returns an image descriptor for the image file at the given plug-in relative path. - * - * @generated - * @param path - * the path - * @return the image descriptor - */ - public static ImageDescriptor getBundledImageDescriptor(String path) { - return AbstractUIPlugin.imageDescriptorFromPlugin(ID, path); - } - - /** - * Respects images residing in any plug-in. If path is relative, then this bundle is looked up - * for the image, otherwise, for absolute path, first segment is taken as id of plug-in with - * image - * - * @generated - * @param path - * the path to image, either absolute (with plug-in id as first segment), or relative - * for bundled images - * @return the image descriptor - */ - public static ImageDescriptor findImageDescriptor(String path) { - final IPath p = new Path(path); - if(p.isAbsolute() && p.segmentCount() > 1) { - return AbstractUIPlugin.imageDescriptorFromPlugin(p.segment(0), p.removeFirstSegments(1).makeAbsolute() - .toString()); - } else { - return getBundledImageDescriptor(p.makeAbsolute().toString()); - } - } - - /** - * Returns string from plug-in's resource bundle - * - * @generated - */ - public static String getString(String key) { - return Platform.getResourceString(getInstance().getBundle(), "%" + key); //$NON-NLS-1$ - } - - /** - * Returns an image for the image file at the given plug-in relative path. Client do not need to - * dispose this image. Images will be disposed automatically. - * - * @generated - * @param path - * the path - * @return image instance - */ - public Image getBundledImage(String path) { - Image image = getImageRegistry().get(path); - if(image == null) { - getImageRegistry().put(path, getBundledImageDescriptor(path)); - image = getImageRegistry().get(path); - } - return image; - } - - /** - * @generated - */ - public void logError(String error) { - logError(error, null); - } - - /** - * @param throwable - * actual error or null could be passed - * @generated - */ - public void logError(String error, Throwable throwable) { - if(error == null && throwable != null) { - error = throwable.getMessage(); - } - getLog().log(new Status(IStatus.ERROR, Activator.ID, IStatus.OK, error, throwable)); - debug(error, throwable); - } - - /** - * @generated - */ - public void logInfo(String message) { - logInfo(message, null); - } - - /** - * @param throwable - * actual error or null could be passed - * @generated - */ - public void logInfo(String message, Throwable throwable) { - if(message == null && throwable != null) { - message = throwable.getMessage(); - } - getLog().log(new Status(IStatus.INFO, Activator.ID, IStatus.OK, message, throwable)); - debug(message, throwable); - } - - /** - * @generated - */ - private void debug(String message, Throwable throwable) { - if(!isDebugging()) { - return; - } - if(message != null) { - System.err.println(message); - } - if(throwable != null) { - throwable.printStackTrace(); - } - } - - /** - * Returns an image descriptor for the image file at the given plug-in relative path. - * - * @param path - * the path - * - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(String path) { - return imageDescriptorFromPlugin(ID, path); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/DiagramsUtil.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/DiagramsUtil.java deleted file mode 100644 index 2e5b470b4ff..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/DiagramsUtil.java +++ /dev/null @@ -1,75 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.adaptor.gmf; - -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.papyrus.core.utils.DiResourceSet; - - -public class DiagramsUtil { - - /** - * Gets the diagrams associated to element. - * - * @param element - * @param resourceSet - * can be null, it will then try to retrieve it from the element. - * @return the list of diagrams associated with the given element - */ - public static List getAssociatedDiagrams(EObject element, ResourceSet resourceSet) { - if(resourceSet == null) { - if(element != null && element.eResource() != null) { - resourceSet = element.eResource().getResourceSet(); - } - } - - if(resourceSet instanceof DiResourceSet) { - Resource notationResource = ((DiResourceSet)resourceSet).getAssociatedNotationResource(element); - return getAssociatedDiagramsFromNotationResource(element, notationResource); - } - - return Collections.EMPTY_LIST; - } - - /** - * Gets the diagrams associated to element. - * - * @param element - * @param notationResource - * the notation resource where to look for diagrams - * @return the list of diagrams associated with the given element - */ - public static List getAssociatedDiagramsFromNotationResource(EObject element, Resource notationResource) { - if(notationResource != null) { - LinkedList diagrams = new LinkedList(); - for(EObject eObj : notationResource.getContents()) { - if(eObj instanceof Diagram) { - Diagram diagram = (Diagram)eObj; - if(element.equals(diagram.getElement())) { - diagrams.add(diagram); - } - } - } - return diagrams; - } - return Collections.EMPTY_LIST; - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/GmfEditorFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/GmfEditorFactory.java deleted file mode 100644 index 989fc7e9096..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/GmfEditorFactory.java +++ /dev/null @@ -1,219 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.adaptor.gmf; - -import java.lang.reflect.Constructor; - -import org.eclipse.gef.ui.parts.GraphicalEditor; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.papyrus.core.editor.BackboneException; -import org.eclipse.papyrus.core.extension.diagrameditor.AbstractEditorFactory; -import org.eclipse.papyrus.core.multidiagram.actionbarcontributor.ActionBarContributorRegistry; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.sasheditor.contentprovider.IEditorModel; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.EditorActionBarContributor; - -/** - * Base class of GmfEditor factories. Editor should subclass this class and provide a 0 args - * constructor initializing the super class. - * - * @author Cedric Dumoulin - * @author Remi Schnekenburger - * @author Patrick Tessier - */ -public class GmfEditorFactory extends AbstractEditorFactory { - - /** - * Creates a new GmfEditorFactory. - * - * @param diagramClass - * expected Class of the diagram to create. - * @param expectedType - * expected diagram type (@see {@link Diagram#getType()}) - */ - protected GmfEditorFactory(Class diagramClass, String expectedType) { - super(diagramClass, expectedType); - } - - /** - * Return true if this PageModelFactory can create a PageModel for the specified pageIdentifier. - * The pageIdentifier is an instance of Diagram. - * - * @see org.eclipse.papyrus.core.extension.diagrameditor.IPluggableEditorFactory#isPageModelFactoryFor(java.lang.Object) - * @param pageIdentifier - * @return - * - */ - public boolean isPageModelFactoryFor(Object pageIdentifier) { - - if(pageIdentifier instanceof Diagram) { - Diagram diagram = (Diagram)pageIdentifier; - // disable it when diagram is a proxy (dedicated factory will handle it) - if(!diagram.eIsProxy()) { - final String type = diagram.getType(); - return getExpectedType().equals(type); - } - } - // no - return false; - - } - - /** - * - * @see org.eclipse.papyrus.core.extension.diagrameditor.IPluggableEditorFactory#createIPageModel(java.lang.Object) - * @param pageIdentifier - * @return - * - */ - public IPageModel createIPageModel(Object pageIdentifier) { - - return new GMFEditorModel((Diagram)pageIdentifier, getServiceRegistry()); - } - - /** - * IEditorModel handling creation of the requested Editor. - * - * @author dumoulin - * - */ - class GMFEditorModel implements IEditorModel { - - /** - * The Diagram object describing the diagram. - */ - private Diagram diagram; - - /** - * The servicesRegistry provided at creation. - */ - private ServicesRegistry servicesRegistry; - - /** - * - * Constructor. - */ - public GMFEditorModel(Diagram pageIdentifier, ServicesRegistry servicesRegistry) { - diagram = pageIdentifier; - this.servicesRegistry = servicesRegistry; - } - - /** - * Create the IEditor for the diagram. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IEditorModel#createIEditorPart() - * @return - * @throws PartInitException - * - */ - public IEditorPart createIEditorPart() throws PartInitException { - GraphicalEditor editor; - try { - Constructor c = getDiagramClass().getConstructor(ServicesRegistry.class, Diagram.class); - editor = (GraphicalEditor)c.newInstance(servicesRegistry, diagram); - return editor; - - } catch (Exception e) { - // Lets propagate. This is an implementation problem that should be solved by - // programmer. - throw new PartInitException(Messages.GmfEditorFactory_ErrorCreatingEditorPart + diagram, e); - } - - } - - /** - * Get the action bar requested by the Editor. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IEditorModel#getActionBarContributor() - * @return - * - */ - public EditorActionBarContributor getActionBarContributor() { - - String actionBarId = editorDescriptor.getActionBarContributorId(); - - // Do nothing if no EditorActionBarContributor is specify. - if(actionBarId == null || actionBarId.length() == 0) { - return null; - } - - // Try to get it. - - // Get ServiceRegistry - // ServicesRegistry serviceRegistry = getServicesRegistry(); - ActionBarContributorRegistry registry; - try { - registry = (ActionBarContributorRegistry)servicesRegistry.getService(ActionBarContributorRegistry.class); - } catch (ServiceException e) { - // Service not found - // TODO Log the error - e.printStackTrace(); - return null; - } - - try { - return registry.getActionBarContributor(actionBarId); - } catch (BackboneException e) { - // TODO Log the error and throw an exception instead - e.printStackTrace(); - return null; - } - } - - /** - * Get the underlying RawModel. Return the Diagram. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageModel#getRawModel() - * @return - * - */ - public Object getRawModel() { - return diagram; - } - - /** - * Get the icon to be shown by Tabs - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageModel#getTabIcon() - * @return - * - */ - public Image getTabIcon() { - ImageDescriptor imageDescriptor = getEditorDescriptor().getIcon(); - if(imageDescriptor == null) - return null; - - return imageDescriptor.createImage(); - } - - /** - * Get the title of the Diagram. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageModel#getTabTitle() - * @return - * - */ - public String getTabTitle() { - return diagram.getName(); - } - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/GmfMultiDiagramDocumentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/GmfMultiDiagramDocumentProvider.java deleted file mode 100644 index 6af275307f6..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/GmfMultiDiagramDocumentProvider.java +++ /dev/null @@ -1,1133 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.adaptor.gmf; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.resources.IStorage; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.core.runtime.jobs.MultiRule; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.ui.URIEditorInput; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.util.EContentAdapter; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; -import org.eclipse.emf.transaction.NotificationFilter; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.DiagramDocument; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocumentProvider; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.EditorStatusCodes; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.util.DiagramIOUtil; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.part.FileEditorInput; - -/** - * @generated - */ -public class GmfMultiDiagramDocumentProvider extends AbstractDocumentProvider implements IDiagramDocumentProvider, - IEditingDomainProvider { - - public static String EditingDomainID = "com.cea.papyrus.core.PapyrusEditingDomainID"; //$NON-NLS-1$ - - /** - * The shared ResourceSet. - */ - private TransactionalEditingDomain sharedEditingDomain = null; - - /** - * ResourceSet to use when creation EditingDomain. Can be null. - */ - private ResourceSet resourceSet; - - /** - * @param resourceSet - */ - public GmfMultiDiagramDocumentProvider(ResourceSet resourceSet) { - super(); - this.resourceSet = resourceSet; - } - - /** - * @param resourceSet - */ - public GmfMultiDiagramDocumentProvider(TransactionalEditingDomain editingDomain) { - super(); - this.sharedEditingDomain = editingDomain; - configureEditingDomain(sharedEditingDomain); - } - - /** - * Constructor. - */ - public GmfMultiDiagramDocumentProvider() { - // TODO Auto-generated constructor stub - } - - /** - * @generated - */ - protected ElementInfo createElementInfo(Object element) throws CoreException { - if(false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) { - throw new CoreException(new Status(IStatus.ERROR, Activator.ID, 0, NLS.bind( - Messages.GmfMultiDiagramDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ - null)); - } - IEditorInput editorInput = (IEditorInput)element; - IDiagramDocument document = (IDiagramDocument)createDocument(editorInput); - - ResourceSetInfo info = new ResourceSetInfo(document, editorInput); - info.setModificationStamp(computeModificationStamp(info)); - info.fStatus = null; - return info; - } - - /** - * @generated - */ - protected IDocument createDocument(Object element) throws CoreException { - if(false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) { - throw new CoreException(new Status(IStatus.ERROR, Activator.ID, 0, NLS.bind( - Messages.GmfMultiDiagramDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ - null)); - } - IDocument document = createEmptyDocument(); - setDocumentContent(document, (IEditorInput)element); - setupDocument(element, document); - return document; - } - - /** - * Sets up the given document as it would be provided for the given element. The content of the - * document is not changed. This default implementation is empty. Subclasses may reimplement. - * - * @param element - * the blue-print element - * @param document - * the document to set up - * @generated - */ - protected void setupDocument(Object element, IDocument document) { - // for subclasses - } - - /** - * @generated - */ - private long computeModificationStamp(ResourceSetInfo info) { - int result = 0; - for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { - Resource nextResource = it.next(); - - // bug 347300: skip faulty URIs - if( isBadURI(nextResource)) { - continue; - } - IFile file = WorkspaceSynchronizer.getFile(nextResource); - if(file != null) { - if(file.getLocation() != null) { - result += file.getLocation().toFile().lastModified(); - } else { - result += file.getModificationStamp(); - } - } - } - return result; - } - - /** - * Return true if the URI is a faulty URI, false otherwise. - * Faulty URI: scheme = pathmap, platform - * @param resource - * @return - */ - private boolean isBadURI(Resource resource) { - try { - java.net.URI uri = new java.net.URI(resource.getURI().toString()); - String scheme = uri.getScheme(); - if( "pathmap".equals(scheme) || "platform".equals(scheme)) { - return true; - } - - // not a bad uri - return false; - } catch (URISyntaxException e) { - return true; - } - } - - /** - * @generated - */ - protected IDocument createEmptyDocument() { - DiagramDocument document = new DiagramDocument(); - document.setEditingDomain(createEditingDomain()); - return document; - } - - /** - * Create the editing Domain. All Editing Domain will be created with the same ResourceSet. The - * first creation will record the ResourceSet, other creation will use it. - */ - private TransactionalEditingDomain createEditingDomain() { - - TransactionalEditingDomain editingDomain = null; - // System.out.println(this.getClass().getSimpleName() + "- (" + this + ")"); - // Check if edit domain exist - if(sharedEditingDomain != null) { // Already initialized - editingDomain = sharedEditingDomain; -// System.out.println(this.getClass().getSimpleName() -// + ".createEditingDomain() - got EditingDomain from previous call (" + editingDomain + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - return editingDomain; - } - - // No editingDomain. Create and initialize a new one. - - // Try to get a registered one if any - editingDomain = TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(EditingDomainID); - if(editingDomain != null) { - // got it - sharedEditingDomain = editingDomain; - Activator.log.debug((this.getClass().getSimpleName() - + ".createEditingDomain() - got EditingDomain from REGISTRY (" + editingDomain + ")")); //$NON-NLS-1$ //$NON-NLS-2$ - return editingDomain; - } - - // Create EditingDomain using provided ResourceSet if any. - if(resourceSet == null) { - editingDomain = DiagramEditingDomainFactory.getInstance().createEditingDomain(); - } else { - editingDomain = DiagramEditingDomainFactory.getInstance().createEditingDomain(resourceSet); - } - sharedEditingDomain = editingDomain; - editingDomain.setID(EditingDomainID); //$NON-NLS-1$ - Activator.log.debug(this.getClass().getSimpleName() - + ".createEditingDomain() - create a new EditingDomain (" + editingDomain + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - - configureEditingDomain(editingDomain); - - return editingDomain; - } - - /** - * Configure an EditingDomain suitable for GMF. This method should be called only once for an - * EditingDomain. - * - * @param editingDomain - */ - private void configureEditingDomain(TransactionalEditingDomain editingDomain) { - // Add listener on resource change - final NotificationFilter diagramResourceModifiedFilter = NotificationFilter.createNotifierFilter( - editingDomain.getResourceSet()).and(NotificationFilter.createEventTypeFilter(Notification.ADD)).and( - NotificationFilter.createFeatureFilter(ResourceSet.class, ResourceSet.RESOURCE_SET__RESOURCES)); - editingDomain.getResourceSet().eAdapters().add(new Adapter() { - - private Notifier myTarger; - - public Notifier getTarget() { - return myTarger; - } - - public boolean isAdapterForType(Object type) { - return false; - } - - public void notifyChanged(Notification notification) { - if(diagramResourceModifiedFilter.matches(notification)) { - Object value = notification.getNewValue(); - if(value instanceof Resource) { - ((Resource)value).setTrackingModification(true); - } - } - } - - public void setTarget(Notifier newTarget) { - myTarger = newTarget; - } - - }); - } - - /** - * @generated - */ - protected void setDocumentContent(IDocument document, IEditorInput element) throws CoreException { - IDiagramDocument diagramDocument = (IDiagramDocument)document; - TransactionalEditingDomain domain = diagramDocument.getEditingDomain(); - if(element instanceof FileEditorInput) { - IStorage storage = ((FileEditorInput)element).getStorage(); - Diagram diagram = DiagramIOUtil.load(domain, storage, true, getProgressMonitor()); - document.setContent(diagram); - } else if(element instanceof URIEditorInput) { - URI uri = ((URIEditorInput)element).getURI(); - Resource resource = null; - try { - resource = domain.getResourceSet().getResource(uri.trimFragment(), false); - if(resource == null) { - resource = domain.getResourceSet().createResource(uri.trimFragment()); - } - if(!resource.isLoaded()) { - try { - Map options = new HashMap(GMFResourceFactory.getDefaultLoadOptions()); - // @see 171060 - // options.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, - // Boolean.TRUE); - resource.load(options); - } catch (IOException e) { - resource.unload(); - throw e; - } - } - if(uri.fragment() != null) { - EObject rootElement = resource.getEObject(uri.fragment()); - if(rootElement instanceof Diagram) { - document.setContent((Diagram)rootElement); - return; - } - } else { - for(Iterator it = resource.getContents().iterator(); it.hasNext();) { - Object rootElement = it.next(); - if(rootElement instanceof Diagram) { - document.setContent((Diagram)rootElement); - return; - } - } - } - throw new RuntimeException(Messages.GmfMultiDiagramDocumentProvider_NoDiagramInResourceError); - } catch (Exception e) { - CoreException thrownExcp = null; - if(e instanceof CoreException) { - thrownExcp = (CoreException)e; - } else { - String msg = e.getLocalizedMessage(); - thrownExcp = new CoreException(new Status(IStatus.ERROR, Activator.ID, 0, msg != null ? msg - : Messages.GmfMultiDiagramDocumentProvider_DiagramLoadingError, e)); - } - throw thrownExcp; - } - } else { - throw new CoreException(new Status(IStatus.ERROR, Activator.ID, 0, NLS.bind( - Messages.GmfMultiDiagramDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ - null)); - } - } - - /** - * @generated - */ - public long getModificationStamp(Object element) { - ResourceSetInfo info = getResourceSetInfo(element); - if(info != null) { - return computeModificationStamp(info); - } - return super.getModificationStamp(element); - } - - /** - * @generated - */ - public boolean isDeleted(Object element) { - IDiagramDocument document = getDiagramDocument(element); - if(document != null) { - Resource diagramResource = document.getDiagram().eResource(); - if(diagramResource != null) { - IFile file = WorkspaceSynchronizer.getFile(diagramResource); - return file == null || file.getLocation() == null || !file.getLocation().toFile().exists(); - } - } - return super.isDeleted(element); - } - - /** - * @generated - */ - public ResourceSetInfo getResourceSetInfo(Object editorInput) { - return (ResourceSetInfo)super.getElementInfo(editorInput); - } - - /** - * @generated - */ - protected void disposeElementInfo(Object element, ElementInfo info) { - if(info instanceof ResourceSetInfo) { - ResourceSetInfo resourceSetInfo = (ResourceSetInfo)info; - resourceSetInfo.dispose(); - } - super.disposeElementInfo(element, info); - } - - /** - * @generated - */ - protected void doValidateState(Object element, Object computationContext) throws CoreException { - ResourceSetInfo info = getResourceSetInfo(element); - if(info != null) { - Collection files2Validate = new ArrayList(); - for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { - Resource nextResource = (Resource)it.next(); - IFile file = WorkspaceSynchronizer.getFile(nextResource); - if(file != null && file.isReadOnly()) { - files2Validate.add(file); - } - } - ResourcesPlugin.getWorkspace().validateEdit( - (IFile[])files2Validate.toArray(new IFile[files2Validate.size()]), computationContext); - } - - super.doValidateState(element, computationContext); - } - - /** - * @generated - */ - public boolean isReadOnly(Object element) { - ResourceSetInfo info = getResourceSetInfo(element); - if(info != null) { - if(info.isUpdateCache()) { - try { - updateCache(element); - } catch (CoreException ex) { - Activator.getInstance().logError(Messages.GmfMultiDiagramDocumentProvider_isModifiable, ex); - // Error message to log was initially taken from - // org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable - } - } - return info.isReadOnly(); - } - return super.isReadOnly(element); - } - - /** - * @generated - */ - public boolean isModifiable(Object element) { - if(!isStateValidated(element)) { - if(element instanceof FileEditorInput || element instanceof URIEditorInput) { - return true; - } - } - ResourceSetInfo info = getResourceSetInfo(element); - if(info != null) { - if(info.isUpdateCache()) { - try { - updateCache(element); - } catch (CoreException ex) { - Activator.getInstance().logError(Messages.GmfMultiDiagramDocumentProvider_isModifiable, ex); - // Error message to log was initially taken from - // org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable - } - } - return info.isModifiable(); - } - return super.isModifiable(element); - } - - /** - * @generated - */ - protected void updateCache(Object element) throws CoreException { - ResourceSetInfo info = getResourceSetInfo(element); - if(info != null) { - for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { - Resource nextResource = (Resource)it.next(); - IFile file = WorkspaceSynchronizer.getFile(nextResource); - if(file != null && file.isReadOnly()) { - info.setReadOnly(true); - info.setModifiable(false); - return; - } - } - info.setReadOnly(false); - info.setModifiable(true); - return; - } - } - - /** - * @generated - */ - protected void doUpdateStateCache(Object element) throws CoreException { - ResourceSetInfo info = getResourceSetInfo(element); - if(info != null) { - info.setUpdateCache(true); - } - super.doUpdateStateCache(element); - } - - /** - * @generated - */ - public boolean isSynchronized(Object element) { - ResourceSetInfo info = getResourceSetInfo(element); - if(info != null) { - return info.isSynchronized(); - } - return super.isSynchronized(element); - } - - /** - * @generated - */ - protected ISchedulingRule getResetRule(Object element) { - ResourceSetInfo info = getResourceSetInfo(element); - if(info != null) { - Collection rules = new ArrayList(); - for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { - Resource nextResource = (Resource)it.next(); - IFile file = WorkspaceSynchronizer.getFile(nextResource); - if(file != null) { - rules.add(ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(file)); - } - } - return new MultiRule((ISchedulingRule[])rules.toArray(new ISchedulingRule[rules.size()])); - } - return null; - } - - /** - * @generated - */ - protected ISchedulingRule getSaveRule(Object element) { - ResourceSetInfo info = getResourceSetInfo(element); - if(info != null) { - Collection rules = new ArrayList(); - for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { - Resource nextResource = (Resource)it.next(); - IFile file = WorkspaceSynchronizer.getFile(nextResource); - if(file != null) { - rules.add(computeSchedulingRule(file)); - } - } - return new MultiRule((ISchedulingRule[])rules.toArray(new ISchedulingRule[rules.size()])); - } - return null; - } - - /** - * @generated - */ - protected ISchedulingRule getSynchronizeRule(Object element) { - ResourceSetInfo info = getResourceSetInfo(element); - if(info != null) { - Collection rules = new ArrayList(); - for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { - Resource nextResource = (Resource)it.next(); - IFile file = WorkspaceSynchronizer.getFile(nextResource); - if(file != null) { - rules.add(ResourcesPlugin.getWorkspace().getRuleFactory().refreshRule(file)); - } - } - return new MultiRule((ISchedulingRule[])rules.toArray(new ISchedulingRule[rules.size()])); - } - return null; - } - - /** - * @generated - */ - protected ISchedulingRule getValidateStateRule(Object element) { - ResourceSetInfo info = getResourceSetInfo(element); - if(info != null) { - Collection files = new ArrayList(); - for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { - Resource nextResource = (Resource)it.next(); - IFile file = WorkspaceSynchronizer.getFile(nextResource); - if(file != null) { - files.add(file); - } - } - return ResourcesPlugin.getWorkspace().getRuleFactory().validateEditRule( - (IFile[])files.toArray(new IFile[files.size()])); - } - return null; - } - - /** - * @generated - */ - private ISchedulingRule computeSchedulingRule(IResource toCreateOrModify) { - if(toCreateOrModify.exists()) - return ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(toCreateOrModify); - - IResource parent = toCreateOrModify; - do { - /* - * XXX This is a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=67601 - * IResourceRuleFactory.createRule should iterate the hierarchy itself. - */ - toCreateOrModify = parent; - parent = toCreateOrModify.getParent(); - } while(parent != null && !parent.exists()); - - return ResourcesPlugin.getWorkspace().getRuleFactory().createRule(toCreateOrModify); - } - - /** - * @generated - */ - protected void doSynchronize(Object element, IProgressMonitor monitor) throws CoreException { - ResourceSetInfo info = getResourceSetInfo(element); - if(info != null) { - for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { - Resource nextResource = (Resource)it.next(); - handleElementChanged(info, nextResource, monitor); - } - return; - } - super.doSynchronize(element, monitor); - } - - /** - * @generated - */ - protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) - throws CoreException { - ResourceSetInfo info = getResourceSetInfo(element); - if(info != null) { - if(!overwrite && !info.isSynchronized()) { - throw new CoreException(new Status(IStatus.ERROR, Activator.ID, IResourceStatus.OUT_OF_SYNC_LOCAL, - Messages.GmfMultiDiagramDocumentProvider_UnsynchronizedFileSaveError, null)); - } - info.stopResourceListening(); - fireElementStateChanging(element); - List resources = info.getResourceSet().getResources(); - try { - monitor.beginTask(Messages.GmfMultiDiagramDocumentProvider_SaveDiagramTask, resources.size() + 1); // "Saving diagram" - for(Iterator it = resources.iterator(); it.hasNext();) { - Resource nextResource = (Resource)it.next(); - monitor.setTaskName(NLS.bind(Messages.GmfMultiDiagramDocumentProvider_SaveNextResourceTask, - nextResource.getURI())); - if(nextResource.isLoaded() && !info.getEditingDomain().isReadOnly(nextResource)) { - try { - nextResource.save(UMLDiagramEditorUtil.getSaveOptions()); - } catch (IOException e) { - fireElementStateChangeFailed(element); - throw new CoreException(new Status(IStatus.ERROR, Activator.ID, - EditorStatusCodes.RESOURCE_FAILURE, e.getLocalizedMessage(), null)); - } - } - monitor.worked(1); - } - monitor.done(); - info.setModificationStamp(computeModificationStamp(info)); - } catch (RuntimeException x) { - fireElementStateChangeFailed(element); - throw x; - } finally { - info.startResourceListening(); - } - } else { - URI newResoruceURI; - List affectedFiles = null; - if(element instanceof FileEditorInput) { - IFile newFile = ((FileEditorInput)element).getFile(); - affectedFiles = Collections.singletonList(newFile); - newResoruceURI = URI.createPlatformResourceURI(newFile.getFullPath().toString(), true); - } else if(element instanceof URIEditorInput) { - newResoruceURI = ((URIEditorInput)element).getURI(); - } else { - fireElementStateChangeFailed(element); - throw new CoreException(new Status(IStatus.ERROR, Activator.ID, 0, NLS.bind( - Messages.GmfMultiDiagramDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ - null)); - } - if(false == document instanceof IDiagramDocument) { - fireElementStateChangeFailed(element); - throw new CoreException( - new Status( - IStatus.ERROR, - Activator.ID, - 0, - "Incorrect document used: " + document + " instead of org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument", null)); //$NON-NLS-1$ //$NON-NLS-2$ - } - IDiagramDocument diagramDocument = (IDiagramDocument)document; - final Resource newResource = diagramDocument.getEditingDomain().getResourceSet().createResource( - newResoruceURI); - final Diagram diagramCopy = (Diagram)EcoreUtil.copy(diagramDocument.getDiagram()); - try { - new AbstractTransactionalCommand(diagramDocument.getEditingDomain(), NLS.bind( - Messages.GmfMultiDiagramDocumentProvider_SaveAsOperation, diagramCopy.getName()), affectedFiles) { - - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { - newResource.getContents().add(diagramCopy); - return CommandResult.newOKCommandResult(); - } - }.execute(monitor, null); - newResource.save(UMLDiagramEditorUtil.getSaveOptions()); - } catch (ExecutionException e) { - fireElementStateChangeFailed(element); - throw new CoreException(new Status(IStatus.ERROR, Activator.ID, 0, e.getLocalizedMessage(), null)); - } catch (IOException e) { - fireElementStateChangeFailed(element); - throw new CoreException(new Status(IStatus.ERROR, Activator.ID, 0, e.getLocalizedMessage(), null)); - } - newResource.unload(); - } - } - - /** - * @generated - */ - protected void handleElementChanged(ResourceSetInfo info, Resource changedResource, IProgressMonitor monitor) { - IFile file = WorkspaceSynchronizer.getFile(changedResource); - if(file != null) { - try { - file.refreshLocal(IResource.DEPTH_INFINITE, monitor); - } catch (CoreException ex) { - Activator.getInstance().logError(Messages.GmfMultiDiagramDocumentProvider_handleElementContentChanged, - ex); - // Error message to log was initially taken from - // org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.FileDocumentProvider_handleElementContentChanged - } - } - changedResource.unload(); - - fireElementContentAboutToBeReplaced(info.getEditorInput()); - removeUnchangedElementListeners(info.getEditorInput(), info); - info.fStatus = null; - try { - setDocumentContent(info.fDocument, info.getEditorInput()); - } catch (CoreException e) { - info.fStatus = e.getStatus(); - } - if(!info.fCanBeSaved) { - info.setModificationStamp(computeModificationStamp(info)); - } - addUnchangedElementListeners(info.getEditorInput(), info); - fireElementContentReplaced(info.getEditorInput()); - } - - /** - * @generated - */ - protected void handleElementMoved(IEditorInput input, URI uri) { - if(input instanceof FileEditorInput) { - IFile newFile = ResourcesPlugin.getWorkspace().getRoot().getFile( - new Path(URI.decode(uri.path())).removeFirstSegments(1)); - fireElementMoved(input, newFile == null ? null : new FileEditorInput(newFile)); - return; - } - // TODO: append suffix to the URI! (use diagram as a parameter) - fireElementMoved(input, new URIEditorInput(uri)); - } - - /** - * @generated - */ - public IEditorInput createInputWithEditingDomain(IEditorInput editorInput, TransactionalEditingDomain domain) { - return editorInput; - } - - /** - * @generated - */ - public IDiagramDocument getDiagramDocument(Object element) { - IDocument doc = getDocument(element); - if(doc instanceof IDiagramDocument) { - return (IDiagramDocument)doc; - } - return null; - } - - /** - * @generated - */ - protected IRunnableContext getOperationRunner(IProgressMonitor monitor) { - return null; - } - - /** - * @generated - */ - protected class ResourceSetInfo extends ElementInfo { - - /** - * @generated - */ - private long myModificationStamp = IResource.NULL_STAMP; - - /** - * @generated - */ - private WorkspaceSynchronizer mySynchronizer; - - /** - * @generated - */ - private Collection myUnSynchronizedResources = new ArrayList(); - - /** - * @generated - */ - private IDiagramDocument myDocument; - - /** - * @generated - */ - private IEditorInput myEditorInput; - - /** - * @generated - */ - private boolean myUpdateCache = true; - - /** - * @generated - */ - private boolean myModifiable = false; - - /** - * @generated - */ - private boolean myReadOnly = true; - - /** - * @generated - */ - private ResourceSetModificationListener myResourceSetListener; - - /** - * @generated - */ - public ResourceSetInfo(IDiagramDocument document, IEditorInput editorInput) { - super(document); - myDocument = document; - myEditorInput = editorInput; - startResourceListening(); - myResourceSetListener = new ResourceSetModificationListener(this); - getResourceSet().eAdapters().add(myResourceSetListener); - } - - /** - * @generated - */ - public long getModificationStamp() { - return myModificationStamp; - } - - /** - * @generated - */ - public void setModificationStamp(long modificationStamp) { - myModificationStamp = modificationStamp; - } - - /** - * @generated - */ - public TransactionalEditingDomain getEditingDomain() { - return myDocument.getEditingDomain(); - } - - /** - * @generated - */ - public ResourceSet getResourceSet() { - return getEditingDomain().getResourceSet(); - } - - /** - * @generated - */ - public IEditorInput getEditorInput() { - return myEditorInput; - } - - /** - * @generated - */ - public void dispose() { - stopResourceListening(); - getResourceSet().eAdapters().remove(myResourceSetListener); - for(Iterator it = getResourceSet().getResources().iterator(); it.hasNext();) { - Resource resource = (Resource)it.next(); - // Do not unload the resource because the DocumentProvider can be disposed while its - // Diagram node is - // kept for future re-openeing. - // resource.unload(); - } - } - - /** - * @generated - */ - public boolean isSynchronized() { - return myUnSynchronizedResources.size() == 0; - } - - /** - * @generated - */ - public void setUnSynchronized(Resource resource) { - myUnSynchronizedResources.add(resource); - } - - /** - * @generated - */ - public void setSynchronized(Resource resource) { - myUnSynchronizedResources.remove(resource); - } - - /** - * @generated - */ - public final void stopResourceListening() { - // mySynchronizer.dispose(); - mySynchronizer = null; - } - - /** - * @generated - */ - public final void startResourceListening() { - // Do not listen because all document use the same EditingDomain - // mySynchronizer = new WorkspaceSynchronizer(getEditingDomain(), new - // SynchronizerDelegate()); - } - - /** - * @generated - */ - public boolean isUpdateCache() { - return myUpdateCache; - } - - /** - * @generated - */ - public void setUpdateCache(boolean update) { - myUpdateCache = update; - } - - /** - * @generated - */ - public boolean isModifiable() { - return myModifiable; - } - - /** - * @generated - */ - public void setModifiable(boolean modifiable) { - myModifiable = modifiable; - } - - /** - * @generated - */ - public boolean isReadOnly() { - return myReadOnly; - } - - /** - * @generated - */ - public void setReadOnly(boolean readOnly) { - myReadOnly = readOnly; - } - - /** - * @generated - */ - private class SynchronizerDelegate implements WorkspaceSynchronizer.Delegate { - - /** - * @generated - */ - public void dispose() { - } - - /** - * @generated - */ - public boolean handleResourceChanged(final Resource resource) { - synchronized(ResourceSetInfo.this) { - if(ResourceSetInfo.this.fCanBeSaved) { - ResourceSetInfo.this.setUnSynchronized(resource); - return true; - } - } - Display.getDefault().asyncExec(new Runnable() { - - public void run() { - handleElementChanged(ResourceSetInfo.this, resource, null); - } - }); - return true; - } - - /** - * @generated - */ - public boolean handleResourceDeleted(Resource resource) { - synchronized(ResourceSetInfo.this) { - if(ResourceSetInfo.this.fCanBeSaved) { - ResourceSetInfo.this.setUnSynchronized(resource); - return true; - } - } - Display.getDefault().asyncExec(new Runnable() { - - public void run() { - fireElementDeleted(ResourceSetInfo.this.getEditorInput()); - } - }); - return true; - } - - /** - * @generated - */ - public boolean handleResourceMoved(Resource resource, final URI newURI) { - synchronized(ResourceSetInfo.this) { - if(ResourceSetInfo.this.fCanBeSaved) { - ResourceSetInfo.this.setUnSynchronized(resource); - return true; - } - } - if(myDocument.getDiagram().eResource() == resource) { - Display.getDefault().asyncExec(new Runnable() { - - public void run() { - handleElementMoved(ResourceSetInfo.this.getEditorInput(), newURI); - } - }); - } else { - handleResourceDeleted(resource); - } - return true; - } - - } - - } - - /** - * @generated - */ - private class ResourceSetModificationListener extends EContentAdapter { - - /** - * @generated - */ - private NotificationFilter myModifiedFilter; - - /** - * @generated - */ - private ResourceSetInfo myInfo; - - /** - * @generated - */ - public ResourceSetModificationListener(ResourceSetInfo info) { - myInfo = info; - myModifiedFilter = NotificationFilter.createEventTypeFilter(Notification.SET).or( - NotificationFilter.createEventTypeFilter(Notification.UNSET)).and( - NotificationFilter.createFeatureFilter(Resource.class, Resource.RESOURCE__IS_MODIFIED)); - } - - /** - * @generated - */ - public void notifyChanged(Notification notification) { - if(notification.getNotifier() instanceof ResourceSet) { - super.notifyChanged(notification); - } - if(!notification.isTouch() && myModifiedFilter.matches(notification)) { - if(notification.getNotifier() instanceof Resource) { - Resource resource = (Resource)notification.getNotifier(); - if(resource.isLoaded()) { - boolean modified = false; - for(Iterator it = myInfo.getResourceSet().getResources().iterator(); it.hasNext() && !modified;) { - Resource nextResource = (Resource)it.next(); - if(nextResource.isLoaded()) { - modified = nextResource.isModified(); - } - } - boolean dirtyStateChanged = false; - synchronized(myInfo) { - if(modified != myInfo.fCanBeSaved) { - myInfo.fCanBeSaved = modified; - dirtyStateChanged = true; - } - if(!resource.isModified()) { - myInfo.setSynchronized(resource); - } - } - if(dirtyStateChanged) { - fireElementDirtyStateChanged(myInfo.getEditorInput(), modified); - - if(!modified) { - myInfo.setModificationStamp(computeModificationStamp(myInfo)); - } - } - } - } - } - } - - } - - /** - * Return the editingDomain - */ - public EditingDomain getEditingDomain() { - if(sharedEditingDomain == null) { - createEditingDomain(); - } - return sharedEditingDomain; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/Messages.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/Messages.java deleted file mode 100644 index 976e2cf8f39..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/Messages.java +++ /dev/null @@ -1,80 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.adaptor.gmf; - -import org.eclipse.osgi.util.NLS; - -/** - * @generated - */ -public class Messages extends NLS { - - /** - * @generated - */ - static { - NLS.initializeMessages("messages", Messages.class); //$NON-NLS-1$ - } - - /** - * @generated - */ - private Messages() { - } - - public static String MultiPagesEditorActionBarContributor_PapyrusMenu; - - public static String AbstractPapyrusGmfCreateDiagramCommandHandler_CreateDiagramCommandLabel; - - public static String AbstractPapyrusGmfCreateDiagramCommandHandler_NewDiagramName; - - public static String AbstractPapyrusGmfCreateDiagramCommandHandler_NotSupportedEditor; - - public static String AbstractPapyrusGmfCreateDiagramCommandHandler_SelectNewDiagramName; - - public static String AbstractPapyrusGmfCreateDiagramCommandHandler_UnableCreateModelAndDiagram; - - public static String GmfEditorFactory_ErrorCreatingEditorPart; - - public static String GmfEditorFactory_ErrorRetrievingDiagram; - - public static String GmfMultiDiagramDocumentProvider_isModifiable; - - public static String GmfMultiDiagramDocumentProvider_handleElementContentChanged; - - public static String GmfMultiDiagramDocumentProvider_IncorrectInputError; - - public static String GmfMultiDiagramDocumentProvider_NoDiagramInResourceError; - - public static String GmfMultiDiagramDocumentProvider_DiagramLoadingError; - - public static String GmfMultiDiagramDocumentProvider_UnsynchronizedFileSaveError; - - public static String GmfMultiDiagramDocumentProvider_SaveDiagramTask; - - public static String GmfMultiDiagramDocumentProvider_SaveNextResourceTask; - - public static String GmfMultiDiagramDocumentProvider_SaveAsOperation; - - public static String ModelManagerEditor_SavingDeletedFile; - - public static String ModelManagerEditor_SaveAsErrorTitle; - - public static String ModelManagerEditor_SaveAsErrorMessage; - - public static String ModelManagerEditor_SaveErrorTitle; - - public static String ModelManagerEditor_SaveErrorMessage; - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/ModelManagerEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/ModelManagerEditor.java deleted file mode 100644 index 790430cfa33..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/ModelManagerEditor.java +++ /dev/null @@ -1,594 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.adaptor.gmf; - -import java.beans.PropertyChangeSupport; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.DiagramDocument; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.MEditingDomainElement; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.l10n.EditorMessages; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.window.Window; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorMatchingStrategy; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IEditorRegistry; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.SaveAsDialog; -import org.eclipse.ui.part.FileEditorInput; -import org.osgi.framework.Bundle; - -/** - * This class is used as an model manager for regular GMF Editor. All editor capabilities are - * neutralize, except the model load and save capabilities. - * - * @author dumoulin - * - */ -public class ModelManagerEditor { - - public static final String DIAGRAM_ADDED = "DIAGRAM_ADDED"; //$NON-NLS-1$ - - public static final String DIAGRAM_MOVED = "DIAGRAM_MOVED"; //$NON-NLS-1$ - - public static final String DIAGRAM_REMOVED = "DIAGRAM_REMOVED"; //$NON-NLS-1$ - - /** - * The underlying document provider. - */ - protected IDocumentProvider documentProvider; - - /** - * EditorInput provided when the editor is created. - */ - protected IEditorInput editorInput; - - protected IEditorSite site; - - /** - * Listener on diagram added/removed. - */ - private PropertyChangeSupport diagramListListener = new PropertyChangeSupport(this); - - /** - * Adapter listening to diagram addition/remove events - */ - private Adapter adapter = new Adapter() { - - Notifier notifier; - - public Notifier getTarget() { - return notifier; - } - - public boolean isAdapterForType(Object type) { - // TODO Auto-generated method stub - return false; - } - - /** - * Notifies that a change to some feature has occurred. - * - * @param notification - * a description of the change. - */ - public void notifyChanged(Notification notification) { - // System.out.println("notifyChanged("+ notification +")"); - // System.out.println("getEventType=" + notification.getEventType() ); - // System.out.println("getFeature=" + notification.getFeature() ); - // System.out.println("getNotifier=" + notification.getNotifier() ); - - int eventType = notification.getEventType(); - if(eventType == Notification.ADD) { - Object newValue = notification.getNewValue(); - if(newValue instanceof Diagram) - diagramListListener.firePropertyChange(DIAGRAM_ADDED, null, newValue); - } else if(eventType == Notification.MOVE) { - Object newValue = notification.getNewValue(); - if(newValue instanceof Diagram) - diagramListListener.firePropertyChange(DIAGRAM_MOVED, null, newValue); - - } else if(eventType == Notification.REMOVE) { - Object newValue = notification.getNewValue(); - if(newValue == null) - Activator.log.debug(getClass().getName() + "- Warning: can't get removed object."); //$NON-NLS-1$ - - if(newValue instanceof Diagram) - diagramListListener.firePropertyChange(DIAGRAM_REMOVED, null, newValue); - } - } - - public void setTarget(Notifier newTarget) { - notifier = newTarget; - - } - - }; - - /** - * @param hasFlyoutPalette - */ - public ModelManagerEditor(IDocumentProvider documentProvider) { - this.documentProvider = documentProvider; - } - - public IDocumentProvider getDocumentProvider() { - return documentProvider; - } - - /** - * - */ - public TransactionalEditingDomain getEditingDomain() { - IDocument document = getEditorInput() != null ? getDocumentProvider().getDocument(getEditorInput()) : null; - if(document instanceof IDiagramDocument) { - return ((IDiagramDocument)document).getEditingDomain(); - } - return getEditorInput() instanceof MEditingDomainElement ? ((MEditingDomainElement)getEditorInput()) - .getEditingDomain() : null; - } - - /** - * @cdm - */ - public void setInput(IEditorInput input) { - Activator.log.debug(this + ".setInput(IEditorInput input)"); //$NON-NLS-1$ - } - - /** - * - * @param site - * @param input - * @throws PartInitException - */ - public void init(IEditorSite site, IEditorInput input) throws PartInitException { - // System.out.println(this + ".init(IEditorSite site, IEditorInput input)"); - this.editorInput = input; - this.site = site; - try { - getDocumentProvider().connect(input); - } catch (CoreException x) { - // code from DiagramDocumentEditor.setInput(IEditorInput) - String title = EditorMessages.Editor_error_setinput_title; - String msg = EditorMessages.Editor_error_setinput_message; - Shell shell = site.getShell(); - ErrorDialog.openError(shell, title, msg, x.getStatus()); - } - } - - /** - * Returns diagram list listener. This listener send event whenever a diagram is added or - * removed to the eResource. - * - * @return the listener - */ - public PropertyChangeSupport getDiagramListListener() { - return diagramListListener; - } - - /** - * Called when the editor should be activated. Subclass should implements this method to - * register listeners to the model. - * - */ - public void activate() { - getNotationModelEResource().eAdapters().add(adapter); - - } - - /** - * Called when the editor is deactivated. - * - */ - public void deactivate() { - getNotationModelEResource().eAdapters().remove(adapter); - } - - private Resource getNotationModelEResource() { - // Get the default diagram document - DiagramDocument document = (DiagramDocument)getDocumentProvider().getDocument(getEditorInput()); - Diagram diagram = document.getDiagram(); - - return diagram.eResource(); - } - - /** - * Get the resource for notation model. - * - * @return - */ - public Resource getNotationResource() { - return getNotationModelEResource(); - } - - /** - * Get the resource for the domain model. - * - * @return - */ - public Resource getDomainResource() { - // Get the default diagram document - DiagramDocument document = (DiagramDocument)getDocumentProvider().getDocument(getEditorInput()); - Diagram diagram = document.getDiagram(); - - EObject rootObject = diagram.getElement(); - return rootObject.eResource(); - } - - /** - * @return the editorInput - */ - public IEditorInput getEditorInput() { - return editorInput; - } - - /** - * The AbstractDiagramEditor implementation of this IEditorPart method - * may be extended by subclasses. - * - * @param progressMonitor - * the progress monitor for communicating result state or null - */ - public void doSave(IProgressMonitor progressMonitor) { - - IDocumentProvider p = getDocumentProvider(); - if(p == null) - return; - - if(p.isDeleted(getEditorInput())) { - - if(isSaveAsAllowed()) { - - /* - * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors. Changed - * Behavior to make sure that if called inside a regular save (because of deletion - * of input element) there is a way to report back to the caller. - */ - performSaveAs(progressMonitor); - - } else { - - Shell shell = getSite().getShell(); - String title = EditorMessages.Editor_error_save_deleted_title; - String msg = EditorMessages.Editor_error_save_deleted_message; - MessageDialog.openError(shell, title, msg); - } - - } else { - updateState(getEditorInput()); - validateState(getEditorInput()); - performSave(false, progressMonitor); - } - } - - /** - * Updates the state of the given editor input such as read-only flag. - * - * @param input - * the input to be validated - * - */ - protected void updateState(IEditorInput input) { - IDocumentProvider provider = getDocumentProvider(); - try { - - provider.updateStateCache(input); - - // if (getDiagramEditPart() != null) { - // if(isEditable()) - // getDiagramEditPart().enableEditMode(); - // else - // getDiagramEditPart().disableEditMode(); - // } - - } catch (CoreException x) { - Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID); - ILog log = Platform.getLog(bundle); - log.log(x.getStatus()); - } - } - - /** - * Validates the state of the given editor input. The predominate intent of this method is to - * take any action probably necessary to ensure that the input can persistently be changed. - * - * @param input - * the input to be validated - * - */ - protected void validateState(IEditorInput input) { - - IDocumentProvider provider = getDocumentProvider(); - - try { - - provider.validateState(input, getSite().getShell()); - - } catch (CoreException x) { - IStatus status = x.getStatus(); - if(status == null || status.getSeverity() != IStatus.CANCEL) { - Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID); - ILog log = Platform.getLog(bundle); - log.log(x.getStatus()); - - Shell shell = getSite().getShell(); - String title = EditorMessages.Editor_error_validateEdit_title; - String msg = EditorMessages.Editor_error_validateEdit_message; - ErrorDialog.openError(shell, title, msg, x.getStatus()); - } - return; - } - - // if (getDiagramEditPart() != null) { - // if(isEditable()) - // getDiagramEditPart().enableEditMode(); - // else - // getDiagramEditPart().disableEditMode(); - // } - - } - - /** - * @generated - */ - public boolean isSaveAsAllowed() { - return true; - } - - /** - * @generated - */ - public void doSaveAs() { - performSaveAs(new NullProgressMonitor()); - } - - /** - * Performs the save and handles errors appropriately. - * - * @param overwrite - * indicates whether or not overwriting is allowed - * @param progressMonitor - * the monitor in which to run the operation - * - */ - protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) { - - IDocumentProvider provider = getDocumentProvider(); - if(provider == null) - return; - - try { - - provider.aboutToChange(getEditorInput()); - IEditorInput input = getEditorInput(); - provider.saveDocument(progressMonitor, input, getDocumentProvider().getDocument(input), overwrite); - // editorSaved(); - - } catch (CoreException x) { - IStatus status = x.getStatus(); - if(status == null || status.getSeverity() != IStatus.CANCEL) - handleExceptionOnSave(x, progressMonitor); - } finally { - provider.changed(getEditorInput()); - } - } - - /** - * @generated - */ - protected void performSaveAs(IProgressMonitor progressMonitor) { - Shell shell = getSite().getShell(); - IEditorInput input = getEditorInput(); - SaveAsDialog dialog = new SaveAsDialog(shell); - IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput)input).getFile() : null; - if(original != null) { - dialog.setOriginalFile(original); - } - dialog.create(); - IDocumentProvider provider = getDocumentProvider(); - if(provider == null) { - // editor has been programmatically closed while the dialog was open - return; - } - if(provider.isDeleted(input) && original != null) { - String message = NLS.bind(Messages.ModelManagerEditor_SavingDeletedFile, original.getName()); - dialog.setErrorMessage(null); - dialog.setMessage(message, IMessageProvider.WARNING); - } - if(dialog.open() == Window.CANCEL) { - if(progressMonitor != null) { - progressMonitor.setCanceled(true); - } - return; - } - IPath filePath = dialog.getResult(); - if(filePath == null) { - if(progressMonitor != null) { - progressMonitor.setCanceled(true); - } - return; - } - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - IFile file = workspaceRoot.getFile(filePath); - final IEditorInput newInput = new FileEditorInput(file); - // Check if the editor is already open - IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); - IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() - .getEditorReferences(); - for(int i = 0; i < editorRefs.length; i++) { - if(matchingStrategy.matches(editorRefs[i], newInput)) { - MessageDialog.openWarning(shell, Messages.ModelManagerEditor_SaveAsErrorTitle, - Messages.ModelManagerEditor_SaveAsErrorMessage); - return; - } - } - boolean success = false; - try { - provider.aboutToChange(newInput); - // getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, - // getDocumentProvider().getDocument(getEditorInput()), true); - getDocumentProvider().saveDocument(progressMonitor, newInput, - getDocumentProvider().getDocument(getEditorInput()), true); - success = true; - } catch (CoreException x) { - IStatus status = x.getStatus(); - if(status == null || status.getSeverity() != IStatus.CANCEL) { - ErrorDialog.openError(shell, Messages.ModelManagerEditor_SaveErrorTitle, - Messages.ModelManagerEditor_SaveErrorMessage, x.getStatus()); - } - } finally { - provider.changed(newInput); - if(success) { - setInput(newInput); - } - } - if(progressMonitor != null) { - progressMonitor.setCanceled(!success); - } - } - - /** - * Retrieves the descriptor for this editor - * - * @return the editor descriptor - */ - final protected IEditorDescriptor getEditorDescriptor() { - IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry(); - IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId()); - return editorDesc; - } - - /** - * The number of re-entrances into error correction code while saving. - * - */ - private int fErrorCorrectionOnSave; - - /** - * Handles the given exception. If the exception reports an out-of-sync situation, this is - * reported to the user. Otherwise, the exception is generically reported. - * - * @param exception - * the exception to handle - * @param progressMonitor - * the progress monitor - */ - protected void handleExceptionOnSave(CoreException exception, IProgressMonitor progressMonitor) { - - try { - ++fErrorCorrectionOnSave; - - Shell shell = getSite().getShell(); - - boolean isSynchronized = false; - IDocumentProvider p = getDocumentProvider(); - - isSynchronized = p.isSynchronized(getEditorInput()); - - if(isNotSynchronizedException(exception) && fErrorCorrectionOnSave == 1 && !isSynchronized) { - String title = EditorMessages.Editor_error_save_outofsync_title; - String msg = EditorMessages.Editor_error_save_outofsync_message; - - if(MessageDialog.openQuestion(shell, title, msg)) - performSave(true, progressMonitor); - else { - /* - * 1GEUPKR: ITPJUI:ALL - Loosing work with simultaneous edits Set progress - * monitor to canceled in order to report back to enclosing operations. - */ - if(progressMonitor != null) - progressMonitor.setCanceled(true); - } - } else { - String title = EditorMessages.Editor_error_save_title; - String msg = EditorMessages.Editor_error_save_message; - ErrorDialog.openError(shell, title, msg, exception.getStatus()); - - /* - * 1GEUPKR: ITPJUI:ALL - Loosing work with simultaneous edits Set progress monitor - * to canceled in order to report back to enclosing operations. - */ - if(progressMonitor != null) - progressMonitor.setCanceled(true); - } - } finally { - --fErrorCorrectionOnSave; - } - } - - /** - * Tells whether the given core exception is exactly the exception which is thrown for a - * non-synchronized element. - *

- * XXX: After 3.1 this method must be delegated to the document provider see - *

- * - * @param ex - * the core exception - * @return true iff the given core exception is exactly the exception which is - * thrown for a non-synchronized element - * - */ - private boolean isNotSynchronizedException(CoreException ex) { - if(ex == null) - return false; - - IStatus status = ex.getStatus(); - if(status == null || status instanceof MultiStatus) - return false; - - if(status.getException() != null) - return false; - - // Can't access IResourceStatus.OUT_OF_SYNC_LOCAL, using value: 274 - return status.getCode() == 274; - } - - /** - * @return the site - */ - public IEditorSite getSite() { - return site; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/SemanticFromGMFElement.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/SemanticFromGMFElement.java deleted file mode 100644 index 7f75a88ebf5..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/SemanticFromGMFElement.java +++ /dev/null @@ -1,44 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.adaptor.gmf; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.papyrus.core.IElementWithSemantic; - -/** - * this class is used to obtain the semantic element for element of a gmf diagram - * - */ -public class SemanticFromGMFElement implements IElementWithSemantic { - /** - * - * @see org.eclipse.papyrus.core.IElementWithSemantic#getSemanticElement(java.lang.Object) - * - * @param wrapper can be for examplean editpart of gmf - * @return the semantic element linked to this or null element - */ - public Object getSemanticElement(Object wrapper) { - if(wrapper instanceof IGraphicalEditPart){ - return ((IGraphicalEditPart)wrapper).resolveSemanticElement(); - } - if( wrapper instanceof IAdaptable){ - return ((IAdaptable)wrapper).getAdapter(EObject.class); - } - return null; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/SynchronizableGmfDiagramEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/SynchronizableGmfDiagramEditor.java deleted file mode 100644 index 920cd1efa16..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/SynchronizableGmfDiagramEditor.java +++ /dev/null @@ -1,101 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.adaptor.gmf; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl; -import org.eclipse.gef.DefaultEditDomain; -import org.eclipse.gef.GraphicalViewer; -import org.eclipse.gef.commands.CommandStack; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart; -import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor; -import org.eclipse.papyrus.commands.CheckedDiagramCommandStack; -import org.eclipse.papyrus.core.ui.IRevealSemanticElement; - -/** - /** - * - * This GMF editor contains a methods in order to reveal visual element from a list of semantic element. - * - */ - -public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implements IRevealSemanticElement { - - public SynchronizableGmfDiagramEditor(boolean hasFlyoutPalette) { - super(hasFlyoutPalette); - } - - - /** - * reveal all editpart that represent an element in the given list. - * @see org.eclipse.papyrus.core.ui.IRevealSemanticElement#revealSemanticElement(java.util.List) - * - */ - public void revealSemanticElement(List elementList) { - //create an instance that can get semantic element from gmf - SemanticFromGMFElement semanticFromGMFElement= new SemanticFromGMFElement(); - - // get the graphical viewer - GraphicalViewer graphicalViewer =getGraphicalViewer() ; - if( graphicalViewer!=null){ - - //look for among all edit part if the semantic is contained in the list - Iterator iter=graphicalViewer.getEditPartRegistry().values().iterator(); - IGraphicalEditPart researchedEditPart=null; - while(iter.hasNext()&& researchedEditPart==null) { - Object currentEditPart = (Object)iter.next(); - //look for only among IPrimary editpart to avoid compartment and labels of links - if(currentEditPart instanceof IPrimaryEditPart){ - if(elementList.contains(semanticFromGMFElement.getSemanticElement(currentEditPart))){ - researchedEditPart=((IGraphicalEditPart)currentEditPart);} - } - - } - //an editpart has been found so put selection on it. - if(researchedEditPart!=null){ - graphicalViewer.select(researchedEditPart); - } - } - } - - /** - * Configures my diagram edit domain with its command stack. - * This method has been completely overridden in order to use a proxy stack. - */ - @Override - protected void configureDiagramEditDomain() { - - DefaultEditDomain editDomain = getEditDomain(); - - if(editDomain != null) { - CommandStack stack = editDomain.getCommandStack(); - if(stack != null) { - // dispose the old stack - stack.dispose(); - } - - // create and assign the new stack - CheckedDiagramCommandStack diagramStack = new CheckedDiagramCommandStack(getDiagramEditDomain()); - - editDomain.setCommandStack(diagramStack); - } - - DiagramEditDomain diagEditDomain = (DiagramEditDomain)getDiagramEditDomain(); - diagEditDomain.setActionManager(createActionManager()); - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/UMLDiagramEditorUtil.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/UMLDiagramEditorUtil.java deleted file mode 100644 index 557bda65e46..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/core/adaptor/gmf/UMLDiagramEditorUtil.java +++ /dev/null @@ -1,37 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.adaptor.gmf; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.xmi.XMLResource; - -/** - * @generated - */ -public class UMLDiagramEditorUtil { - - /** - * @generated - */ - public static Map getSaveOptions() { - Map saveOptions = new HashMap(); - saveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$ - saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); - return saveOptions; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/AbstractPapyrusGmfCreateDiagramCommandHandler.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/AbstractPapyrusGmfCreateDiagramCommandHandler.java new file mode 100644 index 00000000000..b1195a015f1 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/AbstractPapyrusGmfCreateDiagramCommandHandler.java @@ -0,0 +1,355 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.adaptor.gmf; + +import java.util.ArrayList; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; +import org.eclipse.gmf.runtime.diagram.core.services.ViewService; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; +import org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.core.utils.BusinessModelResolver; +import org.eclipse.papyrus.infra.core.utils.DiResourceSet; +import org.eclipse.papyrus.infra.core.utils.EditorUtils; +import org.eclipse.papyrus.infra.core.utils.OpenDiagramCommand; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; + +/** + * Command creating a new GMF diagram in Papyrus. This command is intended to be used in eclipse + * extensions. + * + * Commands to create a GMF Diagram can subclass this class. There is two kinds of commands: - + * Eclipse handlers issuing commands (toolbar, menu, ...). This commands can find the active editor + * by using the Worbench.getActivePArt(). The entry point is {@link #execute(ExecutionEvent)}. - + * Commands called during editor initializing (like wizard). This commands require the diResourceSet + * to work. The entry point is {@link #createDiagram(DiResourceSet, EObject, String)} + * + * @author cedric dumoulin + * @author Jerome Benois + */ +public abstract class AbstractPapyrusGmfCreateDiagramCommandHandler extends AbstractHandler implements IHandler, ICreationCommand { + + /** + * Method called when the command is invoked. + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + + EObject container = null; + // if editor is open and active + if(getMultiDiagramEditor() != null) { + container = getSelectedElement(); + } + runAsTransaction(container); + return null; + } + + /** + * Create a new class diagram + * + * @param sharedObjects + * @param container + * The uml element to which the diagram should be attached, if possible. + * @throws ExecutionException + */ + protected void runAsTransaction(EObject container) throws ExecutionException { + + DiResourceSet diResourceSet; + try { + diResourceSet = EditorUtils.getServiceRegistry().getService(DiResourceSet.class); + } catch (ServiceException e) { + throw new ExecutionException("Can't get diResourceSet", e); + } + + runAsTransaction(diResourceSet, container, null); + } + + /** + * Create a new gmf diagram + * + * @param sharedObjects + * @param container + * The eObject to which the diagram should be attached, if possible. + */ + protected void runAsTransaction(final DiResourceSet diResourceSet, final EObject container, String name) { + TransactionalEditingDomain dom = diResourceSet.getTransactionalEditingDomain(); + CompositeCommand cmd = new CompositeCommand("Create diagram"); + ICommand createCmd = getCreateDiagramCommand(diResourceSet, container, name); + cmd.add(createCmd); + cmd.add(new OpenDiagramCommand(dom, createCmd)); + + dom.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd)); + } + + /** + * Get the root element associated with canvas. + */ + protected EObject getRootElement(Resource modelResource) { + EObject rootElement = null; + if(modelResource != null && modelResource.getContents() != null && modelResource.getContents().size() > 0) { + Object root = modelResource.getContents().get(0); + if(root instanceof EObject) { + rootElement = (EObject)root; + } + } + + return rootElement; + } + + /** + * Store model element in the resource. + */ + protected void attachModelToResource(EObject root, Resource resource) { + resource.getContents().add(root); + } + + /** + * Get the type of the diagram to create. + * + * @return diagram type + */ + public String getCreatedDiagramType() { + return getDiagramNotationID(); + } + + /** + * @return + */ + abstract protected String getDiagramNotationID(); + + /** + * @return + */ + abstract protected PreferencesHint getPreferenceHint(); + + /** + * Get the name used for diagram. + * + * @return + */ + abstract protected String getDefaultDiagramName(); + + /** + * Get currently selected element. + * + * @return The currently selected element, or null if any. + */ + protected EObject getSelectedElement() { + EObject eObject = null; + Object selection = getCurrentSelection(); + if(selection != null) { + Object businessObject = BusinessModelResolver.getInstance().getBusinessModel(selection); + if(businessObject instanceof EObject) { + eObject = (EObject)businessObject; + } + } + return eObject; + } + + /** + * Get current selection first element. + * + * @return the selected element or null. + */ + private Object getCurrentSelection() { + ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); + if(selection instanceof IStructuredSelection) { + IStructuredSelection structuredSelection = (IStructuredSelection)selection; + return structuredSelection.getFirstElement(); + } + + return null; + } + + /** + * Create a diagram. + * + * @param diagramResource + * the diagram resource + * @param owner + * the diagram container + * @param name + * the diagram name + * @return + */ + protected Diagram createDiagram(Resource diagramResource, EObject owner, String name) { + // create diagram + Diagram diagram = ViewService.createDiagram(owner, getDiagramNotationID(), getPreferenceHint()); + if(diagram != null) { + diagram.setName(name); + diagram.setElement(owner); + initializeDiagram(diagram); + diagramResource.getContents().add(diagram); + } + return diagram; + } + + protected void initializeDiagram(EObject diagram) { + }; + + /** + * Get the current MultiDiagramEditor. + * + * @return + */ + protected IMultiDiagramEditor getMultiDiagramEditor() { + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IEditorPart editorPart = page.getActiveEditor(); + return (IMultiDiagramEditor)editorPart; + } + + /** + * Open popup to enter the new diagram name + * + * @param defaultValue + * the default value + * @return the entered diagram name + */ + protected String openDiagramNameDialog(String defaultValue) { + if(defaultValue == null) { + defaultValue = ""; + } + + InputDialog inputDialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.AbstractPapyrusGmfCreateDiagramCommandHandler_SelectNewDiagramName, Messages.AbstractPapyrusGmfCreateDiagramCommandHandler_NewDiagramName, defaultValue, null); + int result = inputDialog.open(); + + if(result == Window.OK) { + String name = inputDialog.getValue(); + if(name == null || name.length() == 0) { + name = defaultValue; + } + return name; + } + return null; + } + + /** + * {@inheritDoc} + */ + public void createDiagram(final DiResourceSet diResourceSet, final EObject container, final String diagramName) { + TransactionalEditingDomain transactionalEditingDomain = diResourceSet.getTransactionalEditingDomain(); + RecordingCommand command = new RecordingCommand(transactionalEditingDomain) { + + @Override + protected void doExecute() { + runAsTransaction(diResourceSet, container, diagramName); + } + }; + transactionalEditingDomain.getCommandStack().execute(command); + } + + /** + * {@inheritDoc} + */ + public ICommand getCreateDiagramCommand(final DiResourceSet diResourceSet, final EObject container, final String diagramName) { + final Resource modelResource = diResourceSet.getAssociatedModelResource(container); + final Resource notationResource = diResourceSet.getAssociatedNotationResource(container); + final Resource diResource = diResourceSet.getAssociatedDiResource(container); + + ArrayList modifiedFiles = new ArrayList(); + modifiedFiles.add(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(modelResource.getURI().toPlatformString(true)))); + modifiedFiles.add(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(notationResource.getURI().toPlatformString(true)))); + modifiedFiles.add(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(diResource.getURI().toPlatformString(true)))); + + return new AbstractTransactionalCommand(diResourceSet.getTransactionalEditingDomain(), Messages.AbstractPapyrusGmfCreateDiagramCommandHandler_CreateDiagramCommandLabel, modifiedFiles) { + + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + + String name = diagramName; + if(name == null) { + name = openDiagramNameDialog(getDefaultDiagramName()); + } + // canceled + if(name == null) { + return CommandResult.newCancelledCommandResult(); + } + + EObject model = container; + if(model == null) { + model = getRootElement(modelResource); + attachModelToResource(model, modelResource); + } + + Diagram diagram = createDiagram(notationResource, model, name); + + if(diagram != null) { + IPageMngr pageMngr = EditorUtils.getIPageMngr(diResource); + pageMngr.addPage(diagram); + return CommandResult.newOKCommandResult(diagram); + } + return CommandResult.newErrorCommandResult("Error during diagram creation"); + } + }; + } + + /** + * Get the ServiceRegistry of the main editor. + * + * @return + */ + protected ServicesRegistry getServiceRegistry() { + return EditorUtils.getServiceRegistry(); + } + + /** + * Get the ISashWindowsContentProvider from the main editor. + * + * @return + */ + protected ISashWindowsContentProvider getISashWindowsContentProvider() { + return EditorUtils.getISashWindowsContentProvider(); + + } + + /** + * Check if the creation of this diagram is strongly attached to its parent or if it can be reassigned after creation. + * + * @return true if parent can be reassigned + */ + public boolean isParentReassignable() { + // yes by default + return true; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/Activator.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/Activator.java new file mode 100644 index 00000000000..1590460ccda --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/Activator.java @@ -0,0 +1,278 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.adaptor.gmf; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +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.IItemLabelProvider; +import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; +import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; +import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; +import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.papyrus.infra.core.log.LogHelper; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * @generated + */ +public class Activator extends AbstractUIPlugin { + + /** + * @generated + */ + public static final String ID = "org.eclipse.papyrus.infra.core.adaptor.gmf"; //$NON-NLS-1$ + + /** + * @generated + */ + public static final PreferencesHint DIAGRAM_PREFERENCES_HINT = new PreferencesHint(ID); + + /** + * @generated + */ + private static Activator instance; + + /** + * @generated + */ + private ComposedAdapterFactory adapterFactory; + + /** + * @generated + */ + public Activator() { + } + + /** Logging helper */ + public static LogHelper log; + + /** + * @generated + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + instance = this; + // register the login helper + log = new LogHelper(this); + PreferencesHint.registerPreferenceStore(DIAGRAM_PREFERENCES_HINT, getPreferenceStore()); + adapterFactory = createAdapterFactory(); + } + + /** + * @generated + */ + @Override + public void stop(BundleContext context) throws Exception { + adapterFactory.dispose(); + adapterFactory = null; + log = null; + instance = null; + super.stop(context); + } + + /** + * @generated + */ + public static Activator getInstance() { + return instance; + } + + /** + * @generated + */ + protected ComposedAdapterFactory createAdapterFactory() { + List factories = new ArrayList(); + // fillItemProviderFactories(factories); + return new ComposedAdapterFactory(factories); + } + + /** + * @generated + */ + protected void fillItemProviderFactoriesGen(List factories) { + factories.add(new EcoreItemProviderAdapterFactory()); + factories.add(new ResourceItemProviderAdapterFactory()); + factories.add(new ReflectiveItemProviderAdapterFactory()); + } + + /** + * Use alternative UMLItemProviderAdapterFactory insteadof UMLItemProviderAdapterFactory + * + * @see org.eclipse.emf.edit.provider.ComposedAdapterFactory#getFactoryForTypes(java.util.Collection) + * @generated NOT + */ + // protected void fillItemProviderFactories(List factories) { + // factories.add(new AlternativeUMLItemProviderAdapterFactory(getPreferenceStore())); + // fillItemProviderFactoriesGen(factories); + // } + + /** + * @generated + */ + public AdapterFactory getItemProvidersAdapterFactory() { + return adapterFactory; + } + + /** + * @generated + */ + public ImageDescriptor getItemImageDescriptor(Object item) { + IItemLabelProvider labelProvider = (IItemLabelProvider)adapterFactory.adapt(item, IItemLabelProvider.class); + if(labelProvider != null) { + return ExtendedImageRegistry.getInstance().getImageDescriptor(labelProvider.getImage(item)); + } + return null; + } + + /** + * Returns an image descriptor for the image file at the given plug-in relative path. + * + * @generated + * @param path + * the path + * @return the image descriptor + */ + public static ImageDescriptor getBundledImageDescriptor(String path) { + return AbstractUIPlugin.imageDescriptorFromPlugin(ID, path); + } + + /** + * Respects images residing in any plug-in. If path is relative, then this bundle is looked up + * for the image, otherwise, for absolute path, first segment is taken as id of plug-in with + * image + * + * @generated + * @param path + * the path to image, either absolute (with plug-in id as first segment), or relative + * for bundled images + * @return the image descriptor + */ + public static ImageDescriptor findImageDescriptor(String path) { + final IPath p = new Path(path); + if(p.isAbsolute() && p.segmentCount() > 1) { + return AbstractUIPlugin.imageDescriptorFromPlugin(p.segment(0), p.removeFirstSegments(1).makeAbsolute() + .toString()); + } else { + return getBundledImageDescriptor(p.makeAbsolute().toString()); + } + } + + /** + * Returns string from plug-in's resource bundle + * + * @generated + */ + public static String getString(String key) { + return Platform.getResourceString(getInstance().getBundle(), "%" + key); //$NON-NLS-1$ + } + + /** + * Returns an image for the image file at the given plug-in relative path. Client do not need to + * dispose this image. Images will be disposed automatically. + * + * @generated + * @param path + * the path + * @return image instance + */ + public Image getBundledImage(String path) { + Image image = getImageRegistry().get(path); + if(image == null) { + getImageRegistry().put(path, getBundledImageDescriptor(path)); + image = getImageRegistry().get(path); + } + return image; + } + + /** + * @generated + */ + public void logError(String error) { + logError(error, null); + } + + /** + * @param throwable + * actual error or null could be passed + * @generated + */ + public void logError(String error, Throwable throwable) { + if(error == null && throwable != null) { + error = throwable.getMessage(); + } + getLog().log(new Status(IStatus.ERROR, Activator.ID, IStatus.OK, error, throwable)); + debug(error, throwable); + } + + /** + * @generated + */ + public void logInfo(String message) { + logInfo(message, null); + } + + /** + * @param throwable + * actual error or null could be passed + * @generated + */ + public void logInfo(String message, Throwable throwable) { + if(message == null && throwable != null) { + message = throwable.getMessage(); + } + getLog().log(new Status(IStatus.INFO, Activator.ID, IStatus.OK, message, throwable)); + debug(message, throwable); + } + + /** + * @generated + */ + private void debug(String message, Throwable throwable) { + if(!isDebugging()) { + return; + } + if(message != null) { + System.err.println(message); + } + if(throwable != null) { + throwable.printStackTrace(); + } + } + + /** + * Returns an image descriptor for the image file at the given plug-in relative path. + * + * @param path + * the path + * + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(ID, path); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/DiagramsUtil.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/DiagramsUtil.java new file mode 100644 index 00000000000..05a0a21e2be --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/DiagramsUtil.java @@ -0,0 +1,75 @@ +/***************************************************************************** + * 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: + * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.adaptor.gmf; + +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.papyrus.infra.core.utils.DiResourceSet; + + +public class DiagramsUtil { + + /** + * Gets the diagrams associated to element. + * + * @param element + * @param resourceSet + * can be null, it will then try to retrieve it from the element. + * @return the list of diagrams associated with the given element + */ + public static List getAssociatedDiagrams(EObject element, ResourceSet resourceSet) { + if(resourceSet == null) { + if(element != null && element.eResource() != null) { + resourceSet = element.eResource().getResourceSet(); + } + } + + if(resourceSet instanceof DiResourceSet) { + Resource notationResource = ((DiResourceSet)resourceSet).getAssociatedNotationResource(element); + return getAssociatedDiagramsFromNotationResource(element, notationResource); + } + + return Collections.EMPTY_LIST; + } + + /** + * Gets the diagrams associated to element. + * + * @param element + * @param notationResource + * the notation resource where to look for diagrams + * @return the list of diagrams associated with the given element + */ + public static List getAssociatedDiagramsFromNotationResource(EObject element, Resource notationResource) { + if(notationResource != null) { + LinkedList diagrams = new LinkedList(); + for(EObject eObj : notationResource.getContents()) { + if(eObj instanceof Diagram) { + Diagram diagram = (Diagram)eObj; + if(element.equals(diagram.getElement())) { + diagrams.add(diagram); + } + } + } + return diagrams; + } + return Collections.EMPTY_LIST; + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/GmfEditorFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/GmfEditorFactory.java new file mode 100644 index 00000000000..c3a68ba04a1 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/GmfEditorFactory.java @@ -0,0 +1,219 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.adaptor.gmf; + +import java.lang.reflect.Constructor; + +import org.eclipse.gef.ui.parts.GraphicalEditor; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.papyrus.infra.core.editor.BackboneException; +import org.eclipse.papyrus.infra.core.extension.diagrameditor.AbstractEditorFactory; +import org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor.ActionBarContributorRegistry; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.part.EditorActionBarContributor; + +/** + * Base class of GmfEditor factories. Editor should subclass this class and provide a 0 args + * constructor initializing the super class. + * + * @author Cedric Dumoulin + * @author Remi Schnekenburger + * @author Patrick Tessier + */ +public class GmfEditorFactory extends AbstractEditorFactory { + + /** + * Creates a new GmfEditorFactory. + * + * @param diagramClass + * expected Class of the diagram to create. + * @param expectedType + * expected diagram type (@see {@link Diagram#getType()}) + */ + protected GmfEditorFactory(Class diagramClass, String expectedType) { + super(diagramClass, expectedType); + } + + /** + * Return true if this PageModelFactory can create a PageModel for the specified pageIdentifier. + * The pageIdentifier is an instance of Diagram. + * + * @see org.eclipse.papyrus.infra.core.extension.diagrameditor.IPluggableEditorFactory#isPageModelFactoryFor(java.lang.Object) + * @param pageIdentifier + * @return + * + */ + public boolean isPageModelFactoryFor(Object pageIdentifier) { + + if(pageIdentifier instanceof Diagram) { + Diagram diagram = (Diagram)pageIdentifier; + // disable it when diagram is a proxy (dedicated factory will handle it) + if(!diagram.eIsProxy()) { + final String type = diagram.getType(); + return getExpectedType().equals(type); + } + } + // no + return false; + + } + + /** + * + * @see org.eclipse.papyrus.infra.core.extension.diagrameditor.IPluggableEditorFactory#createIPageModel(java.lang.Object) + * @param pageIdentifier + * @return + * + */ + public IPageModel createIPageModel(Object pageIdentifier) { + + return new GMFEditorModel((Diagram)pageIdentifier, getServiceRegistry()); + } + + /** + * IEditorModel handling creation of the requested Editor. + * + * @author dumoulin + * + */ + class GMFEditorModel implements IEditorModel { + + /** + * The Diagram object describing the diagram. + */ + private Diagram diagram; + + /** + * The servicesRegistry provided at creation. + */ + private ServicesRegistry servicesRegistry; + + /** + * + * Constructor. + */ + public GMFEditorModel(Diagram pageIdentifier, ServicesRegistry servicesRegistry) { + diagram = pageIdentifier; + this.servicesRegistry = servicesRegistry; + } + + /** + * Create the IEditor for the diagram. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel#createIEditorPart() + * @return + * @throws PartInitException + * + */ + public IEditorPart createIEditorPart() throws PartInitException { + GraphicalEditor editor; + try { + Constructor c = getDiagramClass().getConstructor(ServicesRegistry.class, Diagram.class); + editor = (GraphicalEditor)c.newInstance(servicesRegistry, diagram); + return editor; + + } catch (Exception e) { + // Lets propagate. This is an implementation problem that should be solved by + // programmer. + throw new PartInitException(Messages.GmfEditorFactory_ErrorCreatingEditorPart + diagram, e); + } + + } + + /** + * Get the action bar requested by the Editor. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel#getActionBarContributor() + * @return + * + */ + public EditorActionBarContributor getActionBarContributor() { + + String actionBarId = editorDescriptor.getActionBarContributorId(); + + // Do nothing if no EditorActionBarContributor is specify. + if(actionBarId == null || actionBarId.length() == 0) { + return null; + } + + // Try to get it. + + // Get ServiceRegistry + // ServicesRegistry serviceRegistry = getServicesRegistry(); + ActionBarContributorRegistry registry; + try { + registry = (ActionBarContributorRegistry)servicesRegistry.getService(ActionBarContributorRegistry.class); + } catch (ServiceException e) { + // Service not found + // TODO Log the error + e.printStackTrace(); + return null; + } + + try { + return registry.getActionBarContributor(actionBarId); + } catch (BackboneException e) { + // TODO Log the error and throw an exception instead + e.printStackTrace(); + return null; + } + } + + /** + * Get the underlying RawModel. Return the Diagram. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getRawModel() + * @return + * + */ + public Object getRawModel() { + return diagram; + } + + /** + * Get the icon to be shown by Tabs + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getTabIcon() + * @return + * + */ + public Image getTabIcon() { + ImageDescriptor imageDescriptor = getEditorDescriptor().getIcon(); + if(imageDescriptor == null) + return null; + + return imageDescriptor.createImage(); + } + + /** + * Get the title of the Diagram. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getTabTitle() + * @return + * + */ + public String getTabTitle() { + return diagram.getName(); + } + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/GmfMultiDiagramDocumentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/GmfMultiDiagramDocumentProvider.java new file mode 100644 index 00000000000..6c1a9b3820a --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/GmfMultiDiagramDocumentProvider.java @@ -0,0 +1,1133 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.adaptor.gmf; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.IStorage; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.core.runtime.jobs.MultiRule; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.ui.URIEditorInput; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.util.EContentAdapter; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.edit.domain.IEditingDomainProvider; +import org.eclipse.emf.transaction.NotificationFilter; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.DiagramDocument; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocumentProvider; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.EditorStatusCodes; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.util.DiagramIOUtil; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.jface.operation.IRunnableContext; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.part.FileEditorInput; + +/** + * @generated + */ +public class GmfMultiDiagramDocumentProvider extends AbstractDocumentProvider implements IDiagramDocumentProvider, + IEditingDomainProvider { + + public static String EditingDomainID = "com.cea.papyrus.core.PapyrusEditingDomainID"; //$NON-NLS-1$ + + /** + * The shared ResourceSet. + */ + private TransactionalEditingDomain sharedEditingDomain = null; + + /** + * ResourceSet to use when creation EditingDomain. Can be null. + */ + private ResourceSet resourceSet; + + /** + * @param resourceSet + */ + public GmfMultiDiagramDocumentProvider(ResourceSet resourceSet) { + super(); + this.resourceSet = resourceSet; + } + + /** + * @param resourceSet + */ + public GmfMultiDiagramDocumentProvider(TransactionalEditingDomain editingDomain) { + super(); + this.sharedEditingDomain = editingDomain; + configureEditingDomain(sharedEditingDomain); + } + + /** + * Constructor. + */ + public GmfMultiDiagramDocumentProvider() { + // TODO Auto-generated constructor stub + } + + /** + * @generated + */ + protected ElementInfo createElementInfo(Object element) throws CoreException { + if(false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) { + throw new CoreException(new Status(IStatus.ERROR, Activator.ID, 0, NLS.bind( + Messages.GmfMultiDiagramDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ + null)); + } + IEditorInput editorInput = (IEditorInput)element; + IDiagramDocument document = (IDiagramDocument)createDocument(editorInput); + + ResourceSetInfo info = new ResourceSetInfo(document, editorInput); + info.setModificationStamp(computeModificationStamp(info)); + info.fStatus = null; + return info; + } + + /** + * @generated + */ + protected IDocument createDocument(Object element) throws CoreException { + if(false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) { + throw new CoreException(new Status(IStatus.ERROR, Activator.ID, 0, NLS.bind( + Messages.GmfMultiDiagramDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ + null)); + } + IDocument document = createEmptyDocument(); + setDocumentContent(document, (IEditorInput)element); + setupDocument(element, document); + return document; + } + + /** + * Sets up the given document as it would be provided for the given element. The content of the + * document is not changed. This default implementation is empty. Subclasses may reimplement. + * + * @param element + * the blue-print element + * @param document + * the document to set up + * @generated + */ + protected void setupDocument(Object element, IDocument document) { + // for subclasses + } + + /** + * @generated + */ + private long computeModificationStamp(ResourceSetInfo info) { + int result = 0; + for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { + Resource nextResource = it.next(); + + // bug 347300: skip faulty URIs + if( isBadURI(nextResource)) { + continue; + } + IFile file = WorkspaceSynchronizer.getFile(nextResource); + if(file != null) { + if(file.getLocation() != null) { + result += file.getLocation().toFile().lastModified(); + } else { + result += file.getModificationStamp(); + } + } + } + return result; + } + + /** + * Return true if the URI is a faulty URI, false otherwise. + * Faulty URI: scheme = pathmap, platform + * @param resource + * @return + */ + private boolean isBadURI(Resource resource) { + try { + java.net.URI uri = new java.net.URI(resource.getURI().toString()); + String scheme = uri.getScheme(); + if( "pathmap".equals(scheme) || "platform".equals(scheme)) { + return true; + } + + // not a bad uri + return false; + } catch (URISyntaxException e) { + return true; + } + } + + /** + * @generated + */ + protected IDocument createEmptyDocument() { + DiagramDocument document = new DiagramDocument(); + document.setEditingDomain(createEditingDomain()); + return document; + } + + /** + * Create the editing Domain. All Editing Domain will be created with the same ResourceSet. The + * first creation will record the ResourceSet, other creation will use it. + */ + private TransactionalEditingDomain createEditingDomain() { + + TransactionalEditingDomain editingDomain = null; + // System.out.println(this.getClass().getSimpleName() + "- (" + this + ")"); + // Check if edit domain exist + if(sharedEditingDomain != null) { // Already initialized + editingDomain = sharedEditingDomain; +// System.out.println(this.getClass().getSimpleName() +// + ".createEditingDomain() - got EditingDomain from previous call (" + editingDomain + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + return editingDomain; + } + + // No editingDomain. Create and initialize a new one. + + // Try to get a registered one if any + editingDomain = TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(EditingDomainID); + if(editingDomain != null) { + // got it + sharedEditingDomain = editingDomain; + Activator.log.debug((this.getClass().getSimpleName() + + ".createEditingDomain() - got EditingDomain from REGISTRY (" + editingDomain + ")")); //$NON-NLS-1$ //$NON-NLS-2$ + return editingDomain; + } + + // Create EditingDomain using provided ResourceSet if any. + if(resourceSet == null) { + editingDomain = DiagramEditingDomainFactory.getInstance().createEditingDomain(); + } else { + editingDomain = DiagramEditingDomainFactory.getInstance().createEditingDomain(resourceSet); + } + sharedEditingDomain = editingDomain; + editingDomain.setID(EditingDomainID); //$NON-NLS-1$ + Activator.log.debug(this.getClass().getSimpleName() + + ".createEditingDomain() - create a new EditingDomain (" + editingDomain + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + + configureEditingDomain(editingDomain); + + return editingDomain; + } + + /** + * Configure an EditingDomain suitable for GMF. This method should be called only once for an + * EditingDomain. + * + * @param editingDomain + */ + private void configureEditingDomain(TransactionalEditingDomain editingDomain) { + // Add listener on resource change + final NotificationFilter diagramResourceModifiedFilter = NotificationFilter.createNotifierFilter( + editingDomain.getResourceSet()).and(NotificationFilter.createEventTypeFilter(Notification.ADD)).and( + NotificationFilter.createFeatureFilter(ResourceSet.class, ResourceSet.RESOURCE_SET__RESOURCES)); + editingDomain.getResourceSet().eAdapters().add(new Adapter() { + + private Notifier myTarger; + + public Notifier getTarget() { + return myTarger; + } + + public boolean isAdapterForType(Object type) { + return false; + } + + public void notifyChanged(Notification notification) { + if(diagramResourceModifiedFilter.matches(notification)) { + Object value = notification.getNewValue(); + if(value instanceof Resource) { + ((Resource)value).setTrackingModification(true); + } + } + } + + public void setTarget(Notifier newTarget) { + myTarger = newTarget; + } + + }); + } + + /** + * @generated + */ + protected void setDocumentContent(IDocument document, IEditorInput element) throws CoreException { + IDiagramDocument diagramDocument = (IDiagramDocument)document; + TransactionalEditingDomain domain = diagramDocument.getEditingDomain(); + if(element instanceof FileEditorInput) { + IStorage storage = ((FileEditorInput)element).getStorage(); + Diagram diagram = DiagramIOUtil.load(domain, storage, true, getProgressMonitor()); + document.setContent(diagram); + } else if(element instanceof URIEditorInput) { + URI uri = ((URIEditorInput)element).getURI(); + Resource resource = null; + try { + resource = domain.getResourceSet().getResource(uri.trimFragment(), false); + if(resource == null) { + resource = domain.getResourceSet().createResource(uri.trimFragment()); + } + if(!resource.isLoaded()) { + try { + Map options = new HashMap(GMFResourceFactory.getDefaultLoadOptions()); + // @see 171060 + // options.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, + // Boolean.TRUE); + resource.load(options); + } catch (IOException e) { + resource.unload(); + throw e; + } + } + if(uri.fragment() != null) { + EObject rootElement = resource.getEObject(uri.fragment()); + if(rootElement instanceof Diagram) { + document.setContent((Diagram)rootElement); + return; + } + } else { + for(Iterator it = resource.getContents().iterator(); it.hasNext();) { + Object rootElement = it.next(); + if(rootElement instanceof Diagram) { + document.setContent((Diagram)rootElement); + return; + } + } + } + throw new RuntimeException(Messages.GmfMultiDiagramDocumentProvider_NoDiagramInResourceError); + } catch (Exception e) { + CoreException thrownExcp = null; + if(e instanceof CoreException) { + thrownExcp = (CoreException)e; + } else { + String msg = e.getLocalizedMessage(); + thrownExcp = new CoreException(new Status(IStatus.ERROR, Activator.ID, 0, msg != null ? msg + : Messages.GmfMultiDiagramDocumentProvider_DiagramLoadingError, e)); + } + throw thrownExcp; + } + } else { + throw new CoreException(new Status(IStatus.ERROR, Activator.ID, 0, NLS.bind( + Messages.GmfMultiDiagramDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ + null)); + } + } + + /** + * @generated + */ + public long getModificationStamp(Object element) { + ResourceSetInfo info = getResourceSetInfo(element); + if(info != null) { + return computeModificationStamp(info); + } + return super.getModificationStamp(element); + } + + /** + * @generated + */ + public boolean isDeleted(Object element) { + IDiagramDocument document = getDiagramDocument(element); + if(document != null) { + Resource diagramResource = document.getDiagram().eResource(); + if(diagramResource != null) { + IFile file = WorkspaceSynchronizer.getFile(diagramResource); + return file == null || file.getLocation() == null || !file.getLocation().toFile().exists(); + } + } + return super.isDeleted(element); + } + + /** + * @generated + */ + public ResourceSetInfo getResourceSetInfo(Object editorInput) { + return (ResourceSetInfo)super.getElementInfo(editorInput); + } + + /** + * @generated + */ + protected void disposeElementInfo(Object element, ElementInfo info) { + if(info instanceof ResourceSetInfo) { + ResourceSetInfo resourceSetInfo = (ResourceSetInfo)info; + resourceSetInfo.dispose(); + } + super.disposeElementInfo(element, info); + } + + /** + * @generated + */ + protected void doValidateState(Object element, Object computationContext) throws CoreException { + ResourceSetInfo info = getResourceSetInfo(element); + if(info != null) { + Collection files2Validate = new ArrayList(); + for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { + Resource nextResource = (Resource)it.next(); + IFile file = WorkspaceSynchronizer.getFile(nextResource); + if(file != null && file.isReadOnly()) { + files2Validate.add(file); + } + } + ResourcesPlugin.getWorkspace().validateEdit( + (IFile[])files2Validate.toArray(new IFile[files2Validate.size()]), computationContext); + } + + super.doValidateState(element, computationContext); + } + + /** + * @generated + */ + public boolean isReadOnly(Object element) { + ResourceSetInfo info = getResourceSetInfo(element); + if(info != null) { + if(info.isUpdateCache()) { + try { + updateCache(element); + } catch (CoreException ex) { + Activator.getInstance().logError(Messages.GmfMultiDiagramDocumentProvider_isModifiable, ex); + // Error message to log was initially taken from + // org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable + } + } + return info.isReadOnly(); + } + return super.isReadOnly(element); + } + + /** + * @generated + */ + public boolean isModifiable(Object element) { + if(!isStateValidated(element)) { + if(element instanceof FileEditorInput || element instanceof URIEditorInput) { + return true; + } + } + ResourceSetInfo info = getResourceSetInfo(element); + if(info != null) { + if(info.isUpdateCache()) { + try { + updateCache(element); + } catch (CoreException ex) { + Activator.getInstance().logError(Messages.GmfMultiDiagramDocumentProvider_isModifiable, ex); + // Error message to log was initially taken from + // org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable + } + } + return info.isModifiable(); + } + return super.isModifiable(element); + } + + /** + * @generated + */ + protected void updateCache(Object element) throws CoreException { + ResourceSetInfo info = getResourceSetInfo(element); + if(info != null) { + for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { + Resource nextResource = (Resource)it.next(); + IFile file = WorkspaceSynchronizer.getFile(nextResource); + if(file != null && file.isReadOnly()) { + info.setReadOnly(true); + info.setModifiable(false); + return; + } + } + info.setReadOnly(false); + info.setModifiable(true); + return; + } + } + + /** + * @generated + */ + protected void doUpdateStateCache(Object element) throws CoreException { + ResourceSetInfo info = getResourceSetInfo(element); + if(info != null) { + info.setUpdateCache(true); + } + super.doUpdateStateCache(element); + } + + /** + * @generated + */ + public boolean isSynchronized(Object element) { + ResourceSetInfo info = getResourceSetInfo(element); + if(info != null) { + return info.isSynchronized(); + } + return super.isSynchronized(element); + } + + /** + * @generated + */ + protected ISchedulingRule getResetRule(Object element) { + ResourceSetInfo info = getResourceSetInfo(element); + if(info != null) { + Collection rules = new ArrayList(); + for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { + Resource nextResource = (Resource)it.next(); + IFile file = WorkspaceSynchronizer.getFile(nextResource); + if(file != null) { + rules.add(ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(file)); + } + } + return new MultiRule((ISchedulingRule[])rules.toArray(new ISchedulingRule[rules.size()])); + } + return null; + } + + /** + * @generated + */ + protected ISchedulingRule getSaveRule(Object element) { + ResourceSetInfo info = getResourceSetInfo(element); + if(info != null) { + Collection rules = new ArrayList(); + for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { + Resource nextResource = (Resource)it.next(); + IFile file = WorkspaceSynchronizer.getFile(nextResource); + if(file != null) { + rules.add(computeSchedulingRule(file)); + } + } + return new MultiRule((ISchedulingRule[])rules.toArray(new ISchedulingRule[rules.size()])); + } + return null; + } + + /** + * @generated + */ + protected ISchedulingRule getSynchronizeRule(Object element) { + ResourceSetInfo info = getResourceSetInfo(element); + if(info != null) { + Collection rules = new ArrayList(); + for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { + Resource nextResource = (Resource)it.next(); + IFile file = WorkspaceSynchronizer.getFile(nextResource); + if(file != null) { + rules.add(ResourcesPlugin.getWorkspace().getRuleFactory().refreshRule(file)); + } + } + return new MultiRule((ISchedulingRule[])rules.toArray(new ISchedulingRule[rules.size()])); + } + return null; + } + + /** + * @generated + */ + protected ISchedulingRule getValidateStateRule(Object element) { + ResourceSetInfo info = getResourceSetInfo(element); + if(info != null) { + Collection files = new ArrayList(); + for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { + Resource nextResource = (Resource)it.next(); + IFile file = WorkspaceSynchronizer.getFile(nextResource); + if(file != null) { + files.add(file); + } + } + return ResourcesPlugin.getWorkspace().getRuleFactory().validateEditRule( + (IFile[])files.toArray(new IFile[files.size()])); + } + return null; + } + + /** + * @generated + */ + private ISchedulingRule computeSchedulingRule(IResource toCreateOrModify) { + if(toCreateOrModify.exists()) + return ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(toCreateOrModify); + + IResource parent = toCreateOrModify; + do { + /* + * XXX This is a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=67601 + * IResourceRuleFactory.createRule should iterate the hierarchy itself. + */ + toCreateOrModify = parent; + parent = toCreateOrModify.getParent(); + } while(parent != null && !parent.exists()); + + return ResourcesPlugin.getWorkspace().getRuleFactory().createRule(toCreateOrModify); + } + + /** + * @generated + */ + protected void doSynchronize(Object element, IProgressMonitor monitor) throws CoreException { + ResourceSetInfo info = getResourceSetInfo(element); + if(info != null) { + for(Iterator it = info.getResourceSet().getResources().iterator(); it.hasNext();) { + Resource nextResource = (Resource)it.next(); + handleElementChanged(info, nextResource, monitor); + } + return; + } + super.doSynchronize(element, monitor); + } + + /** + * @generated + */ + protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) + throws CoreException { + ResourceSetInfo info = getResourceSetInfo(element); + if(info != null) { + if(!overwrite && !info.isSynchronized()) { + throw new CoreException(new Status(IStatus.ERROR, Activator.ID, IResourceStatus.OUT_OF_SYNC_LOCAL, + Messages.GmfMultiDiagramDocumentProvider_UnsynchronizedFileSaveError, null)); + } + info.stopResourceListening(); + fireElementStateChanging(element); + List resources = info.getResourceSet().getResources(); + try { + monitor.beginTask(Messages.GmfMultiDiagramDocumentProvider_SaveDiagramTask, resources.size() + 1); // "Saving diagram" + for(Iterator it = resources.iterator(); it.hasNext();) { + Resource nextResource = (Resource)it.next(); + monitor.setTaskName(NLS.bind(Messages.GmfMultiDiagramDocumentProvider_SaveNextResourceTask, + nextResource.getURI())); + if(nextResource.isLoaded() && !info.getEditingDomain().isReadOnly(nextResource)) { + try { + nextResource.save(UMLDiagramEditorUtil.getSaveOptions()); + } catch (IOException e) { + fireElementStateChangeFailed(element); + throw new CoreException(new Status(IStatus.ERROR, Activator.ID, + EditorStatusCodes.RESOURCE_FAILURE, e.getLocalizedMessage(), null)); + } + } + monitor.worked(1); + } + monitor.done(); + info.setModificationStamp(computeModificationStamp(info)); + } catch (RuntimeException x) { + fireElementStateChangeFailed(element); + throw x; + } finally { + info.startResourceListening(); + } + } else { + URI newResoruceURI; + List affectedFiles = null; + if(element instanceof FileEditorInput) { + IFile newFile = ((FileEditorInput)element).getFile(); + affectedFiles = Collections.singletonList(newFile); + newResoruceURI = URI.createPlatformResourceURI(newFile.getFullPath().toString(), true); + } else if(element instanceof URIEditorInput) { + newResoruceURI = ((URIEditorInput)element).getURI(); + } else { + fireElementStateChangeFailed(element); + throw new CoreException(new Status(IStatus.ERROR, Activator.ID, 0, NLS.bind( + Messages.GmfMultiDiagramDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ + null)); + } + if(false == document instanceof IDiagramDocument) { + fireElementStateChangeFailed(element); + throw new CoreException( + new Status( + IStatus.ERROR, + Activator.ID, + 0, + "Incorrect document used: " + document + " instead of org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument", null)); //$NON-NLS-1$ //$NON-NLS-2$ + } + IDiagramDocument diagramDocument = (IDiagramDocument)document; + final Resource newResource = diagramDocument.getEditingDomain().getResourceSet().createResource( + newResoruceURI); + final Diagram diagramCopy = (Diagram)EcoreUtil.copy(diagramDocument.getDiagram()); + try { + new AbstractTransactionalCommand(diagramDocument.getEditingDomain(), NLS.bind( + Messages.GmfMultiDiagramDocumentProvider_SaveAsOperation, diagramCopy.getName()), affectedFiles) { + + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + newResource.getContents().add(diagramCopy); + return CommandResult.newOKCommandResult(); + } + }.execute(monitor, null); + newResource.save(UMLDiagramEditorUtil.getSaveOptions()); + } catch (ExecutionException e) { + fireElementStateChangeFailed(element); + throw new CoreException(new Status(IStatus.ERROR, Activator.ID, 0, e.getLocalizedMessage(), null)); + } catch (IOException e) { + fireElementStateChangeFailed(element); + throw new CoreException(new Status(IStatus.ERROR, Activator.ID, 0, e.getLocalizedMessage(), null)); + } + newResource.unload(); + } + } + + /** + * @generated + */ + protected void handleElementChanged(ResourceSetInfo info, Resource changedResource, IProgressMonitor monitor) { + IFile file = WorkspaceSynchronizer.getFile(changedResource); + if(file != null) { + try { + file.refreshLocal(IResource.DEPTH_INFINITE, monitor); + } catch (CoreException ex) { + Activator.getInstance().logError(Messages.GmfMultiDiagramDocumentProvider_handleElementContentChanged, + ex); + // Error message to log was initially taken from + // org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.FileDocumentProvider_handleElementContentChanged + } + } + changedResource.unload(); + + fireElementContentAboutToBeReplaced(info.getEditorInput()); + removeUnchangedElementListeners(info.getEditorInput(), info); + info.fStatus = null; + try { + setDocumentContent(info.fDocument, info.getEditorInput()); + } catch (CoreException e) { + info.fStatus = e.getStatus(); + } + if(!info.fCanBeSaved) { + info.setModificationStamp(computeModificationStamp(info)); + } + addUnchangedElementListeners(info.getEditorInput(), info); + fireElementContentReplaced(info.getEditorInput()); + } + + /** + * @generated + */ + protected void handleElementMoved(IEditorInput input, URI uri) { + if(input instanceof FileEditorInput) { + IFile newFile = ResourcesPlugin.getWorkspace().getRoot().getFile( + new Path(URI.decode(uri.path())).removeFirstSegments(1)); + fireElementMoved(input, newFile == null ? null : new FileEditorInput(newFile)); + return; + } + // TODO: append suffix to the URI! (use diagram as a parameter) + fireElementMoved(input, new URIEditorInput(uri)); + } + + /** + * @generated + */ + public IEditorInput createInputWithEditingDomain(IEditorInput editorInput, TransactionalEditingDomain domain) { + return editorInput; + } + + /** + * @generated + */ + public IDiagramDocument getDiagramDocument(Object element) { + IDocument doc = getDocument(element); + if(doc instanceof IDiagramDocument) { + return (IDiagramDocument)doc; + } + return null; + } + + /** + * @generated + */ + protected IRunnableContext getOperationRunner(IProgressMonitor monitor) { + return null; + } + + /** + * @generated + */ + protected class ResourceSetInfo extends ElementInfo { + + /** + * @generated + */ + private long myModificationStamp = IResource.NULL_STAMP; + + /** + * @generated + */ + private WorkspaceSynchronizer mySynchronizer; + + /** + * @generated + */ + private Collection myUnSynchronizedResources = new ArrayList(); + + /** + * @generated + */ + private IDiagramDocument myDocument; + + /** + * @generated + */ + private IEditorInput myEditorInput; + + /** + * @generated + */ + private boolean myUpdateCache = true; + + /** + * @generated + */ + private boolean myModifiable = false; + + /** + * @generated + */ + private boolean myReadOnly = true; + + /** + * @generated + */ + private ResourceSetModificationListener myResourceSetListener; + + /** + * @generated + */ + public ResourceSetInfo(IDiagramDocument document, IEditorInput editorInput) { + super(document); + myDocument = document; + myEditorInput = editorInput; + startResourceListening(); + myResourceSetListener = new ResourceSetModificationListener(this); + getResourceSet().eAdapters().add(myResourceSetListener); + } + + /** + * @generated + */ + public long getModificationStamp() { + return myModificationStamp; + } + + /** + * @generated + */ + public void setModificationStamp(long modificationStamp) { + myModificationStamp = modificationStamp; + } + + /** + * @generated + */ + public TransactionalEditingDomain getEditingDomain() { + return myDocument.getEditingDomain(); + } + + /** + * @generated + */ + public ResourceSet getResourceSet() { + return getEditingDomain().getResourceSet(); + } + + /** + * @generated + */ + public IEditorInput getEditorInput() { + return myEditorInput; + } + + /** + * @generated + */ + public void dispose() { + stopResourceListening(); + getResourceSet().eAdapters().remove(myResourceSetListener); + for(Iterator it = getResourceSet().getResources().iterator(); it.hasNext();) { + Resource resource = (Resource)it.next(); + // Do not unload the resource because the DocumentProvider can be disposed while its + // Diagram node is + // kept for future re-openeing. + // resource.unload(); + } + } + + /** + * @generated + */ + public boolean isSynchronized() { + return myUnSynchronizedResources.size() == 0; + } + + /** + * @generated + */ + public void setUnSynchronized(Resource resource) { + myUnSynchronizedResources.add(resource); + } + + /** + * @generated + */ + public void setSynchronized(Resource resource) { + myUnSynchronizedResources.remove(resource); + } + + /** + * @generated + */ + public final void stopResourceListening() { + // mySynchronizer.dispose(); + mySynchronizer = null; + } + + /** + * @generated + */ + public final void startResourceListening() { + // Do not listen because all document use the same EditingDomain + // mySynchronizer = new WorkspaceSynchronizer(getEditingDomain(), new + // SynchronizerDelegate()); + } + + /** + * @generated + */ + public boolean isUpdateCache() { + return myUpdateCache; + } + + /** + * @generated + */ + public void setUpdateCache(boolean update) { + myUpdateCache = update; + } + + /** + * @generated + */ + public boolean isModifiable() { + return myModifiable; + } + + /** + * @generated + */ + public void setModifiable(boolean modifiable) { + myModifiable = modifiable; + } + + /** + * @generated + */ + public boolean isReadOnly() { + return myReadOnly; + } + + /** + * @generated + */ + public void setReadOnly(boolean readOnly) { + myReadOnly = readOnly; + } + + /** + * @generated + */ + private class SynchronizerDelegate implements WorkspaceSynchronizer.Delegate { + + /** + * @generated + */ + public void dispose() { + } + + /** + * @generated + */ + public boolean handleResourceChanged(final Resource resource) { + synchronized(ResourceSetInfo.this) { + if(ResourceSetInfo.this.fCanBeSaved) { + ResourceSetInfo.this.setUnSynchronized(resource); + return true; + } + } + Display.getDefault().asyncExec(new Runnable() { + + public void run() { + handleElementChanged(ResourceSetInfo.this, resource, null); + } + }); + return true; + } + + /** + * @generated + */ + public boolean handleResourceDeleted(Resource resource) { + synchronized(ResourceSetInfo.this) { + if(ResourceSetInfo.this.fCanBeSaved) { + ResourceSetInfo.this.setUnSynchronized(resource); + return true; + } + } + Display.getDefault().asyncExec(new Runnable() { + + public void run() { + fireElementDeleted(ResourceSetInfo.this.getEditorInput()); + } + }); + return true; + } + + /** + * @generated + */ + public boolean handleResourceMoved(Resource resource, final URI newURI) { + synchronized(ResourceSetInfo.this) { + if(ResourceSetInfo.this.fCanBeSaved) { + ResourceSetInfo.this.setUnSynchronized(resource); + return true; + } + } + if(myDocument.getDiagram().eResource() == resource) { + Display.getDefault().asyncExec(new Runnable() { + + public void run() { + handleElementMoved(ResourceSetInfo.this.getEditorInput(), newURI); + } + }); + } else { + handleResourceDeleted(resource); + } + return true; + } + + } + + } + + /** + * @generated + */ + private class ResourceSetModificationListener extends EContentAdapter { + + /** + * @generated + */ + private NotificationFilter myModifiedFilter; + + /** + * @generated + */ + private ResourceSetInfo myInfo; + + /** + * @generated + */ + public ResourceSetModificationListener(ResourceSetInfo info) { + myInfo = info; + myModifiedFilter = NotificationFilter.createEventTypeFilter(Notification.SET).or( + NotificationFilter.createEventTypeFilter(Notification.UNSET)).and( + NotificationFilter.createFeatureFilter(Resource.class, Resource.RESOURCE__IS_MODIFIED)); + } + + /** + * @generated + */ + public void notifyChanged(Notification notification) { + if(notification.getNotifier() instanceof ResourceSet) { + super.notifyChanged(notification); + } + if(!notification.isTouch() && myModifiedFilter.matches(notification)) { + if(notification.getNotifier() instanceof Resource) { + Resource resource = (Resource)notification.getNotifier(); + if(resource.isLoaded()) { + boolean modified = false; + for(Iterator it = myInfo.getResourceSet().getResources().iterator(); it.hasNext() && !modified;) { + Resource nextResource = (Resource)it.next(); + if(nextResource.isLoaded()) { + modified = nextResource.isModified(); + } + } + boolean dirtyStateChanged = false; + synchronized(myInfo) { + if(modified != myInfo.fCanBeSaved) { + myInfo.fCanBeSaved = modified; + dirtyStateChanged = true; + } + if(!resource.isModified()) { + myInfo.setSynchronized(resource); + } + } + if(dirtyStateChanged) { + fireElementDirtyStateChanged(myInfo.getEditorInput(), modified); + + if(!modified) { + myInfo.setModificationStamp(computeModificationStamp(myInfo)); + } + } + } + } + } + } + + } + + /** + * Return the editingDomain + */ + public EditingDomain getEditingDomain() { + if(sharedEditingDomain == null) { + createEditingDomain(); + } + return sharedEditingDomain; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/Messages.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/Messages.java new file mode 100644 index 00000000000..c3a6797ccf9 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/Messages.java @@ -0,0 +1,80 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.adaptor.gmf; + +import org.eclipse.osgi.util.NLS; + +/** + * @generated + */ +public class Messages extends NLS { + + /** + * @generated + */ + static { + NLS.initializeMessages("messages", Messages.class); //$NON-NLS-1$ + } + + /** + * @generated + */ + private Messages() { + } + + public static String MultiPagesEditorActionBarContributor_PapyrusMenu; + + public static String AbstractPapyrusGmfCreateDiagramCommandHandler_CreateDiagramCommandLabel; + + public static String AbstractPapyrusGmfCreateDiagramCommandHandler_NewDiagramName; + + public static String AbstractPapyrusGmfCreateDiagramCommandHandler_NotSupportedEditor; + + public static String AbstractPapyrusGmfCreateDiagramCommandHandler_SelectNewDiagramName; + + public static String AbstractPapyrusGmfCreateDiagramCommandHandler_UnableCreateModelAndDiagram; + + public static String GmfEditorFactory_ErrorCreatingEditorPart; + + public static String GmfEditorFactory_ErrorRetrievingDiagram; + + public static String GmfMultiDiagramDocumentProvider_isModifiable; + + public static String GmfMultiDiagramDocumentProvider_handleElementContentChanged; + + public static String GmfMultiDiagramDocumentProvider_IncorrectInputError; + + public static String GmfMultiDiagramDocumentProvider_NoDiagramInResourceError; + + public static String GmfMultiDiagramDocumentProvider_DiagramLoadingError; + + public static String GmfMultiDiagramDocumentProvider_UnsynchronizedFileSaveError; + + public static String GmfMultiDiagramDocumentProvider_SaveDiagramTask; + + public static String GmfMultiDiagramDocumentProvider_SaveNextResourceTask; + + public static String GmfMultiDiagramDocumentProvider_SaveAsOperation; + + public static String ModelManagerEditor_SavingDeletedFile; + + public static String ModelManagerEditor_SaveAsErrorTitle; + + public static String ModelManagerEditor_SaveAsErrorMessage; + + public static String ModelManagerEditor_SaveErrorTitle; + + public static String ModelManagerEditor_SaveErrorMessage; + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/ModelManagerEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/ModelManagerEditor.java new file mode 100644 index 00000000000..f1e898f02ae --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/ModelManagerEditor.java @@ -0,0 +1,594 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.adaptor.gmf; + +import java.beans.PropertyChangeSupport; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.DiagramDocument; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.MEditingDomainElement; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.l10n.EditorMessages; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.window.Window; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IEditorDescriptor; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorMatchingStrategy; +import org.eclipse.ui.IEditorReference; +import org.eclipse.ui.IEditorRegistry; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.SaveAsDialog; +import org.eclipse.ui.part.FileEditorInput; +import org.osgi.framework.Bundle; + +/** + * This class is used as an model manager for regular GMF Editor. All editor capabilities are + * neutralize, except the model load and save capabilities. + * + * @author dumoulin + * + */ +public class ModelManagerEditor { + + public static final String DIAGRAM_ADDED = "DIAGRAM_ADDED"; //$NON-NLS-1$ + + public static final String DIAGRAM_MOVED = "DIAGRAM_MOVED"; //$NON-NLS-1$ + + public static final String DIAGRAM_REMOVED = "DIAGRAM_REMOVED"; //$NON-NLS-1$ + + /** + * The underlying document provider. + */ + protected IDocumentProvider documentProvider; + + /** + * EditorInput provided when the editor is created. + */ + protected IEditorInput editorInput; + + protected IEditorSite site; + + /** + * Listener on diagram added/removed. + */ + private PropertyChangeSupport diagramListListener = new PropertyChangeSupport(this); + + /** + * Adapter listening to diagram addition/remove events + */ + private Adapter adapter = new Adapter() { + + Notifier notifier; + + public Notifier getTarget() { + return notifier; + } + + public boolean isAdapterForType(Object type) { + // TODO Auto-generated method stub + return false; + } + + /** + * Notifies that a change to some feature has occurred. + * + * @param notification + * a description of the change. + */ + public void notifyChanged(Notification notification) { + // System.out.println("notifyChanged("+ notification +")"); + // System.out.println("getEventType=" + notification.getEventType() ); + // System.out.println("getFeature=" + notification.getFeature() ); + // System.out.println("getNotifier=" + notification.getNotifier() ); + + int eventType = notification.getEventType(); + if(eventType == Notification.ADD) { + Object newValue = notification.getNewValue(); + if(newValue instanceof Diagram) + diagramListListener.firePropertyChange(DIAGRAM_ADDED, null, newValue); + } else if(eventType == Notification.MOVE) { + Object newValue = notification.getNewValue(); + if(newValue instanceof Diagram) + diagramListListener.firePropertyChange(DIAGRAM_MOVED, null, newValue); + + } else if(eventType == Notification.REMOVE) { + Object newValue = notification.getNewValue(); + if(newValue == null) + Activator.log.debug(getClass().getName() + "- Warning: can't get removed object."); //$NON-NLS-1$ + + if(newValue instanceof Diagram) + diagramListListener.firePropertyChange(DIAGRAM_REMOVED, null, newValue); + } + } + + public void setTarget(Notifier newTarget) { + notifier = newTarget; + + } + + }; + + /** + * @param hasFlyoutPalette + */ + public ModelManagerEditor(IDocumentProvider documentProvider) { + this.documentProvider = documentProvider; + } + + public IDocumentProvider getDocumentProvider() { + return documentProvider; + } + + /** + * + */ + public TransactionalEditingDomain getEditingDomain() { + IDocument document = getEditorInput() != null ? getDocumentProvider().getDocument(getEditorInput()) : null; + if(document instanceof IDiagramDocument) { + return ((IDiagramDocument)document).getEditingDomain(); + } + return getEditorInput() instanceof MEditingDomainElement ? ((MEditingDomainElement)getEditorInput()) + .getEditingDomain() : null; + } + + /** + * @cdm + */ + public void setInput(IEditorInput input) { + Activator.log.debug(this + ".setInput(IEditorInput input)"); //$NON-NLS-1$ + } + + /** + * + * @param site + * @param input + * @throws PartInitException + */ + public void init(IEditorSite site, IEditorInput input) throws PartInitException { + // System.out.println(this + ".init(IEditorSite site, IEditorInput input)"); + this.editorInput = input; + this.site = site; + try { + getDocumentProvider().connect(input); + } catch (CoreException x) { + // code from DiagramDocumentEditor.setInput(IEditorInput) + String title = EditorMessages.Editor_error_setinput_title; + String msg = EditorMessages.Editor_error_setinput_message; + Shell shell = site.getShell(); + ErrorDialog.openError(shell, title, msg, x.getStatus()); + } + } + + /** + * Returns diagram list listener. This listener send event whenever a diagram is added or + * removed to the eResource. + * + * @return the listener + */ + public PropertyChangeSupport getDiagramListListener() { + return diagramListListener; + } + + /** + * Called when the editor should be activated. Subclass should implements this method to + * register listeners to the model. + * + */ + public void activate() { + getNotationModelEResource().eAdapters().add(adapter); + + } + + /** + * Called when the editor is deactivated. + * + */ + public void deactivate() { + getNotationModelEResource().eAdapters().remove(adapter); + } + + private Resource getNotationModelEResource() { + // Get the default diagram document + DiagramDocument document = (DiagramDocument)getDocumentProvider().getDocument(getEditorInput()); + Diagram diagram = document.getDiagram(); + + return diagram.eResource(); + } + + /** + * Get the resource for notation model. + * + * @return + */ + public Resource getNotationResource() { + return getNotationModelEResource(); + } + + /** + * Get the resource for the domain model. + * + * @return + */ + public Resource getDomainResource() { + // Get the default diagram document + DiagramDocument document = (DiagramDocument)getDocumentProvider().getDocument(getEditorInput()); + Diagram diagram = document.getDiagram(); + + EObject rootObject = diagram.getElement(); + return rootObject.eResource(); + } + + /** + * @return the editorInput + */ + public IEditorInput getEditorInput() { + return editorInput; + } + + /** + * The AbstractDiagramEditor implementation of this IEditorPart method + * may be extended by subclasses. + * + * @param progressMonitor + * the progress monitor for communicating result state or null + */ + public void doSave(IProgressMonitor progressMonitor) { + + IDocumentProvider p = getDocumentProvider(); + if(p == null) + return; + + if(p.isDeleted(getEditorInput())) { + + if(isSaveAsAllowed()) { + + /* + * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors. Changed + * Behavior to make sure that if called inside a regular save (because of deletion + * of input element) there is a way to report back to the caller. + */ + performSaveAs(progressMonitor); + + } else { + + Shell shell = getSite().getShell(); + String title = EditorMessages.Editor_error_save_deleted_title; + String msg = EditorMessages.Editor_error_save_deleted_message; + MessageDialog.openError(shell, title, msg); + } + + } else { + updateState(getEditorInput()); + validateState(getEditorInput()); + performSave(false, progressMonitor); + } + } + + /** + * Updates the state of the given editor input such as read-only flag. + * + * @param input + * the input to be validated + * + */ + protected void updateState(IEditorInput input) { + IDocumentProvider provider = getDocumentProvider(); + try { + + provider.updateStateCache(input); + + // if (getDiagramEditPart() != null) { + // if(isEditable()) + // getDiagramEditPart().enableEditMode(); + // else + // getDiagramEditPart().disableEditMode(); + // } + + } catch (CoreException x) { + Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID); + ILog log = Platform.getLog(bundle); + log.log(x.getStatus()); + } + } + + /** + * Validates the state of the given editor input. The predominate intent of this method is to + * take any action probably necessary to ensure that the input can persistently be changed. + * + * @param input + * the input to be validated + * + */ + protected void validateState(IEditorInput input) { + + IDocumentProvider provider = getDocumentProvider(); + + try { + + provider.validateState(input, getSite().getShell()); + + } catch (CoreException x) { + IStatus status = x.getStatus(); + if(status == null || status.getSeverity() != IStatus.CANCEL) { + Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID); + ILog log = Platform.getLog(bundle); + log.log(x.getStatus()); + + Shell shell = getSite().getShell(); + String title = EditorMessages.Editor_error_validateEdit_title; + String msg = EditorMessages.Editor_error_validateEdit_message; + ErrorDialog.openError(shell, title, msg, x.getStatus()); + } + return; + } + + // if (getDiagramEditPart() != null) { + // if(isEditable()) + // getDiagramEditPart().enableEditMode(); + // else + // getDiagramEditPart().disableEditMode(); + // } + + } + + /** + * @generated + */ + public boolean isSaveAsAllowed() { + return true; + } + + /** + * @generated + */ + public void doSaveAs() { + performSaveAs(new NullProgressMonitor()); + } + + /** + * Performs the save and handles errors appropriately. + * + * @param overwrite + * indicates whether or not overwriting is allowed + * @param progressMonitor + * the monitor in which to run the operation + * + */ + protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) { + + IDocumentProvider provider = getDocumentProvider(); + if(provider == null) + return; + + try { + + provider.aboutToChange(getEditorInput()); + IEditorInput input = getEditorInput(); + provider.saveDocument(progressMonitor, input, getDocumentProvider().getDocument(input), overwrite); + // editorSaved(); + + } catch (CoreException x) { + IStatus status = x.getStatus(); + if(status == null || status.getSeverity() != IStatus.CANCEL) + handleExceptionOnSave(x, progressMonitor); + } finally { + provider.changed(getEditorInput()); + } + } + + /** + * @generated + */ + protected void performSaveAs(IProgressMonitor progressMonitor) { + Shell shell = getSite().getShell(); + IEditorInput input = getEditorInput(); + SaveAsDialog dialog = new SaveAsDialog(shell); + IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput)input).getFile() : null; + if(original != null) { + dialog.setOriginalFile(original); + } + dialog.create(); + IDocumentProvider provider = getDocumentProvider(); + if(provider == null) { + // editor has been programmatically closed while the dialog was open + return; + } + if(provider.isDeleted(input) && original != null) { + String message = NLS.bind(Messages.ModelManagerEditor_SavingDeletedFile, original.getName()); + dialog.setErrorMessage(null); + dialog.setMessage(message, IMessageProvider.WARNING); + } + if(dialog.open() == Window.CANCEL) { + if(progressMonitor != null) { + progressMonitor.setCanceled(true); + } + return; + } + IPath filePath = dialog.getResult(); + if(filePath == null) { + if(progressMonitor != null) { + progressMonitor.setCanceled(true); + } + return; + } + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + IFile file = workspaceRoot.getFile(filePath); + final IEditorInput newInput = new FileEditorInput(file); + // Check if the editor is already open + IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); + IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() + .getEditorReferences(); + for(int i = 0; i < editorRefs.length; i++) { + if(matchingStrategy.matches(editorRefs[i], newInput)) { + MessageDialog.openWarning(shell, Messages.ModelManagerEditor_SaveAsErrorTitle, + Messages.ModelManagerEditor_SaveAsErrorMessage); + return; + } + } + boolean success = false; + try { + provider.aboutToChange(newInput); + // getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, + // getDocumentProvider().getDocument(getEditorInput()), true); + getDocumentProvider().saveDocument(progressMonitor, newInput, + getDocumentProvider().getDocument(getEditorInput()), true); + success = true; + } catch (CoreException x) { + IStatus status = x.getStatus(); + if(status == null || status.getSeverity() != IStatus.CANCEL) { + ErrorDialog.openError(shell, Messages.ModelManagerEditor_SaveErrorTitle, + Messages.ModelManagerEditor_SaveErrorMessage, x.getStatus()); + } + } finally { + provider.changed(newInput); + if(success) { + setInput(newInput); + } + } + if(progressMonitor != null) { + progressMonitor.setCanceled(!success); + } + } + + /** + * Retrieves the descriptor for this editor + * + * @return the editor descriptor + */ + final protected IEditorDescriptor getEditorDescriptor() { + IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry(); + IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId()); + return editorDesc; + } + + /** + * The number of re-entrances into error correction code while saving. + * + */ + private int fErrorCorrectionOnSave; + + /** + * Handles the given exception. If the exception reports an out-of-sync situation, this is + * reported to the user. Otherwise, the exception is generically reported. + * + * @param exception + * the exception to handle + * @param progressMonitor + * the progress monitor + */ + protected void handleExceptionOnSave(CoreException exception, IProgressMonitor progressMonitor) { + + try { + ++fErrorCorrectionOnSave; + + Shell shell = getSite().getShell(); + + boolean isSynchronized = false; + IDocumentProvider p = getDocumentProvider(); + + isSynchronized = p.isSynchronized(getEditorInput()); + + if(isNotSynchronizedException(exception) && fErrorCorrectionOnSave == 1 && !isSynchronized) { + String title = EditorMessages.Editor_error_save_outofsync_title; + String msg = EditorMessages.Editor_error_save_outofsync_message; + + if(MessageDialog.openQuestion(shell, title, msg)) + performSave(true, progressMonitor); + else { + /* + * 1GEUPKR: ITPJUI:ALL - Loosing work with simultaneous edits Set progress + * monitor to canceled in order to report back to enclosing operations. + */ + if(progressMonitor != null) + progressMonitor.setCanceled(true); + } + } else { + String title = EditorMessages.Editor_error_save_title; + String msg = EditorMessages.Editor_error_save_message; + ErrorDialog.openError(shell, title, msg, exception.getStatus()); + + /* + * 1GEUPKR: ITPJUI:ALL - Loosing work with simultaneous edits Set progress monitor + * to canceled in order to report back to enclosing operations. + */ + if(progressMonitor != null) + progressMonitor.setCanceled(true); + } + } finally { + --fErrorCorrectionOnSave; + } + } + + /** + * Tells whether the given core exception is exactly the exception which is thrown for a + * non-synchronized element. + *

+ * XXX: After 3.1 this method must be delegated to the document provider see + *

+ * + * @param ex + * the core exception + * @return true iff the given core exception is exactly the exception which is + * thrown for a non-synchronized element + * + */ + private boolean isNotSynchronizedException(CoreException ex) { + if(ex == null) + return false; + + IStatus status = ex.getStatus(); + if(status == null || status instanceof MultiStatus) + return false; + + if(status.getException() != null) + return false; + + // Can't access IResourceStatus.OUT_OF_SYNC_LOCAL, using value: 274 + return status.getCode() == 274; + } + + /** + * @return the site + */ + public IEditorSite getSite() { + return site; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/SemanticFromGMFElement.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/SemanticFromGMFElement.java new file mode 100644 index 00000000000..d1b1fc795f3 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/SemanticFromGMFElement.java @@ -0,0 +1,44 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.adaptor.gmf; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.papyrus.infra.core.IElementWithSemantic; + +/** + * this class is used to obtain the semantic element for element of a gmf diagram + * + */ +public class SemanticFromGMFElement implements IElementWithSemantic { + /** + * + * @see org.eclipse.papyrus.infra.core.IElementWithSemantic#getSemanticElement(java.lang.Object) + * + * @param wrapper can be for examplean editpart of gmf + * @return the semantic element linked to this or null element + */ + public Object getSemanticElement(Object wrapper) { + if(wrapper instanceof IGraphicalEditPart){ + return ((IGraphicalEditPart)wrapper).resolveSemanticElement(); + } + if( wrapper instanceof IAdaptable){ + return ((IAdaptable)wrapper).getAdapter(EObject.class); + } + return null; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/SynchronizableGmfDiagramEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/SynchronizableGmfDiagramEditor.java new file mode 100644 index 00000000000..4b553193a58 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/SynchronizableGmfDiagramEditor.java @@ -0,0 +1,101 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.adaptor.gmf; + +import java.util.Iterator; +import java.util.List; + +import org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl; +import org.eclipse.gef.DefaultEditDomain; +import org.eclipse.gef.GraphicalViewer; +import org.eclipse.gef.commands.CommandStack; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart; +import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor; +import org.eclipse.papyrus.commands.CheckedDiagramCommandStack; +import org.eclipse.papyrus.infra.core.ui.IRevealSemanticElement; + +/** + /** + * + * This GMF editor contains a methods in order to reveal visual element from a list of semantic element. + * + */ + +public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implements IRevealSemanticElement { + + public SynchronizableGmfDiagramEditor(boolean hasFlyoutPalette) { + super(hasFlyoutPalette); + } + + + /** + * reveal all editpart that represent an element in the given list. + * @see org.eclipse.papyrus.infra.core.ui.IRevealSemanticElement#revealSemanticElement(java.util.List) + * + */ + public void revealSemanticElement(List elementList) { + //create an instance that can get semantic element from gmf + SemanticFromGMFElement semanticFromGMFElement= new SemanticFromGMFElement(); + + // get the graphical viewer + GraphicalViewer graphicalViewer =getGraphicalViewer() ; + if( graphicalViewer!=null){ + + //look for among all edit part if the semantic is contained in the list + Iterator iter=graphicalViewer.getEditPartRegistry().values().iterator(); + IGraphicalEditPart researchedEditPart=null; + while(iter.hasNext()&& researchedEditPart==null) { + Object currentEditPart = (Object)iter.next(); + //look for only among IPrimary editpart to avoid compartment and labels of links + if(currentEditPart instanceof IPrimaryEditPart){ + if(elementList.contains(semanticFromGMFElement.getSemanticElement(currentEditPart))){ + researchedEditPart=((IGraphicalEditPart)currentEditPart);} + } + + } + //an editpart has been found so put selection on it. + if(researchedEditPart!=null){ + graphicalViewer.select(researchedEditPart); + } + } + } + + /** + * Configures my diagram edit domain with its command stack. + * This method has been completely overridden in order to use a proxy stack. + */ + @Override + protected void configureDiagramEditDomain() { + + DefaultEditDomain editDomain = getEditDomain(); + + if(editDomain != null) { + CommandStack stack = editDomain.getCommandStack(); + if(stack != null) { + // dispose the old stack + stack.dispose(); + } + + // create and assign the new stack + CheckedDiagramCommandStack diagramStack = new CheckedDiagramCommandStack(getDiagramEditDomain()); + + editDomain.setCommandStack(diagramStack); + } + + DiagramEditDomain diagEditDomain = (DiagramEditDomain)getDiagramEditDomain(); + diagEditDomain.setActionManager(createActionManager()); + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/UMLDiagramEditorUtil.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/UMLDiagramEditorUtil.java new file mode 100644 index 00000000000..29d549ca7a6 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.adaptor.gmf/src/org/eclipse/papyrus/infra/core/adaptor/gmf/UMLDiagramEditorUtil.java @@ -0,0 +1,37 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.adaptor.gmf; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.xmi.XMLResource; + +/** + * @generated + */ +public class UMLDiagramEditorUtil { + + /** + * @generated + */ + public static Map getSaveOptions() { + Map saveOptions = new HashMap(); + saveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$ + saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); + return saveOptions; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.log/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core.log/META-INF/MANIFEST.MF index f4dc9b1fa38..35ff14081d5 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.log/META-INF/MANIFEST.MF +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.log/META-INF/MANIFEST.MF @@ -1,12 +1,12 @@ Manifest-Version: 1.0 -Export-Package: org.eclipse.papyrus.log +Export-Package: org.eclipse.papyrus.infra.core.log Require-Bundle: org.eclipse.core.runtime Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-Version: 0.9.0.qualifier Bundle-Localization: plugin Bundle-Name: %pluginName -Bundle-Activator: org.eclipse.papyrus.log.internal.Activator +Bundle-Activator: org.eclipse.papyrus.infra.core.log.internal.Activator Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.papyrus.infra.core.log Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/infra/core/log/LogHelper.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/infra/core/log/LogHelper.java new file mode 100644 index 00000000000..33a5ae706b0 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/infra/core/log/LogHelper.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * 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.infra.core.log; + +import java.lang.reflect.InvocationTargetException; +import java.util.logging.Logger; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Status; + +/** + * A Log Helper. + * + * @author tszadel + * + */ +public class LogHelper { + + /** The plugin Id. */ + private String pluginId; + + /** The plugin related to that helper. */ + private Plugin activator; + + + + /** + * Default Constructor. + * The associated plugin can be set later. + * If no plugin is set, use java log. + */ + public LogHelper() { + } + + /** + * Constructor. + * + * @param activator + * The activator. + */ + public LogHelper(Plugin activator) { + setPlugin(activator); + } + + /** + * Set the associated plugin. + * This plugin log will be used as log. + * @param activator + */ + public void setPlugin( Plugin activator ) { + this.pluginId = activator.getBundle().getSymbolicName(); + this.activator = activator; + } + + /** + * Log an informative message into the Eclipse log file + * + * @param message + * the message to log + */ + public void info(String message) { + log(message, IStatus.INFO); + } + + /** + * Log a debug message into the Eclipse log file + * + * @param message + * the message to log + */ + public void debug(String message) { + if(isDebugEnabled()) { + log("[DEBUG] " + message, IStatus.INFO); + } + } + + /** + * Test if the platform is in debug mode. + * + * @return True if the platform is in debug mode. + */ + public boolean isDebugEnabled() { + if( activator != null) + return Platform.inDebugMode(); + + return false; + } + + /** + * Log a message with given level into the Eclipse log file + * + * @param message + * the message to log + * @param level + * the message priority + */ + private void log(String message, int level) { + log( new Status(level, pluginId, message )); + } + + /** + * + * @param status + */ + private void log( IStatus status ) { + + if( activator == null) { + // TODO Do log with java ? + } + else { + activator.getLog().log(status ); + } + } + + /** + * Log a warning message. + * + * @param e + * the exception to log + */ + public void warn(String message) { + log(message, IStatus.WARNING); + } + + + /** + * Log an exception into the Eclipse log file + * + * @param e + * the exception to log + */ + public void error(Throwable e) { + error("Unexpected Error", e); + } + + /** + * Log an exception into the Eclipse log file + * + * @param message + * the message + * @param e + * the exception to log + */ + public void error(String message, Throwable e) { + + Throwable t = e; + if(e instanceof InvocationTargetException) { + t = ((InvocationTargetException)e).getTargetException(); + } + + IStatus status; + if(t instanceof CoreException) { + status = ((CoreException)t).getStatus(); + } else { + status = new Status(IStatus.ERROR, pluginId, message, e); + } + + log(status); + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/infra/core/log/internal/Activator.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/infra/core/log/internal/Activator.java new file mode 100644 index 00000000000..384c6029c5e --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/infra/core/log/internal/Activator.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * 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.infra.core.log.internal; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends Plugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.log"; + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.Plugin#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; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/log/LogHelper.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/log/LogHelper.java deleted file mode 100644 index 5db8c6fc71a..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/log/LogHelper.java +++ /dev/null @@ -1,171 +0,0 @@ -/******************************************************************************* - * 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.log; - -import java.lang.reflect.InvocationTargetException; -import java.util.logging.Logger; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Status; - -/** - * A Log Helper. - * - * @author tszadel - * - */ -public class LogHelper { - - /** The plugin Id. */ - private String pluginId; - - /** The plugin related to that helper. */ - private Plugin activator; - - - - /** - * Default Constructor. - * The associated plugin can be set later. - * If no plugin is set, use java log. - */ - public LogHelper() { - } - - /** - * Constructor. - * - * @param activator - * The activator. - */ - public LogHelper(Plugin activator) { - setPlugin(activator); - } - - /** - * Set the associated plugin. - * This plugin log will be used as log. - * @param activator - */ - public void setPlugin( Plugin activator ) { - this.pluginId = activator.getBundle().getSymbolicName(); - this.activator = activator; - } - - /** - * Log an informative message into the Eclipse log file - * - * @param message - * the message to log - */ - public void info(String message) { - log(message, IStatus.INFO); - } - - /** - * Log a debug message into the Eclipse log file - * - * @param message - * the message to log - */ - public void debug(String message) { - if(isDebugEnabled()) { - log("[DEBUG] " + message, IStatus.INFO); - } - } - - /** - * Test if the platform is in debug mode. - * - * @return True if the platform is in debug mode. - */ - public boolean isDebugEnabled() { - if( activator != null) - return Platform.inDebugMode(); - - return false; - } - - /** - * Log a message with given level into the Eclipse log file - * - * @param message - * the message to log - * @param level - * the message priority - */ - private void log(String message, int level) { - log( new Status(level, pluginId, message )); - } - - /** - * - * @param status - */ - private void log( IStatus status ) { - - if( activator == null) { - // TODO Do log with java ? - } - else { - activator.getLog().log(status ); - } - } - - /** - * Log a warning message. - * - * @param e - * the exception to log - */ - public void warn(String message) { - log(message, IStatus.WARNING); - } - - - /** - * Log an exception into the Eclipse log file - * - * @param e - * the exception to log - */ - public void error(Throwable e) { - error("Unexpected Error", e); - } - - /** - * Log an exception into the Eclipse log file - * - * @param message - * the message - * @param e - * the exception to log - */ - public void error(String message, Throwable e) { - - Throwable t = e; - if(e instanceof InvocationTargetException) { - t = ((InvocationTargetException)e).getTargetException(); - } - - IStatus status; - if(t instanceof CoreException) { - status = ((CoreException)t).getStatus(); - } else { - status = new Status(IStatus.ERROR, pluginId, message, e); - } - - log(status); - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/log/internal/Activator.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/log/internal/Activator.java deleted file mode 100644 index e40f9fbc22d..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.log/src/org/eclipse/papyrus/log/internal/Activator.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * 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.log.internal; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends Plugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.log"; - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.Plugin#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; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/.project b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/.project index ebd7fbdba7e..46189987209 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/.project +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/.project @@ -1,6 +1,6 @@ - org.eclipse.papyrus.infra.sasheditor.di + org.eclipse.papyrus.infra.core.sasheditor.di diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/META-INF/MANIFEST.MF index be0aa23f171..1fd48589df7 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/META-INF/MANIFEST.MF +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/META-INF/MANIFEST.MF @@ -1,19 +1,19 @@ Manifest-Version: 1.0 Require-Bundle: org.eclipse.swt;bundle-version="3.5.0";visibility:=reexport, - org.eclipse.papyrus.infra.sasheditor;bundle-version="0.9.0";visibility:=reexport, + org.eclipse.papyrus.infra.core.sasheditor;bundle-version="0.9.0";visibility:=reexport, org.eclipse.ui;bundle-version="3.6.0", org.eclipse.core.runtime;bundle-version="3.6.0", org.eclipse.emf.ecore;visibility:=reexport, org.eclipse.emf.ecore.xmi;bundle-version="2.5.0", org.eclipse.emf.transaction;bundle-version="1.4.0", org.eclipse.gmf.runtime.notation;bundle-version="1.5.0" -Export-Package: org.eclipse.papyrus.sasheditor.contentprovider.di, - org.eclipse.papyrus.sasheditor.contentprovider.di.commands, - org.eclipse.papyrus.sasheditor.contentprovider.di.utils, - org.eclipse.papyrus.sashwindows.di, - org.eclipse.papyrus.sashwindows.di.exception, - org.eclipse.papyrus.sashwindows.di.impl, - org.eclipse.papyrus.sashwindows.di.util +Export-Package: org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider, + org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.commands, + org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.utils, + org.eclipse.papyrus.infra.core.sashwindows.di, + org.eclipse.papyrus.infra.core.sashwindows.di.exception, + org.eclipse.papyrus.infra.core.sashwindows.di.impl, + org.eclipse.papyrus.infra.core.sashwindows.di.util Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-ClassPath: . @@ -21,6 +21,6 @@ Bundle-Version: 0.9.0.qualifier Bundle-Localization: plugin Bundle-Name: %pluginName Bundle-ManifestVersion: 2 -Bundle-SymbolicName: org.eclipse.papyrus.infra.sasheditor.di;singleton:=true +Bundle-SymbolicName: org.eclipse.papyrus.infra.core.sasheditor.di;singleton:=true Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/antBuild.xml b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/antBuild.xml index 35ad5315f91..e332a1d501d 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/antBuild.xml +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/antBuild.xml @@ -4,7 +4,7 @@ - + diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/DiSashModelMngr.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/DiSashModelMngr.java new file mode 100644 index 00000000000..cc22d3b7b16 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/DiSashModelMngr.java @@ -0,0 +1,235 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider; + +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedProvider; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.ContentChangedEventProvider; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.DiContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.PageMngrImpl; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr; +import org.eclipse.papyrus.infra.core.sashwindows.di.util.DiUtils; + +/** + * Class used as main entry point to access a sash model build on EMF / di + * + * @author cedric dumoulin + */ +public class DiSashModelMngr { + + /** The EMF model used to store the sash windows structure and pages */ + protected SashWindowsMngr sashWindowMngr; + + /** + * Instance of the pageMngr. + */ + private PageMngrImpl pageMngr = null; + + /** + * Instance of the DiContentProvider used to manipulate SashModel. + */ + private DiContentProvider contentProvider; + + /** + * Object used externally listen to model changes. The object is also used + * internally to control how events are fired (limit multiple events). + */ + protected ContentChangedEventProvider contentChangedEventProvider; + + /** The factory used to create IPageModel */ + private IPageModelFactory pageModelFactory; + + /** + * Constructor. Create a DiSashModelMngr with the specified factory. A + * SashModel is created but not attached to a resource. This constructor is + * for subclasses. The subclasses should initialize the sashWindowMngr + * + * @param pageModelFactory + * @param createDefaultSashModel + * If true, create the default SashModel by calling {@link #createDefaultSashModel()} + */ + protected DiSashModelMngr(IPageModelFactory pageModelFactory, boolean createDefaultSashModel) { + this.pageModelFactory = pageModelFactory; + // Create a SashModel + if(createDefaultSashModel) { + sashWindowMngr = createDefaultSashModel(); + } + } + + /** + * Constructor. Create a DiSashModelMngr with the specified factory. A + * SashModel is created but not attached to a resource. + * + * @param pageModelFactory + */ + public DiSashModelMngr(IPageModelFactory pageModelFactory) { + this.pageModelFactory = pageModelFactory; + // Create a SashModel + sashWindowMngr = createDefaultSashModel(); + } + + /** + * Constructor. Create a DiSashModelMngr with the specified factory. The + * SashModel is searched in the Resource. If not found, create one in the + * resource. + * + * @param pageModelFactory + * @param diResource + */ + public DiSashModelMngr(IPageModelFactory pageModelFactory, Resource diResource) { + this.pageModelFactory = pageModelFactory; + + // lookup the SashModel + sashWindowMngr = lookupSashWindowMngr(diResource); + if(sashWindowMngr == null) { + // Create a default model and attach it to resource. + sashWindowMngr = createDefaultSashModel(); + diResource.getContents().add(sashWindowMngr); + } + } + + /** + * Constructor. Create a DiSashModelMngr with the specified factory and + * sashModel. + * + * @param pageModelFactory + * @param sashModel + */ + public DiSashModelMngr(IPageModelFactory pageModelFactory, SashWindowsMngr sashModel) { + this.pageModelFactory = pageModelFactory; + this.sashWindowMngr = sashModel; + } + + /** + * Get the internal EMF implementation. Intended to be used by tests. + * + * @return the sashWindowMngr + */ + protected SashWindowsMngr getDiSashWindowsMngr() { + return sashWindowMngr; + } + + /** + * Return the internal implementation of ContentProvider. Create if if + * needed. This method should not be subclassed + * + * @return the contentProvider + */ + protected final DiContentProvider getDiContentProvider() { + if(contentProvider == null) { + contentProvider = new DiContentProvider(sashWindowMngr.getSashModel(), pageModelFactory, getContentChangedEventProvider()); + } + return contentProvider; + } + + /** + * Return the internal implementation of PageMngr. Create if if needed. This + * method should not be subclassed + * + * @return the PageMngrImpl + */ + protected final PageMngrImpl getPageMngrImpl() { + if(pageMngr == null) { + pageMngr = new PageMngrImpl(sashWindowMngr, getContentChangedEventProvider()); + } + + return pageMngr; + } + + /** + * Return the internal implementation of ContentChangedEventProvider. Create + * if if needed. This method should not be subclassed + * + * @return the PageMngrImpl + */ + protected final ContentChangedEventProvider getContentChangedEventProvider() { + if(contentChangedEventProvider == null) { + contentChangedEventProvider = new ContentChangedEventProvider(sashWindowMngr); + } + + return contentChangedEventProvider; + } + + /** + * Get the IPageMngr providing basic methods to manage Pages in the sash + * model. + * + * @return + */ + public IPageMngr getIPageMngr() { + return getPageMngrImpl(); + } + + /** + * Get the ContentProvider used by the SashWindows system. This class can + * also be used to accurately manage the sash model. + * + * @return + */ + public ISashWindowsContentProvider getISashWindowsContentProvider() { + + return getDiContentProvider(); + + } + + /** + * Get the ContentChangedProvider for the SashModel + * + * @return + */ + public IContentChangedProvider getSashModelContentChangedProvider() { + return getContentChangedEventProvider(); + } + + /** + * Create a default model with one window and one folder. + * + * @param diResource + * @return + */ + protected SashWindowsMngr createDefaultSashModel() { + return DiUtils.createDefaultSashWindowsMngr(); + } + + /** + * Lookup for the SashModel object in the resource + * + * @param diResource + * @return + */ + protected SashWindowsMngr lookupSashWindowMngr(Resource diResource) { + + return DiUtils.lookupSashWindowsMngr(diResource); + } + + /** + * Create an instance of IPageMngr acting on the provided resource. This + * instance is suitable to add, remove, close or open diagrams. + * + * @param diResource + * @return The non transactional version of the IPageMngr + */ + public static IPageMngr createIPageMngr(Resource diResource) { + + // Create an instance of the DiSashModelMngr with no factory. + // The factory is not needed since we don't get the + // ISashWindowsContentProvider. + return new DiSashModelMngr(null, diResource).getIPageMngr(); + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/IPageModelFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/IPageModelFactory.java new file mode 100644 index 00000000000..0359df0d9e5 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/IPageModelFactory.java @@ -0,0 +1,40 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; + +/** + * Factory used to create IPageModel from an object identifying a page. + * IPageModel are objects used by the Sash Windows to create a page. + * + * @author cedric dumoulin + */ +public interface IPageModelFactory { + + /** + * Create the IPageModel for the pageIdentifier. The pageIdentifier is the + * object passed to the {@link IPageMngr#addEditor(EObject)}. This factory + * method is called by the Sash Windows whenever it needs to create a page. + * The identifier is found in the sash model. + * + * @param pageIdentifier + * The identifier identifying the page to create. + * @return + */ + public IPageModel createIPageModel(Object pageIdentifier); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/TransactionalDiSashModelMngr.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/TransactionalDiSashModelMngr.java new file mode 100644 index 00000000000..87888ff0681 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/TransactionalDiSashModelMngr.java @@ -0,0 +1,132 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider; + +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.TransactionalDiContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.TransactionalPageMngrImpl; + +/** + * DiSashModelMngr providing transactional commands to modify SashModel. + * + * @author cedric dumoulin + * + */ +public class TransactionalDiSashModelMngr extends DiSashModelMngr { + + private TransactionalDiContentProvider transDiContentProvider; + + private TransactionalPageMngrImpl transPageMngrImpl; + + /** + * + * Constructor. + * + * @param pageModelFactory + * @param diResource + */ + public TransactionalDiSashModelMngr(IPageModelFactory pageModelFactory, final Resource diResource, TransactionalEditingDomain editingDomain) { + super(pageModelFactory, false); + + // lookup the SashModel + sashWindowMngr = lookupSashWindowMngr(diResource); + // If no SashWindow structure is found, create a new one using a + // transaction. + if(sashWindowMngr == null) { + RecordingCommand command = new RecordingCommand(editingDomain) { + + @Override + protected void doExecute() { + // Create a default model and attach it to resource. + sashWindowMngr = createDefaultSashModel(); + diResource.getContents().add(sashWindowMngr); + } + }; + editingDomain.getCommandStack().execute(command); + } + + // Create the TransactionalDiContentProvider + transDiContentProvider = new TransactionalDiContentProvider(getDiContentProvider(), editingDomain); + + // Create the TransactionalPageMngrImpl + transPageMngrImpl = new TransactionalPageMngrImpl(getPageMngrImpl(), editingDomain); + } + + /** + * + * Constructor. Only create a {@link IPageMngr} impl. Do not create the + * DiContentProvider as there is no factory provided. Internal use. + * + * @param pageModelFactory + * @param diResource + */ + private TransactionalDiSashModelMngr(final Resource diResource, TransactionalEditingDomain editingDomain) { + super(null, false); + + // lookup the SashModel + sashWindowMngr = lookupSashWindowMngr(diResource); + // If no SashWindow structure is found, create a new one using a + // transaction. + if(sashWindowMngr == null) { + RecordingCommand command = new RecordingCommand(editingDomain) { + + @Override + protected void doExecute() { + // Create a default model and attach it to resource. + sashWindowMngr = createDefaultSashModel(); + diResource.getContents().add(sashWindowMngr); + } + }; + editingDomain.getCommandStack().execute(command); + } + + // Create the TransactionalPageMngrImpl + transPageMngrImpl = new TransactionalPageMngrImpl(getPageMngrImpl(), editingDomain); + } + + /** + * Return the transactional version + * + * @see org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelMngr#getISashWindowsContentProvider() + * @return + * + */ + @Override + public ISashWindowsContentProvider getISashWindowsContentProvider() { + return transDiContentProvider; + } + + /** + * Return the transactional version + * + * @see org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelMngr#getIPageMngr() + * + * @return + */ + @Override + public IPageMngr getIPageMngr() { + return transPageMngrImpl; + } + + /** + * Create an instance of IPageMngr acting on the provided resource. This + * instance is suitable to add, remove, close or open diagrams. + * + * @param diResource + * @return The non transactional version of the IPageMngr + */ + public static IPageMngr createIPageMngr(Resource diResource, TransactionalEditingDomain editingDomain) { + + // Create an instance of the DiSashModelMngr with no factory. + // The factory is not needed since we don't get the + // ISashWindowsContentProvider. + return new TransactionalDiSashModelMngr(diResource, editingDomain).getIPageMngr(); + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseAllDiagramsCommand.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseAllDiagramsCommand.java new file mode 100644 index 00000000000..997ff32487c --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseAllDiagramsCommand.java @@ -0,0 +1,77 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.commands; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * A command to be used with the Eclipse Commands Framework. This command allows + * to close all diagrams openened in the current SashContainer implemented on + * di. + * + * @author cedric dumoulin + * + */ +public class CloseAllDiagramsCommand extends AbstractHandler { + + /** + * Check if the Command is enabled. + */ + @Override + public void setEnabled(Object evaluationContext) { + // System.out.println("call to CloseAllDiagramsCommand.setEnable(" + + // evaluationContext + ")"); + } + + /** + * Execute the command. This method is called when the action is triggered. + * + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + + IPageMngr pageMngr; + try { + pageMngr = getPageMngr(event); + } catch (NullPointerException e) { + // PageMngr can't be found + return null; + } + execute(pageMngr); + + return null; + } + + /** + * Get the PageMngr used to interact with the content provider. + * + * @param event + * @return + * @throws NullPointerException + * if the PageMngr can't be found. + */ + private IPageMngr getPageMngr(ExecutionEvent event) { + + IEditorPart part = HandlerUtil.getActiveEditor(event); + IPageMngr pageMngr = (IPageMngr)part.getAdapter(IPageMngr.class); + + return pageMngr; + + } + + /** + * Close all the diagrams. + * + * @param pageMngr + */ + public void execute(IPageMngr pageMngr) { + + pageMngr.closeAllOpenedPages(); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseDiagramCommand.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseDiagramCommand.java new file mode 100644 index 00000000000..16d9ea06138 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseDiagramCommand.java @@ -0,0 +1,72 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.commands; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * A command to be used with the Eclipse Commands Framework. This command is to + * be used with {@link SashWindowsContainer} implemented with the Di model. This + * command allows to close the currently openened diagram. + * + * @author cedric dumoulin + * + */ +public class CloseDiagramCommand extends AbstractHandler { + + /** + * Check if the Command is enabled. + */ + @Override + public void setEnabled(Object evaluationContext) { + // System.out.println("call to CloseDiagramCommand.setEnable(" + + // evaluationContext + ")"); + } + + /** + * Execute the command. This method is called when the action is triggered. + * + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + + try { + IEditorPart part = HandlerUtil.getActiveEditor(event); + IPageMngr pageMngr = (IPageMngr)part.getAdapter(IPageMngr.class); + ISashWindowsContainer container = (ISashWindowsContainer)part.getAdapter(ISashWindowsContainer.class); + Object pageIdentifier = container.getActiveSashWindowsPage().getRawModel(); + // Bug from sash Di to be corrected + if(pageIdentifier instanceof PageRef) { + pageIdentifier = ((PageRef)pageIdentifier).getPageIdentifier(); + } + + execute(pageMngr, pageIdentifier); + + } catch (NullPointerException e) { + // PageMngr can't be found + return null; + } + + return null; + } + + /** + * Close selected page. + * + * @param pageMngr + */ + public void execute(IPageMngr pageMngr, Object pageIdentifier) { + + if(pageMngr.isOpen(pageIdentifier)) { + pageMngr.closePage(pageIdentifier); + } + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseOtherDiagramsCommand.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseOtherDiagramsCommand.java new file mode 100644 index 00000000000..f0030935646 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseOtherDiagramsCommand.java @@ -0,0 +1,70 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.commands; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * A command to be used with the Eclipse Commands Framework. This command is to + * be used with {@link SashWindowsContainer} implemented with the Di model. This + * command allows to close all diagrams in the folder, except the currently + * openened one. + * + * @author cedric dumoulin + * + */ +public class CloseOtherDiagramsCommand extends AbstractHandler { + + /** + * Check if the Command is enabled. + */ + @Override + public void setEnabled(Object evaluationContext) { + // System.out.println("call to CloseDiagramCommand.setEnable(" + + // evaluationContext + ")"); + } + + /** + * Execute the command. This method is called when the action is triggered. + * + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + + try { + IEditorPart part = HandlerUtil.getActiveEditor(event); + IPageMngr pageMngr = (IPageMngr)part.getAdapter(IPageMngr.class); + ISashWindowsContainer container = (ISashWindowsContainer)part.getAdapter(ISashWindowsContainer.class); + Object pageIdentifier = container.getActiveSashWindowsPage().getRawModel(); + // Bug from sash Di to be corrected + if(pageIdentifier instanceof PageRef) { + pageIdentifier = ((PageRef)pageIdentifier).getPageIdentifier(); + } + execute(pageMngr, pageIdentifier); + + } catch (NullPointerException e) { + // PageMngr can't be found + return null; + } + + return null; + } + + /** + * Close selected page. + * + * @param pageMngr + */ + public void execute(IPageMngr pageMngr, Object pageIdentifier) { + + pageMngr.closeOtherPages(pageIdentifier); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/ContentChangedEventProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/ContentChangedEventProvider.java new file mode 100644 index 00000000000..4fd2f8b2e05 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/ContentChangedEventProvider.java @@ -0,0 +1,198 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.util.EContentAdapter; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedListener; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedProvider; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedListener.ContentEvent; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr; +import org.eclipse.papyrus.infra.core.sashwindows.di.Window; + +/** + * A class listening on changes on the internal model and delivering events to + * registered listeners. + * + * @author cedric dumoulin + * + */ +public class ContentChangedEventProvider implements IContentChangedProvider { + + private List listeners; + + /** Is this mngr delivering events ? */ + private boolean isDeliverEnable = true; + + /** Last event stored when isDeliverEnable == false; */ + private ContentEvent storedEvent; + + private EMFAdapter emfAdapter = new EMFAdapter(); + + /** + * The model firing events + */ + private SashModel diSashModel; + + /** + * + * Constructor. + * + * @param diSashModel + */ + public ContentChangedEventProvider(SashModel diSashModel) { + this.diSashModel = diSashModel; + activate(); + } + + /** + * + * Constructor. + * + * @param diSashModel + */ + public ContentChangedEventProvider(SashWindowsMngr sashWindowMngr) { + this(sashWindowMngr.getSashModel()); + } + + /** + * Connect EMF changeListener to the {@link ContentChangeListenerManager}. + * Changes in the EMF di model will be fired by the + * ContentChangeListenerManager. + */ + protected void activate() { + diSashModel.eAdapters().add(emfAdapter); + setDeliver(true); + } + + protected void deactivate() { + setDeliver(false); + diSashModel.eAdapters().remove(emfAdapter); + } + + /** + * @return the isDeliverEnable + */ + protected boolean isDeliver() { + return isDeliverEnable; + } + + /** + * @param isDeliverEnable + * the isDeliverEnable to set + */ + protected void setDeliver(boolean isDeliverEnable) { + + if(this.isDeliverEnable == isDeliverEnable) + return; + + // Check if the old value is not delivering event + if(!this.isDeliverEnable) { + this.isDeliverEnable = true; + // reenable events. Check if an event is stored + if(storedEvent != null) + fireContentChanged(storedEvent); + + } else + this.isDeliverEnable = isDeliverEnable; + + storedEvent = null; + } + + /** + * Add a listener listening on content changed. This listener will be + * notified each time the content change. + * + * @param listener + */ + public void addListener(IContentChangedListener listener) { + if(listeners == null) + createListeners(); + + // Check if already exists. + if(listeners.contains(listener)) + return; + + listeners.add(listener); + } + + /** + * Add a listener listening on content changed. This listener will be + * notified each time the content change. + * + * @param listener + */ + public void removeListener(IContentChangedListener listener) { + if(listeners == null) + return; + + listeners.remove(listener); + } + + /** + * Create the list of listeners. + */ + private void createListeners() { + if(listeners == null) + listeners = new ArrayList(); + + } + + /** + * Fire the changed event. + * + * @param event + */ + protected void fireContentChanged(ContentEvent event) { + if(listeners == null) + return; + + if(!isDeliverEnable) { + storedEvent = event; + return; + } + + for(IContentChangedListener listener : listeners) { + listener.contentChanged(event); + } + } + + /** + * Change event Adapter. Forward EMF changeEvent to the {@link ContentChangeListenerManager}. + * + * @author cedric dumoulin + */ + public class EMFAdapter extends EContentAdapter { + + /** + * ContentProvider Model has changed. Changes includes : ADD, REMOVE and + * MOVE of elements + * + * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification) + * + * @param msg + */ + @Override + public void notifyChanged(Notification msg) { + super.notifyChanged(msg); + + // Filter out notification of type RESOLVE + // We don't need to be noti + if(msg.getEventType() == Notification.RESOLVE) + return; + + // W + Object sender = msg.getNotifier(); + if(sender instanceof AbstractPanel || sender instanceof Window || sender instanceof PageRef) + fireContentChanged(new ContentEvent(msg.getEventType(), sender, null)); + } + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/DiContentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/DiContentProvider.java new file mode 100644 index 00000000000..894faa2455f --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/DiContentProvider.java @@ -0,0 +1,288 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedListener.ContentEvent; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IPageModelFactory; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiFactory; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder; + +/** + * EMF implementation of the {@link ISashWindowsContentProvider}. + * + * @author dumoulin + */ +public class DiContentProvider implements ISashWindowsContentProvider { + + /** Internal EMF model */ + private SashModel diSashModel; + + /** Factory used to create SWT Editor or Component from Page Identifiers. */ + private IPageModelFactory pageModelFactory; + + /** + * Object delivering event to listeners. Used to control how the events are + * triggered + */ + private ContentChangedEventProvider contentChangedEventProvider; + + /** + * Create a ContentProvider + * + * @param diSashModel + * @param pageModelFactory + * The factory that will be used when a page will be created. + * @throws IllegalArgumentException + * If the factory is null. + */ + public DiContentProvider(SashModel diSashModel, IPageModelFactory pageModelFactory) throws IllegalArgumentException { + + this(diSashModel, pageModelFactory, new ContentChangedEventProvider(diSashModel)); + } + + /** + * Create a ContentProvider + * + * @param diSashModel + * @param pageModelFactory + * The factory that will be used when a page will be created. + * @throws IllegalArgumentException + * If the factory is null. + */ + public DiContentProvider(SashModel diSashModel, IPageModelFactory pageModelFactory, ContentChangedEventProvider contentChangedEventProvider) throws IllegalArgumentException { + + if(pageModelFactory == null) + throw new IllegalArgumentException("A IPageModelFactory should be provided."); + + this.diSashModel = diSashModel; + this.pageModelFactory = pageModelFactory; + this.contentChangedEventProvider = contentChangedEventProvider; + } + + /** + * Access to internal structure for tests. This method is not intended to be + * used for other purpose. + * + * @return the diSashModel + */ + protected SashModel getDiSashModel() { + return diSashModel; + } + + /** + * @return the contentChangedEventProvider + */ + protected ContentChangedEventProvider getContentChangedEventProvider() { + return contentChangedEventProvider; + } + + /** + * Add a page identifier to the SashModel. This page identifier will be + * added as "child" of the current TabFolder. + * + * @param pageIdentifier + */ + public void addPage(Object pageIdentifier) { + diSashModel.addPage(pageIdentifier); + } + + /** + * Add a page to the current folder. Create the Page (Editor or Component) + * with the help of the factory. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#addPage(int, + * org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel) + * + * @param index + * @param tabItem + */ + public void addPage(Object page, int index) { + + throw new UnsupportedOperationException("Not yet implemented."); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#createFolder(org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel, + * int, org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel, int) + * + * @param tabFolder + * @param tabIndex + * @param targetFolder + * @param side + * @return + */ + public void createFolder(ITabFolderModel tabFolder, int tabIndex, ITabFolderModel targetFolder, int side) { + + // disable fired events + contentChangedEventProvider.setDeliver(false); + // Create new folder. Parent will be set when inserted. + TabFolder newFolder = DiFactory.eINSTANCE.createTabFolder(); + + TabFolder refFolder = ((TabFolderModel)targetFolder).getTabFolder(); + TabFolder pageSrcFolder = ((TabFolderModel)tabFolder).getTabFolder(); + + // Insert folder + diSashModel.insertFolder(newFolder, refFolder, side); + // Move tab from folder to folder + diSashModel.movePage(pageSrcFolder, tabIndex, newFolder); + // Remove unused folder if necessary + diSashModel.removeEmptyFolder(pageSrcFolder); + diSashModel.setCurrentSelection(newFolder); + + // Reenable events, and fire the last one + contentChangedEventProvider.setDeliver(true); + + } + + /** + * Set the current folder. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#setCurrentFolder(java.lang.Object) + * + * @param rawModel + * The object identifying the folder. + */ + public void setCurrentFolder(Object rawModel) { + + if(!(rawModel instanceof TabFolder)) { + return; + } + diSashModel.setCurrentSelection((TabFolder)rawModel); + } + + /** + * Get the node used as root of the SashWindows. For now, this is the first + * window. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#getRootModel() + * + * @return + */ + public Object getRootModel() { + // Get the first window. + return diSashModel.getWindows().get(0).getPanel(); + } + + /** + * Create the IPanelModel for the rootModel returned by {@link DiContentProvider#getRootModel()}. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#createChildSashModel(java.lang.Object) + * + * @param root + * @return + */ + public IAbstractPanelModel createChildSashModel(Object root) { + + if(root instanceof SashPanel) + return new SashPanelModel((SashPanel)root, pageModelFactory); + else if(root instanceof TabFolder) + return new TabFolderModel((TabFolder)root, pageModelFactory); + else + throw new IllegalArgumentException("Can't create IPanelModel from raw model '" + root + "'."); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#movePage(org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel, + * int, int) + * + * @param folderModel + * @param oldIndex + * @param newIndex + */ + public void movePage(ITabFolderModel folderModel, int oldIndex, int newIndex) { + TabFolder folder = ((TabFolderModel)folderModel).getTabFolder(); + + contentChangedEventProvider.setDeliver(false); + folder.movePage(oldIndex, newIndex); + diSashModel.setCurrentSelection(folder); + contentChangedEventProvider.setDeliver(true); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#movePage(org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel, + * int, org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel, int) + * + * @param srcFolderModel + * @param sourceIndex + * @param targetFolderModel + * @param targetIndex + */ + public void movePage(ITabFolderModel srcFolderModel, int sourceIndex, ITabFolderModel targetFolderModel, int targetIndex) { + + TabFolder srcFolder = ((TabFolderModel)srcFolderModel).getTabFolder(); + TabFolder targetFolder = ((TabFolderModel)targetFolderModel).getTabFolder(); + + contentChangedEventProvider.setDeliver(false); + diSashModel.movePage(srcFolder, sourceIndex, targetFolder, targetIndex); + diSashModel.removeEmptyFolder(srcFolder); + diSashModel.setCurrentSelection(targetFolder); + contentChangedEventProvider.setDeliver(true); + + } + + /** + * Remove specified page from the current folder. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#removePage(int) + * + * @param index + */ + public void removePage(int index) { + diSashModel.removePage(index); + + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#removePage(org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel) + * + * @param tabItem + */ + public void removePage(Object page) { + throw new UnsupportedOperationException("Not yet implemented."); + + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#removePage(org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel, + * int) + * + * @param parentFolder + * @param tabIndex + */ + public void removePage(ITabFolderModel parentFolder, int tabIndex) { + TabFolder folder = ((TabFolderModel)parentFolder).getTabFolder(); + + contentChangedEventProvider.setDeliver(false); + folder.removePage(tabIndex); + diSashModel.removeEmptyFolder(folder); + contentChangedEventProvider.setDeliver(true); + } + + /** + * Add a listener listening on content changed. This listener will be + * notified each time the content change. + * + * @param listener + */ + protected void firePropertyChanged(ContentEvent event) { + contentChangedEventProvider.fireContentChanged(event); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageMngrImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageMngrImpl.java new file mode 100644 index 00000000000..23d568c6922 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageMngrImpl.java @@ -0,0 +1,373 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * Anass Radouani (Atos) - add history management + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Stack; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr; +import org.eclipse.ui.ISelectionService; +import org.eclipse.ui.PlatformUI; + +/** + * Implementation of the page manager. The page manager provides basic methods + * to access the DiSashModel and its PageList. This is the users interface to + * add, open, close and remove pages. + * + * @author cedric dumoulin + */ +public class PageMngrImpl implements IPageMngr { + + /** Internal EMF model */ + private SashWindowsMngr diSashModel; + + /** Contains the current page and previously opened pages */ + private Stack previousStack = new Stack(); + + private Stack nextStack = new Stack(); + + /** + * true when an update is currently performed to not add a page two times to + * the stack + */ + private boolean updating = false; + + /** true when a page closing is currently performed */ + private boolean closingPage = false; + + ContentChangedEventProvider contentChangedEventProvider; + + /** + * @return the updating + */ + public boolean isUpdating() { + return updating; + } + + /** + * @param updating + * the boolean to set + */ + public void setUpdating(boolean updating) { + this.updating = updating; + } + + /** + * @return the closingPage + */ + public boolean isClosingPage() { + return closingPage; + } + + /** + * @param closingPage + * the boolean to set + */ + public void setClosingPage(boolean closingPage) { + this.closingPage = closingPage; + } + + public PageMngrImpl(SashWindowsMngr diSashModel, ContentChangedEventProvider contentChangedEventProvider) { + this.diSashModel = diSashModel; + this.contentChangedEventProvider = contentChangedEventProvider; + if(diSashModel.getSashModel() != null && diSashModel.getSashModel().getCurrentSelection() != null && !diSashModel.getSashModel().getCurrentSelection().getChildren().isEmpty()) { + addToPreviousStack(diSashModel.getSashModel().getCurrentSelection().getChildren().get(0).getPageIdentifier()); + } + } + + /** + * Add a page to the PageList. Do not open the corresponding editor. The + * page will be visible in the list. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#addEditor(org.eclipse.emf.ecore.EObject) + * + * @param pageIdentifier + */ + public void addPage(Object pageIdentifier) { + + // We do not need to disable event delivering, + // as addition to pageList doesn't fire events. + diSashModel.getPageList().addPage(pageIdentifier); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#allPages() + * + * @return + */ + public List allPages() { + + // TODO : use and return a shadow list ? + List list = new ArrayList(); + for(PageRef pageRef : diSashModel.getPageList().getAvailablePage()) { + + list.add(pageRef.getPageIdentifier()); + } + + return list; + } + + /** + * Remove the page from the SashModel + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#closePage(org.eclipse.emf.ecore.EObject) + * + * @param pageIdentifier + */ + public void closePage(Object pageIdentifier) { + + contentChangedEventProvider.setDeliver(false); + diSashModel.getSashModel().removePage(pageIdentifier); + contentChangedEventProvider.setDeliver(true); + } + + /** + * Remove all pages from the SashModel. Left only the top level folder + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#closePage(org.eclipse.emf.ecore.EObject) + * + * @param pageIdentifier + */ + public void closeAllOpenedPages() { + + contentChangedEventProvider.setDeliver(false); + diSashModel.getSashModel().removeAllPages(); + contentChangedEventProvider.setDeliver(true); + + } + + /** + * Remove all pages from the SashModel. Left only the top level folder + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#closePage(org.eclipse.emf.ecore.EObject) + * + * @param pageIdentifier + */ + public void closeOtherPages(Object pageIdentifier) { + contentChangedEventProvider.setDeliver(false); + diSashModel.getSashModel().removeOtherPages(pageIdentifier); + contentChangedEventProvider.setDeliver(true); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#openPage(org.eclipse.emf.ecore.EObject) + * + * @param pageIdentifier + */ + public void openPage(Object pageIdentifier) { + // Add the page to the SashModel and to the PageList + + // We do not need to disable event delivering as the operation already + // fired + // one single event. + + addToPreviousStack(pageIdentifier); + + Iterator iterator = diSashModel.getPageList().getAvailablePage().iterator(); + boolean found = false; + while(iterator.hasNext() && found == false) { + // Bug #288806 : the test should be inversed + if(pageIdentifier.equals(iterator.next().getPageIdentifier())) { + found = true; + } + } + if(!found) { + diSashModel.getPageList().addPage(pageIdentifier); + } + diSashModel.getSashModel().addPage(pageIdentifier); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#openPage(org.eclipse.emf.ecore.EObject) + * + * @param pageIdentifier + */ + private void openPageWithoutStack(Object pageIdentifier) { + // Add the page to the SashModel and to the PageList + + // We do not need to disable event delivering as the operation already + // fired + // one single event. + Iterator iterator = diSashModel.getPageList().getAvailablePage().iterator(); + boolean found = false; + while(iterator.hasNext() && found == false) { + // Bug #288806 : the test should be inversed + if(pageIdentifier.equals(iterator.next().getPageIdentifier())) { + found = true; + } + } + if(!found) { + diSashModel.getPageList().addPage(pageIdentifier); + } + diSashModel.getSashModel().addPage(pageIdentifier); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#removePage(org.eclipse.emf.ecore.EObject) + * + * @param pageIdentifier + */ + public void removePage(Object pageIdentifier) { + // remove from pageList and from SashModel + diSashModel.getPageList().removePage(pageIdentifier); + + contentChangedEventProvider.setDeliver(false); + diSashModel.getSashModel().removePage(pageIdentifier); + contentChangedEventProvider.setDeliver(true); + } + + /** + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#isOpen(java.lang.Object) + * @param pageIdentifier + * @return + * + */ + public boolean isOpen(Object pageIdentifier) { + return diSashModel.getSashModel().lookupPage(pageIdentifier) != null; + } + + /** + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#openPrevious() + * + */ + public void openPrevious() { + + setUpdating(true); + + if(previousStack.size() > 1) { + nextStack.push(previousStack.pop()); + Object pageIdentifier = previousStack.peek(); + if(isOpen(pageIdentifier)) { + + closePage(pageIdentifier); + } + openPageWithoutStack(pageIdentifier); + } + + setUpdating(false); + } + + /** + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#openNext() + * + */ + public void openNext() { + setUpdating(true); + if(!nextStack.isEmpty()) { + Object pageIdentifier = nextStack.pop(); + previousStack.push(pageIdentifier); + if(isOpen(pageIdentifier)) { + closePage(pageIdentifier); + } + openPageWithoutStack(pageIdentifier); + } + setUpdating(false); + } + + /** + * Add a page to the previous Stack + * + * @param page + * the page to add + */ + private void addToPreviousStack(Object page) { + if(previousStack.isEmpty() || previousStack.peek() != page) { + if(!nextStack.isEmpty()) { + nextStack.clear(); + } + previousStack.push(page); + } + } + + public void pageChanged(IPage newPage) { + if(newPage != null) { + if(!isUpdating() && !isClosingPage()) { + Object md = newPage.getRawModel(); + if(md instanceof PageRef) { + Object page = ((PageRef)md).getPageIdentifier();// .getEmfPageIdentifier(); + addToPreviousStack(page); + } + } else if(!isUpdating() && isClosingPage()) { + setClosingPage(false); + Object md = newPage.getRawModel(); + if(md instanceof PageRef) { + Object page = ((PageRef)md).getPageIdentifier(); + if(!previousStack.isEmpty()) { + previousStack.pop(); + } + addToPreviousStack(page); + } + } + } + } + + /** + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#hasPreviousHistory() + * + */ + public boolean hasPreviousHistory() { + return previousStack.size() > 1; + } + + /** + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#hasNextHistory() + * + */ + public boolean hasNextHistory() { + return !nextStack.isEmpty(); + } + + /** + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#isInHsitory() + * + */ + public int isInHsitory(Object pageIdentifier) { + return previousStack.lastIndexOf(pageIdentifier); + } + + public void pageOpened(IPage page) { + setClosingPage(false); + } + + public void pageClosed(IPage page) { + setClosingPage(true); + } + + public void pageActivated(IPage page) { + } + + public void pageDeactivated(IPage page) { + } + + public void pageAboutToBeOpened(IPage page) { + } + + public void pageAboutToBeClosed(IPage page) { + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/SashPanelModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/SashPanelModel.java new file mode 100644 index 00000000000..a742519fef7 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/SashPanelModel.java @@ -0,0 +1,82 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal; + +import java.util.List; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IPageModelFactory; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder; + +/** + * @author cedric dumoulin + */ +public class SashPanelModel implements IAbstractPanelModel, ISashPanelModel { + + /** + * Factory used to create PageModel. + */ + private IPageModelFactory pageModelFactory; + + /** + * The underlying di node. + */ + private SashPanel sashPanel; + + /** + * + * @param sashPanel + */ + public SashPanelModel(SashPanel sashPanel, IPageModelFactory pageModelFactory) { + this.sashPanel = sashPanel; + this.pageModelFactory = pageModelFactory; + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel#getChildren() + * + * @return + */ + public List getChildren() { + return sashPanel.getChildren(); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel#createChildSashModel(java.lang.Object) + * + * @param child + * @return + */ + public IAbstractPanelModel createChildSashModel(Object child) { + if(child instanceof SashPanel) + return new SashPanelModel((SashPanel)child, pageModelFactory); + else if(child instanceof TabFolder) + return new TabFolderModel((TabFolder)child, pageModelFactory); + else + throw new IllegalArgumentException("Can't create IPanelModel from raw model '" + child + "'."); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel#getSashDirection() + * + * @return + */ + public int getSashDirection() { + return sashPanel.getDirection(); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TabFolderModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TabFolderModel.java new file mode 100644 index 00000000000..71e7a08e9f3 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TabFolderModel.java @@ -0,0 +1,81 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal; + +import java.util.List; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IPageModelFactory; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder; + +/** + * @author dumoulin + */ +public class TabFolderModel implements ITabFolderModel { + + /** + * The di Model. + */ + private TabFolder tabFolder; + + private IPageModelFactory pageModelFactory; + + /** + * + * @param root + */ + public TabFolderModel(TabFolder tabFolder, IPageModelFactory pageModelFactory) { + this.tabFolder = tabFolder; + this.pageModelFactory = pageModelFactory; + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel#getChildren() + * + * @return + */ + public List getChildren() { + return tabFolder.getChildren(); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel#createChildSashModel(java.lang.Object) + * + * @param child + * The child object returned by {@link TabFolderModel#getChildren} + * @return + */ + public IPageModel createChildSashModel(Object child) { + + PageRef pageRef = (PageRef)child; + + Object pageIdentifier = pageRef.getPageIdentifier(); + if(pageIdentifier != null) { + return pageModelFactory.createIPageModel(pageIdentifier); + } else { + return null; + } + } + + /** + * @return the tabFolder + */ + public TabFolder getTabFolder() { + return tabFolder; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalDiContentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalDiContentProvider.java new file mode 100644 index 00000000000..badba02fbaa --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalDiContentProvider.java @@ -0,0 +1,264 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal; + +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel; + +/** + * A content provider based on EMF di and using Transactions. This + * implementation is a wrapper on {@link DiContentProvider}. Each method is + * wrapped in a {@link RecordingCommand}. + * + * @author cedric dumoulin + * + */ +public class TransactionalDiContentProvider implements ISashWindowsContentProvider { + + /** + * wrapped ContentProvider. All commands will use this provider. + */ + private DiContentProvider diContentProvider; + + private TransactionalEditingDomain editingDomain; + + /** + * + * Constructor. + * + * @param diContentProvider + */ + public TransactionalDiContentProvider(DiContentProvider diContentProvider, TransactionalEditingDomain editingDomain) { + this.diContentProvider = diContentProvider; + this.editingDomain = editingDomain; + } + + /** + * Get the editing domain used to perform transactions. + * + * @return + */ + private TransactionalEditingDomain getTransactionalEditingDomain() { + return editingDomain; + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#addPage(java.lang.Object) + * @param page + * + */ + public void addPage(final Object page) { + TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); + + RecordingCommand command = new RecordingCommand(editingDomain) { + + @Override + protected void doExecute() { + diContentProvider.addPage(page); + + } + }; + + editingDomain.getCommandStack().execute(command); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#addPage(java.lang.Object, int) + * @param page + * @param index + * + */ + public void addPage(final Object page, final int index) { + TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); + + RecordingCommand command = new RecordingCommand(editingDomain) { + + @Override + protected void doExecute() { + diContentProvider.addPage(page, index); + + } + }; + + editingDomain.getCommandStack().execute(command); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#createChildSashModel(java.lang.Object) + * @param root + * @return + * + */ + public IAbstractPanelModel createChildSashModel(final Object root) { + return diContentProvider.createChildSashModel(root); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#createFolder(org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel, + * int, org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel, int) + * @param tabFolder + * @param tabIndex + * @param targetFolder + * @param side + * + */ + public void createFolder(final ITabFolderModel tabFolder, final int tabIndex, final ITabFolderModel targetFolder, final int side) { + TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); + + RecordingCommand command = new RecordingCommand(editingDomain) { + + @Override + protected void doExecute() { + diContentProvider.createFolder(tabFolder, tabIndex, targetFolder, side); + + } + }; + + editingDomain.getCommandStack().execute(command); + } + + /** + * Keep trace of the current folder. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#setCurrentFolder(java.lang.Object) + * + * @param rawModel + */ + public void setCurrentFolder(final Object rawModel) { + TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); + + RecordingCommand command = new RecordingCommand(editingDomain) { + + @Override + protected void doExecute() { + diContentProvider.setCurrentFolder(rawModel); + + } + }; + + editingDomain.getCommandStack().execute(command); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#getRootModel() + * @return + * + */ + public Object getRootModel() { + return diContentProvider.getRootModel(); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#movePage(org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel, + * int, int) + * @param folderModel + * @param oldIndex + * @param newIndex + * + */ + public void movePage(final ITabFolderModel folderModel, final int oldIndex, final int newIndex) { + TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); + + RecordingCommand command = new RecordingCommand(editingDomain) { + + @Override + protected void doExecute() { + diContentProvider.movePage(folderModel, oldIndex, newIndex); + + } + }; + + editingDomain.getCommandStack().execute(command); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#movePage(org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel, + * int, org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel, int) + * @param srcFolderModel + * @param sourceIndex + * @param targetFolderModel + * @param targetIndex + * + */ + public void movePage(final ITabFolderModel srcFolderModel, final int sourceIndex, final ITabFolderModel targetFolderModel, final int targetIndex) { + TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); + + RecordingCommand command = new RecordingCommand(editingDomain) { + + @Override + protected void doExecute() { + diContentProvider.movePage(srcFolderModel, sourceIndex, targetFolderModel, targetIndex); + + } + }; + + editingDomain.getCommandStack().execute(command); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#removePage(int) + * @param index + * + */ + public void removePage(final int index) { + TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); + + RecordingCommand command = new RecordingCommand(editingDomain) { + + @Override + protected void doExecute() { + diContentProvider.removePage(index); + + } + }; + + editingDomain.getCommandStack().execute(command); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#removePage(java.lang.Object) + * @param page + * + */ + public void removePage(final Object page) { + TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); + + RecordingCommand command = new RecordingCommand(editingDomain) { + + @Override + protected void doExecute() { + diContentProvider.removePage(page); + + } + }; + + editingDomain.getCommandStack().execute(command); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#removePage(org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel, + * int) + * @param parentFolder + * @param tabIndex + * + */ + public void removePage(final ITabFolderModel parentFolder, final int tabIndex) { + TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); + + RecordingCommand command = new RecordingCommand(editingDomain) { + + @Override + protected void doExecute() { + diContentProvider.removePage(parentFolder, tabIndex); + + } + }; + + editingDomain.getCommandStack().execute(command); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalPageMngrImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalPageMngrImpl.java new file mode 100644 index 00000000000..23d46c606f2 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalPageMngrImpl.java @@ -0,0 +1,317 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal; + +import java.util.List; + +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage; + +/** + * A PageMngr based on EMF di and using Transactions. This implementation is a + * wrapper on {@link PageMngrImpl}. Each method is wrapped in a {@link RecordingCommand}. + * + * @author cedric dumoulin + */ +public class TransactionalPageMngrImpl implements IPageMngr { + + /** + * wrapped ContentProvider. All commands will use this provider. + */ + private PageMngrImpl pageMngr; + + private TransactionalEditingDomain editingDomain; + + /** + * + * Constructor. + * + * @param diContentProvider + */ + public TransactionalPageMngrImpl(PageMngrImpl pageMngr, TransactionalEditingDomain editingDomain) { + this.pageMngr = pageMngr; + this.editingDomain = editingDomain; + } + + /** + * Get the editing domain used to perform transactions. + * + * @return + */ + private TransactionalEditingDomain getTransactionalEditingDomain() { + return editingDomain; + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#addPage(java.lang.Object) + * + * @param pageIdentifier + */ + public void addPage(final Object pageIdentifier) { + + new TransactionPageMngrRunnable() { + + @Override + public void doRun() { + pageMngr.addPage(pageIdentifier); + } + }.run(); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#allPages() + * + * @return + */ + public List allPages() { + return pageMngr.allPages(); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#closePage(java.lang.Object) + * + * @param pageIdentifier + */ + public void closePage(final Object pageIdentifier) { + + new TransactionPageMngrRunnable() { + + @Override + public void doRun() { + pageMngr.closePage(pageIdentifier); + } + }.run(); + } + + /** + * Remove all pages from the SashModel. Left only the top level folder + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#closePage(org.eclipse.emf.ecore.EObject) + * + * @param pageIdentifier + */ + public void closeAllOpenedPages() { + + new TransactionPageMngrRunnable() { + + @Override + public void doRun() { + pageMngr.closeAllOpenedPages(); + } + }.run(); + } + + /** + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#closePage(org.eclipse.emf.ecore.EObject) + * + * @param pageIdentifier + */ + public void closeOtherPages(final Object pageIdentifier) { + + new TransactionPageMngrRunnable() { + + @Override + public void doRun() { + pageMngr.closeOtherPages(pageIdentifier); + } + }.run(); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#openPage(java.lang.Object) + * + * @param pageIdentifier + */ + public void openPage(final Object pageIdentifier) { + + new TransactionPageMngrRunnable() { + + @Override + public void doRun() { + pageMngr.openPage(pageIdentifier); + } + }.run(); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#removePage(java.lang.Object) + * + * @param pageIdentifier + */ + public void removePage(final Object pageIdentifier) { + + new TransactionPageMngrRunnable() { + + @Override + public void doRun() { + pageMngr.removePage(pageIdentifier); + } + }.run(); + } + + /** + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#isOpen(java.lang.Object) + * @param pageIdentifier + * @return + * + */ + public boolean isOpen(Object pageIdentifier) { + return pageMngr.isOpen(pageIdentifier); + } + + /** + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#openPrevious() + * + */ + public void openPrevious() { + + new TransactionPageMngrRunnable() { + + @Override + public void doRun() { + pageMngr.openPrevious(); + } + }.run(); + } + + /** + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#openNext() + * + */ + public void openNext() { + + new TransactionPageMngrRunnable() { + + @Override + public void doRun() { + pageMngr.openNext(); + } + }.run(); + } + + public void pageChanged(final IPage page) { + new TransactionPageMngrRunnable() { + + @Override + public void doRun() { + pageMngr.pageChanged(page); + } + }.run(); + + } + + /** + * class runnable to encapsulate a command + * + * @author aradouan + * + */ + public abstract class TransactionPageMngrRunnable implements Runnable { + + public void run() { + TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); + RecordingCommand command = new RecordingCommand(editingDomain) { + + @Override + protected void doExecute() { + doRun(); + } + }; + editingDomain.getCommandStack().execute(command); + } + + public abstract void doRun(); + + } + + public void pageOpened(final IPage page) { + new TransactionPageMngrRunnable() { + + @Override + public void doRun() { + pageMngr.pageOpened(page); + } + }.run(); + } + + public void pageClosed(final IPage page) { + new TransactionPageMngrRunnable() { + + @Override + public void doRun() { + pageMngr.pageClosed(page); + } + }.run(); + } + + public void pageActivated(final IPage page) { + new TransactionPageMngrRunnable() { + + @Override + public void doRun() { + pageMngr.pageActivated(page); + } + }.run(); + } + + public void pageDeactivated(final IPage page) { + new TransactionPageMngrRunnable() { + + @Override + public void doRun() { + pageMngr.pageDeactivated(page); + } + }.run(); + } + + public void pageAboutToBeOpened(final IPage page) { + new TransactionPageMngrRunnable() { + + @Override + public void doRun() { + pageMngr.pageAboutToBeOpened(page); + } + }.run(); + } + + public void pageAboutToBeClosed(final IPage page) { + new TransactionPageMngrRunnable() { + + @Override + public void doRun() { + pageMngr.pageAboutToBeClosed(page); + } + }.run(); + } + + public boolean hasPreviousHistory() { + return pageMngr.hasPreviousHistory(); + } + + public boolean hasNextHistory() { + return pageMngr.hasNextHistory(); + } + + public int isInHsitory(Object pageIdentifier) { + return pageMngr.isInHsitory(pageIdentifier); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/utils/IPageUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/utils/IPageUtils.java new file mode 100644 index 00000000000..f9c4dc46b39 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/utils/IPageUtils.java @@ -0,0 +1,50 @@ +/***************************************************************************** + * Copyright (c) 2010 LIFL & CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.utils; + +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; + +/** + * Class providing a utility methods allowing to get the real Model from the {@link IPage#getRawModel()}. The utility takes into account the bug + * 309943. + * + * @author cedric dumoulin + * + */ +public class IPageUtils { + + /** + * Get the real model rather than the PageRef. This method is a trick to + * temporally solve the bug 309943. + * + * @param page + * @return + */ + public static Object getRawModel(IPage page) { + + if(page == null) + return null; + + Object pageModel = page.getRawModel(); + // Get the real model because of bug + if(pageModel instanceof PageRef) { + return ((PageRef)pageModel).getPageIdentifier(); + } + // do not use trick + return pageModel; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/DiSashModelMngr.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/DiSashModelMngr.java deleted file mode 100644 index 60b3b6d10ac..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/DiSashModelMngr.java +++ /dev/null @@ -1,235 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.sasheditor.contentprovider.di; - -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.papyrus.sasheditor.contentprovider.IContentChangedProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.di.internal.ContentChangedEventProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.di.internal.DiContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.di.internal.PageMngrImpl; -import org.eclipse.papyrus.sashwindows.di.SashWindowsMngr; -import org.eclipse.papyrus.sashwindows.di.util.DiUtils; - -/** - * Class used as main entry point to access a sash model build on EMF / di - * - * @author cedric dumoulin - */ -public class DiSashModelMngr { - - /** The EMF model used to store the sash windows structure and pages */ - protected SashWindowsMngr sashWindowMngr; - - /** - * Instance of the pageMngr. - */ - private PageMngrImpl pageMngr = null; - - /** - * Instance of the DiContentProvider used to manipulate SashModel. - */ - private DiContentProvider contentProvider; - - /** - * Object used externally listen to model changes. The object is also used - * internally to control how events are fired (limit multiple events). - */ - protected ContentChangedEventProvider contentChangedEventProvider; - - /** The factory used to create IPageModel */ - private IPageModelFactory pageModelFactory; - - /** - * Constructor. Create a DiSashModelMngr with the specified factory. A - * SashModel is created but not attached to a resource. This constructor is - * for subclasses. The subclasses should initialize the sashWindowMngr - * - * @param pageModelFactory - * @param createDefaultSashModel - * If true, create the default SashModel by calling {@link #createDefaultSashModel()} - */ - protected DiSashModelMngr(IPageModelFactory pageModelFactory, boolean createDefaultSashModel) { - this.pageModelFactory = pageModelFactory; - // Create a SashModel - if(createDefaultSashModel) { - sashWindowMngr = createDefaultSashModel(); - } - } - - /** - * Constructor. Create a DiSashModelMngr with the specified factory. A - * SashModel is created but not attached to a resource. - * - * @param pageModelFactory - */ - public DiSashModelMngr(IPageModelFactory pageModelFactory) { - this.pageModelFactory = pageModelFactory; - // Create a SashModel - sashWindowMngr = createDefaultSashModel(); - } - - /** - * Constructor. Create a DiSashModelMngr with the specified factory. The - * SashModel is searched in the Resource. If not found, create one in the - * resource. - * - * @param pageModelFactory - * @param diResource - */ - public DiSashModelMngr(IPageModelFactory pageModelFactory, Resource diResource) { - this.pageModelFactory = pageModelFactory; - - // lookup the SashModel - sashWindowMngr = lookupSashWindowMngr(diResource); - if(sashWindowMngr == null) { - // Create a default model and attach it to resource. - sashWindowMngr = createDefaultSashModel(); - diResource.getContents().add(sashWindowMngr); - } - } - - /** - * Constructor. Create a DiSashModelMngr with the specified factory and - * sashModel. - * - * @param pageModelFactory - * @param sashModel - */ - public DiSashModelMngr(IPageModelFactory pageModelFactory, SashWindowsMngr sashModel) { - this.pageModelFactory = pageModelFactory; - this.sashWindowMngr = sashModel; - } - - /** - * Get the internal EMF implementation. Intended to be used by tests. - * - * @return the sashWindowMngr - */ - protected SashWindowsMngr getDiSashWindowsMngr() { - return sashWindowMngr; - } - - /** - * Return the internal implementation of ContentProvider. Create if if - * needed. This method should not be subclassed - * - * @return the contentProvider - */ - protected final DiContentProvider getDiContentProvider() { - if(contentProvider == null) { - contentProvider = new DiContentProvider(sashWindowMngr.getSashModel(), pageModelFactory, getContentChangedEventProvider()); - } - return contentProvider; - } - - /** - * Return the internal implementation of PageMngr. Create if if needed. This - * method should not be subclassed - * - * @return the PageMngrImpl - */ - protected final PageMngrImpl getPageMngrImpl() { - if(pageMngr == null) { - pageMngr = new PageMngrImpl(sashWindowMngr, getContentChangedEventProvider()); - } - - return pageMngr; - } - - /** - * Return the internal implementation of ContentChangedEventProvider. Create - * if if needed. This method should not be subclassed - * - * @return the PageMngrImpl - */ - protected final ContentChangedEventProvider getContentChangedEventProvider() { - if(contentChangedEventProvider == null) { - contentChangedEventProvider = new ContentChangedEventProvider(sashWindowMngr); - } - - return contentChangedEventProvider; - } - - /** - * Get the IPageMngr providing basic methods to manage Pages in the sash - * model. - * - * @return - */ - public IPageMngr getIPageMngr() { - return getPageMngrImpl(); - } - - /** - * Get the ContentProvider used by the SashWindows system. This class can - * also be used to accurately manage the sash model. - * - * @return - */ - public ISashWindowsContentProvider getISashWindowsContentProvider() { - - return getDiContentProvider(); - - } - - /** - * Get the ContentChangedProvider for the SashModel - * - * @return - */ - public IContentChangedProvider getSashModelContentChangedProvider() { - return getContentChangedEventProvider(); - } - - /** - * Create a default model with one window and one folder. - * - * @param diResource - * @return - */ - protected SashWindowsMngr createDefaultSashModel() { - return DiUtils.createDefaultSashWindowsMngr(); - } - - /** - * Lookup for the SashModel object in the resource - * - * @param diResource - * @return - */ - protected SashWindowsMngr lookupSashWindowMngr(Resource diResource) { - - return DiUtils.lookupSashWindowsMngr(diResource); - } - - /** - * Create an instance of IPageMngr acting on the provided resource. This - * instance is suitable to add, remove, close or open diagrams. - * - * @param diResource - * @return The non transactional version of the IPageMngr - */ - public static IPageMngr createIPageMngr(Resource diResource) { - - // Create an instance of the DiSashModelMngr with no factory. - // The factory is not needed since we don't get the - // ISashWindowsContentProvider. - return new DiSashModelMngr(null, diResource).getIPageMngr(); - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/IPageModelFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/IPageModelFactory.java deleted file mode 100644 index ee16f061b8d..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/IPageModelFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.sasheditor.contentprovider.di; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; - -/** - * Factory used to create IPageModel from an object identifying a page. - * IPageModel are objects used by the Sash Windows to create a page. - * - * @author cedric dumoulin - */ -public interface IPageModelFactory { - - /** - * Create the IPageModel for the pageIdentifier. The pageIdentifier is the - * object passed to the {@link IPageMngr#addEditor(EObject)}. This factory - * method is called by the Sash Windows whenever it needs to create a page. - * The identifier is found in the sash model. - * - * @param pageIdentifier - * The identifier identifying the page to create. - * @return - */ - public IPageModel createIPageModel(Object pageIdentifier); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/TransactionalDiSashModelMngr.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/TransactionalDiSashModelMngr.java deleted file mode 100644 index f7072add1dd..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/TransactionalDiSashModelMngr.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.contentprovider.di; - -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.di.internal.TransactionalDiContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.di.internal.TransactionalPageMngrImpl; - -/** - * DiSashModelMngr providing transactional commands to modify SashModel. - * - * @author cedric dumoulin - * - */ -public class TransactionalDiSashModelMngr extends DiSashModelMngr { - - private TransactionalDiContentProvider transDiContentProvider; - - private TransactionalPageMngrImpl transPageMngrImpl; - - /** - * - * Constructor. - * - * @param pageModelFactory - * @param diResource - */ - public TransactionalDiSashModelMngr(IPageModelFactory pageModelFactory, final Resource diResource, TransactionalEditingDomain editingDomain) { - super(pageModelFactory, false); - - // lookup the SashModel - sashWindowMngr = lookupSashWindowMngr(diResource); - // If no SashWindow structure is found, create a new one using a - // transaction. - if(sashWindowMngr == null) { - RecordingCommand command = new RecordingCommand(editingDomain) { - - @Override - protected void doExecute() { - // Create a default model and attach it to resource. - sashWindowMngr = createDefaultSashModel(); - diResource.getContents().add(sashWindowMngr); - } - }; - editingDomain.getCommandStack().execute(command); - } - - // Create the TransactionalDiContentProvider - transDiContentProvider = new TransactionalDiContentProvider(getDiContentProvider(), editingDomain); - - // Create the TransactionalPageMngrImpl - transPageMngrImpl = new TransactionalPageMngrImpl(getPageMngrImpl(), editingDomain); - } - - /** - * - * Constructor. Only create a {@link IPageMngr} impl. Do not create the - * DiContentProvider as there is no factory provided. Internal use. - * - * @param pageModelFactory - * @param diResource - */ - private TransactionalDiSashModelMngr(final Resource diResource, TransactionalEditingDomain editingDomain) { - super(null, false); - - // lookup the SashModel - sashWindowMngr = lookupSashWindowMngr(diResource); - // If no SashWindow structure is found, create a new one using a - // transaction. - if(sashWindowMngr == null) { - RecordingCommand command = new RecordingCommand(editingDomain) { - - @Override - protected void doExecute() { - // Create a default model and attach it to resource. - sashWindowMngr = createDefaultSashModel(); - diResource.getContents().add(sashWindowMngr); - } - }; - editingDomain.getCommandStack().execute(command); - } - - // Create the TransactionalPageMngrImpl - transPageMngrImpl = new TransactionalPageMngrImpl(getPageMngrImpl(), editingDomain); - } - - /** - * Return the transactional version - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.di.DiSashModelMngr#getISashWindowsContentProvider() - * @return - * - */ - @Override - public ISashWindowsContentProvider getISashWindowsContentProvider() { - return transDiContentProvider; - } - - /** - * Return the transactional version - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.di.DiSashModelMngr#getIPageMngr() - * - * @return - */ - @Override - public IPageMngr getIPageMngr() { - return transPageMngrImpl; - } - - /** - * Create an instance of IPageMngr acting on the provided resource. This - * instance is suitable to add, remove, close or open diagrams. - * - * @param diResource - * @return The non transactional version of the IPageMngr - */ - public static IPageMngr createIPageMngr(Resource diResource, TransactionalEditingDomain editingDomain) { - - // Create an instance of the DiSashModelMngr with no factory. - // The factory is not needed since we don't get the - // ISashWindowsContentProvider. - return new TransactionalDiSashModelMngr(diResource, editingDomain).getIPageMngr(); - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/commands/CloseAllDiagramsCommand.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/commands/CloseAllDiagramsCommand.java deleted file mode 100644 index fbd8c573cab..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/commands/CloseAllDiagramsCommand.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.contentprovider.di.commands; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.handlers.HandlerUtil; - -/** - * A command to be used with the Eclipse Commands Framework. This command allows - * to close all diagrams openened in the current SashContainer implemented on - * di. - * - * @author cedric dumoulin - * - */ -public class CloseAllDiagramsCommand extends AbstractHandler { - - /** - * Check if the Command is enabled. - */ - @Override - public void setEnabled(Object evaluationContext) { - // System.out.println("call to CloseAllDiagramsCommand.setEnable(" + - // evaluationContext + ")"); - } - - /** - * Execute the command. This method is called when the action is triggered. - * - */ - public Object execute(ExecutionEvent event) throws ExecutionException { - - IPageMngr pageMngr; - try { - pageMngr = getPageMngr(event); - } catch (NullPointerException e) { - // PageMngr can't be found - return null; - } - execute(pageMngr); - - return null; - } - - /** - * Get the PageMngr used to interact with the content provider. - * - * @param event - * @return - * @throws NullPointerException - * if the PageMngr can't be found. - */ - private IPageMngr getPageMngr(ExecutionEvent event) { - - IEditorPart part = HandlerUtil.getActiveEditor(event); - IPageMngr pageMngr = (IPageMngr)part.getAdapter(IPageMngr.class); - - return pageMngr; - - } - - /** - * Close all the diagrams. - * - * @param pageMngr - */ - public void execute(IPageMngr pageMngr) { - - pageMngr.closeAllOpenedPages(); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/commands/CloseDiagramCommand.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/commands/CloseDiagramCommand.java deleted file mode 100644 index 268fc6c9543..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/commands/CloseDiagramCommand.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.contentprovider.di.commands; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; -import org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.handlers.HandlerUtil; - -/** - * A command to be used with the Eclipse Commands Framework. This command is to - * be used with {@link SashWindowsContainer} implemented with the Di model. This - * command allows to close the currently openened diagram. - * - * @author cedric dumoulin - * - */ -public class CloseDiagramCommand extends AbstractHandler { - - /** - * Check if the Command is enabled. - */ - @Override - public void setEnabled(Object evaluationContext) { - // System.out.println("call to CloseDiagramCommand.setEnable(" + - // evaluationContext + ")"); - } - - /** - * Execute the command. This method is called when the action is triggered. - * - */ - public Object execute(ExecutionEvent event) throws ExecutionException { - - try { - IEditorPart part = HandlerUtil.getActiveEditor(event); - IPageMngr pageMngr = (IPageMngr)part.getAdapter(IPageMngr.class); - ISashWindowsContainer container = (ISashWindowsContainer)part.getAdapter(ISashWindowsContainer.class); - Object pageIdentifier = container.getActiveSashWindowsPage().getRawModel(); - // Bug from sash Di to be corrected - if(pageIdentifier instanceof PageRef) { - pageIdentifier = ((PageRef)pageIdentifier).getPageIdentifier(); - } - - execute(pageMngr, pageIdentifier); - - } catch (NullPointerException e) { - // PageMngr can't be found - return null; - } - - return null; - } - - /** - * Close selected page. - * - * @param pageMngr - */ - public void execute(IPageMngr pageMngr, Object pageIdentifier) { - - if(pageMngr.isOpen(pageIdentifier)) { - pageMngr.closePage(pageIdentifier); - } - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/commands/CloseOtherDiagramsCommand.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/commands/CloseOtherDiagramsCommand.java deleted file mode 100644 index b3f1020888d..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/commands/CloseOtherDiagramsCommand.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.contentprovider.di.commands; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; -import org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.handlers.HandlerUtil; - -/** - * A command to be used with the Eclipse Commands Framework. This command is to - * be used with {@link SashWindowsContainer} implemented with the Di model. This - * command allows to close all diagrams in the folder, except the currently - * openened one. - * - * @author cedric dumoulin - * - */ -public class CloseOtherDiagramsCommand extends AbstractHandler { - - /** - * Check if the Command is enabled. - */ - @Override - public void setEnabled(Object evaluationContext) { - // System.out.println("call to CloseDiagramCommand.setEnable(" + - // evaluationContext + ")"); - } - - /** - * Execute the command. This method is called when the action is triggered. - * - */ - public Object execute(ExecutionEvent event) throws ExecutionException { - - try { - IEditorPart part = HandlerUtil.getActiveEditor(event); - IPageMngr pageMngr = (IPageMngr)part.getAdapter(IPageMngr.class); - ISashWindowsContainer container = (ISashWindowsContainer)part.getAdapter(ISashWindowsContainer.class); - Object pageIdentifier = container.getActiveSashWindowsPage().getRawModel(); - // Bug from sash Di to be corrected - if(pageIdentifier instanceof PageRef) { - pageIdentifier = ((PageRef)pageIdentifier).getPageIdentifier(); - } - execute(pageMngr, pageIdentifier); - - } catch (NullPointerException e) { - // PageMngr can't be found - return null; - } - - return null; - } - - /** - * Close selected page. - * - * @param pageMngr - */ - public void execute(IPageMngr pageMngr, Object pageIdentifier) { - - pageMngr.closeOtherPages(pageIdentifier); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/ContentChangedEventProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/ContentChangedEventProvider.java deleted file mode 100644 index 3134c9c0372..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/ContentChangedEventProvider.java +++ /dev/null @@ -1,198 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.contentprovider.di.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.util.EContentAdapter; -import org.eclipse.papyrus.sasheditor.contentprovider.IContentChangedListener; -import org.eclipse.papyrus.sasheditor.contentprovider.IContentChangedListener.ContentEvent; -import org.eclipse.papyrus.sasheditor.contentprovider.IContentChangedProvider; -import org.eclipse.papyrus.sashwindows.di.AbstractPanel; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.papyrus.sashwindows.di.SashModel; -import org.eclipse.papyrus.sashwindows.di.SashWindowsMngr; -import org.eclipse.papyrus.sashwindows.di.Window; - -/** - * A class listening on changes on the internal model and delivering events to - * registered listeners. - * - * @author cedric dumoulin - * - */ -public class ContentChangedEventProvider implements IContentChangedProvider { - - private List listeners; - - /** Is this mngr delivering events ? */ - private boolean isDeliverEnable = true; - - /** Last event stored when isDeliverEnable == false; */ - private ContentEvent storedEvent; - - private EMFAdapter emfAdapter = new EMFAdapter(); - - /** - * The model firing events - */ - private SashModel diSashModel; - - /** - * - * Constructor. - * - * @param diSashModel - */ - public ContentChangedEventProvider(SashModel diSashModel) { - this.diSashModel = diSashModel; - activate(); - } - - /** - * - * Constructor. - * - * @param diSashModel - */ - public ContentChangedEventProvider(SashWindowsMngr sashWindowMngr) { - this(sashWindowMngr.getSashModel()); - } - - /** - * Connect EMF changeListener to the {@link ContentChangeListenerManager}. - * Changes in the EMF di model will be fired by the - * ContentChangeListenerManager. - */ - protected void activate() { - diSashModel.eAdapters().add(emfAdapter); - setDeliver(true); - } - - protected void deactivate() { - setDeliver(false); - diSashModel.eAdapters().remove(emfAdapter); - } - - /** - * @return the isDeliverEnable - */ - protected boolean isDeliver() { - return isDeliverEnable; - } - - /** - * @param isDeliverEnable - * the isDeliverEnable to set - */ - protected void setDeliver(boolean isDeliverEnable) { - - if(this.isDeliverEnable == isDeliverEnable) - return; - - // Check if the old value is not delivering event - if(!this.isDeliverEnable) { - this.isDeliverEnable = true; - // reenable events. Check if an event is stored - if(storedEvent != null) - fireContentChanged(storedEvent); - - } else - this.isDeliverEnable = isDeliverEnable; - - storedEvent = null; - } - - /** - * Add a listener listening on content changed. This listener will be - * notified each time the content change. - * - * @param listener - */ - public void addListener(IContentChangedListener listener) { - if(listeners == null) - createListeners(); - - // Check if already exists. - if(listeners.contains(listener)) - return; - - listeners.add(listener); - } - - /** - * Add a listener listening on content changed. This listener will be - * notified each time the content change. - * - * @param listener - */ - public void removeListener(IContentChangedListener listener) { - if(listeners == null) - return; - - listeners.remove(listener); - } - - /** - * Create the list of listeners. - */ - private void createListeners() { - if(listeners == null) - listeners = new ArrayList(); - - } - - /** - * Fire the changed event. - * - * @param event - */ - protected void fireContentChanged(ContentEvent event) { - if(listeners == null) - return; - - if(!isDeliverEnable) { - storedEvent = event; - return; - } - - for(IContentChangedListener listener : listeners) { - listener.contentChanged(event); - } - } - - /** - * Change event Adapter. Forward EMF changeEvent to the {@link ContentChangeListenerManager}. - * - * @author cedric dumoulin - */ - public class EMFAdapter extends EContentAdapter { - - /** - * ContentProvider Model has changed. Changes includes : ADD, REMOVE and - * MOVE of elements - * - * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification) - * - * @param msg - */ - @Override - public void notifyChanged(Notification msg) { - super.notifyChanged(msg); - - // Filter out notification of type RESOLVE - // We don't need to be noti - if(msg.getEventType() == Notification.RESOLVE) - return; - - // W - Object sender = msg.getNotifier(); - if(sender instanceof AbstractPanel || sender instanceof Window || sender instanceof PageRef) - fireContentChanged(new ContentEvent(msg.getEventType(), sender, null)); - } - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/DiContentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/DiContentProvider.java deleted file mode 100644 index 76e55fc4bdd..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/DiContentProvider.java +++ /dev/null @@ -1,288 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.sasheditor.contentprovider.di.internal; - -import org.eclipse.papyrus.sasheditor.contentprovider.IAbstractPanelModel; -import org.eclipse.papyrus.sasheditor.contentprovider.IContentChangedListener.ContentEvent; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel; -import org.eclipse.papyrus.sasheditor.contentprovider.di.IPageModelFactory; -import org.eclipse.papyrus.sashwindows.di.DiFactory; -import org.eclipse.papyrus.sashwindows.di.SashModel; -import org.eclipse.papyrus.sashwindows.di.SashPanel; -import org.eclipse.papyrus.sashwindows.di.TabFolder; - -/** - * EMF implementation of the {@link ISashWindowsContentProvider}. - * - * @author dumoulin - */ -public class DiContentProvider implements ISashWindowsContentProvider { - - /** Internal EMF model */ - private SashModel diSashModel; - - /** Factory used to create SWT Editor or Component from Page Identifiers. */ - private IPageModelFactory pageModelFactory; - - /** - * Object delivering event to listeners. Used to control how the events are - * triggered - */ - private ContentChangedEventProvider contentChangedEventProvider; - - /** - * Create a ContentProvider - * - * @param diSashModel - * @param pageModelFactory - * The factory that will be used when a page will be created. - * @throws IllegalArgumentException - * If the factory is null. - */ - public DiContentProvider(SashModel diSashModel, IPageModelFactory pageModelFactory) throws IllegalArgumentException { - - this(diSashModel, pageModelFactory, new ContentChangedEventProvider(diSashModel)); - } - - /** - * Create a ContentProvider - * - * @param diSashModel - * @param pageModelFactory - * The factory that will be used when a page will be created. - * @throws IllegalArgumentException - * If the factory is null. - */ - public DiContentProvider(SashModel diSashModel, IPageModelFactory pageModelFactory, ContentChangedEventProvider contentChangedEventProvider) throws IllegalArgumentException { - - if(pageModelFactory == null) - throw new IllegalArgumentException("A IPageModelFactory should be provided."); - - this.diSashModel = diSashModel; - this.pageModelFactory = pageModelFactory; - this.contentChangedEventProvider = contentChangedEventProvider; - } - - /** - * Access to internal structure for tests. This method is not intended to be - * used for other purpose. - * - * @return the diSashModel - */ - protected SashModel getDiSashModel() { - return diSashModel; - } - - /** - * @return the contentChangedEventProvider - */ - protected ContentChangedEventProvider getContentChangedEventProvider() { - return contentChangedEventProvider; - } - - /** - * Add a page identifier to the SashModel. This page identifier will be - * added as "child" of the current TabFolder. - * - * @param pageIdentifier - */ - public void addPage(Object pageIdentifier) { - diSashModel.addPage(pageIdentifier); - } - - /** - * Add a page to the current folder. Create the Page (Editor or Component) - * with the help of the factory. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#addPage(int, - * org.eclipse.papyrus.sasheditor.contentprovider.IPageModel) - * - * @param index - * @param tabItem - */ - public void addPage(Object page, int index) { - - throw new UnsupportedOperationException("Not yet implemented."); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#createFolder(org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel, - * int, org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel, int) - * - * @param tabFolder - * @param tabIndex - * @param targetFolder - * @param side - * @return - */ - public void createFolder(ITabFolderModel tabFolder, int tabIndex, ITabFolderModel targetFolder, int side) { - - // disable fired events - contentChangedEventProvider.setDeliver(false); - // Create new folder. Parent will be set when inserted. - TabFolder newFolder = DiFactory.eINSTANCE.createTabFolder(); - - TabFolder refFolder = ((TabFolderModel)targetFolder).getTabFolder(); - TabFolder pageSrcFolder = ((TabFolderModel)tabFolder).getTabFolder(); - - // Insert folder - diSashModel.insertFolder(newFolder, refFolder, side); - // Move tab from folder to folder - diSashModel.movePage(pageSrcFolder, tabIndex, newFolder); - // Remove unused folder if necessary - diSashModel.removeEmptyFolder(pageSrcFolder); - diSashModel.setCurrentSelection(newFolder); - - // Reenable events, and fire the last one - contentChangedEventProvider.setDeliver(true); - - } - - /** - * Set the current folder. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#setCurrentFolder(java.lang.Object) - * - * @param rawModel - * The object identifying the folder. - */ - public void setCurrentFolder(Object rawModel) { - - if(!(rawModel instanceof TabFolder)) { - return; - } - diSashModel.setCurrentSelection((TabFolder)rawModel); - } - - /** - * Get the node used as root of the SashWindows. For now, this is the first - * window. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#getRootModel() - * - * @return - */ - public Object getRootModel() { - // Get the first window. - return diSashModel.getWindows().get(0).getPanel(); - } - - /** - * Create the IPanelModel for the rootModel returned by {@link DiContentProvider#getRootModel()}. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#createChildSashModel(java.lang.Object) - * - * @param root - * @return - */ - public IAbstractPanelModel createChildSashModel(Object root) { - - if(root instanceof SashPanel) - return new SashPanelModel((SashPanel)root, pageModelFactory); - else if(root instanceof TabFolder) - return new TabFolderModel((TabFolder)root, pageModelFactory); - else - throw new IllegalArgumentException("Can't create IPanelModel from raw model '" + root + "'."); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#movePage(org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel, - * int, int) - * - * @param folderModel - * @param oldIndex - * @param newIndex - */ - public void movePage(ITabFolderModel folderModel, int oldIndex, int newIndex) { - TabFolder folder = ((TabFolderModel)folderModel).getTabFolder(); - - contentChangedEventProvider.setDeliver(false); - folder.movePage(oldIndex, newIndex); - diSashModel.setCurrentSelection(folder); - contentChangedEventProvider.setDeliver(true); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#movePage(org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel, - * int, org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel, int) - * - * @param srcFolderModel - * @param sourceIndex - * @param targetFolderModel - * @param targetIndex - */ - public void movePage(ITabFolderModel srcFolderModel, int sourceIndex, ITabFolderModel targetFolderModel, int targetIndex) { - - TabFolder srcFolder = ((TabFolderModel)srcFolderModel).getTabFolder(); - TabFolder targetFolder = ((TabFolderModel)targetFolderModel).getTabFolder(); - - contentChangedEventProvider.setDeliver(false); - diSashModel.movePage(srcFolder, sourceIndex, targetFolder, targetIndex); - diSashModel.removeEmptyFolder(srcFolder); - diSashModel.setCurrentSelection(targetFolder); - contentChangedEventProvider.setDeliver(true); - - } - - /** - * Remove specified page from the current folder. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#removePage(int) - * - * @param index - */ - public void removePage(int index) { - diSashModel.removePage(index); - - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#removePage(org.eclipse.papyrus.sasheditor.contentprovider.IPageModel) - * - * @param tabItem - */ - public void removePage(Object page) { - throw new UnsupportedOperationException("Not yet implemented."); - - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#removePage(org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel, - * int) - * - * @param parentFolder - * @param tabIndex - */ - public void removePage(ITabFolderModel parentFolder, int tabIndex) { - TabFolder folder = ((TabFolderModel)parentFolder).getTabFolder(); - - contentChangedEventProvider.setDeliver(false); - folder.removePage(tabIndex); - diSashModel.removeEmptyFolder(folder); - contentChangedEventProvider.setDeliver(true); - } - - /** - * Add a listener listening on content changed. This listener will be - * notified each time the content change. - * - * @param listener - */ - protected void firePropertyChanged(ContentEvent event) { - contentChangedEventProvider.fireContentChanged(event); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/PageMngrImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/PageMngrImpl.java deleted file mode 100644 index a38cee57d76..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/PageMngrImpl.java +++ /dev/null @@ -1,373 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * Anass Radouani (Atos) - add history management - * - *****************************************************************************/ - -package org.eclipse.papyrus.sasheditor.contentprovider.di.internal; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Stack; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; -import org.eclipse.papyrus.sasheditor.editor.IPage; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.papyrus.sashwindows.di.SashWindowsMngr; -import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.PlatformUI; - -/** - * Implementation of the page manager. The page manager provides basic methods - * to access the DiSashModel and its PageList. This is the users interface to - * add, open, close and remove pages. - * - * @author cedric dumoulin - */ -public class PageMngrImpl implements IPageMngr { - - /** Internal EMF model */ - private SashWindowsMngr diSashModel; - - /** Contains the current page and previously opened pages */ - private Stack previousStack = new Stack(); - - private Stack nextStack = new Stack(); - - /** - * true when an update is currently performed to not add a page two times to - * the stack - */ - private boolean updating = false; - - /** true when a page closing is currently performed */ - private boolean closingPage = false; - - ContentChangedEventProvider contentChangedEventProvider; - - /** - * @return the updating - */ - public boolean isUpdating() { - return updating; - } - - /** - * @param updating - * the boolean to set - */ - public void setUpdating(boolean updating) { - this.updating = updating; - } - - /** - * @return the closingPage - */ - public boolean isClosingPage() { - return closingPage; - } - - /** - * @param closingPage - * the boolean to set - */ - public void setClosingPage(boolean closingPage) { - this.closingPage = closingPage; - } - - public PageMngrImpl(SashWindowsMngr diSashModel, ContentChangedEventProvider contentChangedEventProvider) { - this.diSashModel = diSashModel; - this.contentChangedEventProvider = contentChangedEventProvider; - if(diSashModel.getSashModel() != null && diSashModel.getSashModel().getCurrentSelection() != null && !diSashModel.getSashModel().getCurrentSelection().getChildren().isEmpty()) { - addToPreviousStack(diSashModel.getSashModel().getCurrentSelection().getChildren().get(0).getPageIdentifier()); - } - } - - /** - * Add a page to the PageList. Do not open the corresponding editor. The - * page will be visible in the list. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#addEditor(org.eclipse.emf.ecore.EObject) - * - * @param pageIdentifier - */ - public void addPage(Object pageIdentifier) { - - // We do not need to disable event delivering, - // as addition to pageList doesn't fire events. - diSashModel.getPageList().addPage(pageIdentifier); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#allPages() - * - * @return - */ - public List allPages() { - - // TODO : use and return a shadow list ? - List list = new ArrayList(); - for(PageRef pageRef : diSashModel.getPageList().getAvailablePage()) { - - list.add(pageRef.getPageIdentifier()); - } - - return list; - } - - /** - * Remove the page from the SashModel - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#closePage(org.eclipse.emf.ecore.EObject) - * - * @param pageIdentifier - */ - public void closePage(Object pageIdentifier) { - - contentChangedEventProvider.setDeliver(false); - diSashModel.getSashModel().removePage(pageIdentifier); - contentChangedEventProvider.setDeliver(true); - } - - /** - * Remove all pages from the SashModel. Left only the top level folder - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#closePage(org.eclipse.emf.ecore.EObject) - * - * @param pageIdentifier - */ - public void closeAllOpenedPages() { - - contentChangedEventProvider.setDeliver(false); - diSashModel.getSashModel().removeAllPages(); - contentChangedEventProvider.setDeliver(true); - - } - - /** - * Remove all pages from the SashModel. Left only the top level folder - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#closePage(org.eclipse.emf.ecore.EObject) - * - * @param pageIdentifier - */ - public void closeOtherPages(Object pageIdentifier) { - contentChangedEventProvider.setDeliver(false); - diSashModel.getSashModel().removeOtherPages(pageIdentifier); - contentChangedEventProvider.setDeliver(true); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#openPage(org.eclipse.emf.ecore.EObject) - * - * @param pageIdentifier - */ - public void openPage(Object pageIdentifier) { - // Add the page to the SashModel and to the PageList - - // We do not need to disable event delivering as the operation already - // fired - // one single event. - - addToPreviousStack(pageIdentifier); - - Iterator iterator = diSashModel.getPageList().getAvailablePage().iterator(); - boolean found = false; - while(iterator.hasNext() && found == false) { - // Bug #288806 : the test should be inversed - if(pageIdentifier.equals(iterator.next().getPageIdentifier())) { - found = true; - } - } - if(!found) { - diSashModel.getPageList().addPage(pageIdentifier); - } - diSashModel.getSashModel().addPage(pageIdentifier); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#openPage(org.eclipse.emf.ecore.EObject) - * - * @param pageIdentifier - */ - private void openPageWithoutStack(Object pageIdentifier) { - // Add the page to the SashModel and to the PageList - - // We do not need to disable event delivering as the operation already - // fired - // one single event. - Iterator iterator = diSashModel.getPageList().getAvailablePage().iterator(); - boolean found = false; - while(iterator.hasNext() && found == false) { - // Bug #288806 : the test should be inversed - if(pageIdentifier.equals(iterator.next().getPageIdentifier())) { - found = true; - } - } - if(!found) { - diSashModel.getPageList().addPage(pageIdentifier); - } - diSashModel.getSashModel().addPage(pageIdentifier); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#removePage(org.eclipse.emf.ecore.EObject) - * - * @param pageIdentifier - */ - public void removePage(Object pageIdentifier) { - // remove from pageList and from SashModel - diSashModel.getPageList().removePage(pageIdentifier); - - contentChangedEventProvider.setDeliver(false); - diSashModel.getSashModel().removePage(pageIdentifier); - contentChangedEventProvider.setDeliver(true); - } - - /** - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#isOpen(java.lang.Object) - * @param pageIdentifier - * @return - * - */ - public boolean isOpen(Object pageIdentifier) { - return diSashModel.getSashModel().lookupPage(pageIdentifier) != null; - } - - /** - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#openPrevious() - * - */ - public void openPrevious() { - - setUpdating(true); - - if(previousStack.size() > 1) { - nextStack.push(previousStack.pop()); - Object pageIdentifier = previousStack.peek(); - if(isOpen(pageIdentifier)) { - - closePage(pageIdentifier); - } - openPageWithoutStack(pageIdentifier); - } - - setUpdating(false); - } - - /** - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#openNext() - * - */ - public void openNext() { - setUpdating(true); - if(!nextStack.isEmpty()) { - Object pageIdentifier = nextStack.pop(); - previousStack.push(pageIdentifier); - if(isOpen(pageIdentifier)) { - closePage(pageIdentifier); - } - openPageWithoutStack(pageIdentifier); - } - setUpdating(false); - } - - /** - * Add a page to the previous Stack - * - * @param page - * the page to add - */ - private void addToPreviousStack(Object page) { - if(previousStack.isEmpty() || previousStack.peek() != page) { - if(!nextStack.isEmpty()) { - nextStack.clear(); - } - previousStack.push(page); - } - } - - public void pageChanged(IPage newPage) { - if(newPage != null) { - if(!isUpdating() && !isClosingPage()) { - Object md = newPage.getRawModel(); - if(md instanceof PageRef) { - Object page = ((PageRef)md).getPageIdentifier();// .getEmfPageIdentifier(); - addToPreviousStack(page); - } - } else if(!isUpdating() && isClosingPage()) { - setClosingPage(false); - Object md = newPage.getRawModel(); - if(md instanceof PageRef) { - Object page = ((PageRef)md).getPageIdentifier(); - if(!previousStack.isEmpty()) { - previousStack.pop(); - } - addToPreviousStack(page); - } - } - } - } - - /** - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#hasPreviousHistory() - * - */ - public boolean hasPreviousHistory() { - return previousStack.size() > 1; - } - - /** - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#hasNextHistory() - * - */ - public boolean hasNextHistory() { - return !nextStack.isEmpty(); - } - - /** - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#isInHsitory() - * - */ - public int isInHsitory(Object pageIdentifier) { - return previousStack.lastIndexOf(pageIdentifier); - } - - public void pageOpened(IPage page) { - setClosingPage(false); - } - - public void pageClosed(IPage page) { - setClosingPage(true); - } - - public void pageActivated(IPage page) { - } - - public void pageDeactivated(IPage page) { - } - - public void pageAboutToBeOpened(IPage page) { - } - - public void pageAboutToBeClosed(IPage page) { - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/SashPanelModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/SashPanelModel.java deleted file mode 100644 index f8f95a74400..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/SashPanelModel.java +++ /dev/null @@ -1,82 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.sasheditor.contentprovider.di.internal; - -import java.util.List; - -import org.eclipse.papyrus.sasheditor.contentprovider.IAbstractPanelModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashPanelModel; -import org.eclipse.papyrus.sasheditor.contentprovider.di.IPageModelFactory; -import org.eclipse.papyrus.sashwindows.di.SashPanel; -import org.eclipse.papyrus.sashwindows.di.TabFolder; - -/** - * @author cedric dumoulin - */ -public class SashPanelModel implements IAbstractPanelModel, ISashPanelModel { - - /** - * Factory used to create PageModel. - */ - private IPageModelFactory pageModelFactory; - - /** - * The underlying di node. - */ - private SashPanel sashPanel; - - /** - * - * @param sashPanel - */ - public SashPanelModel(SashPanel sashPanel, IPageModelFactory pageModelFactory) { - this.sashPanel = sashPanel; - this.pageModelFactory = pageModelFactory; - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashPanelModel#getChildren() - * - * @return - */ - public List getChildren() { - return sashPanel.getChildren(); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashPanelModel#createChildSashModel(java.lang.Object) - * - * @param child - * @return - */ - public IAbstractPanelModel createChildSashModel(Object child) { - if(child instanceof SashPanel) - return new SashPanelModel((SashPanel)child, pageModelFactory); - else if(child instanceof TabFolder) - return new TabFolderModel((TabFolder)child, pageModelFactory); - else - throw new IllegalArgumentException("Can't create IPanelModel from raw model '" + child + "'."); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashPanelModel#getSashDirection() - * - * @return - */ - public int getSashDirection() { - return sashPanel.getDirection(); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/TabFolderModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/TabFolderModel.java deleted file mode 100644 index bb92e23b397..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/TabFolderModel.java +++ /dev/null @@ -1,81 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.sasheditor.contentprovider.di.internal; - -import java.util.List; - -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel; -import org.eclipse.papyrus.sasheditor.contentprovider.di.IPageModelFactory; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.papyrus.sashwindows.di.TabFolder; - -/** - * @author dumoulin - */ -public class TabFolderModel implements ITabFolderModel { - - /** - * The di Model. - */ - private TabFolder tabFolder; - - private IPageModelFactory pageModelFactory; - - /** - * - * @param root - */ - public TabFolderModel(TabFolder tabFolder, IPageModelFactory pageModelFactory) { - this.tabFolder = tabFolder; - this.pageModelFactory = pageModelFactory; - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel#getChildren() - * - * @return - */ - public List getChildren() { - return tabFolder.getChildren(); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel#createChildSashModel(java.lang.Object) - * - * @param child - * The child object returned by {@link TabFolderModel#getChildren} - * @return - */ - public IPageModel createChildSashModel(Object child) { - - PageRef pageRef = (PageRef)child; - - Object pageIdentifier = pageRef.getPageIdentifier(); - if(pageIdentifier != null) { - return pageModelFactory.createIPageModel(pageIdentifier); - } else { - return null; - } - } - - /** - * @return the tabFolder - */ - public TabFolder getTabFolder() { - return tabFolder; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/TransactionalDiContentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/TransactionalDiContentProvider.java deleted file mode 100644 index 540004320aa..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/TransactionalDiContentProvider.java +++ /dev/null @@ -1,264 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.contentprovider.di.internal; - -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.papyrus.sasheditor.contentprovider.IAbstractPanelModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel; - -/** - * A content provider based on EMF di and using Transactions. This - * implementation is a wrapper on {@link DiContentProvider}. Each method is - * wrapped in a {@link RecordingCommand}. - * - * @author cedric dumoulin - * - */ -public class TransactionalDiContentProvider implements ISashWindowsContentProvider { - - /** - * wrapped ContentProvider. All commands will use this provider. - */ - private DiContentProvider diContentProvider; - - private TransactionalEditingDomain editingDomain; - - /** - * - * Constructor. - * - * @param diContentProvider - */ - public TransactionalDiContentProvider(DiContentProvider diContentProvider, TransactionalEditingDomain editingDomain) { - this.diContentProvider = diContentProvider; - this.editingDomain = editingDomain; - } - - /** - * Get the editing domain used to perform transactions. - * - * @return - */ - private TransactionalEditingDomain getTransactionalEditingDomain() { - return editingDomain; - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#addPage(java.lang.Object) - * @param page - * - */ - public void addPage(final Object page) { - TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); - - RecordingCommand command = new RecordingCommand(editingDomain) { - - @Override - protected void doExecute() { - diContentProvider.addPage(page); - - } - }; - - editingDomain.getCommandStack().execute(command); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#addPage(java.lang.Object, int) - * @param page - * @param index - * - */ - public void addPage(final Object page, final int index) { - TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); - - RecordingCommand command = new RecordingCommand(editingDomain) { - - @Override - protected void doExecute() { - diContentProvider.addPage(page, index); - - } - }; - - editingDomain.getCommandStack().execute(command); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#createChildSashModel(java.lang.Object) - * @param root - * @return - * - */ - public IAbstractPanelModel createChildSashModel(final Object root) { - return diContentProvider.createChildSashModel(root); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#createFolder(org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel, - * int, org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel, int) - * @param tabFolder - * @param tabIndex - * @param targetFolder - * @param side - * - */ - public void createFolder(final ITabFolderModel tabFolder, final int tabIndex, final ITabFolderModel targetFolder, final int side) { - TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); - - RecordingCommand command = new RecordingCommand(editingDomain) { - - @Override - protected void doExecute() { - diContentProvider.createFolder(tabFolder, tabIndex, targetFolder, side); - - } - }; - - editingDomain.getCommandStack().execute(command); - } - - /** - * Keep trace of the current folder. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#setCurrentFolder(java.lang.Object) - * - * @param rawModel - */ - public void setCurrentFolder(final Object rawModel) { - TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); - - RecordingCommand command = new RecordingCommand(editingDomain) { - - @Override - protected void doExecute() { - diContentProvider.setCurrentFolder(rawModel); - - } - }; - - editingDomain.getCommandStack().execute(command); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#getRootModel() - * @return - * - */ - public Object getRootModel() { - return diContentProvider.getRootModel(); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#movePage(org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel, - * int, int) - * @param folderModel - * @param oldIndex - * @param newIndex - * - */ - public void movePage(final ITabFolderModel folderModel, final int oldIndex, final int newIndex) { - TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); - - RecordingCommand command = new RecordingCommand(editingDomain) { - - @Override - protected void doExecute() { - diContentProvider.movePage(folderModel, oldIndex, newIndex); - - } - }; - - editingDomain.getCommandStack().execute(command); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#movePage(org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel, - * int, org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel, int) - * @param srcFolderModel - * @param sourceIndex - * @param targetFolderModel - * @param targetIndex - * - */ - public void movePage(final ITabFolderModel srcFolderModel, final int sourceIndex, final ITabFolderModel targetFolderModel, final int targetIndex) { - TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); - - RecordingCommand command = new RecordingCommand(editingDomain) { - - @Override - protected void doExecute() { - diContentProvider.movePage(srcFolderModel, sourceIndex, targetFolderModel, targetIndex); - - } - }; - - editingDomain.getCommandStack().execute(command); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#removePage(int) - * @param index - * - */ - public void removePage(final int index) { - TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); - - RecordingCommand command = new RecordingCommand(editingDomain) { - - @Override - protected void doExecute() { - diContentProvider.removePage(index); - - } - }; - - editingDomain.getCommandStack().execute(command); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#removePage(java.lang.Object) - * @param page - * - */ - public void removePage(final Object page) { - TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); - - RecordingCommand command = new RecordingCommand(editingDomain) { - - @Override - protected void doExecute() { - diContentProvider.removePage(page); - - } - }; - - editingDomain.getCommandStack().execute(command); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#removePage(org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel, - * int) - * @param parentFolder - * @param tabIndex - * - */ - public void removePage(final ITabFolderModel parentFolder, final int tabIndex) { - TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); - - RecordingCommand command = new RecordingCommand(editingDomain) { - - @Override - protected void doExecute() { - diContentProvider.removePage(parentFolder, tabIndex); - - } - }; - - editingDomain.getCommandStack().execute(command); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/TransactionalPageMngrImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/TransactionalPageMngrImpl.java deleted file mode 100644 index 3bfe51eecb7..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/internal/TransactionalPageMngrImpl.java +++ /dev/null @@ -1,317 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.sasheditor.contentprovider.di.internal; - -import java.util.List; - -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; -import org.eclipse.papyrus.sasheditor.editor.IPage; - -/** - * A PageMngr based on EMF di and using Transactions. This implementation is a - * wrapper on {@link PageMngrImpl}. Each method is wrapped in a {@link RecordingCommand}. - * - * @author cedric dumoulin - */ -public class TransactionalPageMngrImpl implements IPageMngr { - - /** - * wrapped ContentProvider. All commands will use this provider. - */ - private PageMngrImpl pageMngr; - - private TransactionalEditingDomain editingDomain; - - /** - * - * Constructor. - * - * @param diContentProvider - */ - public TransactionalPageMngrImpl(PageMngrImpl pageMngr, TransactionalEditingDomain editingDomain) { - this.pageMngr = pageMngr; - this.editingDomain = editingDomain; - } - - /** - * Get the editing domain used to perform transactions. - * - * @return - */ - private TransactionalEditingDomain getTransactionalEditingDomain() { - return editingDomain; - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#addPage(java.lang.Object) - * - * @param pageIdentifier - */ - public void addPage(final Object pageIdentifier) { - - new TransactionPageMngrRunnable() { - - @Override - public void doRun() { - pageMngr.addPage(pageIdentifier); - } - }.run(); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#allPages() - * - * @return - */ - public List allPages() { - return pageMngr.allPages(); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#closePage(java.lang.Object) - * - * @param pageIdentifier - */ - public void closePage(final Object pageIdentifier) { - - new TransactionPageMngrRunnable() { - - @Override - public void doRun() { - pageMngr.closePage(pageIdentifier); - } - }.run(); - } - - /** - * Remove all pages from the SashModel. Left only the top level folder - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#closePage(org.eclipse.emf.ecore.EObject) - * - * @param pageIdentifier - */ - public void closeAllOpenedPages() { - - new TransactionPageMngrRunnable() { - - @Override - public void doRun() { - pageMngr.closeAllOpenedPages(); - } - }.run(); - } - - /** - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#closePage(org.eclipse.emf.ecore.EObject) - * - * @param pageIdentifier - */ - public void closeOtherPages(final Object pageIdentifier) { - - new TransactionPageMngrRunnable() { - - @Override - public void doRun() { - pageMngr.closeOtherPages(pageIdentifier); - } - }.run(); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#openPage(java.lang.Object) - * - * @param pageIdentifier - */ - public void openPage(final Object pageIdentifier) { - - new TransactionPageMngrRunnable() { - - @Override - public void doRun() { - pageMngr.openPage(pageIdentifier); - } - }.run(); - } - - /** - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#removePage(java.lang.Object) - * - * @param pageIdentifier - */ - public void removePage(final Object pageIdentifier) { - - new TransactionPageMngrRunnable() { - - @Override - public void doRun() { - pageMngr.removePage(pageIdentifier); - } - }.run(); - } - - /** - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#isOpen(java.lang.Object) - * @param pageIdentifier - * @return - * - */ - public boolean isOpen(Object pageIdentifier) { - return pageMngr.isOpen(pageIdentifier); - } - - /** - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#openPrevious() - * - */ - public void openPrevious() { - - new TransactionPageMngrRunnable() { - - @Override - public void doRun() { - pageMngr.openPrevious(); - } - }.run(); - } - - /** - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr#openNext() - * - */ - public void openNext() { - - new TransactionPageMngrRunnable() { - - @Override - public void doRun() { - pageMngr.openNext(); - } - }.run(); - } - - public void pageChanged(final IPage page) { - new TransactionPageMngrRunnable() { - - @Override - public void doRun() { - pageMngr.pageChanged(page); - } - }.run(); - - } - - /** - * class runnable to encapsulate a command - * - * @author aradouan - * - */ - public abstract class TransactionPageMngrRunnable implements Runnable { - - public void run() { - TransactionalEditingDomain editingDomain = getTransactionalEditingDomain(); - RecordingCommand command = new RecordingCommand(editingDomain) { - - @Override - protected void doExecute() { - doRun(); - } - }; - editingDomain.getCommandStack().execute(command); - } - - public abstract void doRun(); - - } - - public void pageOpened(final IPage page) { - new TransactionPageMngrRunnable() { - - @Override - public void doRun() { - pageMngr.pageOpened(page); - } - }.run(); - } - - public void pageClosed(final IPage page) { - new TransactionPageMngrRunnable() { - - @Override - public void doRun() { - pageMngr.pageClosed(page); - } - }.run(); - } - - public void pageActivated(final IPage page) { - new TransactionPageMngrRunnable() { - - @Override - public void doRun() { - pageMngr.pageActivated(page); - } - }.run(); - } - - public void pageDeactivated(final IPage page) { - new TransactionPageMngrRunnable() { - - @Override - public void doRun() { - pageMngr.pageDeactivated(page); - } - }.run(); - } - - public void pageAboutToBeOpened(final IPage page) { - new TransactionPageMngrRunnable() { - - @Override - public void doRun() { - pageMngr.pageAboutToBeOpened(page); - } - }.run(); - } - - public void pageAboutToBeClosed(final IPage page) { - new TransactionPageMngrRunnable() { - - @Override - public void doRun() { - pageMngr.pageAboutToBeClosed(page); - } - }.run(); - } - - public boolean hasPreviousHistory() { - return pageMngr.hasPreviousHistory(); - } - - public boolean hasNextHistory() { - return pageMngr.hasNextHistory(); - } - - public int isInHsitory(Object pageIdentifier) { - return pageMngr.isInHsitory(pageIdentifier); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/utils/IPageUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/utils/IPageUtils.java deleted file mode 100644 index ddf15195761..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/sasheditor/contentprovider/di/utils/IPageUtils.java +++ /dev/null @@ -1,50 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 LIFL & CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.sasheditor.contentprovider.di.utils; - -import org.eclipse.papyrus.sasheditor.editor.IPage; -import org.eclipse.papyrus.sashwindows.di.PageRef; - -/** - * Class providing a utility methods allowing to get the real Model from the {@link IPage#getRawModel()}. The utility takes into account the bug - * 309943. - * - * @author cedric dumoulin - * - */ -public class IPageUtils { - - /** - * Get the real model rather than the PageRef. This method is a trick to - * temporally solve the bug 309943. - * - * @param page - * @return - */ - public static Object getRawModel(IPage page) { - - if(page == null) - return null; - - Object pageModel = page.getRawModel(); - // Get the real model because of bug - if(pageModel instanceof PageRef) { - return ((PageRef)pageModel).getPageIdentifier(); - } - // do not use trick - return pageModel; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/model/sashwindowsdi.genmodel b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/model/sashwindowsdi.genmodel index bfe1f9595d3..a77210feaf8 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/model/sashwindowsdi.genmodel +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/model/sashwindowsdi.genmodel @@ -1,8 +1,8 @@
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/model/sashwindowsdi.uml b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/model/sashwindowsdi.uml index 4dc964da7d6..014b02ff374 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/model/sashwindowsdi.uml +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/model/sashwindowsdi.uml @@ -528,7 +528,7 @@ Used to insert a new SashPanel. - + resource=XMI diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/plugin.xml b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/plugin.xml index ac17e8c0b29..392840484d8 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/plugin.xml +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/plugin.xml @@ -13,7 +13,7 @@ diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/PageListImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/PageListImpl.java index e89392e946f..974e4212191 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/PageListImpl.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/PageListImpl.java @@ -4,7 +4,7 @@ * * $Id$ */ -package org.eclipse.papyrus.sashwindows.di.impl; +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; import java.util.ArrayList; import java.util.Collection; @@ -22,10 +22,10 @@ import org.eclipse.emf.ecore.impl.EObjectImpl; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.papyrus.sashwindows.di.DiFactory; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PageList; -import org.eclipse.papyrus.sashwindows.di.PageRef; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiFactory; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageList; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; /** * @@ -34,7 +34,7 @@ import org.eclipse.papyrus.sashwindows.di.PageRef; *

* The following features are implemented: *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.PageListImpl#getAvailablePage Available Page}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageListImpl#getAvailablePage Available Page}
  • *
*

* diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/PageRefImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/PageRefImpl.java index bff08a4e3f7..fd29f53cf6f 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/PageRefImpl.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/PageRefImpl.java @@ -4,7 +4,7 @@ * * $Id$ */ -package org.eclipse.papyrus.sashwindows.di.impl; +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; @@ -18,9 +18,9 @@ import org.eclipse.emf.ecore.impl.EObjectImpl; import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.papyrus.sashwindows.di.TabFolder; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder; /** * @@ -29,8 +29,8 @@ import org.eclipse.papyrus.sashwindows.di.TabFolder; *

* The following features are implemented: *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.PageRefImpl#getPageIdentifier Page Identifier}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.PageRefImpl#getParent Parent}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageRefImpl#getPageIdentifier Page Identifier}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageRefImpl#getParent Parent}
  • *
*

* diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/SashModelImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/SashModelImpl.java index 63953519ceb..cee4503c466 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/SashModelImpl.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/SashModelImpl.java @@ -4,7 +4,7 @@ * * $Id$ */ -package org.eclipse.papyrus.sashwindows.di.impl; +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; import java.util.Collection; import java.util.List; @@ -18,16 +18,16 @@ import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.impl.EObjectImpl; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.papyrus.sashwindows.di.AbstractNode; -import org.eclipse.papyrus.sashwindows.di.AbstractPanel; -import org.eclipse.papyrus.sashwindows.di.DiFactory; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.papyrus.sashwindows.di.SashModel; -import org.eclipse.papyrus.sashwindows.di.SashPanel; -import org.eclipse.papyrus.sashwindows.di.TabFolder; -import org.eclipse.papyrus.sashwindows.di.Window; -import org.eclipse.papyrus.sashwindows.di.util.DiSwitch; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractNode; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiFactory; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder; +import org.eclipse.papyrus.infra.core.sashwindows.di.Window; +import org.eclipse.papyrus.infra.core.sashwindows.di.util.DiSwitch; import org.eclipse.swt.SWT; /** @@ -37,8 +37,8 @@ import org.eclipse.swt.SWT; *

* The following features are implemented: *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.SashModelImpl#getWindows Windows}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.SashModelImpl#getCurrentSelection Current Selection}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashModelImpl#getWindows Windows}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashModelImpl#getCurrentSelection Current Selection}
  • *
*

* @@ -80,7 +80,7 @@ public class SashModelImpl extends EObjectImpl implements SashModel { /** * Iterate over windows - * @see org.eclipse.papyrus.sashwindows.di.util.DiSwitch#caseSashModel(org.eclipse.papyrus.sashwindows.di.SashModel) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.util.DiSwitch#caseSashModel(org.eclipse.papyrus.infra.core.sashwindows.di.SashModel) * * @param object * @return @@ -99,7 +99,7 @@ public class SashModelImpl extends EObjectImpl implements SashModel { /** * Iterate over children - * @see org.eclipse.papyrus.sashwindows.di.util.DiSwitch#caseSashPanel(org.eclipse.papyrus.sashwindows.di.SashPanel) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.util.DiSwitch#caseSashPanel(org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel) * * @param object * @return @@ -118,7 +118,7 @@ public class SashModelImpl extends EObjectImpl implements SashModel { /** * Iterate over PageRef - * @see org.eclipse.papyrus.sashwindows.di.util.DiSwitch#caseTabFolder(org.eclipse.papyrus.sashwindows.di.TabFolder) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.util.DiSwitch#caseTabFolder(org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder) * * @param object * @return diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/SashPanelImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/SashPanelImpl.java index c7f05039fff..f4f555fa25e 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/SashPanelImpl.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/SashPanelImpl.java @@ -4,7 +4,7 @@ * * $Id$ */ -package org.eclipse.papyrus.sashwindows.di.impl; +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; import java.util.Collection; import java.util.List; @@ -22,10 +22,10 @@ import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.papyrus.sashwindows.di.AbstractNode; -import org.eclipse.papyrus.sashwindows.di.AbstractPanel; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.SashPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractNode; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel; /** * @@ -34,9 +34,9 @@ import org.eclipse.papyrus.sashwindows.di.SashPanel; *

* The following features are implemented: *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.SashPanelImpl#getChildren Children}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.SashPanelImpl#getSashPosition Sash Position}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.SashPanelImpl#getDirection Direction}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashPanelImpl#getChildren Children}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashPanelImpl#getSashPosition Sash Position}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashPanelImpl#getDirection Direction}
  • *
*

* diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/TabFolderImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/TabFolderImpl.java index 087cfc1a282..072132603ab 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/TabFolderImpl.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/TabFolderImpl.java @@ -4,7 +4,7 @@ * * $Id$ */ -package org.eclipse.papyrus.sashwindows.di.impl; +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; import java.util.Collection; @@ -14,10 +14,10 @@ import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.papyrus.sashwindows.di.DiFactory; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.papyrus.sashwindows.di.TabFolder; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiFactory; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder; /** * @@ -26,7 +26,7 @@ import org.eclipse.papyrus.sashwindows.di.TabFolder; *

* The following features are implemented: *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.TabFolderImpl#getChildren Children}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.TabFolderImpl#getChildren Children}
  • *
*

* @@ -56,7 +56,7 @@ public class TabFolderImpl extends AbstractPanelImpl implements TabFolder { /** * - * @see org.eclipse.papyrus.sashwindows.di.TabFolder#movePage(int, int) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder#movePage(int, int) * * @param oldIndex * @param newIndex diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/WindowImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/WindowImpl.java index 7f4c528192a..089e0e3e360 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/WindowImpl.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/impl/WindowImpl.java @@ -4,18 +4,18 @@ * * $Id$ */ -package org.eclipse.papyrus.sashwindows.di.impl; +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.papyrus.sashwindows.di.AbstractPanel; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.Position; -import org.eclipse.papyrus.sashwindows.di.Size; -import org.eclipse.papyrus.sashwindows.di.Window; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.Position; +import org.eclipse.papyrus.infra.core.sashwindows.di.Size; +import org.eclipse.papyrus.infra.core.sashwindows.di.Window; /** * @@ -24,9 +24,9 @@ import org.eclipse.papyrus.sashwindows.di.Window; *

* The following features are implemented: *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.WindowImpl#getPanel Panel}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.WindowImpl#getPosition Position}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.WindowImpl#getSize Size}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.WindowImpl#getPanel Panel}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.WindowImpl#getPosition Position}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.WindowImpl#getSize Size}
  • *
*

* diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/util/DiUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/util/DiUtils.java index 70056450b2c..5829076e157 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/util/DiUtils.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src-spare/org/eclipse/papyrus/sashwindows/di/util/DiUtils.java @@ -12,15 +12,15 @@ * *****************************************************************************/ -package org.eclipse.papyrus.sashwindows.di.util; +package org.eclipse.papyrus.infra.core.sashwindows.di.util; import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.papyrus.sashwindows.di.DiFactory; -import org.eclipse.papyrus.sashwindows.di.PageList; -import org.eclipse.papyrus.sashwindows.di.SashModel; -import org.eclipse.papyrus.sashwindows.di.SashWindowsMngr; -import org.eclipse.papyrus.sashwindows.di.TabFolder; -import org.eclipse.papyrus.sashwindows.di.Window; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiFactory; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageList; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr; +import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder; +import org.eclipse.papyrus.infra.core.sashwindows.di.Window; /** diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/AbstractPage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/AbstractPage.java new file mode 100644 index 00000000000..8c07675e391 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/AbstractPage.java @@ -0,0 +1,58 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di; + +import org.eclipse.emf.ecore.EObject; + +/** + * A representation of the model object ' Abstract Page'. + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPage#getPageIdentifier + * Page Identifier}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getAbstractPage() + * @model + * @generated + */ +public interface AbstractPage extends EObject { + + /** + * Returns the value of the 'Page Identifier' attribute. + * + *

+ * If the meaning of the 'Page Identifier' attribute isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Page Identifier' attribute. + * @see #setPageIdentifier(Object) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getAbstractPage_PageIdentifier() + * @model unique="false" + * dataType="org.eclipse.papyrus.infra.core.sashwindows.di.JavaObject" + * required="true" ordered="false" + * @generated + */ + Object getPageIdentifier(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPage#getPageIdentifier + * Page Identifier}' attribute. + * + * @param value + * the new value of the 'Page Identifier' attribute. + * @see #getPageIdentifier() + * @generated + */ + void setPageIdentifier(Object value); + +} // AbstractPage diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/AbstractPanel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/AbstractPanel.java new file mode 100644 index 00000000000..ca5361724b3 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/AbstractPanel.java @@ -0,0 +1,57 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di; + +import org.eclipse.emf.ecore.EObject; + +/** + * A representation of the model object ' Abstract Panel'. + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel#getParent Parent}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getAbstractPanel() + * @model abstract="true" + * @generated + */ +public interface AbstractPanel extends EObject { + + /** + * Returns the value of the 'Parent' container reference. It + * is bidirectional and its opposite is ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent#getChildren + * Children}'. + *

+ * If the meaning of the 'Parent' container reference isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Parent' container reference. + * @see #setParent(PanelParent) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getAbstractPanel_Parent() + * @see org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent#getChildren + * @model opposite="children" required="true" transient="false" + * ordered="false" + * @generated + */ + PanelParent getParent(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel#getParent + * Parent}' container reference. + * + * @param value + * the new value of the 'Parent' container reference. + * @see #getParent() + * @generated + */ + void setParent(PanelParent value); +} // AbstractPanel diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/DiFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/DiFactory.java new file mode 100644 index 00000000000..07a00b69899 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/DiFactory.java @@ -0,0 +1,127 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di; + +import org.eclipse.emf.ecore.EFactory; + +/** + * The Factory for the model. It provides a + * create method for each non-abstract class of the model. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage + * @generated + */ +public interface DiFactory extends EFactory { + + /** + * The singleton instance of the factory. + * + * @generated + */ + DiFactory eINSTANCE = org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiFactoryImpl.init(); + + /** + * Returns a new object of class 'Sash Model'. + * + * @return a new object of class 'Sash Model'. + * @generated + */ + SashModel createSashModel(); + + /** + * Returns a new object of class 'Window'. + * + * + * @return a new object of class 'Window'. + * @generated + */ + Window createWindow(); + + /** + * Returns a new object of class 'Position'. + * + * @return a new object of class 'Position'. + * @generated + */ + Position createPosition(); + + /** + * Returns a new object of class 'Size'. + * + * + * @return a new object of class 'Size'. + * @generated + */ + Size createSize(); + + /** + * Returns a new object of class 'Tab Folder'. + * + * @return a new object of class 'Tab Folder'. + * @generated + */ + TabFolder createTabFolder(); + + /** + * Returns a new object of class 'Page Ref'. + * + * @return a new object of class 'Page Ref'. + * @generated + */ + PageRef createPageRef(); + + /** + * Returns a new object of class 'Sash Panel'. + * + * @return a new object of class 'Sash Panel'. + * @generated + */ + SashPanel createSashPanel(); + + /** + * Returns a new object of class 'Abstract Page'. + * + * @return a new object of class 'Abstract Page'. + * @generated + */ + AbstractPage createAbstractPage(); + + /** + * Returns a new object of class 'Page List'. + * + * @return a new object of class 'Page List'. + * @generated + */ + PageList createPageList(); + + /** + * Returns a new object of class 'Sash Windows Mngr'. + * + * @return a new object of class 'Sash Windows Mngr'. + * @generated + */ + SashWindowsMngr createSashWindowsMngr(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + DiPackage getDiPackage(); + +} // DiFactory diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/DiPackage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/DiPackage.java new file mode 100644 index 00000000000..8d9c684e179 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/DiPackage.java @@ -0,0 +1,1349 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +/** + * The Package for the model. It contains + * accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiFactory + * @model kind="package" + * @generated + */ +public interface DiPackage extends EPackage { + + /** + * The package name. + * + * @generated + */ + String eNAME = "di"; + + /** + * The package namespace URI. + * + * @generated + */ + String eNS_URI = "http://www.eclipse.org/papyrus/0.7.0/sashdi"; + + /** + * The package namespace name. + * + * @generated + */ + String eNS_PREFIX = "di"; + + /** + * The singleton instance of the package. + * + * @generated + */ + DiPackage eINSTANCE = org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl.init(); + + /** + * The meta object id for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashModelImpl + * Sash Model}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashModelImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getSashModel() + * @generated + */ + int SASH_MODEL = 0; + + /** + * The feature id for the 'Windows' containment reference + * list. + * + * @generated + * @ordered + */ + int SASH_MODEL__WINDOWS = 0; + + /** + * The feature id for the 'Current Selection' reference. + * + * + * @generated + * @ordered + */ + int SASH_MODEL__CURRENT_SELECTION = 1; + + /** + * The number of structural features of the 'Sash Model' class. + * + * + * @generated + * @ordered + */ + int SASH_MODEL_FEATURE_COUNT = 2; + + /** + * The meta object id for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PanelParentImpl + * Panel Parent}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.PanelParentImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getPanelParent() + * @generated + */ + int PANEL_PARENT = 2; + + /** + * The feature id for the 'Children' containment reference + * list. + * + * @generated + * @ordered + */ + int PANEL_PARENT__CHILDREN = 0; + + /** + * The number of structural features of the 'Panel Parent' class. + * + * + * @generated + * @ordered + */ + int PANEL_PARENT_FEATURE_COUNT = 1; + + /** + * The meta object id for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.WindowImpl + * Window}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.WindowImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getWindow() + * @generated + */ + int WINDOW = 1; + + /** + * The feature id for the 'Children' containment reference + * list. + * + * @generated + * @ordered + */ + int WINDOW__CHILDREN = PANEL_PARENT__CHILDREN; + + /** + * The feature id for the 'Position' reference. + * + * @generated + * @ordered + */ + int WINDOW__POSITION = PANEL_PARENT_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Size' reference. + * + * @generated + * @ordered + */ + int WINDOW__SIZE = PANEL_PARENT_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Panel' reference. + * + * @generated + * @ordered + */ + int WINDOW__PANEL = PANEL_PARENT_FEATURE_COUNT + 2; + + /** + * The number of structural features of the 'Window' class. + * + * @generated + * @ordered + */ + int WINDOW_FEATURE_COUNT = PANEL_PARENT_FEATURE_COUNT + 3; + + /** + * The meta object id for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.AbstractPanelImpl + * Abstract Panel}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.AbstractPanelImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getAbstractPanel() + * @generated + */ + int ABSTRACT_PANEL = 3; + + /** + * The feature id for the 'Parent' container reference. + * + * @generated + * @ordered + */ + int ABSTRACT_PANEL__PARENT = 0; + + /** + * The number of structural features of the 'Abstract Panel' class. + * + * + * @generated + * @ordered + */ + int ABSTRACT_PANEL_FEATURE_COUNT = 1; + + /** + * The meta object id for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PositionImpl + * Position}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.PositionImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getPosition() + * @generated + */ + int POSITION = 4; + + /** + * The feature id for the 'X' attribute. + * + * @generated + * @ordered + */ + int POSITION__X = 0; + + /** + * The feature id for the 'Y' attribute. + * + * @generated + * @ordered + */ + int POSITION__Y = 1; + + /** + * The number of structural features of the 'Position' class. + * + * @generated + * @ordered + */ + int POSITION_FEATURE_COUNT = 2; + + /** + * The meta object id for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SizeImpl Size}' + * class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.SizeImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getSize() + * @generated + */ + int SIZE = 5; + + /** + * The feature id for the 'Width' attribute. + * + * @generated + * @ordered + */ + int SIZE__WIDTH = 0; + + /** + * The feature id for the 'Length' attribute. + * + * @generated + * @ordered + */ + int SIZE__LENGTH = 1; + + /** + * The number of structural features of the 'Size' class. + * + * @generated + * @ordered + */ + int SIZE_FEATURE_COUNT = 2; + + /** + * The meta object id for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.TabFolderImpl + * Tab Folder}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.TabFolderImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getTabFolder() + * @generated + */ + int TAB_FOLDER = 6; + + /** + * The feature id for the 'Parent' container reference. + * + * @generated + * @ordered + */ + int TAB_FOLDER__PARENT = ABSTRACT_PANEL__PARENT; + + /** + * The feature id for the 'Children' containment reference + * list. + * + * @generated + * @ordered + */ + int TAB_FOLDER__CHILDREN = ABSTRACT_PANEL_FEATURE_COUNT + 0; + + /** + * The number of structural features of the 'Tab Folder' class. + * + * + * @generated + * @ordered + */ + int TAB_FOLDER_FEATURE_COUNT = ABSTRACT_PANEL_FEATURE_COUNT + 1; + + /** + * The meta object id for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageRefImpl + * Page Ref}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageRefImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getPageRef() + * @generated + */ + int PAGE_REF = 7; + + /** + * The feature id for the 'Emf Page Identifier' reference. + * + * + * @generated + * @ordered + */ + int PAGE_REF__EMF_PAGE_IDENTIFIER = 0; + + /** + * The feature id for the 'Page Identifier' attribute. + * + * @generated + * @ordered + */ + int PAGE_REF__PAGE_IDENTIFIER = 1; + + /** + * The feature id for the 'Object Page Identifier' + * attribute. + * + * @generated + * @ordered + */ + int PAGE_REF__OBJECT_PAGE_IDENTIFIER = 2; + + /** + * The feature id for the 'Parent' container reference. + * + * @generated + * @ordered + */ + int PAGE_REF__PARENT = 3; + + /** + * The number of structural features of the 'Page Ref' class. + * + * @generated + * @ordered + */ + int PAGE_REF_FEATURE_COUNT = 4; + + /** + * The meta object id for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashPanelImpl + * Sash Panel}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashPanelImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getSashPanel() + * @generated + */ + int SASH_PANEL = 8; + + /** + * The feature id for the 'Parent' container reference. + * + * @generated + * @ordered + */ + int SASH_PANEL__PARENT = ABSTRACT_PANEL__PARENT; + + /** + * The feature id for the 'Children' containment reference + * list. + * + * @generated + * @ordered + */ + int SASH_PANEL__CHILDREN = ABSTRACT_PANEL_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Sash Position' attribute. + * + * @generated + * @ordered + */ + int SASH_PANEL__SASH_POSITION = ABSTRACT_PANEL_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Direction' attribute. + * + * @generated + * @ordered + */ + int SASH_PANEL__DIRECTION = ABSTRACT_PANEL_FEATURE_COUNT + 2; + + /** + * The number of structural features of the 'Sash Panel' class. + * + * + * @generated + * @ordered + */ + int SASH_PANEL_FEATURE_COUNT = ABSTRACT_PANEL_FEATURE_COUNT + 3; + + /** + * The meta object id for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.AbstractPageImpl + * Abstract Page}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.AbstractPageImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getAbstractPage() + * @generated + */ + int ABSTRACT_PAGE = 9; + + /** + * The feature id for the 'Page Identifier' attribute. + * + * @generated + * @ordered + */ + int ABSTRACT_PAGE__PAGE_IDENTIFIER = 0; + + /** + * The number of structural features of the 'Abstract Page' class. + * + * + * @generated + * @ordered + */ + int ABSTRACT_PAGE_FEATURE_COUNT = 1; + + /** + * The meta object id for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageListImpl + * Page List}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageListImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getPageList() + * @generated + */ + int PAGE_LIST = 10; + + /** + * The feature id for the 'Available Page' containment + * reference list. + * + * @generated + * @ordered + */ + int PAGE_LIST__AVAILABLE_PAGE = 0; + + /** + * The number of structural features of the 'Page List' class. + * + * @generated + * @ordered + */ + int PAGE_LIST_FEATURE_COUNT = 1; + + /** + * The meta object id for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashWindowsMngrImpl + * Sash Windows Mngr}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashWindowsMngrImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getSashWindowsMngr() + * @generated + */ + int SASH_WINDOWS_MNGR = 11; + + /** + * The feature id for the 'Page List' containment reference. + * + * + * @generated + * @ordered + */ + int SASH_WINDOWS_MNGR__PAGE_LIST = 0; + + /** + * The feature id for the 'Sash Model' containment + * reference. + * + * @generated + * @ordered + */ + int SASH_WINDOWS_MNGR__SASH_MODEL = 1; + + /** + * The number of structural features of the 'Sash Windows Mngr' + * class. + * + * @generated + * @ordered + */ + int SASH_WINDOWS_MNGR_FEATURE_COUNT = 2; + + /** + * The meta object id for the 'int' data type. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getint() + * @generated + */ + int INT = 12; + + /** + * The meta object id for the 'Java Object' data type. + * + * @see java.lang.Object + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getJavaObject() + * @generated + */ + int JAVA_OBJECT = 13; + + /** + * The meta object id for the 'Float' data type. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getFloat() + * @generated + */ + int FLOAT = 14; + + /** + * The meta object id for the 'boolean' data type. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getboolean() + * @generated + */ + int BOOLEAN = 15; + + /** + * Returns the meta object for class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashModel Sash Model} '. + * + * @return the meta object for class 'Sash Model'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.SashModel + * @generated + */ + EClass getSashModel(); + + /** + * Returns the meta object for the containment reference list ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashModel#getWindows + * Windows}'. + * + * @return the meta object for the containment reference list ' Windows'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.SashModel#getWindows() + * @see #getSashModel() + * @generated + */ + EReference getSashModel_Windows(); + + /** + * Returns the meta object for the reference ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashModel#getCurrentSelection + * Current Selection}'. + * + * @return the meta object for the reference 'Current Selection'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.SashModel#getCurrentSelection() + * @see #getSashModel() + * @generated + */ + EReference getSashModel_CurrentSelection(); + + /** + * Returns the meta object for class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Window Window}'. + * + * @return the meta object for class 'Window'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.Window + * @generated + */ + EClass getWindow(); + + /** + * Returns the meta object for the reference ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Window#getPosition + * Position}'. + * + * @return the meta object for the reference 'Position'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.Window#getPosition() + * @see #getWindow() + * @generated + */ + EReference getWindow_Position(); + + /** + * Returns the meta object for the reference ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Window#getSize Size}'. + * + * + * @return the meta object for the reference 'Size'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.Window#getSize() + * @see #getWindow() + * @generated + */ + EReference getWindow_Size(); + + /** + * Returns the meta object for the reference ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Window#getPanel Panel} '. + * + * @return the meta object for the reference 'Panel'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.Window#getPanel() + * @see #getWindow() + * @generated + */ + EReference getWindow_Panel(); + + /** + * Returns the meta object for class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent + * Panel Parent}'. + * + * @return the meta object for class 'Panel Parent'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent + * @generated + */ + EClass getPanelParent(); + + /** + * Returns the meta object for the containment reference list ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent#getChildren + * Children}'. + * + * @return the meta object for the containment reference list ' Children'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent#getChildren() + * @see #getPanelParent() + * @generated + */ + EReference getPanelParent_Children(); + + /** + * Returns the meta object for class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel + * Abstract Panel}'. + * + * @return the meta object for class 'Abstract Panel'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel + * @generated + */ + EClass getAbstractPanel(); + + /** + * Returns the meta object for the container reference ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel#getParent + * Parent}'. + * + * @return the meta object for the container reference 'Parent'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel#getParent() + * @see #getAbstractPanel() + * @generated + */ + EReference getAbstractPanel_Parent(); + + /** + * Returns the meta object for class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Position Position}'. + * + * + * @return the meta object for class 'Position'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.Position + * @generated + */ + EClass getPosition(); + + /** + * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Position#getX X}'. + * + * + * @return the meta object for the attribute 'X'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.Position#getX() + * @see #getPosition() + * @generated + */ + EAttribute getPosition_X(); + + /** + * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Position#getY Y}'. + * + * + * @return the meta object for the attribute 'Y'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.Position#getY() + * @see #getPosition() + * @generated + */ + EAttribute getPosition_Y(); + + /** + * Returns the meta object for class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Size Size}'. + * + * @return the meta object for class 'Size'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.Size + * @generated + */ + EClass getSize(); + + /** + * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Size#getWidth Width}'. + * + * + * @return the meta object for the attribute 'Width'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.Size#getWidth() + * @see #getSize() + * @generated + */ + EAttribute getSize_Width(); + + /** + * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Size#getLength Length} '. + * + * @return the meta object for the attribute 'Length'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.Size#getLength() + * @see #getSize() + * @generated + */ + EAttribute getSize_Length(); + + /** + * Returns the meta object for class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder Tab Folder} '. + * + * @return the meta object for class 'Tab Folder'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder + * @generated + */ + EClass getTabFolder(); + + /** + * Returns the meta object for the containment reference list ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder#getChildren + * Children}'. + * + * @return the meta object for the containment reference list ' Children'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder#getChildren() + * @see #getTabFolder() + * @generated + */ + EReference getTabFolder_Children(); + + /** + * Returns the meta object for class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef Page Ref}'. + * + * + * @return the meta object for class 'Page Ref'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.PageRef + * @generated + */ + EClass getPageRef(); + + /** + * Returns the meta object for the reference ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getEmfPageIdentifier + * Emf Page Identifier}'. + * + * @return the meta object for the reference 'Emf Page Identifier'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getEmfPageIdentifier() + * @see #getPageRef() + * @generated + */ + EReference getPageRef_EmfPageIdentifier(); + + /** + * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getPageIdentifier + * Page Identifier}'. + * + * @return the meta object for the attribute 'Page Identifier'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getPageIdentifier() + * @see #getPageRef() + * @generated + */ + EAttribute getPageRef_PageIdentifier(); + + /** + * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getObjectPageIdentifier + * Object Page Identifier}'. + * + * @return the meta object for the attribute ' Object Page Identifier'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getObjectPageIdentifier() + * @see #getPageRef() + * @generated + */ + EAttribute getPageRef_ObjectPageIdentifier(); + + /** + * Returns the meta object for the container reference ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getParent + * Parent}'. + * + * @return the meta object for the container reference 'Parent'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getParent() + * @see #getPageRef() + * @generated + */ + EReference getPageRef_Parent(); + + /** + * Returns the meta object for class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel Sash Panel} '. + * + * @return the meta object for class 'Sash Panel'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel + * @generated + */ + EClass getSashPanel(); + + /** + * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel#getSashPosition + * Sash Position}'. + * + * @return the meta object for the attribute 'Sash Position'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel#getSashPosition() + * @see #getSashPanel() + * @generated + */ + EAttribute getSashPanel_SashPosition(); + + /** + * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel#getDirection + * Direction}'. + * + * @return the meta object for the attribute 'Direction'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel#getDirection() + * @see #getSashPanel() + * @generated + */ + EAttribute getSashPanel_Direction(); + + /** + * Returns the meta object for class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPage + * Abstract Page}'. + * + * @return the meta object for class 'Abstract Page'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPage + * @generated + */ + EClass getAbstractPage(); + + /** + * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPage#getPageIdentifier + * Page Identifier}'. + * + * @return the meta object for the attribute 'Page Identifier'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPage#getPageIdentifier() + * @see #getAbstractPage() + * @generated + */ + EAttribute getAbstractPage_PageIdentifier(); + + /** + * Returns the meta object for class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageList Page List}'. + * + * + * @return the meta object for class 'Page List'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.PageList + * @generated + */ + EClass getPageList(); + + /** + * Returns the meta object for the containment reference list ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageList#getAvailablePage + * Available Page}'. + * + * @return the meta object for the containment reference list ' Available Page'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.PageList#getAvailablePage() + * @see #getPageList() + * @generated + */ + EReference getPageList_AvailablePage(); + + /** + * Returns the meta object for class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr + * Sash Windows Mngr}'. + * + * @return the meta object for class 'Sash Windows Mngr'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr + * @generated + */ + EClass getSashWindowsMngr(); + + /** + * Returns the meta object for the containment reference ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr#getPageList + * Page List}'. + * + * @return the meta object for the containment reference 'Page List '. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr#getPageList() + * @see #getSashWindowsMngr() + * @generated + */ + EReference getSashWindowsMngr_PageList(); + + /** + * Returns the meta object for the containment reference ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr#getSashModel + * Sash Model}'. + * + * @return the meta object for the containment reference ' Sash Model'. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr#getSashModel() + * @see #getSashWindowsMngr() + * @generated + */ + EReference getSashWindowsMngr_SashModel(); + + /** + * Returns the meta object for data type 'int'. + * + * @return the meta object for data type 'int'. + * @model instanceClass="int" + * @generated + */ + EDataType getint(); + + /** + * Returns the meta object for data type '{@link java.lang.Object + * Java Object}'. + * + * @return the meta object for data type 'Java Object'. + * @see java.lang.Object + * @model instanceClass="java.lang.Object" + * @generated + */ + EDataType getJavaObject(); + + /** + * Returns the meta object for data type 'Float'. + * + * @return the meta object for data type 'Float'. + * @model instanceClass="float" + * @generated + */ + EDataType getFloat(); + + /** + * Returns the meta object for data type 'boolean'. + * + * @return the meta object for data type 'boolean'. + * @model instanceClass="boolean" + * @generated + */ + EDataType getboolean(); + + /** + * Returns the factory that creates the instances of the model. + * + * @return the factory that creates the instances of the model. + * @generated + */ + DiFactory getDiFactory(); + + /** + * Defines literals for the meta objects that + * represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * + * @generated + */ + interface Literals { + + /** + * The meta object literal for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashModelImpl + * Sash Model}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashModelImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getSashModel() + * @generated + */ + EClass SASH_MODEL = eINSTANCE.getSashModel(); + + /** + * The meta object literal for the 'Windows' containment + * reference list feature. + * + * @generated + */ + EReference SASH_MODEL__WINDOWS = eINSTANCE.getSashModel_Windows(); + + /** + * The meta object literal for the 'Current Selection' + * reference feature. + * + * @generated + */ + EReference SASH_MODEL__CURRENT_SELECTION = eINSTANCE.getSashModel_CurrentSelection(); + + /** + * The meta object literal for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.WindowImpl + * Window}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.WindowImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getWindow() + * @generated + */ + EClass WINDOW = eINSTANCE.getWindow(); + + /** + * The meta object literal for the 'Position' reference + * feature. + * + * @generated + */ + EReference WINDOW__POSITION = eINSTANCE.getWindow_Position(); + + /** + * The meta object literal for the 'Size' reference + * feature. + * + * @generated + */ + EReference WINDOW__SIZE = eINSTANCE.getWindow_Size(); + + /** + * The meta object literal for the 'Panel' reference + * feature. + * + * @generated + */ + EReference WINDOW__PANEL = eINSTANCE.getWindow_Panel(); + + /** + * The meta object literal for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PanelParentImpl + * Panel Parent}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.PanelParentImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getPanelParent() + * @generated + */ + EClass PANEL_PARENT = eINSTANCE.getPanelParent(); + + /** + * The meta object literal for the 'Children' + * containment reference list feature. + * + * @generated + */ + EReference PANEL_PARENT__CHILDREN = eINSTANCE.getPanelParent_Children(); + + /** + * The meta object literal for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.AbstractPanelImpl + * Abstract Panel}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.AbstractPanelImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getAbstractPanel() + * @generated + */ + EClass ABSTRACT_PANEL = eINSTANCE.getAbstractPanel(); + + /** + * The meta object literal for the 'Parent' container + * reference feature. + * + * @generated + */ + EReference ABSTRACT_PANEL__PARENT = eINSTANCE.getAbstractPanel_Parent(); + + /** + * The meta object literal for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PositionImpl + * Position}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.PositionImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getPosition() + * @generated + */ + EClass POSITION = eINSTANCE.getPosition(); + + /** + * The meta object literal for the 'X' attribute + * feature. + * + * @generated + */ + EAttribute POSITION__X = eINSTANCE.getPosition_X(); + + /** + * The meta object literal for the 'Y' attribute + * feature. + * + * @generated + */ + EAttribute POSITION__Y = eINSTANCE.getPosition_Y(); + + /** + * The meta object literal for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SizeImpl + * Size}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.SizeImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getSize() + * @generated + */ + EClass SIZE = eINSTANCE.getSize(); + + /** + * The meta object literal for the 'Width' attribute + * feature. + * + * @generated + */ + EAttribute SIZE__WIDTH = eINSTANCE.getSize_Width(); + + /** + * The meta object literal for the 'Length' attribute + * feature. + * + * @generated + */ + EAttribute SIZE__LENGTH = eINSTANCE.getSize_Length(); + + /** + * The meta object literal for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.TabFolderImpl + * Tab Folder}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.TabFolderImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getTabFolder() + * @generated + */ + EClass TAB_FOLDER = eINSTANCE.getTabFolder(); + + /** + * The meta object literal for the 'Children' + * containment reference list feature. + * + * @generated + */ + EReference TAB_FOLDER__CHILDREN = eINSTANCE.getTabFolder_Children(); + + /** + * The meta object literal for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageRefImpl + * Page Ref}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageRefImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getPageRef() + * @generated + */ + EClass PAGE_REF = eINSTANCE.getPageRef(); + + /** + * The meta object literal for the 'Emf Page Identifier' + * reference feature. + * + * @generated + */ + EReference PAGE_REF__EMF_PAGE_IDENTIFIER = eINSTANCE.getPageRef_EmfPageIdentifier(); + + /** + * The meta object literal for the 'Page Identifier' + * attribute feature. + * + * @generated + */ + EAttribute PAGE_REF__PAGE_IDENTIFIER = eINSTANCE.getPageRef_PageIdentifier(); + + /** + * The meta object literal for the ' Object Page Identifier' attribute feature. + * + * @generated + */ + EAttribute PAGE_REF__OBJECT_PAGE_IDENTIFIER = eINSTANCE.getPageRef_ObjectPageIdentifier(); + + /** + * The meta object literal for the 'Parent' container + * reference feature. + * + * @generated + */ + EReference PAGE_REF__PARENT = eINSTANCE.getPageRef_Parent(); + + /** + * The meta object literal for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashPanelImpl + * Sash Panel}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashPanelImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getSashPanel() + * @generated + */ + EClass SASH_PANEL = eINSTANCE.getSashPanel(); + + /** + * The meta object literal for the 'Sash Position' + * attribute feature. + * + * @generated + */ + EAttribute SASH_PANEL__SASH_POSITION = eINSTANCE.getSashPanel_SashPosition(); + + /** + * The meta object literal for the 'Direction' attribute + * feature. + * + * @generated + */ + EAttribute SASH_PANEL__DIRECTION = eINSTANCE.getSashPanel_Direction(); + + /** + * The meta object literal for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.AbstractPageImpl + * Abstract Page}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.AbstractPageImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getAbstractPage() + * @generated + */ + EClass ABSTRACT_PAGE = eINSTANCE.getAbstractPage(); + + /** + * The meta object literal for the 'Page Identifier' + * attribute feature. + * + * @generated + */ + EAttribute ABSTRACT_PAGE__PAGE_IDENTIFIER = eINSTANCE.getAbstractPage_PageIdentifier(); + + /** + * The meta object literal for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageListImpl + * Page List}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageListImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getPageList() + * @generated + */ + EClass PAGE_LIST = eINSTANCE.getPageList(); + + /** + * The meta object literal for the 'Available Page' + * containment reference list feature. + * + * @generated + */ + EReference PAGE_LIST__AVAILABLE_PAGE = eINSTANCE.getPageList_AvailablePage(); + + /** + * The meta object literal for the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashWindowsMngrImpl + * Sash Windows Mngr}' class. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashWindowsMngrImpl + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getSashWindowsMngr() + * @generated + */ + EClass SASH_WINDOWS_MNGR = eINSTANCE.getSashWindowsMngr(); + + /** + * The meta object literal for the 'Page List' + * containment reference feature. + * + * @generated + */ + EReference SASH_WINDOWS_MNGR__PAGE_LIST = eINSTANCE.getSashWindowsMngr_PageList(); + + /** + * The meta object literal for the 'Sash Model' + * containment reference feature. + * + * @generated + */ + EReference SASH_WINDOWS_MNGR__SASH_MODEL = eINSTANCE.getSashWindowsMngr_SashModel(); + + /** + * The meta object literal for the 'int' data type. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getint() + * @generated + */ + EDataType INT = eINSTANCE.getint(); + + /** + * The meta object literal for the 'Java Object' data type. + * + * + * @see java.lang.Object + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getJavaObject() + * @generated + */ + EDataType JAVA_OBJECT = eINSTANCE.getJavaObject(); + + /** + * The meta object literal for the 'Float' data type. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getFloat() + * @generated + */ + EDataType FLOAT = eINSTANCE.getFloat(); + + /** + * The meta object literal for the 'boolean' data type. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.impl.DiPackageImpl#getboolean() + * @generated + */ + EDataType BOOLEAN = eINSTANCE.getboolean(); + + } + +} // DiPackage diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/PageList.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/PageList.java new file mode 100644 index 00000000000..2a59fb60323 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/PageList.java @@ -0,0 +1,65 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; + +/** + * A representation of the model object ' Page List'. + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageList#getAvailablePage Available Page}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getPageList() + * @model + * @generated + */ +public interface PageList extends EObject { + + /** + * Returns the value of the 'Available Page' containment + * reference list. The list contents are of type {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef}. + *

+ * If the meaning of the 'Available Page' containment reference list isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Available Page' containment reference + * list. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getPageList_AvailablePage() + * @model containment="true" ordered="false" + * @generated + */ + EList getAvailablePage(); + + /** + * + * + * @model + * pageIdentifierDataType="org.eclipse.papyrus.infra.core.sashwindows.di.JavaObject" + * pageIdentifierRequired="true" pageIdentifierOrdered="false" + * @generated + */ + void addPage(Object pageIdentifier); + + /** + * + * + * @model + * pageIdentifierDataType="org.eclipse.papyrus.infra.core.sashwindows.di.JavaObject" + * pageIdentifierRequired="true" pageIdentifierOrdered="false" + * @generated + */ + void removePage(Object pageIdentifier); + +} // PageList diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/PageRef.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/PageRef.java new file mode 100644 index 00000000000..276fda77a42 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/PageRef.java @@ -0,0 +1,160 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di; + +import org.eclipse.emf.ecore.EObject; + +/** + * A representation of the model object ' Page Ref'. + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getEmfPageIdentifier + * Emf Page Identifier}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getPageIdentifier Page Identifier}
  • + *
  • + * {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getObjectPageIdentifier + * Object Page Identifier}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getParent Parent }
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getPageRef() + * @model + * @generated + */ +public interface PageRef extends EObject { + + /** + * Returns the value of the 'Emf Page Identifier' reference. + * + *

+ * If the meaning of the 'Emf Page Identifier' reference isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Emf Page Identifier' reference. + * @see #setEmfPageIdentifier(EObject) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getPageRef_EmfPageIdentifier() + * @model required="true" ordered="false" + * @generated + */ + EObject getEmfPageIdentifier(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getEmfPageIdentifier + * Emf Page Identifier}' reference. + * + * @param value + * the new value of the 'Emf Page Identifier' reference. + * @see #getEmfPageIdentifier() + * @generated + */ + void setEmfPageIdentifier(EObject value); + + /** + * Returns the value of the 'Page Identifier' attribute. + * + * pageIdentifier can be a plain JavaObject or an EObject. They are not + * stored in the same place. + * + * @return the value of the 'Page Identifier' attribute. + * @see #setPageIdentifier(Object) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getPageRef_PageIdentifier() + * @model unique="false" + * dataType="org.eclipse.papyrus.infra.core.sashwindows.di.JavaObject" + * required="true" transient="true" volatile="true" derived="true" + * ordered="false" + * @generated + */ + Object getPageIdentifier(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getPageIdentifier + * Page Identifier}' attribute. + * + * @param value + * the new value of the 'Page Identifier' attribute. + * @see #getPageIdentifier() + * @generated + */ + void setPageIdentifier(Object value); + + /** + * Returns the value of the 'Object Page Identifier' + * attribute. Storage to store Identifier that are not EObject. + * + * + * @return the value of the 'Object Page Identifier' attribute. + * @see #setObjectPageIdentifier(Object) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getPageRef_ObjectPageIdentifier() + * @model unique="false" + * dataType="org.eclipse.papyrus.infra.core.sashwindows.di.JavaObject" + * required="true" ordered="false" + * @generated + */ + Object getObjectPageIdentifier(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getObjectPageIdentifier + * Object Page Identifier}' attribute. + * + * @param value + * the new value of the 'Object Page Identifier' + * attribute. + * @see #getObjectPageIdentifier() + * @generated + */ + void setObjectPageIdentifier(Object value); + + /** + * Returns the value of the 'Parent' container reference. It + * is bidirectional and its opposite is ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder#getChildren + * Children}'. + *

+ * If the meaning of the 'Parent' container reference isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Parent' container reference. + * @see #setParent(TabFolder) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getPageRef_Parent() + * @see org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder#getChildren + * @model opposite="children" required="true" transient="false" + * ordered="false" + * @generated + */ + TabFolder getParent(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getParent + * Parent}' container reference. + * + * @param value + * the new value of the 'Parent' container reference. + * @see #getParent() + * @generated + */ + void setParent(TabFolder value); + + /** + * + * + * @model required="true" ordered="false" + * pageIdentifierDataType="org.eclipse.papyrus.infra.core.sashwindows.di.JavaObject" + * pageIdentifierRequired="true" pageIdentifierOrdered="false" + * @generated + */ + boolean isForIdentifier(Object pageIdentifier); + +} // PageRef diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/PanelParent.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/PanelParent.java new file mode 100644 index 00000000000..56bd4062128 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/PanelParent.java @@ -0,0 +1,59 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; + +/** + * A representation of the model object ' Panel Parent'. + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent#getChildren Children}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getPanelParent() + * @model abstract="true" + * @generated + */ +public interface PanelParent extends EObject { + + /** + * Returns the value of the 'Children' containment reference + * list. The list contents are of type {@link org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel}. It is + * bidirectional and its opposite is ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel#getParent + * Parent}'. + *

+ * If the meaning of the 'Children' containment reference list isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Children' containment reference list. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getPanelParent_Children() + * @see org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel#getParent + * @model opposite="parent" containment="true" lower="2" upper="2" + * ordered="false" + * @generated + */ + EList getChildren(); + + /** + * + * Replace the specified child by the new value. Don't need to be + * implemented in TabFolder. Used to insert a new SashPanel. + * + * @model oldChildRequired="true" oldChildOrdered="false" + * newChildRequired="true" newChildOrdered="false" + * @generated + */ + void replaceChild(AbstractPanel oldChild, AbstractPanel newChild); + +} // PanelParent diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/Position.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/Position.java new file mode 100644 index 00000000000..48849a1b14d --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/Position.java @@ -0,0 +1,83 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di; + +import org.eclipse.emf.ecore.EObject; + +/** + * A representation of the model object ' Position'. + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.Position#getX X}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.Position#getY Y}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getPosition() + * @model + * @generated + */ +public interface Position extends EObject { + + /** + * Returns the value of the 'X' attribute. + *

+ * If the meaning of the 'X' attribute isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'X' attribute. + * @see #setX(int) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getPosition_X() + * @model unique="false" required="true" ordered="false" + * @generated + */ + int getX(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Position#getX X}' + * attribute. + * + * @param value + * the new value of the 'X' attribute. + * @see #getX() + * @generated + */ + void setX(int value); + + /** + * Returns the value of the 'Y' attribute. + *

+ * If the meaning of the 'Y' attribute isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Y' attribute. + * @see #setY(int) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getPosition_Y() + * @model unique="false" dataType="org.eclipse.papyrus.infra.core.sashwindows.di.int" + * required="true" ordered="false" + * @generated + */ + int getY(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Position#getY Y}' + * attribute. + * + * @param value + * the new value of the 'Y' attribute. + * @see #getY() + * @generated + */ + void setY(int value); + +} // Position diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/SashModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/SashModel.java new file mode 100644 index 00000000000..7da668ac116 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/SashModel.java @@ -0,0 +1,195 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; + +/** + * A representation of the model object ' Sash Model'. + * + * Root node of the model describing the sash windows, + * panels and pages. A SashModel can have several windows containing panels + * separated by sashes. Such panels can be folders containing pages. + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashModel#getWindows Windows}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashModel#getCurrentSelection + * Current Selection}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getSashModel() + * @model + * @generated + */ +public interface SashModel extends EObject { + + /** + * Returns the value of the 'Windows' containment reference + * list. The list contents are of type {@link org.eclipse.papyrus.infra.core.sashwindows.di.Window}. + *

+ * If the meaning of the 'Windows' containment reference list isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Windows' containment reference list. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getSashModel_Windows() + * @model containment="true" ordered="false" + * @generated + */ + EList getWindows(); + + /** + * Returns the value of the 'Current Selection' reference. + * + *

+ * If the meaning of the 'Current Selection' reference isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Current Selection' reference. + * @see #setCurrentSelection(TabFolder) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getSashModel_CurrentSelection() + * @model required="true" ordered="false" + * @generated + */ + TabFolder getCurrentSelection(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashModel#getCurrentSelection + * Current Selection}' reference. + * + * @param value + * the new value of the 'Current Selection' reference. + * @see #getCurrentSelection() + * @generated + */ + void setCurrentSelection(TabFolder value); + + /** + * + * + * @model + * pageIdentifierDataType="org.eclipse.papyrus.infra.core.sashwindows.di.JavaObject" + * pageIdentifierRequired="true" pageIdentifierOrdered="false" + * @generated + */ + void addPage(Object pageIdentifier); + + /** + * + * + * @model + * pageIdentifierDataType="org.eclipse.papyrus.infra.core.sashwindows.di.JavaObject" + * pageIdentifierRequired="true" pageIdentifierOrdered="false" + * @generated + */ + void removePage(Object pageIdentifier); + + /** + * + * Lookup the pageRef identified by the pageIdentifier. Return the pageRef + * or null if not found. Lookup in the entire SashModel structure. + * + * @model required="true" ordered="false" + * pageIdentifierDataType="org.eclipse.papyrus.infra.core.sashwindows.di.JavaObject" + * pageIdentifierRequired="true" pageIdentifierOrdered="false" + * @generated + */ + PageRef lookupPage(Object pageIdentifier); + + /** + * + * + * @model srcParentFolderRequired="true" srcParentFolderOrdered="false" + * srcIndexDataType="org.eclipse.papyrus.infra.core.sashwindows.di.int" + * srcIndexRequired="true" srcIndexOrdered="false" + * targetParentFolderRequired="true" + * targetParentFolderOrdered="false" targetIndexRequired="true" + * targetIndexOrdered="false" + * @generated + */ + void movePage(TabFolder srcParentFolder, int srcIndex, TabFolder targetParentFolder, int targetIndex); + + /** + * + * + * @model folderToInsertRequired="true" folderToInsertOrdered="false" + * refFolderRequired="true" refFolderOrdered="false" + * refFolderSideRequired="true" refFolderSideOrdered="false" + * @generated + */ + void insertFolder(TabFolder folderToInsert, TabFolder refFolder, int refFolderSide); + + /** + * + * + * @model srcParentFolderRequired="true" srcParentFolderOrdered="false" + * srcIndexDataType="org.eclipse.papyrus.infra.core.sashwindows.di.int" + * srcIndexRequired="true" srcIndexOrdered="false" + * targetParentFolderRequired="true" + * targetParentFolderOrdered="false" + * @generated + */ + void movePage(TabFolder srcParentFolder, int srcIndex, TabFolder targetParentFolder); + + /** + * + * + * @model folderRequired="true" folderOrdered="false" + * @generated + */ + void removeEmptyFolder(TabFolder folder); + + /** + * + * Remove all pages from the model. Only left one empty top level folder. + * + * + * @model + * @generated + */ + void removeAllPages(); + + /** + * + * Remove pages other than the one specified from the model. Intermediate + * folders are also removed. + * + * @model + * pageIdentifierDataType="org.eclipse.papyrus.infra.core.sashwindows.di.JavaObject" + * pageIdentifierRequired="true" pageIdentifierOrdered="false" + * @generated + */ + void removeOtherPages(Object pageIdentifier); + + /** + * + * Get the first available window. + * + * @model required="true" ordered="false" + * @generated + */ + Window lookupFirstWindow(); + + /** + * + * Lookup the first available folder. + * + * @model required="true" ordered="false" + * @generated + */ + TabFolder lookupFirstFolder(); + +} // SashModel diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/SashPanel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/SashPanel.java new file mode 100644 index 00000000000..08747641939 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/SashPanel.java @@ -0,0 +1,100 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di; + +/** + * A representation of the model object ' Sash Panel'. + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel#getSashPosition Sash Position}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel#getDirection Direction}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getSashPanel() + * @model + * @generated + */ +public interface SashPanel extends AbstractPanel, PanelParent { + + /** + * Returns the value of the 'Sash Position' attribute. + * Position of the sash in the panel. The position is in percent. The value + * should be between 0 and 100. + * + * @return the value of the 'Sash Position' attribute. + * @see #setSashPosition(float) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getSashPanel_SashPosition() + * @model unique="false" dataType="org.eclipse.papyrus.infra.core.sashwindows.di.Float" + * required="true" ordered="false" + * @generated + */ + float getSashPosition(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel#getSashPosition + * Sash Position}' attribute. + * + * @param value + * the new value of the 'Sash Position' attribute. + * @see #getSashPosition() + * @generated + */ + void setSashPosition(float value); + + /** + * Returns the value of the 'Direction' attribute. + *

+ * If the meaning of the 'Direction' attribute isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Direction' attribute. + * @see #setDirection(int) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getSashPanel_Direction() + * @model unique="false" required="true" ordered="false" + * @generated + */ + int getDirection(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel#getDirection + * Direction}' attribute. + * + * @param value + * the new value of the 'Direction' attribute. + * @see #getDirection() + * @generated + */ + void setDirection(int value); + + /** + * + * + * @model leftChildRequired="true" leftChildOrdered="false" + * rightChildRequired="true" rightChildOrdered="false" + * directionDataType="org.eclipse.papyrus.infra.core.sashwindows.di.int" + * directionRequired="true" directionOrdered="false" + * @generated + */ + void setChildren(AbstractPanel leftChild, AbstractPanel rightChild, int direction); + + /** + * + * + * @model childToDeleteRequired="true" childToDeleteOrdered="false" + * @generated + */ + void delete(AbstractPanel childToDelete); + +} // SashPanel diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/SashWindowsMngr.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/SashWindowsMngr.java new file mode 100644 index 00000000000..218300d95e6 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/SashWindowsMngr.java @@ -0,0 +1,88 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di; + +import org.eclipse.emf.ecore.EObject; + +/** + * A representation of the model object ' Sash Windows Mngr'. + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr#getPageList + * Page List}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr#getSashModel + * Sash Model}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getSashWindowsMngr() + * @model + * @generated + */ +public interface SashWindowsMngr extends EObject { + + /** + * Returns the value of the 'Page List' containment + * reference. + *

+ * If the meaning of the 'Page List' containment reference isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Page List' containment reference. + * @see #setPageList(PageList) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getSashWindowsMngr_PageList() + * @model containment="true" required="true" ordered="false" + * @generated + */ + PageList getPageList(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr#getPageList + * Page List}' containment reference. + * + * @param value + * the new value of the 'Page List' containment + * reference. + * @see #getPageList() + * @generated + */ + void setPageList(PageList value); + + /** + * Returns the value of the 'Sash Model' containment + * reference. + *

+ * If the meaning of the 'Sash Model' containment reference isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Sash Model' containment reference. + * @see #setSashModel(SashModel) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getSashWindowsMngr_SashModel() + * @model containment="true" required="true" ordered="false" + * @generated + */ + SashModel getSashModel(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr#getSashModel + * Sash Model}' containment reference. + * + * @param value + * the new value of the 'Sash Model' containment + * reference. + * @see #getSashModel() + * @generated + */ + void setSashModel(SashModel value); + +} // SashWindowsMngr diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/Size.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/Size.java new file mode 100644 index 00000000000..a4e30ccc3a2 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/Size.java @@ -0,0 +1,84 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di; + +import org.eclipse.emf.ecore.EObject; + +/** + * A representation of the model object ' Size'. + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.Size#getWidth Width}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.Size#getLength Length}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getSize() + * @model + * @generated + */ +public interface Size extends EObject { + + /** + * Returns the value of the 'Width' attribute. + *

+ * If the meaning of the 'Width' attribute isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Width' attribute. + * @see #setWidth(int) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getSize_Width() + * @model unique="false" dataType="org.eclipse.papyrus.infra.core.sashwindows.di.int" + * required="true" ordered="false" + * @generated + */ + int getWidth(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Size#getWidth Width}' + * attribute. + * + * @param value + * the new value of the 'Width' attribute. + * @see #getWidth() + * @generated + */ + void setWidth(int value); + + /** + * Returns the value of the 'Length' attribute. + *

+ * If the meaning of the 'Length' attribute isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Length' attribute. + * @see #setLength(int) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getSize_Length() + * @model unique="false" dataType="org.eclipse.papyrus.infra.core.sashwindows.di.int" + * required="true" ordered="false" + * @generated + */ + int getLength(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Size#getLength Length} ' attribute. + * + * @param value + * the new value of the 'Length' attribute. + * @see #getLength() + * @generated + */ + void setLength(int value); + +} // Size diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/TabFolder.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/TabFolder.java new file mode 100644 index 00000000000..bfc408fd610 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/TabFolder.java @@ -0,0 +1,74 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di; + +import org.eclipse.emf.common.util.EList; + +/** + * A representation of the model object ' Tab Folder'. + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder#getChildren Children}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getTabFolder() + * @model + * @generated + */ +public interface TabFolder extends AbstractPanel { + + /** + * Returns the value of the 'Children' containment reference + * list. The list contents are of type {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef}. It is bidirectional + * and its opposite is ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getParent + * Parent}'. + *

+ * If the meaning of the 'Children' containment reference list isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Children' containment reference list. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getTabFolder_Children() + * @see org.eclipse.papyrus.infra.core.sashwindows.di.PageRef#getParent + * @model opposite="parent" containment="true" ordered="false" + * @generated + */ + EList getChildren(); + + /** + * + * + * @model oldIndexRequired="true" oldIndexOrdered="false" + * newIndexDataType="org.eclipse.papyrus.infra.core.sashwindows.di.int" + * newIndexRequired="true" newIndexOrdered="false" + * @generated + */ + void movePage(int oldIndex, int newIndex); + + /** + * + * + * @model + * pageIdentifierDataType="org.eclipse.papyrus.infra.core.sashwindows.di.JavaObject" + * pageIdentifierRequired="true" pageIdentifierOrdered="false" + * @generated + */ + void addPage(Object pageIdentifier); + + /** + * + * + * @model pageIndexDataType="org.eclipse.papyrus.infra.core.sashwindows.di.int" + * pageIndexRequired="true" pageIndexOrdered="false" + * @generated + */ + void removePage(int pageIndex); + +} // TabFolder diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/Window.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/Window.java new file mode 100644 index 00000000000..3bb74b64838 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/Window.java @@ -0,0 +1,107 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di; + +/** + * A representation of the model object ' Window'. + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.Window#getPosition Position }
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.Window#getSize Size}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.Window#getPanel Panel}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getWindow() + * @model + * @generated + */ +public interface Window extends PanelParent { + + /** + * Returns the value of the 'Position' reference. + *

+ * If the meaning of the 'Position' reference isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Position' reference. + * @see #setPosition(Position) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getWindow_Position() + * @model required="true" ordered="false" + * @generated + */ + Position getPosition(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Window#getPosition + * Position}' reference. + * + * @param value + * the new value of the 'Position' reference. + * @see #getPosition() + * @generated + */ + void setPosition(Position value); + + /** + * Returns the value of the 'Size' reference. + *

+ * If the meaning of the 'Size' reference isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Size' reference. + * @see #setSize(Size) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getWindow_Size() + * @model required="true" ordered="false" + * @generated + */ + Size getSize(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Window#getSize Size}' + * reference. + * + * @param value + * the new value of the 'Size' reference. + * @see #getSize() + * @generated + */ + void setSize(Size value); + + /** + * Returns the value of the 'Panel' reference. + * Redefine children. + * + * @return the value of the 'Panel' reference. + * @see #setPanel(AbstractPanel) + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#getWindow_Panel() + * @model required="true" transient="true" volatile="true" derived="true" + * ordered="false" + * @generated + */ + AbstractPanel getPanel(); + + /** + * Sets the value of the ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Window#getPanel Panel} ' reference. + * + * @param value + * the new value of the 'Panel' reference. + * @see #getPanel() + * @generated + */ + void setPanel(AbstractPanel value); + +} // Window diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/exception/SashEditorException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/exception/SashEditorException.java new file mode 100644 index 00000000000..20ba87d3952 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/exception/SashEditorException.java @@ -0,0 +1,53 @@ +/***************************************************************************** + * 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.infra.core.sashwindows.di.exception; + +/** + * Exception for the Sash editor system + * + * @author eperico + */ +public class SashEditorException extends Exception { + + private static final long serialVersionUID = 1L; + + /** + * Instantiates a new sash editor exception. + */ + public SashEditorException() { + } + + /** + * @param message + */ + public SashEditorException(String message) { + super(message); + } + + /** + * @param cause + */ + public SashEditorException(Throwable cause) { + super(cause); + } + + /** + * @param message + * @param cause + */ + public SashEditorException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/AbstractPageImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/AbstractPageImpl.java new file mode 100644 index 00000000000..eb8526e617d --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/AbstractPageImpl.java @@ -0,0 +1,168 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPage; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; + +/** + * An implementation of the model object ' Abstract Page'. + *

+ * The following features are implemented: + *

    + *
  • + * {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.AbstractPageImpl#getPageIdentifier + * Page Identifier}
  • + *
+ *

+ * + * @generated + */ +public class AbstractPageImpl extends EObjectImpl implements AbstractPage { + + /** + * The default value of the '{@link #getPageIdentifier() + * Page Identifier}' attribute. + * + * @see #getPageIdentifier() + * @generated + * @ordered + */ + protected static final Object PAGE_IDENTIFIER_EDEFAULT = null; + + /** + * The cached value of the '{@link #getPageIdentifier() + * Page Identifier}' attribute. + * + * @see #getPageIdentifier() + * @generated + * @ordered + */ + protected Object pageIdentifier = PAGE_IDENTIFIER_EDEFAULT; + + /** + * + * + * @generated + */ + protected AbstractPageImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiPackage.Literals.ABSTRACT_PAGE; + } + + /** + * + * + * @generated + */ + public Object getPageIdentifier() { + return pageIdentifier; + } + + /** + * + * + * @generated + */ + public void setPageIdentifier(Object newPageIdentifier) { + Object oldPageIdentifier = pageIdentifier; + pageIdentifier = newPageIdentifier; + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.ABSTRACT_PAGE__PAGE_IDENTIFIER, oldPageIdentifier, pageIdentifier)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch(featureID) { + case DiPackage.ABSTRACT_PAGE__PAGE_IDENTIFIER: + return getPageIdentifier(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch(featureID) { + case DiPackage.ABSTRACT_PAGE__PAGE_IDENTIFIER: + setPageIdentifier(newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch(featureID) { + case DiPackage.ABSTRACT_PAGE__PAGE_IDENTIFIER: + setPageIdentifier(PAGE_IDENTIFIER_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch(featureID) { + case DiPackage.ABSTRACT_PAGE__PAGE_IDENTIFIER: + return PAGE_IDENTIFIER_EDEFAULT == null ? pageIdentifier != null : !PAGE_IDENTIFIER_EDEFAULT.equals(pageIdentifier); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if(eIsProxy()) + return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (pageIdentifier: "); + result.append(pageIdentifier); + result.append(')'); + return result.toString(); + } + +} // AbstractPageImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/AbstractPanelImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/AbstractPanelImpl.java new file mode 100644 index 00000000000..39ee2c1ffbd --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/AbstractPanelImpl.java @@ -0,0 +1,198 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent; + +/** + * An implementation of the model object ' Abstract Panel'. + *

+ * The following features are implemented: + *

    + *
  • + * {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.AbstractPanelImpl#getParent + * Parent}
  • + *
+ *

+ * + * @generated + */ +public abstract class AbstractPanelImpl extends EObjectImpl implements AbstractPanel { + + /** + * + * + * @generated + */ + protected AbstractPanelImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiPackage.Literals.ABSTRACT_PANEL; + } + + /** + * + * + * @generated + */ + public PanelParent getParent() { + if(eContainerFeatureID() != DiPackage.ABSTRACT_PANEL__PARENT) + return null; + return (PanelParent)eContainer(); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetParent(PanelParent newParent, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject)newParent, DiPackage.ABSTRACT_PANEL__PARENT, msgs); + return msgs; + } + + /** + * + * + * @generated + */ + public void setParent(PanelParent newParent) { + if(newParent != eInternalContainer() || (eContainerFeatureID() != DiPackage.ABSTRACT_PANEL__PARENT && newParent != null)) { + if(EcoreUtil.isAncestor(this, newParent)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if(eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if(newParent != null) + msgs = ((InternalEObject)newParent).eInverseAdd(this, DiPackage.PANEL_PARENT__CHILDREN, PanelParent.class, msgs); + msgs = basicSetParent(newParent, msgs); + if(msgs != null) + msgs.dispatch(); + } else if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.ABSTRACT_PANEL__PARENT, newParent, newParent)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch(featureID) { + case DiPackage.ABSTRACT_PANEL__PARENT: + if(eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetParent((PanelParent)otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch(featureID) { + case DiPackage.ABSTRACT_PANEL__PARENT: + return basicSetParent(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch(eContainerFeatureID()) { + case DiPackage.ABSTRACT_PANEL__PARENT: + return eInternalContainer().eInverseRemove(this, DiPackage.PANEL_PARENT__CHILDREN, PanelParent.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch(featureID) { + case DiPackage.ABSTRACT_PANEL__PARENT: + return getParent(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch(featureID) { + case DiPackage.ABSTRACT_PANEL__PARENT: + setParent((PanelParent)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch(featureID) { + case DiPackage.ABSTRACT_PANEL__PARENT: + setParent((PanelParent)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch(featureID) { + case DiPackage.ABSTRACT_PANEL__PARENT: + return getParent() != null; + } + return super.eIsSet(featureID); + } + +} // AbstractPanelImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/DiFactoryImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/DiFactoryImpl.java new file mode 100644 index 00000000000..9366bb5323d --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/DiFactoryImpl.java @@ -0,0 +1,331 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.impl.EFactoryImpl; +import org.eclipse.emf.ecore.plugin.EcorePlugin; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPage; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiFactory; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageList; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.papyrus.infra.core.sashwindows.di.Position; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr; +import org.eclipse.papyrus.infra.core.sashwindows.di.Size; +import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder; +import org.eclipse.papyrus.infra.core.sashwindows.di.Window; + +/** + * An implementation of the model Factory. + * + * @generated + */ +public class DiFactoryImpl extends EFactoryImpl implements DiFactory { + + /** + * Creates the default factory implementation. + * + * @generated + */ + public static DiFactory init() { + try { + DiFactory theDiFactory = (DiFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.eclipse.org/papyrus/0.7.0/sashdi"); + if(theDiFactory != null) { + return theDiFactory; + } + } catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new DiFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * @generated + */ + public DiFactoryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch(eClass.getClassifierID()) { + case DiPackage.SASH_MODEL: + return createSashModel(); + case DiPackage.WINDOW: + return createWindow(); + case DiPackage.POSITION: + return createPosition(); + case DiPackage.SIZE: + return createSize(); + case DiPackage.TAB_FOLDER: + return createTabFolder(); + case DiPackage.PAGE_REF: + return createPageRef(); + case DiPackage.SASH_PANEL: + return createSashPanel(); + case DiPackage.ABSTRACT_PAGE: + return createAbstractPage(); + case DiPackage.PAGE_LIST: + return createPageList(); + case DiPackage.SASH_WINDOWS_MNGR: + return createSashWindowsMngr(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + @Override + public Object createFromString(EDataType eDataType, String initialValue) { + switch(eDataType.getClassifierID()) { + case DiPackage.INT: + return createintFromString(eDataType, initialValue); + case DiPackage.JAVA_OBJECT: + return createJavaObjectFromString(eDataType, initialValue); + case DiPackage.FLOAT: + return createFloatFromString(eDataType, initialValue); + case DiPackage.BOOLEAN: + return createbooleanFromString(eDataType, initialValue); + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + @Override + public String convertToString(EDataType eDataType, Object instanceValue) { + switch(eDataType.getClassifierID()) { + case DiPackage.INT: + return convertintToString(eDataType, instanceValue); + case DiPackage.JAVA_OBJECT: + return convertJavaObjectToString(eDataType, instanceValue); + case DiPackage.FLOAT: + return convertFloatToString(eDataType, instanceValue); + case DiPackage.BOOLEAN: + return convertbooleanToString(eDataType, instanceValue); + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public SashModel createSashModel() { + SashModelImpl sashModel = new SashModelImpl(); + return sashModel; + } + + /** + * + * + * @generated + */ + public Window createWindow() { + WindowImpl window = new WindowImpl(); + return window; + } + + /** + * + * + * @generated + */ + public Position createPosition() { + PositionImpl position = new PositionImpl(); + return position; + } + + /** + * + * + * @generated + */ + public Size createSize() { + SizeImpl size = new SizeImpl(); + return size; + } + + /** + * + * + * @generated + */ + public TabFolder createTabFolder() { + TabFolderImpl tabFolder = new TabFolderImpl(); + return tabFolder; + } + + /** + * + * + * @generated + */ + public PageRef createPageRef() { + PageRefImpl pageRef = new PageRefImpl(); + return pageRef; + } + + /** + * + * + * @generated + */ + public SashPanel createSashPanel() { + SashPanelImpl sashPanel = new SashPanelImpl(); + return sashPanel; + } + + /** + * + * + * @generated + */ + public AbstractPage createAbstractPage() { + AbstractPageImpl abstractPage = new AbstractPageImpl(); + return abstractPage; + } + + /** + * + * + * @generated + */ + public PageList createPageList() { + PageListImpl pageList = new PageListImpl(); + return pageList; + } + + /** + * + * + * @generated + */ + public SashWindowsMngr createSashWindowsMngr() { + SashWindowsMngrImpl sashWindowsMngr = new SashWindowsMngrImpl(); + return sashWindowsMngr; + } + + /** + * + * + * @generated + */ + public Integer createintFromString(EDataType eDataType, String initialValue) { + return (Integer)super.createFromString(eDataType, initialValue); + } + + /** + * + * + * @generated + */ + public String convertintToString(EDataType eDataType, Object instanceValue) { + return super.convertToString(eDataType, instanceValue); + } + + /** + * + * + * @generated + */ + public Object createJavaObjectFromString(EDataType eDataType, String initialValue) { + return super.createFromString(eDataType, initialValue); + } + + /** + * + * + * @generated + */ + public String convertJavaObjectToString(EDataType eDataType, Object instanceValue) { + return super.convertToString(eDataType, instanceValue); + } + + /** + * + * + * @generated + */ + public Float createFloatFromString(EDataType eDataType, String initialValue) { + return (Float)super.createFromString(eDataType, initialValue); + } + + /** + * + * + * @generated + */ + public String convertFloatToString(EDataType eDataType, Object instanceValue) { + return super.convertToString(eDataType, instanceValue); + } + + /** + * + * + * @generated + */ + public Boolean createbooleanFromString(EDataType eDataType, String initialValue) { + return (Boolean)super.createFromString(eDataType, initialValue); + } + + /** + * + * + * @generated + */ + public String convertbooleanToString(EDataType eDataType, Object instanceValue) { + return super.convertToString(eDataType, instanceValue); + } + + /** + * + * + * @generated + */ + public DiPackage getDiPackage() { + return (DiPackage)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static DiPackage getPackage() { + return DiPackage.eINSTANCE; + } + +} // DiFactoryImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/DiPackageImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/DiPackageImpl.java new file mode 100644 index 00000000000..5ed10305a5c --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/DiPackageImpl.java @@ -0,0 +1,815 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.impl.EPackageImpl; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPage; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiFactory; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageList; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent; +import org.eclipse.papyrus.infra.core.sashwindows.di.Position; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr; +import org.eclipse.papyrus.infra.core.sashwindows.di.Size; +import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder; +import org.eclipse.papyrus.infra.core.sashwindows.di.Window; + +/** + * An implementation of the model Package. + * + * @generated + */ +public class DiPackageImpl extends EPackageImpl implements DiPackage { + + /** + * + * + * @generated + */ + private EClass sashModelEClass = null; + + /** + * + * + * @generated + */ + private EClass windowEClass = null; + + /** + * + * + * @generated + */ + private EClass panelParentEClass = null; + + /** + * + * + * @generated + */ + private EClass abstractPanelEClass = null; + + /** + * + * + * @generated + */ + private EClass positionEClass = null; + + /** + * + * + * @generated + */ + private EClass sizeEClass = null; + + /** + * + * + * @generated + */ + private EClass tabFolderEClass = null; + + /** + * + * + * @generated + */ + private EClass pageRefEClass = null; + + /** + * + * + * @generated + */ + private EClass sashPanelEClass = null; + + /** + * + * + * @generated + */ + private EClass abstractPageEClass = null; + + /** + * + * + * @generated + */ + private EClass pageListEClass = null; + + /** + * + * + * @generated + */ + private EClass sashWindowsMngrEClass = null; + + /** + * + * + * @generated + */ + private EDataType intEDataType = null; + + /** + * + * + * @generated + */ + private EDataType javaObjectEDataType = null; + + /** + * + * + * @generated + */ + private EDataType floatEDataType = null; + + /** + * + * + * @generated + */ + private EDataType booleanEDataType = null; + + /** + * Creates an instance of the model Package, registered with {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the + * package package URI value. + *

+ * Note: the correct way to create the package is via the static factory method {@link #init init()}, which also performs initialization of the + * package, or returns the registered package, if one already exists. + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage#eNS_URI + * @see #init() + * @generated + */ + private DiPackageImpl() { + super(eNS_URI, DiFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, + * and for any others upon which it depends. + * + *

+ * This method is used to initialize {@link DiPackage#eINSTANCE} when that field is accessed. Clients should not invoke it directly. Instead, they + * should simply access that field to obtain the package. + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static DiPackage init() { + if(isInited) + return (DiPackage)EPackage.Registry.INSTANCE.getEPackage(DiPackage.eNS_URI); + + // Obtain or create and register package + DiPackageImpl theDiPackage = (DiPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof DiPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new DiPackageImpl()); + + isInited = true; + + // Initialize simple dependencies + EcorePackage.eINSTANCE.eClass(); + + // Create package meta-data objects + theDiPackage.createPackageContents(); + + // Initialize created meta-data + theDiPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theDiPackage.freeze(); + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(DiPackage.eNS_URI, theDiPackage); + return theDiPackage; + } + + /** + * + * + * @generated + */ + public EClass getSashModel() { + return sashModelEClass; + } + + /** + * + * + * @generated + */ + public EReference getSashModel_Windows() { + return (EReference)sashModelEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EReference getSashModel_CurrentSelection() { + return (EReference)sashModelEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EClass getWindow() { + return windowEClass; + } + + /** + * + * + * @generated + */ + public EReference getWindow_Position() { + return (EReference)windowEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EReference getWindow_Size() { + return (EReference)windowEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EReference getWindow_Panel() { + return (EReference)windowEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EClass getPanelParent() { + return panelParentEClass; + } + + /** + * + * + * @generated + */ + public EReference getPanelParent_Children() { + return (EReference)panelParentEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EClass getAbstractPanel() { + return abstractPanelEClass; + } + + /** + * + * + * @generated + */ + public EReference getAbstractPanel_Parent() { + return (EReference)abstractPanelEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EClass getPosition() { + return positionEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getPosition_X() { + return (EAttribute)positionEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getPosition_Y() { + return (EAttribute)positionEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EClass getSize() { + return sizeEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getSize_Width() { + return (EAttribute)sizeEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getSize_Length() { + return (EAttribute)sizeEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EClass getTabFolder() { + return tabFolderEClass; + } + + /** + * + * + * @generated + */ + public EReference getTabFolder_Children() { + return (EReference)tabFolderEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EClass getPageRef() { + return pageRefEClass; + } + + /** + * + * + * @generated + */ + public EReference getPageRef_EmfPageIdentifier() { + return (EReference)pageRefEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getPageRef_PageIdentifier() { + return (EAttribute)pageRefEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EAttribute getPageRef_ObjectPageIdentifier() { + return (EAttribute)pageRefEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EReference getPageRef_Parent() { + return (EReference)pageRefEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + public EClass getSashPanel() { + return sashPanelEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getSashPanel_SashPosition() { + return (EAttribute)sashPanelEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getSashPanel_Direction() { + return (EAttribute)sashPanelEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EClass getAbstractPage() { + return abstractPageEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getAbstractPage_PageIdentifier() { + return (EAttribute)abstractPageEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EClass getPageList() { + return pageListEClass; + } + + /** + * + * + * @generated + */ + public EReference getPageList_AvailablePage() { + return (EReference)pageListEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EClass getSashWindowsMngr() { + return sashWindowsMngrEClass; + } + + /** + * + * + * @generated + */ + public EReference getSashWindowsMngr_PageList() { + return (EReference)sashWindowsMngrEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EReference getSashWindowsMngr_SashModel() { + return (EReference)sashWindowsMngrEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EDataType getint() { + return intEDataType; + } + + /** + * + * + * @generated + */ + public EDataType getJavaObject() { + return javaObjectEDataType; + } + + /** + * + * + * @generated + */ + public EDataType getFloat() { + return floatEDataType; + } + + /** + * + * + * @generated + */ + public EDataType getboolean() { + return booleanEDataType; + } + + /** + * + * + * @generated + */ + public DiFactory getDiFactory() { + return (DiFactory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is guarded to + * have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() { + if(isCreated) + return; + isCreated = true; + + // Create classes and their features + sashModelEClass = createEClass(SASH_MODEL); + createEReference(sashModelEClass, SASH_MODEL__WINDOWS); + createEReference(sashModelEClass, SASH_MODEL__CURRENT_SELECTION); + + windowEClass = createEClass(WINDOW); + createEReference(windowEClass, WINDOW__POSITION); + createEReference(windowEClass, WINDOW__SIZE); + createEReference(windowEClass, WINDOW__PANEL); + + panelParentEClass = createEClass(PANEL_PARENT); + createEReference(panelParentEClass, PANEL_PARENT__CHILDREN); + + abstractPanelEClass = createEClass(ABSTRACT_PANEL); + createEReference(abstractPanelEClass, ABSTRACT_PANEL__PARENT); + + positionEClass = createEClass(POSITION); + createEAttribute(positionEClass, POSITION__X); + createEAttribute(positionEClass, POSITION__Y); + + sizeEClass = createEClass(SIZE); + createEAttribute(sizeEClass, SIZE__WIDTH); + createEAttribute(sizeEClass, SIZE__LENGTH); + + tabFolderEClass = createEClass(TAB_FOLDER); + createEReference(tabFolderEClass, TAB_FOLDER__CHILDREN); + + pageRefEClass = createEClass(PAGE_REF); + createEReference(pageRefEClass, PAGE_REF__EMF_PAGE_IDENTIFIER); + createEAttribute(pageRefEClass, PAGE_REF__PAGE_IDENTIFIER); + createEAttribute(pageRefEClass, PAGE_REF__OBJECT_PAGE_IDENTIFIER); + createEReference(pageRefEClass, PAGE_REF__PARENT); + + sashPanelEClass = createEClass(SASH_PANEL); + createEAttribute(sashPanelEClass, SASH_PANEL__SASH_POSITION); + createEAttribute(sashPanelEClass, SASH_PANEL__DIRECTION); + + abstractPageEClass = createEClass(ABSTRACT_PAGE); + createEAttribute(abstractPageEClass, ABSTRACT_PAGE__PAGE_IDENTIFIER); + + pageListEClass = createEClass(PAGE_LIST); + createEReference(pageListEClass, PAGE_LIST__AVAILABLE_PAGE); + + sashWindowsMngrEClass = createEClass(SASH_WINDOWS_MNGR); + createEReference(sashWindowsMngrEClass, SASH_WINDOWS_MNGR__PAGE_LIST); + createEReference(sashWindowsMngrEClass, SASH_WINDOWS_MNGR__SASH_MODEL); + + // Create data types + intEDataType = createEDataType(INT); + javaObjectEDataType = createEDataType(JAVA_OBJECT); + floatEDataType = createEDataType(FLOAT); + booleanEDataType = createEDataType(BOOLEAN); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * @generated + */ + public void initializePackageContents() { + if(isInitialized) + return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + EcorePackage theEcorePackage = (EcorePackage)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + windowEClass.getESuperTypes().add(this.getPanelParent()); + tabFolderEClass.getESuperTypes().add(this.getAbstractPanel()); + sashPanelEClass.getESuperTypes().add(this.getAbstractPanel()); + sashPanelEClass.getESuperTypes().add(this.getPanelParent()); + + // Initialize classes and features; add operations and parameters + initEClass(sashModelEClass, SashModel.class, "SashModel", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getSashModel_Windows(), this.getWindow(), null, "windows", null, 0, -1, SashModel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + initEReference(getSashModel_CurrentSelection(), this.getTabFolder(), null, "currentSelection", null, 1, 1, SashModel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + + EOperation op = addEOperation(sashModelEClass, null, "addPage", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); + + op = addEOperation(sashModelEClass, null, "removePage", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); + + op = addEOperation(sashModelEClass, this.getPageRef(), "lookupPage", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); + + op = addEOperation(sashModelEClass, null, "movePage", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getTabFolder(), "srcParentFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getint(), "srcIndex", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getTabFolder(), "targetParentFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, ecorePackage.getEInt(), "targetIndex", 1, 1, IS_UNIQUE, !IS_ORDERED); + + op = addEOperation(sashModelEClass, null, "insertFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getTabFolder(), "folderToInsert", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getTabFolder(), "refFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, ecorePackage.getEInt(), "refFolderSide", 1, 1, IS_UNIQUE, !IS_ORDERED); + + op = addEOperation(sashModelEClass, null, "movePage", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getTabFolder(), "srcParentFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getint(), "srcIndex", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getTabFolder(), "targetParentFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); + + op = addEOperation(sashModelEClass, null, "removeEmptyFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getTabFolder(), "folder", 1, 1, IS_UNIQUE, !IS_ORDERED); + + addEOperation(sashModelEClass, null, "removeAllPages", 1, 1, IS_UNIQUE, !IS_ORDERED); + + op = addEOperation(sashModelEClass, null, "removeOtherPages", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); + + addEOperation(sashModelEClass, this.getWindow(), "lookupFirstWindow", 1, 1, IS_UNIQUE, !IS_ORDERED); + + addEOperation(sashModelEClass, this.getTabFolder(), "lookupFirstFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); + + initEClass(windowEClass, Window.class, "Window", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getWindow_Position(), this.getPosition(), null, "position", null, 1, 1, Window.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + initEReference(getWindow_Size(), this.getSize(), null, "size", null, 1, 1, Window.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + initEReference(getWindow_Panel(), this.getAbstractPanel(), null, "panel", null, 1, 1, Window.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, IS_DERIVED, !IS_ORDERED); + + initEClass(panelParentEClass, PanelParent.class, "PanelParent", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getPanelParent_Children(), this.getAbstractPanel(), this.getAbstractPanel_Parent(), "children", null, 2, 2, PanelParent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + + op = addEOperation(panelParentEClass, null, "replaceChild", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getAbstractPanel(), "oldChild", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getAbstractPanel(), "newChild", 1, 1, IS_UNIQUE, !IS_ORDERED); + + initEClass(abstractPanelEClass, AbstractPanel.class, "AbstractPanel", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getAbstractPanel_Parent(), this.getPanelParent(), this.getPanelParent_Children(), "parent", null, 1, 1, AbstractPanel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + + initEClass(positionEClass, Position.class, "Position", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getPosition_X(), ecorePackage.getEInt(), "x", null, 1, 1, Position.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + initEAttribute(getPosition_Y(), this.getint(), "y", null, 1, 1, Position.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + + initEClass(sizeEClass, Size.class, "Size", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getSize_Width(), this.getint(), "width", null, 1, 1, Size.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + initEAttribute(getSize_Length(), this.getint(), "length", null, 1, 1, Size.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + + initEClass(tabFolderEClass, TabFolder.class, "TabFolder", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getTabFolder_Children(), this.getPageRef(), this.getPageRef_Parent(), "children", null, 0, -1, TabFolder.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + + op = addEOperation(tabFolderEClass, null, "movePage", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, ecorePackage.getEInt(), "oldIndex", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getint(), "newIndex", 1, 1, IS_UNIQUE, !IS_ORDERED); + + op = addEOperation(tabFolderEClass, null, "addPage", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); + + op = addEOperation(tabFolderEClass, null, "removePage", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getint(), "pageIndex", 1, 1, IS_UNIQUE, !IS_ORDERED); + + initEClass(pageRefEClass, PageRef.class, "PageRef", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getPageRef_EmfPageIdentifier(), theEcorePackage.getEObject(), null, "emfPageIdentifier", null, 1, 1, PageRef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + initEAttribute(getPageRef_PageIdentifier(), this.getJavaObject(), "pageIdentifier", null, 1, 1, PageRef.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, IS_DERIVED, !IS_ORDERED); + initEAttribute(getPageRef_ObjectPageIdentifier(), this.getJavaObject(), "objectPageIdentifier", null, 1, 1, PageRef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + initEReference(getPageRef_Parent(), this.getTabFolder(), this.getTabFolder_Children(), "parent", null, 1, 1, PageRef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + + op = addEOperation(pageRefEClass, ecorePackage.getEBoolean(), "isForIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); + + initEClass(sashPanelEClass, SashPanel.class, "SashPanel", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getSashPanel_SashPosition(), this.getFloat(), "sashPosition", null, 1, 1, SashPanel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + initEAttribute(getSashPanel_Direction(), ecorePackage.getEInt(), "direction", null, 1, 1, SashPanel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + + op = addEOperation(sashPanelEClass, null, "setChildren", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getAbstractPanel(), "leftChild", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getAbstractPanel(), "rightChild", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getint(), "direction", 1, 1, IS_UNIQUE, !IS_ORDERED); + + op = addEOperation(sashPanelEClass, null, "delete", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getAbstractPanel(), "childToDelete", 1, 1, IS_UNIQUE, !IS_ORDERED); + + initEClass(abstractPageEClass, AbstractPage.class, "AbstractPage", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getAbstractPage_PageIdentifier(), this.getJavaObject(), "pageIdentifier", null, 1, 1, AbstractPage.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + + initEClass(pageListEClass, PageList.class, "PageList", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getPageList_AvailablePage(), this.getPageRef(), null, "availablePage", null, 0, -1, PageList.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + + op = addEOperation(pageListEClass, null, "addPage", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); + + op = addEOperation(pageListEClass, null, "removePage", 1, 1, IS_UNIQUE, !IS_ORDERED); + addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); + + initEClass(sashWindowsMngrEClass, SashWindowsMngr.class, "SashWindowsMngr", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getSashWindowsMngr_PageList(), this.getPageList(), null, "pageList", null, 1, 1, SashWindowsMngr.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + initEReference(getSashWindowsMngr_SashModel(), this.getSashModel(), null, "sashModel", null, 1, 1, SashWindowsMngr.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + + // Initialize data types + initEDataType(intEDataType, int.class, "int", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(javaObjectEDataType, Object.class, "JavaObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(floatEDataType, float.class, "Float", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(booleanEDataType, boolean.class, "boolean", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + + // Create resource + createResource(eNS_URI); + + // Create annotations + // resource=XMI + createResourceXMIAnnotations(); + } + + /** + * Initializes the annotations for resource=XMI. + * + * @generated + */ + protected void createResourceXMIAnnotations() { + String source = "resource=XMI"; + addAnnotation(this, source, new String[]{}); + } + +} // DiPackageImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PageListImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PageListImpl.java new file mode 100644 index 00000000000..15f359aa0a4 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PageListImpl.java @@ -0,0 +1,182 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.EObjectImpl; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiFactory; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageList; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; + +/** + * An implementation of the model object ' Page List'. + *

+ * The following features are implemented: + *

    + *
  • + * {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageListImpl#getAvailablePage + * Available Page}
  • + *
+ *

+ * + * @generated + */ +public class PageListImpl extends EObjectImpl implements PageList { + + /** + * The cached value of the '{@link #getAvailablePage() + * Available Page}' containment reference list. + * + * @see #getAvailablePage() + * @generated + * @ordered + */ + protected EList availablePage; + + /** + * + * + * @generated + */ + protected PageListImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiPackage.Literals.PAGE_LIST; + } + + /** + * + * + * @generated + */ + public EList getAvailablePage() { + if(availablePage == null) { + availablePage = new EObjectContainmentEList(PageRef.class, this, DiPackage.PAGE_LIST__AVAILABLE_PAGE); + } + return availablePage; + } + + /** + * + * + * @generated NOT + */ + public void addPage(Object pageIdentifier) { + + PageRef pageRef = DiFactory.eINSTANCE.createPageRef(); + pageRef.setPageIdentifier(pageIdentifier); + getAvailablePage().add(pageRef); + + } + + /** + * + * + * @generated NOT + */ + public void removePage(Object pageIdentifier) { + for(PageRef pageRef : getAvailablePage()) { + + if(pageRef.isForIdentifier(pageIdentifier)) { + getAvailablePage().remove(pageRef); + return; + } + } + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch(featureID) { + case DiPackage.PAGE_LIST__AVAILABLE_PAGE: + return ((InternalEList)getAvailablePage()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch(featureID) { + case DiPackage.PAGE_LIST__AVAILABLE_PAGE: + return getAvailablePage(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch(featureID) { + case DiPackage.PAGE_LIST__AVAILABLE_PAGE: + getAvailablePage().clear(); + getAvailablePage().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch(featureID) { + case DiPackage.PAGE_LIST__AVAILABLE_PAGE: + getAvailablePage().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch(featureID) { + case DiPackage.PAGE_LIST__AVAILABLE_PAGE: + return availablePage != null && !availablePage.isEmpty(); + } + return super.eIsSet(featureID); + } + +} // PageListImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PageRefImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PageRefImpl.java new file mode 100644 index 00000000000..18e137e3b86 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PageRefImpl.java @@ -0,0 +1,406 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder; + +/** + * An implementation of the model object ' Page Ref'. + *

+ * The following features are implemented: + *

    + *
  • + * {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageRefImpl#getEmfPageIdentifier + * Emf Page Identifier}
  • + *
  • + * {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageRefImpl#getPageIdentifier + * Page Identifier}
  • + *
  • + * {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageRefImpl#getObjectPageIdentifier + * Object Page Identifier}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PageRefImpl#getParent Parent}
  • + *
+ *

+ * + * @generated + */ +public class PageRefImpl extends EObjectImpl implements PageRef { + + /** + * The cached value of the '{@link #getEmfPageIdentifier() + * Emf Page Identifier}' reference. + * + * @see #getEmfPageIdentifier() + * @generated + * @ordered + */ + protected EObject emfPageIdentifier; + + /** + * The default value of the '{@link #getPageIdentifier() + * Page Identifier}' attribute. + * + * @see #getPageIdentifier() + * @generated + * @ordered + */ + protected static final Object PAGE_IDENTIFIER_EDEFAULT = null; + + /** + * The default value of the '{@link #getObjectPageIdentifier() + * Object Page Identifier}' attribute. + * + * @see #getObjectPageIdentifier() + * @generated + * @ordered + */ + protected static final Object OBJECT_PAGE_IDENTIFIER_EDEFAULT = null; + + /** + * The cached value of the '{@link #getObjectPageIdentifier() + * Object Page Identifier}' attribute. + * + * @see #getObjectPageIdentifier() + * @generated + * @ordered + */ + protected Object objectPageIdentifier = OBJECT_PAGE_IDENTIFIER_EDEFAULT; + + /** + * + * + * @generated + */ + protected PageRefImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiPackage.Literals.PAGE_REF; + } + + /** + * + * + * @generated + */ + public EObject getEmfPageIdentifier() { + if(emfPageIdentifier != null && emfPageIdentifier.eIsProxy()) { + InternalEObject oldEmfPageIdentifier = (InternalEObject)emfPageIdentifier; + emfPageIdentifier = eResolveProxy(oldEmfPageIdentifier); + if(emfPageIdentifier != oldEmfPageIdentifier) { + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, DiPackage.PAGE_REF__EMF_PAGE_IDENTIFIER, oldEmfPageIdentifier, emfPageIdentifier)); + } + } + return emfPageIdentifier; + } + + /** + * + * + * @generated + */ + public EObject basicGetEmfPageIdentifier() { + return emfPageIdentifier; + } + + /** + * + * + * @generated + */ + public void setEmfPageIdentifier(EObject newEmfPageIdentifier) { + EObject oldEmfPageIdentifier = emfPageIdentifier; + emfPageIdentifier = newEmfPageIdentifier; + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.PAGE_REF__EMF_PAGE_IDENTIFIER, oldEmfPageIdentifier, emfPageIdentifier)); + } + + /** + * + * + * @generated NOT + */ + public Object getPageIdentifier() { + Object res = getEmfPageIdentifier(); + + if(res != null) { + return res; + } else + return getObjectPageIdentifier(); + } + + /** + * + * + * @generated NOT + */ + public boolean isForIdentifier(Object pageIdentifier) { + if(getPageIdentifier() != null) { + return getPageIdentifier().equals(pageIdentifier); + } + return false; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch(featureID) { + case DiPackage.PAGE_REF__PARENT: + if(eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetParent((TabFolder)otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch(featureID) { + case DiPackage.PAGE_REF__PARENT: + return basicSetParent(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch(eContainerFeatureID()) { + case DiPackage.PAGE_REF__PARENT: + return eInternalContainer().eInverseRemove(this, DiPackage.TAB_FOLDER__CHILDREN, TabFolder.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch(featureID) { + case DiPackage.PAGE_REF__EMF_PAGE_IDENTIFIER: + if(resolve) + return getEmfPageIdentifier(); + return basicGetEmfPageIdentifier(); + case DiPackage.PAGE_REF__PAGE_IDENTIFIER: + return getPageIdentifier(); + case DiPackage.PAGE_REF__OBJECT_PAGE_IDENTIFIER: + return getObjectPageIdentifier(); + case DiPackage.PAGE_REF__PARENT: + return getParent(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch(featureID) { + case DiPackage.PAGE_REF__EMF_PAGE_IDENTIFIER: + setEmfPageIdentifier((EObject)newValue); + return; + case DiPackage.PAGE_REF__PAGE_IDENTIFIER: + setPageIdentifier(newValue); + return; + case DiPackage.PAGE_REF__OBJECT_PAGE_IDENTIFIER: + setObjectPageIdentifier(newValue); + return; + case DiPackage.PAGE_REF__PARENT: + setParent((TabFolder)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch(featureID) { + case DiPackage.PAGE_REF__EMF_PAGE_IDENTIFIER: + setEmfPageIdentifier((EObject)null); + return; + case DiPackage.PAGE_REF__PAGE_IDENTIFIER: + setPageIdentifier(PAGE_IDENTIFIER_EDEFAULT); + return; + case DiPackage.PAGE_REF__OBJECT_PAGE_IDENTIFIER: + setObjectPageIdentifier(OBJECT_PAGE_IDENTIFIER_EDEFAULT); + return; + case DiPackage.PAGE_REF__PARENT: + setParent((TabFolder)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch(featureID) { + case DiPackage.PAGE_REF__EMF_PAGE_IDENTIFIER: + return emfPageIdentifier != null; + case DiPackage.PAGE_REF__PAGE_IDENTIFIER: + return PAGE_IDENTIFIER_EDEFAULT == null ? getPageIdentifier() != null : !PAGE_IDENTIFIER_EDEFAULT.equals(getPageIdentifier()); + case DiPackage.PAGE_REF__OBJECT_PAGE_IDENTIFIER: + return OBJECT_PAGE_IDENTIFIER_EDEFAULT == null ? objectPageIdentifier != null : !OBJECT_PAGE_IDENTIFIER_EDEFAULT.equals(objectPageIdentifier); + case DiPackage.PAGE_REF__PARENT: + return getParent() != null; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if(eIsProxy()) + return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (objectPageIdentifier: "); + result.append(objectPageIdentifier); + result.append(')'); + return result.toString(); + } + + /** + * + * + * @generated NOT + */ + public void setPageIdentifier(Object newPageIdentifier) { + + if(newPageIdentifier instanceof EObject) { + setEmfPageIdentifier((EObject)newPageIdentifier); + return; + } + + // if null, unset all + if(newPageIdentifier == null && getEmfPageIdentifier() != null) { + setEmfPageIdentifier(null); + } + + // By default, consider newPageIdentifier as an Object + setObjectPageIdentifier(newPageIdentifier); + + } + + /** + * + * + * @generated + */ + public Object getObjectPageIdentifier() { + return objectPageIdentifier; + } + + /** + * + * + * @generated + */ + public void setObjectPageIdentifier(Object newObjectPageIdentifier) { + Object oldObjectPageIdentifier = objectPageIdentifier; + objectPageIdentifier = newObjectPageIdentifier; + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.PAGE_REF__OBJECT_PAGE_IDENTIFIER, oldObjectPageIdentifier, objectPageIdentifier)); + } + + /** + * + * + * @generated + */ + public TabFolder getParent() { + if(eContainerFeatureID() != DiPackage.PAGE_REF__PARENT) + return null; + return (TabFolder)eContainer(); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetParent(TabFolder newParent, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject)newParent, DiPackage.PAGE_REF__PARENT, msgs); + return msgs; + } + + /** + * + * + * @generated + */ + public void setParent(TabFolder newParent) { + if(newParent != eInternalContainer() || (eContainerFeatureID() != DiPackage.PAGE_REF__PARENT && newParent != null)) { + if(EcoreUtil.isAncestor(this, newParent)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if(eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if(newParent != null) + msgs = ((InternalEObject)newParent).eInverseAdd(this, DiPackage.TAB_FOLDER__CHILDREN, TabFolder.class, msgs); + msgs = basicSetParent(newParent, msgs); + if(msgs != null) + msgs.dispatch(); + } else if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.PAGE_REF__PARENT, newParent, newParent)); + } + +} // PageRefImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PanelParentImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PanelParentImpl.java new file mode 100644 index 00000000000..e70af59c414 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PanelParentImpl.java @@ -0,0 +1,178 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.EObjectImpl; +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent; + +/** + * An implementation of the model object ' Panel Parent'. + *

+ * The following features are implemented: + *

    + *
  • + * {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PanelParentImpl#getChildren + * Children}
  • + *
+ *

+ * + * @generated + */ +public abstract class PanelParentImpl extends EObjectImpl implements PanelParent { + + /** + * The cached value of the '{@link #getChildren() Children}' + * containment reference list. + * + * @see #getChildren() + * @generated + * @ordered + */ + protected EList children; + + /** + * + * + * @generated + */ + protected PanelParentImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiPackage.Literals.PANEL_PARENT; + } + + /** + * + * + * @generated + */ + public EList getChildren() { + if(children == null) { + children = new EObjectContainmentWithInverseEList(AbstractPanel.class, this, DiPackage.PANEL_PARENT__CHILDREN, DiPackage.ABSTRACT_PANEL__PARENT); + } + return children; + } + + /** + * + * + * @generated + */ + public void replaceChild(AbstractPanel oldChild, AbstractPanel newChild) { + // TODO: implement this method + // Ensure that you remove @generated or mark it @generated NOT + throw new UnsupportedOperationException(); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch(featureID) { + case DiPackage.PANEL_PARENT__CHILDREN: + return ((InternalEList)(InternalEList)getChildren()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch(featureID) { + case DiPackage.PANEL_PARENT__CHILDREN: + return ((InternalEList)getChildren()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch(featureID) { + case DiPackage.PANEL_PARENT__CHILDREN: + return getChildren(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch(featureID) { + case DiPackage.PANEL_PARENT__CHILDREN: + getChildren().clear(); + getChildren().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch(featureID) { + case DiPackage.PANEL_PARENT__CHILDREN: + getChildren().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch(featureID) { + case DiPackage.PANEL_PARENT__CHILDREN: + return children != null && !children.isEmpty(); + } + return super.eIsSet(featureID); + } + +} // PanelParentImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PositionImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PositionImpl.java new file mode 100644 index 00000000000..78d381bfcc5 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/PositionImpl.java @@ -0,0 +1,218 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.Position; + +/** + * An implementation of the model object ' Position'. + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PositionImpl#getX X }
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.PositionImpl#getY Y }
  • + *
+ *

+ * + * @generated + */ +public class PositionImpl extends EObjectImpl implements Position { + + /** + * The default value of the '{@link #getX() X}' attribute. + * + * @see #getX() + * @generated + * @ordered + */ + protected static final int X_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getX() X}' attribute. + * + * @see #getX() + * @generated + * @ordered + */ + protected int x = X_EDEFAULT; + + /** + * The default value of the '{@link #getY() Y}' attribute. + * + * @see #getY() + * @generated + * @ordered + */ + protected static final int Y_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getY() Y}' attribute. + * + * @see #getY() + * @generated + * @ordered + */ + protected int y = Y_EDEFAULT; + + /** + * + * + * @generated + */ + protected PositionImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiPackage.Literals.POSITION; + } + + /** + * + * + * @generated + */ + public int getX() { + return x; + } + + /** + * + * + * @generated + */ + public void setX(int newX) { + int oldX = x; + x = newX; + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.POSITION__X, oldX, x)); + } + + /** + * + * + * @generated + */ + public int getY() { + return y; + } + + /** + * + * + * @generated + */ + public void setY(int newY) { + int oldY = y; + y = newY; + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.POSITION__Y, oldY, y)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch(featureID) { + case DiPackage.POSITION__X: + return getX(); + case DiPackage.POSITION__Y: + return getY(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch(featureID) { + case DiPackage.POSITION__X: + setX((Integer)newValue); + return; + case DiPackage.POSITION__Y: + setY((Integer)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch(featureID) { + case DiPackage.POSITION__X: + setX(X_EDEFAULT); + return; + case DiPackage.POSITION__Y: + setY(Y_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch(featureID) { + case DiPackage.POSITION__X: + return x != X_EDEFAULT; + case DiPackage.POSITION__Y: + return y != Y_EDEFAULT; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if(eIsProxy()) + return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (x: "); + result.append(x); + result.append(", y: "); + result.append(y); + result.append(')'); + return result.toString(); + } + +} // PositionImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SashModelImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SashModelImpl.java new file mode 100644 index 00000000000..b2d8a843e8a --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SashModelImpl.java @@ -0,0 +1,587 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiFactory; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder; +import org.eclipse.papyrus.infra.core.sashwindows.di.Window; +import org.eclipse.papyrus.infra.core.sashwindows.di.util.DiSwitch; +import org.eclipse.swt.SWT; + +/** + * An implementation of the model object ' Sash Model'. + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashModelImpl#getWindows + * Windows}
  • + *
  • + * {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashModelImpl#getCurrentSelection + * Current Selection}
  • + *
+ *

+ * + * @generated + */ +public class SashModelImpl extends EObjectImpl implements SashModel { + + /** + * The cached value of the '{@link #getWindows() Windows}' + * containment reference list. + * + * @see #getWindows() + * @generated + * @ordered + */ + protected EList windows; + + /** + * The cached value of the '{@link #getCurrentSelection() + * Current Selection}' reference. + * + * @see #getCurrentSelection() + * @generated + * @ordered + */ + protected TabFolder currentSelection; + + /** + * + * + * @generated + */ + protected SashModelImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiPackage.Literals.SASH_MODEL; + } + + /** + * + * + * @generated + */ + public EList getWindows() { + if(windows == null) { + windows = new EObjectContainmentEList(Window.class, this, DiPackage.SASH_MODEL__WINDOWS); + } + return windows; + } + + /** + * + * + * @generated + */ + public TabFolder getCurrentSelection() { + if(currentSelection != null && currentSelection.eIsProxy()) { + InternalEObject oldCurrentSelection = (InternalEObject)currentSelection; + currentSelection = (TabFolder)eResolveProxy(oldCurrentSelection); + if(currentSelection != oldCurrentSelection) { + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, DiPackage.SASH_MODEL__CURRENT_SELECTION, oldCurrentSelection, currentSelection)); + } + } + return currentSelection; + } + + /** + * + * + * @generated + */ + public TabFolder basicGetCurrentSelection() { + return currentSelection; + } + + /** + * + * + * @generated + */ + public void setCurrentSelection(TabFolder newCurrentSelection) { + TabFolder oldCurrentSelection = currentSelection; + currentSelection = newCurrentSelection; + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.SASH_MODEL__CURRENT_SELECTION, oldCurrentSelection, currentSelection)); + } + + /** + * + * + * @generated NOT + */ + public void addPage(Object pageIdentifier) { + getCurrentSelection().addPage(pageIdentifier); + } + + /** + * + * + * @generated NOT + */ + public void removePage(Object pageIdentifier) { + PageRef pageRef = lookupPage(pageIdentifier); + if(pageRef == null) + return; + + // Remove it + pageRef.getParent().getChildren().remove(pageRef); + } + + /** + * + * + * @generated NOT + */ + public PageRef lookupPage(final Object pageIdentifier) { + + // Create appropriate visitor. + DiSwitch visitor = new DiSwitch() { + + /** + * Iterate over windows + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.util.DiSwitch#caseSashModel(org.eclipse.papyrus.infra.core.sashwindows.di.SashModel) + * + * @param object + * @return + */ + public PageRef caseSashModel(SashModel object) { + PageRef res = null; + for(Window window : object.getWindows()) { + res = this.doSwitch(window); + if(res != null) + return res; + } + + return super.caseSashModel(object); + } + + /** + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.util.DiSwitch#caseWindow(org.eclipse.papyrus.infra.core.sashwindows.di.Window) + * + * @param object + * @return + */ + public PageRef caseWindow(Window window) { + + AbstractPanel panel = window.getPanel(); + if(panel == null) + return null; + + PageRef res = this.doSwitch(panel); + if(res != null) + return res; + + return super.caseWindow(window); + } + + /** + * Iterate over children + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.util.DiSwitch#caseSashPanel(org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel) + * + * @param object + * @return + */ + public PageRef caseSashPanel(SashPanel object) { + PageRef res = null; + for(AbstractPanel panel : object.getChildren()) { + res = this.doSwitch(panel); + if(res != null) + return res; + } + + return super.caseSashPanel(object); + } + + /** + * Iterate over PageRef + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.util.DiSwitch#caseTabFolder(org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder) + * + * @param object + * @return + */ + public PageRef caseTabFolder(TabFolder object) { + for(PageRef pageRef : object.getChildren()) { + + if(pageRef.isForIdentifier(pageIdentifier)) + return pageRef; + } + + return super.caseTabFolder(object); + } + + }; + + // Do lookup + PageRef res = visitor.doSwitch(this); + + return res; + } + + /** + * TODO Add method to + * metamodel + * + * @generated NOT + */ + public TabFolder lookupFirstFolder() { + + // Create appropriate visitor. + DiSwitch visitor = new DiSwitch() { + + /** + * Iterate over windows + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.util.DiSwitch#caseSashModel(org.eclipse.papyrus.infra.core.sashwindows.di.SashModel) + * + * @param object + * @return + */ + public TabFolder caseSashModel(SashModel object) { + TabFolder res = null; + for(Window window : object.getWindows()) { + res = this.doSwitch(window); + if(res != null) + return res; + } + + return super.caseSashModel(object); + } + + /** + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.util.DiSwitch#caseWindow(org.eclipse.papyrus.infra.core.sashwindows.di.Window) + * + * @param object + * @return + */ + public TabFolder caseWindow(Window window) { + + AbstractPanel panel = window.getPanel(); + if(panel == null) + return null; + + TabFolder res = this.doSwitch(panel); + if(res != null) + return res; + + return super.caseWindow(window); + } + + /** + * Iterate over children + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.util.DiSwitch#caseSashPanel(org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel) + * + * @param object + * @return + */ + public TabFolder caseSashPanel(SashPanel object) { + TabFolder res = null; + for(AbstractPanel panel : object.getChildren()) { + res = this.doSwitch(panel); + if(res != null) + return res; + } + + return super.caseSashPanel(object); + } + + /** + * Iterate over PageRef + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.util.DiSwitch#caseTabFolder(org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder) + * + * @param object + * @return + */ + public TabFolder caseTabFolder(TabFolder object) { + return object; + } + + }; + + // Do lookup + TabFolder res = visitor.doSwitch(this); + + return res; + } + + /** + * TODO Add method to + * metamodel + * + * @generated NOT + */ + public Window lookupFirstWindow() { + + List list = getWindows(); + if(list.size() == 0) + return null; + + return list.get(0); + } + + /** + * + * + * @generated NOT + */ + public void movePage(TabFolder srcParentFolder, int srcIndex, TabFolder targetParentFolder, int targetIndex) { + + // Check if we move all pages of srcFolder + if(srcIndex == -1) { + // move all + List srcChildrens = srcParentFolder.getChildren(); + List targetChildrens = targetParentFolder.getChildren(); + while(srcChildrens.size() > 0) { + PageRef pageRef = srcChildrens.remove(0); + targetChildrens.add(pageRef); + } + return; + } + + // Move only one + PageRef pageRef = srcParentFolder.getChildren().remove(srcIndex); + + List targetChildrens = targetParentFolder.getChildren(); + // Check if out of target range. + if(targetIndex < 0 || targetIndex > targetChildrens.size()) + targetChildrens.add(pageRef); + else + targetChildrens.add(targetIndex, pageRef); + } + + /** + * + * + * @generated NOT + */ + public void insertFolder(TabFolder folderToInsert, TabFolder refFolder, int side) { + + // Get the parent under which the sash will be inserted + PanelParent refParent = refFolder.getParent(); + + SashPanel newSash; + int direction; + + // Compute sash direction + if(side == SWT.LEFT || side == SWT.RIGHT) + direction = SWT.HORIZONTAL; + else + direction = SWT.VERTICAL; + // Create sash + newSash = DiFactory.eINSTANCE.createSashPanel(); + // Insert in parent. Should be done before setting childrens, otherwise, + // the child can't be + // replaced as it will not belong to parent anymore. + refParent.replaceChild(refFolder, newSash); + + if(side == SWT.LEFT || side == SWT.UP) { // insert left + newSash.setChildren(folderToInsert, refFolder, direction); + } else { + newSash.setChildren(refFolder, folderToInsert, direction); + } + + } + + /** + * + * + * @generated NOT + */ + public void movePage(TabFolder srcParentFolder, int srcIndex, TabFolder targetParentFolder) { + + PageRef pageRef = srcParentFolder.getChildren().remove(srcIndex); + + List targetChildrens = targetParentFolder.getChildren(); + // Check if out of target range. + targetChildrens.add(pageRef); + } + + /** + * + * + * @generated NOT + */ + public void removeEmptyFolder(TabFolder folder) { + + EList children = folder.getChildren(); + + // Check if empty + if(children.size() > 0) + return; + + PanelParent parent = folder.getParent(); + // Forbid removing of the last folder + if(parent instanceof Window) + return; + + // Parent is a sash. Ask it to remove the child and itself + ((SashPanel)parent).delete(folder); + // adjust current selection if the old folder was the currentSelection + if(getCurrentSelection() == folder) { + setCurrentSelection(lookupFirstFolder()); + } + } + + /** + * + * + * @generated NOT + */ + public void removeAllPages() { + + // Get a the first window and a folder. + // Clear the folder and set it as the root folder. + // This disguard all other folder and pages ... + Window firstWindow = lookupFirstWindow(); + TabFolder folder = lookupFirstFolder(); + + folder.getChildren().clear(); + firstWindow.setPanel(folder); + } + + /** + * + * + * @generated NOT + */ + public void removeOtherPages(Object pageIdentifier) { + // Get a the first window and a folder. + // Clear the folder and set it as the root folder. + // This disguard all other folder and pages ... + Window firstWindow = lookupFirstWindow(); + TabFolder folder = lookupFirstFolder(); + PageRef page = lookupPage(pageIdentifier); + + folder.getChildren().clear(); + if(page != null) { + folder.getChildren().add(page); + } + firstWindow.setPanel(folder); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch(featureID) { + case DiPackage.SASH_MODEL__WINDOWS: + return ((InternalEList)getWindows()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch(featureID) { + case DiPackage.SASH_MODEL__WINDOWS: + return getWindows(); + case DiPackage.SASH_MODEL__CURRENT_SELECTION: + if(resolve) + return getCurrentSelection(); + return basicGetCurrentSelection(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch(featureID) { + case DiPackage.SASH_MODEL__WINDOWS: + getWindows().clear(); + getWindows().addAll((Collection)newValue); + return; + case DiPackage.SASH_MODEL__CURRENT_SELECTION: + setCurrentSelection((TabFolder)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch(featureID) { + case DiPackage.SASH_MODEL__WINDOWS: + getWindows().clear(); + return; + case DiPackage.SASH_MODEL__CURRENT_SELECTION: + setCurrentSelection((TabFolder)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch(featureID) { + case DiPackage.SASH_MODEL__WINDOWS: + return windows != null && !windows.isEmpty(); + case DiPackage.SASH_MODEL__CURRENT_SELECTION: + return currentSelection != null; + } + return super.eIsSet(featureID); + } + +} // SashModelImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SashPanelImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SashPanelImpl.java new file mode 100644 index 00000000000..9e83e63a224 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SashPanelImpl.java @@ -0,0 +1,389 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel; + +/** + * An implementation of the model object ' Sash Panel'. + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashPanelImpl#getChildren + * Children}
  • + *
  • + * {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashPanelImpl#getSashPosition + * Sash Position}
  • + *
  • + * {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashPanelImpl#getDirection + * Direction}
  • + *
+ *

+ * + * @generated + */ +public class SashPanelImpl extends AbstractPanelImpl implements SashPanel { + + /** + * The cached value of the '{@link #getChildren() Children}' + * containment reference list. + * + * @see #getChildren() + * @generated + * @ordered + */ + protected EList children; + + /** + * The default value of the '{@link #getSashPosition() + * Sash Position}' attribute. + * + * @see #getSashPosition() + * @generated + * @ordered + */ + protected static final float SASH_POSITION_EDEFAULT = 0.0F; + + /** + * The cached value of the '{@link #getSashPosition() + * Sash Position}' attribute. + * + * @see #getSashPosition() + * @generated + * @ordered + */ + protected float sashPosition = SASH_POSITION_EDEFAULT; + + /** + * The default value of the '{@link #getDirection() Direction}' + * attribute. + * + * @see #getDirection() + * @generated + * @ordered + */ + protected static final int DIRECTION_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getDirection() Direction}' + * attribute. + * + * @see #getDirection() + * @generated + * @ordered + */ + protected int direction = DIRECTION_EDEFAULT; + + /** + * + * + * @generated + */ + protected SashPanelImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiPackage.Literals.SASH_PANEL; + } + + /** + * + * + * @generated + */ + public EList getChildren() { + if(children == null) { + children = new EObjectContainmentWithInverseEList(AbstractPanel.class, this, DiPackage.SASH_PANEL__CHILDREN, DiPackage.ABSTRACT_PANEL__PARENT); + } + return children; + } + + /** + * + * + * @generated + */ + public float getSashPosition() { + return sashPosition; + } + + /** + * + * + * @generated + */ + public void setSashPosition(float newSashPosition) { + float oldSashPosition = sashPosition; + sashPosition = newSashPosition; + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.SASH_PANEL__SASH_POSITION, oldSashPosition, sashPosition)); + } + + /** + * + * + * @generated + */ + public int getDirection() { + return direction; + } + + /** + * + * + * @generated + */ + public void setDirection(int newDirection) { + int oldDirection = direction; + direction = newDirection; + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.SASH_PANEL__DIRECTION, oldDirection, direction)); + } + + /** + * + * + * + * + * @generated NOT + */ + public void setChildren(AbstractPanel leftChild, AbstractPanel rightChild, int direction) { + setDirection(direction); + List children = getChildren(); + + if(children.size() == 0) { + children.add(leftChild); + children.add(rightChild); + + } else { + children.set(0, leftChild); + children.set(1, rightChild); + } + + } + + /** + * + * + * @generated NOT + */ + public void delete(AbstractPanel childToDelete) { + // Get the other child + EList children = getChildren(); + AbstractPanel otherChild = (childToDelete == children.get(0) ? children.get(1) : children.get(0)); + + PanelParent parent = getParent(); + // Change parent + // otherChild.setParent( parent ); + parent.replaceChild(this, otherChild); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch(featureID) { + case DiPackage.SASH_PANEL__CHILDREN: + return ((InternalEList)(InternalEList)getChildren()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch(featureID) { + case DiPackage.SASH_PANEL__CHILDREN: + return ((InternalEList)getChildren()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch(featureID) { + case DiPackage.SASH_PANEL__CHILDREN: + return getChildren(); + case DiPackage.SASH_PANEL__SASH_POSITION: + return getSashPosition(); + case DiPackage.SASH_PANEL__DIRECTION: + return getDirection(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch(featureID) { + case DiPackage.SASH_PANEL__CHILDREN: + getChildren().clear(); + getChildren().addAll((Collection)newValue); + return; + case DiPackage.SASH_PANEL__SASH_POSITION: + setSashPosition((Float)newValue); + return; + case DiPackage.SASH_PANEL__DIRECTION: + setDirection((Integer)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch(featureID) { + case DiPackage.SASH_PANEL__CHILDREN: + getChildren().clear(); + return; + case DiPackage.SASH_PANEL__SASH_POSITION: + setSashPosition(SASH_POSITION_EDEFAULT); + return; + case DiPackage.SASH_PANEL__DIRECTION: + setDirection(DIRECTION_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch(featureID) { + case DiPackage.SASH_PANEL__CHILDREN: + return children != null && !children.isEmpty(); + case DiPackage.SASH_PANEL__SASH_POSITION: + return sashPosition != SASH_POSITION_EDEFAULT; + case DiPackage.SASH_PANEL__DIRECTION: + return direction != DIRECTION_EDEFAULT; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) { + if(baseClass == PanelParent.class) { + switch(derivedFeatureID) { + case DiPackage.SASH_PANEL__CHILDREN: + return DiPackage.PANEL_PARENT__CHILDREN; + default: + return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) { + if(baseClass == PanelParent.class) { + switch(baseFeatureID) { + case DiPackage.PANEL_PARENT__CHILDREN: + return DiPackage.SASH_PANEL__CHILDREN; + default: + return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if(eIsProxy()) + return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (sashPosition: "); + result.append(sashPosition); + result.append(", direction: "); + result.append(direction); + result.append(')'); + return result.toString(); + } + + /** + * Set both ends (parent and child). + * + * @generated NOT + */ + public void replaceChild(AbstractPanel oldChild, AbstractPanel newChild) { + + int index = getChildren().indexOf(oldChild); + if(index >= 0) { + // do replace + getChildren().set(index, newChild); + newChild.setParent(this); + } else + throw new IndexOutOfBoundsException("Child '" + oldChild + "' not found in sash. Can't replace it."); + } + +} // SashPanelImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SashWindowsMngrImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SashWindowsMngrImpl.java new file mode 100644 index 00000000000..4f0d533f750 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SashWindowsMngrImpl.java @@ -0,0 +1,253 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageList; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr; + +/** + * An implementation of the model object ' Sash Windows Mngr'. + *

+ * The following features are implemented: + *

    + *
  • + * {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashWindowsMngrImpl#getPageList + * Page List}
  • + *
  • + * {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SashWindowsMngrImpl#getSashModel + * Sash Model}
  • + *
+ *

+ * + * @generated + */ +public class SashWindowsMngrImpl extends EObjectImpl implements SashWindowsMngr { + + /** + * The cached value of the '{@link #getPageList() Page List}' + * containment reference. + * + * @see #getPageList() + * @generated + * @ordered + */ + protected PageList pageList; + + /** + * The cached value of the '{@link #getSashModel() Sash Model}' + * containment reference. + * + * @see #getSashModel() + * @generated + * @ordered + */ + protected SashModel sashModel; + + /** + * + * + * @generated + */ + protected SashWindowsMngrImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiPackage.Literals.SASH_WINDOWS_MNGR; + } + + /** + * + * + * @generated + */ + public PageList getPageList() { + return pageList; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetPageList(PageList newPageList, NotificationChain msgs) { + PageList oldPageList = pageList; + pageList = newPageList; + if(eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST, oldPageList, newPageList); + if(msgs == null) + msgs = notification; + else + msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setPageList(PageList newPageList) { + if(newPageList != pageList) { + NotificationChain msgs = null; + if(pageList != null) + msgs = ((InternalEObject)pageList).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST, null, msgs); + if(newPageList != null) + msgs = ((InternalEObject)newPageList).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST, null, msgs); + msgs = basicSetPageList(newPageList, msgs); + if(msgs != null) + msgs.dispatch(); + } else if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST, newPageList, newPageList)); + } + + /** + * + * + * @generated + */ + public SashModel getSashModel() { + return sashModel; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetSashModel(SashModel newSashModel, NotificationChain msgs) { + SashModel oldSashModel = sashModel; + sashModel = newSashModel; + if(eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL, oldSashModel, newSashModel); + if(msgs == null) + msgs = notification; + else + msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setSashModel(SashModel newSashModel) { + if(newSashModel != sashModel) { + NotificationChain msgs = null; + if(sashModel != null) + msgs = ((InternalEObject)sashModel).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL, null, msgs); + if(newSashModel != null) + msgs = ((InternalEObject)newSashModel).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL, null, msgs); + msgs = basicSetSashModel(newSashModel, msgs); + if(msgs != null) + msgs.dispatch(); + } else if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL, newSashModel, newSashModel)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch(featureID) { + case DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST: + return basicSetPageList(null, msgs); + case DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL: + return basicSetSashModel(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch(featureID) { + case DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST: + return getPageList(); + case DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL: + return getSashModel(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch(featureID) { + case DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST: + setPageList((PageList)newValue); + return; + case DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL: + setSashModel((SashModel)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch(featureID) { + case DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST: + setPageList((PageList)null); + return; + case DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL: + setSashModel((SashModel)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch(featureID) { + case DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST: + return pageList != null; + case DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL: + return sashModel != null; + } + return super.eIsSet(featureID); + } + +} // SashWindowsMngrImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SizeImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SizeImpl.java new file mode 100644 index 00000000000..f63082fc72d --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/SizeImpl.java @@ -0,0 +1,218 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.Size; + +/** + * An implementation of the model object ' Size'. + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SizeImpl#getWidth Width}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.SizeImpl#getLength Length}
  • + *
+ *

+ * + * @generated + */ +public class SizeImpl extends EObjectImpl implements Size { + + /** + * The default value of the '{@link #getWidth() Width}' attribute. + * + * + * @see #getWidth() + * @generated + * @ordered + */ + protected static final int WIDTH_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getWidth() Width}' attribute. + * + * + * @see #getWidth() + * @generated + * @ordered + */ + protected int width = WIDTH_EDEFAULT; + + /** + * The default value of the '{@link #getLength() Length}' + * attribute. + * + * @see #getLength() + * @generated + * @ordered + */ + protected static final int LENGTH_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getLength() Length}' attribute. + * + * + * @see #getLength() + * @generated + * @ordered + */ + protected int length = LENGTH_EDEFAULT; + + /** + * + * + * @generated + */ + protected SizeImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiPackage.Literals.SIZE; + } + + /** + * + * + * @generated + */ + public int getWidth() { + return width; + } + + /** + * + * + * @generated + */ + public void setWidth(int newWidth) { + int oldWidth = width; + width = newWidth; + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.SIZE__WIDTH, oldWidth, width)); + } + + /** + * + * + * @generated + */ + public int getLength() { + return length; + } + + /** + * + * + * @generated + */ + public void setLength(int newLength) { + int oldLength = length; + length = newLength; + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.SIZE__LENGTH, oldLength, length)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch(featureID) { + case DiPackage.SIZE__WIDTH: + return getWidth(); + case DiPackage.SIZE__LENGTH: + return getLength(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch(featureID) { + case DiPackage.SIZE__WIDTH: + setWidth((Integer)newValue); + return; + case DiPackage.SIZE__LENGTH: + setLength((Integer)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch(featureID) { + case DiPackage.SIZE__WIDTH: + setWidth(WIDTH_EDEFAULT); + return; + case DiPackage.SIZE__LENGTH: + setLength(LENGTH_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch(featureID) { + case DiPackage.SIZE__WIDTH: + return width != WIDTH_EDEFAULT; + case DiPackage.SIZE__LENGTH: + return length != LENGTH_EDEFAULT; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if(eIsProxy()) + return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (width: "); + result.append(width); + result.append(", length: "); + result.append(length); + result.append(')'); + return result.toString(); + } + +} // SizeImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/TabFolderImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/TabFolderImpl.java new file mode 100644 index 00000000000..2cfb025f9f4 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/TabFolderImpl.java @@ -0,0 +1,212 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiFactory; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder; + +/** + * An implementation of the model object ' Tab Folder'. + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.TabFolderImpl#getChildren + * Children}
  • + *
+ *

+ * + * @generated + */ +public class TabFolderImpl extends AbstractPanelImpl implements TabFolder { + + /** + * The cached value of the '{@link #getChildren() Children}' + * containment reference list. + * + * @see #getChildren() + * @generated + * @ordered + */ + protected EList children; + + /** + * + * + * @generated + */ + protected TabFolderImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiPackage.Literals.TAB_FOLDER; + } + + /** + * + * + * @generated + */ + public EList getChildren() { + if(children == null) { + children = new EObjectContainmentWithInverseEList(PageRef.class, this, DiPackage.TAB_FOLDER__CHILDREN, DiPackage.PAGE_REF__PARENT); + } + return children; + } + + /** + * + * + * @generated NOT + */ + public void addPage(Object pageIdentifier) { + PageRef newPage = DiFactory.eINSTANCE.createPageRef(); + newPage.setPageIdentifier(pageIdentifier); + getChildren().add(newPage); + } + + /** + * + * + * @generated NOT + */ + public void removePage(int pageIndex) { + getChildren().remove(pageIndex); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch(featureID) { + case DiPackage.TAB_FOLDER__CHILDREN: + return ((InternalEList)(InternalEList)getChildren()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch(featureID) { + case DiPackage.TAB_FOLDER__CHILDREN: + return ((InternalEList)getChildren()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch(featureID) { + case DiPackage.TAB_FOLDER__CHILDREN: + return getChildren(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch(featureID) { + case DiPackage.TAB_FOLDER__CHILDREN: + getChildren().clear(); + getChildren().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch(featureID) { + case DiPackage.TAB_FOLDER__CHILDREN: + getChildren().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch(featureID) { + case DiPackage.TAB_FOLDER__CHILDREN: + return children != null && !children.isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder#movePage(int, int) + * + * @param oldIndex + * @param newIndex + * @generated NOT + */ + public void movePage(int oldIndex, int newIndex) { + int listSize = getChildren().size(); + if(newIndex >= listSize) { + newIndex = listSize - 1; + } + if(newIndex < 0) { + newIndex = 0; + } + + if(oldIndex == newIndex) + return; + + if(listSize == 0) + return; + + getChildren().move(newIndex, oldIndex); + } + +} // TabFolderImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/WindowImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/WindowImpl.java new file mode 100644 index 00000000000..8a419aff6f3 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/impl/WindowImpl.java @@ -0,0 +1,280 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.Position; +import org.eclipse.papyrus.infra.core.sashwindows.di.Size; +import org.eclipse.papyrus.infra.core.sashwindows.di.Window; + +/** + * An implementation of the model object ' Window'. + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.WindowImpl#getPosition + * Position}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.WindowImpl#getSize Size}
  • + *
  • {@link org.eclipse.papyrus.infra.core.sashwindows.di.impl.WindowImpl#getPanel Panel}
  • + *
+ *

+ * + * @generated + */ +public class WindowImpl extends PanelParentImpl implements Window { + + /** + * The cached value of the '{@link #getPosition() Position}' + * reference. + * + * @see #getPosition() + * @generated + * @ordered + */ + protected Position position; + + /** + * The cached value of the '{@link #getSize() Size}' reference. + * + * + * @see #getSize() + * @generated + * @ordered + */ + protected Size size; + + /** + * + * + * @generated + */ + protected WindowImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return DiPackage.Literals.WINDOW; + } + + /** + * + * + * @generated + */ + public Position getPosition() { + if(position != null && position.eIsProxy()) { + InternalEObject oldPosition = (InternalEObject)position; + position = (Position)eResolveProxy(oldPosition); + if(position != oldPosition) { + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, DiPackage.WINDOW__POSITION, oldPosition, position)); + } + } + return position; + } + + /** + * + * + * @generated + */ + public Position basicGetPosition() { + return position; + } + + /** + * + * + * @generated + */ + public void setPosition(Position newPosition) { + Position oldPosition = position; + position = newPosition; + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.WINDOW__POSITION, oldPosition, position)); + } + + /** + * + * + * @generated + */ + public Size getSize() { + if(size != null && size.eIsProxy()) { + InternalEObject oldSize = (InternalEObject)size; + size = (Size)eResolveProxy(oldSize); + if(size != oldSize) { + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, DiPackage.WINDOW__SIZE, oldSize, size)); + } + } + return size; + } + + /** + * + * + * @generated + */ + public Size basicGetSize() { + return size; + } + + /** + * + * + * @generated + */ + public void setSize(Size newSize) { + Size oldSize = size; + size = newSize; + if(eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.WINDOW__SIZE, oldSize, size)); + } + + /** + * + * + * @generated + */ + public AbstractPanel getPanel() { + AbstractPanel panel = basicGetPanel(); + return panel != null && panel.eIsProxy() ? (AbstractPanel)eResolveProxy((InternalEObject)panel) : panel; + } + + /** + * + * + * @generated NOT + */ + public AbstractPanel basicGetPanel() { + EList list = getChildren(); + if(list.size() > 0) + return list.get(0); + else + return null; + } + + /** + * + * + * @generated NOT + */ + public void setPanel(AbstractPanel newPanel) { + EList list = getChildren(); + if(list.size() > 0) + list.set(0, newPanel); + else + list.add(newPanel); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch(featureID) { + case DiPackage.WINDOW__POSITION: + if(resolve) + return getPosition(); + return basicGetPosition(); + case DiPackage.WINDOW__SIZE: + if(resolve) + return getSize(); + return basicGetSize(); + case DiPackage.WINDOW__PANEL: + if(resolve) + return getPanel(); + return basicGetPanel(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch(featureID) { + case DiPackage.WINDOW__POSITION: + setPosition((Position)newValue); + return; + case DiPackage.WINDOW__SIZE: + setSize((Size)newValue); + return; + case DiPackage.WINDOW__PANEL: + setPanel((AbstractPanel)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch(featureID) { + case DiPackage.WINDOW__POSITION: + setPosition((Position)null); + return; + case DiPackage.WINDOW__SIZE: + setSize((Size)null); + return; + case DiPackage.WINDOW__PANEL: + setPanel((AbstractPanel)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch(featureID) { + case DiPackage.WINDOW__POSITION: + return position != null; + case DiPackage.WINDOW__SIZE: + return size != null; + case DiPackage.WINDOW__PANEL: + return basicGetPanel() != null; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated NOT + */ + public void replaceChild(AbstractPanel oldChild, AbstractPanel newChild) { + setPanel(newChild); + } + +} // WindowImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiAdapterFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiAdapterFactory.java new file mode 100644 index 00000000000..20dbe948eb0 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiAdapterFactory.java @@ -0,0 +1,347 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.util; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPage; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageList; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent; +import org.eclipse.papyrus.infra.core.sashwindows.di.Position; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr; +import org.eclipse.papyrus.infra.core.sashwindows.di.Size; +import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder; +import org.eclipse.papyrus.infra.core.sashwindows.di.Window; + +/** + * The Adapter Factory for the model. It provides + * an adapter createXXX method for each class of the model. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage + * @generated + */ +public class DiAdapterFactory extends AdapterFactoryImpl { + + /** + * The cached model package. + * + * @generated + */ + protected static DiPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * @generated + */ + public DiAdapterFactory() { + if(modelPackage == null) { + modelPackage = DiPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * This implementation returns true if + * the object is either the model's package or is an instance object of the + * model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) { + if(object == modelPackage) { + return true; + } + if(object instanceof EObject) { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * @generated + */ + protected DiSwitch modelSwitch = new DiSwitch() { + + @Override + public Adapter caseSashModel(SashModel object) { + return createSashModelAdapter(); + } + + @Override + public Adapter caseWindow(Window object) { + return createWindowAdapter(); + } + + @Override + public Adapter casePanelParent(PanelParent object) { + return createPanelParentAdapter(); + } + + @Override + public Adapter caseAbstractPanel(AbstractPanel object) { + return createAbstractPanelAdapter(); + } + + @Override + public Adapter casePosition(Position object) { + return createPositionAdapter(); + } + + @Override + public Adapter caseSize(Size object) { + return createSizeAdapter(); + } + + @Override + public Adapter caseTabFolder(TabFolder object) { + return createTabFolderAdapter(); + } + + @Override + public Adapter casePageRef(PageRef object) { + return createPageRefAdapter(); + } + + @Override + public Adapter caseSashPanel(SashPanel object) { + return createSashPanelAdapter(); + } + + @Override + public Adapter caseAbstractPage(AbstractPage object) { + return createAbstractPageAdapter(); + } + + @Override + public Adapter casePageList(PageList object) { + return createPageListAdapter(); + } + + @Override + public Adapter caseSashWindowsMngr(SashWindowsMngr object) { + return createSashWindowsMngrAdapter(); + } + + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target + * the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject)target); + } + + /** + * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashModel Sash Model} '. This default implementation returns null so + * that we can easily ignore cases; it's useful to ignore a case when + * inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.SashModel + * @generated + */ + public Adapter createSashModelAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Window Window}'. This default implementation returns null so that we + * can easily ignore cases; it's useful to ignore a case when inheritance + * will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.Window + * @generated + */ + public Adapter createWindowAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent + * Panel Parent}'. This default + * implementation returns null so that we can easily ignore cases; it's + * useful to ignore a case when inheritance will catch all the cases anyway. + * + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent + * @generated + */ + public Adapter createPanelParentAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel + * Abstract Panel}'. This default + * implementation returns null so that we can easily ignore cases; it's + * useful to ignore a case when inheritance will catch all the cases anyway. + * + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel + * @generated + */ + public Adapter createAbstractPanelAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Position Position}'. + * This default implementation returns null so that + * we can easily ignore cases; it's useful to ignore a case when inheritance + * will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.Position + * @generated + */ + public Adapter createPositionAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.Size Size}'. This default implementation returns null so that we + * can easily ignore cases; it's useful to ignore a case when inheritance + * will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.Size + * @generated + */ + public Adapter createSizeAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder Tab Folder} '. This default implementation returns null so + * that we can easily ignore cases; it's useful to ignore a case when + * inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder + * @generated + */ + public Adapter createTabFolderAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageRef Page Ref}'. + * This default implementation returns null so that + * we can easily ignore cases; it's useful to ignore a case when inheritance + * will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.PageRef + * @generated + */ + public Adapter createPageRefAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel Sash Panel} '. This default implementation returns null so + * that we can easily ignore cases; it's useful to ignore a case when + * inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel + * @generated + */ + public Adapter createSashPanelAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPage + * Abstract Page}'. This default + * implementation returns null so that we can easily ignore cases; it's + * useful to ignore a case when inheritance will catch all the cases anyway. + * + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPage + * @generated + */ + public Adapter createAbstractPageAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.PageList Page List}'. + * This default implementation returns null so that + * we can easily ignore cases; it's useful to ignore a case when inheritance + * will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.PageList + * @generated + */ + public Adapter createPageListAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr + * Sash Windows Mngr}'. This default + * implementation returns null so that we can easily ignore cases; it's + * useful to ignore a case when inheritance will catch all the cases anyway. + * + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr + * @generated + */ + public Adapter createSashWindowsMngrAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. This + * default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} // DiAdapterFactory diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiResourceFactoryImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiResourceFactoryImpl.java new file mode 100644 index 00000000000..6703c73d8ee --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiResourceFactoryImpl.java @@ -0,0 +1,48 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.util; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.emf.ecore.resource.Resource; + +import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; + +import org.eclipse.emf.ecore.xmi.XMLResource; + +/** + * The Resource Factory associated with the + * package. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.util.DiResourceImpl + * @generated + */ +public class DiResourceFactoryImpl extends ResourceFactoryImpl { + + /** + * Creates an instance of the resource factory. + * + * @generated + */ + public DiResourceFactoryImpl() { + super(); + } + + /** + * Creates an instance of the resource. + * + * @generated + */ + @Override + public Resource createResource(URI uri) { + XMLResource result = new DiResourceImpl(uri); + return result; + } + +} // DiResourceFactoryImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiResourceImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiResourceImpl.java new file mode 100644 index 00000000000..a47292b81a1 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiResourceImpl.java @@ -0,0 +1,34 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.util; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; + +/** + * The Resource associated with the package. + * + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.util.DiResourceFactoryImpl + * @generated + */ +public class DiResourceImpl extends XMIResourceImpl { + + /** + * Creates an instance of the resource. + * + * @param uri + * the URI of the new resource. + * @generated + */ + public DiResourceImpl(URI uri) { + super(uri); + } + +} // DiResourceImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiSwitch.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiSwitch.java new file mode 100644 index 00000000000..128c79d4158 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiSwitch.java @@ -0,0 +1,401 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.core.sashwindows.di.util; + +import java.util.List; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPage; +import org.eclipse.papyrus.infra.core.sashwindows.di.AbstractPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageList; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.papyrus.infra.core.sashwindows.di.PanelParent; +import org.eclipse.papyrus.infra.core.sashwindows.di.Position; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr; +import org.eclipse.papyrus.infra.core.sashwindows.di.Size; +import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder; +import org.eclipse.papyrus.infra.core.sashwindows.di.Window; + +/** + * The Switch for the model's inheritance + * hierarchy. It supports the call {@link #doSwitch(EObject) doSwitch(object)} to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object and proceeding up the + * inheritance hierarchy until a non-null result is returned, which is the + * result of the switch. + * + * @see org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage + * @generated + */ +public class DiSwitch { + + /** + * The cached model package + * + * @generated + */ + protected static DiPackage modelPackage; + + /** + * Creates an instance of the switch. + * + * @generated + */ + public DiSwitch() { + if(modelPackage == null) { + modelPackage = DiPackage.eINSTANCE; + } + } + + /** + * Calls caseXXX for each class of the model until one returns + * a non null result; it yields that result. + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + public T doSwitch(EObject theEObject) { + return doSwitch(theEObject.eClass(), theEObject); + } + + /** + * Calls caseXXX for each class of the model until one returns + * a non null result; it yields that result. + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + protected T doSwitch(EClass theEClass, EObject theEObject) { + if(theEClass.eContainer() == modelPackage) { + return doSwitch(theEClass.getClassifierID(), theEObject); + } else { + List eSuperTypes = theEClass.getESuperTypes(); + return eSuperTypes.isEmpty() ? defaultCase(theEObject) : doSwitch(eSuperTypes.get(0), theEObject); + } + } + + /** + * Calls caseXXX for each class of the model until one returns + * a non null result; it yields that result. + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + protected T doSwitch(int classifierID, EObject theEObject) { + switch(classifierID) { + case DiPackage.SASH_MODEL: + { + SashModel sashModel = (SashModel)theEObject; + T result = caseSashModel(sashModel); + if(result == null) + result = defaultCase(theEObject); + return result; + } + case DiPackage.WINDOW: + { + Window window = (Window)theEObject; + T result = caseWindow(window); + if(result == null) + result = casePanelParent(window); + if(result == null) + result = defaultCase(theEObject); + return result; + } + case DiPackage.PANEL_PARENT: + { + PanelParent panelParent = (PanelParent)theEObject; + T result = casePanelParent(panelParent); + if(result == null) + result = defaultCase(theEObject); + return result; + } + case DiPackage.ABSTRACT_PANEL: + { + AbstractPanel abstractPanel = (AbstractPanel)theEObject; + T result = caseAbstractPanel(abstractPanel); + if(result == null) + result = defaultCase(theEObject); + return result; + } + case DiPackage.POSITION: + { + Position position = (Position)theEObject; + T result = casePosition(position); + if(result == null) + result = defaultCase(theEObject); + return result; + } + case DiPackage.SIZE: + { + Size size = (Size)theEObject; + T result = caseSize(size); + if(result == null) + result = defaultCase(theEObject); + return result; + } + case DiPackage.TAB_FOLDER: + { + TabFolder tabFolder = (TabFolder)theEObject; + T result = caseTabFolder(tabFolder); + if(result == null) + result = caseAbstractPanel(tabFolder); + if(result == null) + result = defaultCase(theEObject); + return result; + } + case DiPackage.PAGE_REF: + { + PageRef pageRef = (PageRef)theEObject; + T result = casePageRef(pageRef); + if(result == null) + result = defaultCase(theEObject); + return result; + } + case DiPackage.SASH_PANEL: + { + SashPanel sashPanel = (SashPanel)theEObject; + T result = caseSashPanel(sashPanel); + if(result == null) + result = caseAbstractPanel(sashPanel); + if(result == null) + result = casePanelParent(sashPanel); + if(result == null) + result = defaultCase(theEObject); + return result; + } + case DiPackage.ABSTRACT_PAGE: + { + AbstractPage abstractPage = (AbstractPage)theEObject; + T result = caseAbstractPage(abstractPage); + if(result == null) + result = defaultCase(theEObject); + return result; + } + case DiPackage.PAGE_LIST: + { + PageList pageList = (PageList)theEObject; + T result = casePageList(pageList); + if(result == null) + result = defaultCase(theEObject); + return result; + } + case DiPackage.SASH_WINDOWS_MNGR: + { + SashWindowsMngr sashWindowsMngr = (SashWindowsMngr)theEObject; + T result = caseSashWindowsMngr(sashWindowsMngr); + if(result == null) + result = defaultCase(theEObject); + return result; + } + default: + return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of ' Sash Model'. This implementation returns + * null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of ' Sash Model'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseSashModel(SashModel object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of ' Window'. This implementation returns + * null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of ' Window'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseWindow(Window object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of ' Panel Parent'. This implementation + * returns null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of ' Panel Parent'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePanelParent(PanelParent object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of ' Abstract Panel'. This implementation + * returns null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of ' Abstract Panel'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseAbstractPanel(AbstractPanel object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of ' Position'. This implementation returns + * null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of ' Position'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePosition(Position object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of ' Size'. This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of ' Size'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseSize(Size object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of ' Tab Folder'. This implementation returns + * null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of ' Tab Folder'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseTabFolder(TabFolder object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of ' Page Ref'. This implementation returns + * null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of ' Page Ref'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePageRef(PageRef object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of ' Sash Panel'. This implementation returns + * null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of ' Sash Panel'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseSashPanel(SashPanel object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of ' Abstract Page'. This implementation + * returns null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of ' Abstract Page'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseAbstractPage(AbstractPage object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of ' Page List'. This implementation returns + * null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of ' Page List'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePageList(PageList object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of ' Sash Windows Mngr'. This implementation + * returns null; returning a non-null result will terminate the switch. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of ' Sash Windows Mngr'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseSashWindowsMngr(SashWindowsMngr object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of ' EObject'. This implementation returns + * null; returning a non-null result will terminate the switch, but this is + * the last case anyway. + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of ' EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + public T defaultCase(EObject object) { + return null; + } + +} // DiSwitch diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiUtils.java new file mode 100644 index 00000000000..d236265bf4e --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/infra/core/sashwindows/di/util/DiUtils.java @@ -0,0 +1,188 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * Emilien Perico emilien.perico@atosorigin.com - add methods to manage di resource + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.sashwindows.di.util; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.infra.core.sashwindows.di.DiFactory; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageList; +import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel; +import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr; +import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder; +import org.eclipse.papyrus.infra.core.sashwindows.di.Window; +import org.eclipse.papyrus.infra.core.sashwindows.di.exception.SashEditorException; + +/** + * Set of utility methods + * + * @author dumoulin + */ +public class DiUtils { + + /** + * Create a default SashModel with one window and one folder. Set the + * current folder. + * + * @param diResource + * @return + */ + static public SashModel createDefaultSashModel() { + + // SashModel + SashModel sashModel = DiFactory.eINSTANCE.createSashModel(); + Window window = DiFactory.eINSTANCE.createWindow(); + sashModel.getWindows().add(window); + + TabFolder folder = DiFactory.eINSTANCE.createTabFolder(); + window.setPanel(folder); + // Default folder + sashModel.setCurrentSelection(folder); + + return sashModel; + } + + /** + * Create a default SashWindowsMngr with one PageLit and one default + * SashModel. Set the current folder. + * + * @param diResource + * @return + */ + static public SashWindowsMngr createDefaultSashWindowsMngr() { + SashWindowsMngr model; + + model = DiFactory.eINSTANCE.createSashWindowsMngr(); + + // SashModel + SashModel layout = createDefaultSashModel(); + + model.setSashModel(layout); + + // PageList + PageList pageList = DiFactory.eINSTANCE.createPageList(); + model.setPageList(pageList); + return model; + } + + /** + * Lookup for the SashModel object in the resource. + * + * @param diResource + * @return The {@link DiSashModel} or null if not found. + */ + static public SashWindowsMngr lookupSashWindowsMngr(Resource diResource) { + + for(Object node : diResource.getContents()) { + if(node instanceof SashWindowsMngr) + return (SashWindowsMngr)node; + } + return null; + } + + /** + * Gets the page reference of the specified eObject + * + * @param diResource + * @param eObject + * + * @return the page ref of eObject, null if not found TODO This method use + * too low level mechanism for its implementation. Consider to move + * it in a more appropriate class. Furthermore, some similar methods + * already exist. Can't we use them instead ? + */ + static public PageRef getPageRef(Resource diResource, EObject eObject) { + SashWindowsMngr windowsMngr = lookupSashWindowsMngr(diResource); + if(windowsMngr != null && windowsMngr.getPageList() != null) { + + for(PageRef pageRef : windowsMngr.getPageList().getAvailablePage()) { + + EObject emfPageIdentifier = pageRef.getEmfPageIdentifier(); + if(eObject != null && eObject.equals(emfPageIdentifier)) { + return pageRef; + } + } + } + return null; + } + + /** + * Adds page to the page list of the sash windows manager + * + * @param diResource + * @param pageRef + * @throws SashEditorException + * TODO This method use too low level mechanism for its + * implementation. Consider to move it in a more appropriate + * class. Furthermore, some similar methods already exist. Can't + * we use them instead ? + */ + static public void addPageToPageList(Resource diResource, PageRef pageRef) throws SashEditorException { + SashWindowsMngr windowsMngr = lookupSashWindowsMngr(diResource); + addPageToPageList(windowsMngr, pageRef); + } + + /** + * Adds page to the page list of the sash windows manager. + * + * @param pageRef + * @param windowsMngr + * @throws SashEditorException + * TODO This method use too low level mechanism for its + * implementation. Consider to move it in a more appropriate + * class. Furthermore, some similar methods already exist. Can't + * we use them instead ? + */ + static public void addPageToPageList(SashWindowsMngr windowsMngr, PageRef pageRef) throws SashEditorException { + if(windowsMngr != null && windowsMngr.getPageList() != null) { + windowsMngr.getPageList().addPage(pageRef.getPageIdentifier()); + } else { + throw new SashEditorException("Unable to add the page to the windows manager"); + } + } + + /** + * Adds page to tab folder. + * + * @param windowsMngr + * @param pageRef + * @throws SashEditorException + * TODO This method use too low level mechanism for its + * implementation. Consider to move it in a more appropriate + * class. Furthermore, some similar methods already exist. Can't + * we use them instead ? + */ + static public void addPageToTabFolder(SashWindowsMngr windowsMngr, PageRef pageRef) throws SashEditorException { + + // Check parameters + if(pageRef == null || pageRef.getPageIdentifier() == null) + throw new SashEditorException("Unable to add the page to the tab folder: parameters are null"); + + SashModel sashModel = windowsMngr.getSashModel(); + if(sashModel == null) { + throw new SashEditorException("Unable to add the page to the tab folder: can't find SashModel"); + } + + // Get the currently active folder in order to add the page. + TabFolder tabFolder = sashModel.getCurrentSelection(); + if(tabFolder == null) { + throw new SashEditorException("Unable to add the page to the tab folder: No active folder"); + } + + tabFolder.addPage(pageRef.getPageIdentifier()); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/AbstractPage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/AbstractPage.java deleted file mode 100644 index 15b0d907d99..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/AbstractPage.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di; - -import org.eclipse.emf.ecore.EObject; - -/** - * A representation of the model object ' Abstract Page'. - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.AbstractPage#getPageIdentifier - * Page Identifier}
  • - *
- *

- * - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getAbstractPage() - * @model - * @generated - */ -public interface AbstractPage extends EObject { - - /** - * Returns the value of the 'Page Identifier' attribute. - * - *

- * If the meaning of the 'Page Identifier' attribute isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Page Identifier' attribute. - * @see #setPageIdentifier(Object) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getAbstractPage_PageIdentifier() - * @model unique="false" - * dataType="org.eclipse.papyrus.sashwindows.di.JavaObject" - * required="true" ordered="false" - * @generated - */ - Object getPageIdentifier(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.AbstractPage#getPageIdentifier - * Page Identifier}' attribute. - * - * @param value - * the new value of the 'Page Identifier' attribute. - * @see #getPageIdentifier() - * @generated - */ - void setPageIdentifier(Object value); - -} // AbstractPage diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/AbstractPanel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/AbstractPanel.java deleted file mode 100644 index 6113ae01962..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/AbstractPanel.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di; - -import org.eclipse.emf.ecore.EObject; - -/** - * A representation of the model object ' Abstract Panel'. - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.AbstractPanel#getParent Parent}
  • - *
- *

- * - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getAbstractPanel() - * @model abstract="true" - * @generated - */ -public interface AbstractPanel extends EObject { - - /** - * Returns the value of the 'Parent' container reference. It - * is bidirectional and its opposite is ' {@link org.eclipse.papyrus.sashwindows.di.PanelParent#getChildren - * Children}'. - *

- * If the meaning of the 'Parent' container reference isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Parent' container reference. - * @see #setParent(PanelParent) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getAbstractPanel_Parent() - * @see org.eclipse.papyrus.sashwindows.di.PanelParent#getChildren - * @model opposite="children" required="true" transient="false" - * ordered="false" - * @generated - */ - PanelParent getParent(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.AbstractPanel#getParent - * Parent}' container reference. - * - * @param value - * the new value of the 'Parent' container reference. - * @see #getParent() - * @generated - */ - void setParent(PanelParent value); -} // AbstractPanel diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/DiFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/DiFactory.java deleted file mode 100644 index 74958488500..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/DiFactory.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di; - -import org.eclipse.emf.ecore.EFactory; - -/** - * The Factory for the model. It provides a - * create method for each non-abstract class of the model. - * - * @see org.eclipse.papyrus.sashwindows.di.DiPackage - * @generated - */ -public interface DiFactory extends EFactory { - - /** - * The singleton instance of the factory. - * - * @generated - */ - DiFactory eINSTANCE = org.eclipse.papyrus.sashwindows.di.impl.DiFactoryImpl.init(); - - /** - * Returns a new object of class 'Sash Model'. - * - * @return a new object of class 'Sash Model'. - * @generated - */ - SashModel createSashModel(); - - /** - * Returns a new object of class 'Window'. - * - * - * @return a new object of class 'Window'. - * @generated - */ - Window createWindow(); - - /** - * Returns a new object of class 'Position'. - * - * @return a new object of class 'Position'. - * @generated - */ - Position createPosition(); - - /** - * Returns a new object of class 'Size'. - * - * - * @return a new object of class 'Size'. - * @generated - */ - Size createSize(); - - /** - * Returns a new object of class 'Tab Folder'. - * - * @return a new object of class 'Tab Folder'. - * @generated - */ - TabFolder createTabFolder(); - - /** - * Returns a new object of class 'Page Ref'. - * - * @return a new object of class 'Page Ref'. - * @generated - */ - PageRef createPageRef(); - - /** - * Returns a new object of class 'Sash Panel'. - * - * @return a new object of class 'Sash Panel'. - * @generated - */ - SashPanel createSashPanel(); - - /** - * Returns a new object of class 'Abstract Page'. - * - * @return a new object of class 'Abstract Page'. - * @generated - */ - AbstractPage createAbstractPage(); - - /** - * Returns a new object of class 'Page List'. - * - * @return a new object of class 'Page List'. - * @generated - */ - PageList createPageList(); - - /** - * Returns a new object of class 'Sash Windows Mngr'. - * - * @return a new object of class 'Sash Windows Mngr'. - * @generated - */ - SashWindowsMngr createSashWindowsMngr(); - - /** - * Returns the package supported by this factory. - * - * - * @return the package supported by this factory. - * @generated - */ - DiPackage getDiPackage(); - -} // DiFactory diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/DiPackage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/DiPackage.java deleted file mode 100644 index 35029867070..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/DiPackage.java +++ /dev/null @@ -1,1349 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; - -/** - * The Package for the model. It contains - * accessors for the meta objects to represent - *
    - *
  • each class,
  • - *
  • each feature of each class,
  • - *
  • each enum,
  • - *
  • and each data type
  • - *
- * - * - * @see org.eclipse.papyrus.sashwindows.di.DiFactory - * @model kind="package" - * @generated - */ -public interface DiPackage extends EPackage { - - /** - * The package name. - * - * @generated - */ - String eNAME = "di"; - - /** - * The package namespace URI. - * - * @generated - */ - String eNS_URI = "http://www.eclipse.org/papyrus/0.7.0/sashdi"; - - /** - * The package namespace name. - * - * @generated - */ - String eNS_PREFIX = "di"; - - /** - * The singleton instance of the package. - * - * @generated - */ - DiPackage eINSTANCE = org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl.init(); - - /** - * The meta object id for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.SashModelImpl - * Sash Model}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.SashModelImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getSashModel() - * @generated - */ - int SASH_MODEL = 0; - - /** - * The feature id for the 'Windows' containment reference - * list. - * - * @generated - * @ordered - */ - int SASH_MODEL__WINDOWS = 0; - - /** - * The feature id for the 'Current Selection' reference. - * - * - * @generated - * @ordered - */ - int SASH_MODEL__CURRENT_SELECTION = 1; - - /** - * The number of structural features of the 'Sash Model' class. - * - * - * @generated - * @ordered - */ - int SASH_MODEL_FEATURE_COUNT = 2; - - /** - * The meta object id for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.PanelParentImpl - * Panel Parent}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.PanelParentImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getPanelParent() - * @generated - */ - int PANEL_PARENT = 2; - - /** - * The feature id for the 'Children' containment reference - * list. - * - * @generated - * @ordered - */ - int PANEL_PARENT__CHILDREN = 0; - - /** - * The number of structural features of the 'Panel Parent' class. - * - * - * @generated - * @ordered - */ - int PANEL_PARENT_FEATURE_COUNT = 1; - - /** - * The meta object id for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.WindowImpl - * Window}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.WindowImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getWindow() - * @generated - */ - int WINDOW = 1; - - /** - * The feature id for the 'Children' containment reference - * list. - * - * @generated - * @ordered - */ - int WINDOW__CHILDREN = PANEL_PARENT__CHILDREN; - - /** - * The feature id for the 'Position' reference. - * - * @generated - * @ordered - */ - int WINDOW__POSITION = PANEL_PARENT_FEATURE_COUNT + 0; - - /** - * The feature id for the 'Size' reference. - * - * @generated - * @ordered - */ - int WINDOW__SIZE = PANEL_PARENT_FEATURE_COUNT + 1; - - /** - * The feature id for the 'Panel' reference. - * - * @generated - * @ordered - */ - int WINDOW__PANEL = PANEL_PARENT_FEATURE_COUNT + 2; - - /** - * The number of structural features of the 'Window' class. - * - * @generated - * @ordered - */ - int WINDOW_FEATURE_COUNT = PANEL_PARENT_FEATURE_COUNT + 3; - - /** - * The meta object id for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.AbstractPanelImpl - * Abstract Panel}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.AbstractPanelImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getAbstractPanel() - * @generated - */ - int ABSTRACT_PANEL = 3; - - /** - * The feature id for the 'Parent' container reference. - * - * @generated - * @ordered - */ - int ABSTRACT_PANEL__PARENT = 0; - - /** - * The number of structural features of the 'Abstract Panel' class. - * - * - * @generated - * @ordered - */ - int ABSTRACT_PANEL_FEATURE_COUNT = 1; - - /** - * The meta object id for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.PositionImpl - * Position}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.PositionImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getPosition() - * @generated - */ - int POSITION = 4; - - /** - * The feature id for the 'X' attribute. - * - * @generated - * @ordered - */ - int POSITION__X = 0; - - /** - * The feature id for the 'Y' attribute. - * - * @generated - * @ordered - */ - int POSITION__Y = 1; - - /** - * The number of structural features of the 'Position' class. - * - * @generated - * @ordered - */ - int POSITION_FEATURE_COUNT = 2; - - /** - * The meta object id for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.SizeImpl Size}' - * class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.SizeImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getSize() - * @generated - */ - int SIZE = 5; - - /** - * The feature id for the 'Width' attribute. - * - * @generated - * @ordered - */ - int SIZE__WIDTH = 0; - - /** - * The feature id for the 'Length' attribute. - * - * @generated - * @ordered - */ - int SIZE__LENGTH = 1; - - /** - * The number of structural features of the 'Size' class. - * - * @generated - * @ordered - */ - int SIZE_FEATURE_COUNT = 2; - - /** - * The meta object id for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.TabFolderImpl - * Tab Folder}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.TabFolderImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getTabFolder() - * @generated - */ - int TAB_FOLDER = 6; - - /** - * The feature id for the 'Parent' container reference. - * - * @generated - * @ordered - */ - int TAB_FOLDER__PARENT = ABSTRACT_PANEL__PARENT; - - /** - * The feature id for the 'Children' containment reference - * list. - * - * @generated - * @ordered - */ - int TAB_FOLDER__CHILDREN = ABSTRACT_PANEL_FEATURE_COUNT + 0; - - /** - * The number of structural features of the 'Tab Folder' class. - * - * - * @generated - * @ordered - */ - int TAB_FOLDER_FEATURE_COUNT = ABSTRACT_PANEL_FEATURE_COUNT + 1; - - /** - * The meta object id for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.PageRefImpl - * Page Ref}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.PageRefImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getPageRef() - * @generated - */ - int PAGE_REF = 7; - - /** - * The feature id for the 'Emf Page Identifier' reference. - * - * - * @generated - * @ordered - */ - int PAGE_REF__EMF_PAGE_IDENTIFIER = 0; - - /** - * The feature id for the 'Page Identifier' attribute. - * - * @generated - * @ordered - */ - int PAGE_REF__PAGE_IDENTIFIER = 1; - - /** - * The feature id for the 'Object Page Identifier' - * attribute. - * - * @generated - * @ordered - */ - int PAGE_REF__OBJECT_PAGE_IDENTIFIER = 2; - - /** - * The feature id for the 'Parent' container reference. - * - * @generated - * @ordered - */ - int PAGE_REF__PARENT = 3; - - /** - * The number of structural features of the 'Page Ref' class. - * - * @generated - * @ordered - */ - int PAGE_REF_FEATURE_COUNT = 4; - - /** - * The meta object id for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.SashPanelImpl - * Sash Panel}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.SashPanelImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getSashPanel() - * @generated - */ - int SASH_PANEL = 8; - - /** - * The feature id for the 'Parent' container reference. - * - * @generated - * @ordered - */ - int SASH_PANEL__PARENT = ABSTRACT_PANEL__PARENT; - - /** - * The feature id for the 'Children' containment reference - * list. - * - * @generated - * @ordered - */ - int SASH_PANEL__CHILDREN = ABSTRACT_PANEL_FEATURE_COUNT + 0; - - /** - * The feature id for the 'Sash Position' attribute. - * - * @generated - * @ordered - */ - int SASH_PANEL__SASH_POSITION = ABSTRACT_PANEL_FEATURE_COUNT + 1; - - /** - * The feature id for the 'Direction' attribute. - * - * @generated - * @ordered - */ - int SASH_PANEL__DIRECTION = ABSTRACT_PANEL_FEATURE_COUNT + 2; - - /** - * The number of structural features of the 'Sash Panel' class. - * - * - * @generated - * @ordered - */ - int SASH_PANEL_FEATURE_COUNT = ABSTRACT_PANEL_FEATURE_COUNT + 3; - - /** - * The meta object id for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.AbstractPageImpl - * Abstract Page}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.AbstractPageImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getAbstractPage() - * @generated - */ - int ABSTRACT_PAGE = 9; - - /** - * The feature id for the 'Page Identifier' attribute. - * - * @generated - * @ordered - */ - int ABSTRACT_PAGE__PAGE_IDENTIFIER = 0; - - /** - * The number of structural features of the 'Abstract Page' class. - * - * - * @generated - * @ordered - */ - int ABSTRACT_PAGE_FEATURE_COUNT = 1; - - /** - * The meta object id for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.PageListImpl - * Page List}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.PageListImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getPageList() - * @generated - */ - int PAGE_LIST = 10; - - /** - * The feature id for the 'Available Page' containment - * reference list. - * - * @generated - * @ordered - */ - int PAGE_LIST__AVAILABLE_PAGE = 0; - - /** - * The number of structural features of the 'Page List' class. - * - * @generated - * @ordered - */ - int PAGE_LIST_FEATURE_COUNT = 1; - - /** - * The meta object id for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.SashWindowsMngrImpl - * Sash Windows Mngr}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.SashWindowsMngrImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getSashWindowsMngr() - * @generated - */ - int SASH_WINDOWS_MNGR = 11; - - /** - * The feature id for the 'Page List' containment reference. - * - * - * @generated - * @ordered - */ - int SASH_WINDOWS_MNGR__PAGE_LIST = 0; - - /** - * The feature id for the 'Sash Model' containment - * reference. - * - * @generated - * @ordered - */ - int SASH_WINDOWS_MNGR__SASH_MODEL = 1; - - /** - * The number of structural features of the 'Sash Windows Mngr' - * class. - * - * @generated - * @ordered - */ - int SASH_WINDOWS_MNGR_FEATURE_COUNT = 2; - - /** - * The meta object id for the 'int' data type. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getint() - * @generated - */ - int INT = 12; - - /** - * The meta object id for the 'Java Object' data type. - * - * @see java.lang.Object - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getJavaObject() - * @generated - */ - int JAVA_OBJECT = 13; - - /** - * The meta object id for the 'Float' data type. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getFloat() - * @generated - */ - int FLOAT = 14; - - /** - * The meta object id for the 'boolean' data type. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getboolean() - * @generated - */ - int BOOLEAN = 15; - - /** - * Returns the meta object for class ' {@link org.eclipse.papyrus.sashwindows.di.SashModel Sash Model} '. - * - * @return the meta object for class 'Sash Model'. - * @see org.eclipse.papyrus.sashwindows.di.SashModel - * @generated - */ - EClass getSashModel(); - - /** - * Returns the meta object for the containment reference list ' {@link org.eclipse.papyrus.sashwindows.di.SashModel#getWindows - * Windows}'. - * - * @return the meta object for the containment reference list ' Windows'. - * @see org.eclipse.papyrus.sashwindows.di.SashModel#getWindows() - * @see #getSashModel() - * @generated - */ - EReference getSashModel_Windows(); - - /** - * Returns the meta object for the reference ' {@link org.eclipse.papyrus.sashwindows.di.SashModel#getCurrentSelection - * Current Selection}'. - * - * @return the meta object for the reference 'Current Selection'. - * @see org.eclipse.papyrus.sashwindows.di.SashModel#getCurrentSelection() - * @see #getSashModel() - * @generated - */ - EReference getSashModel_CurrentSelection(); - - /** - * Returns the meta object for class ' {@link org.eclipse.papyrus.sashwindows.di.Window Window}'. - * - * @return the meta object for class 'Window'. - * @see org.eclipse.papyrus.sashwindows.di.Window - * @generated - */ - EClass getWindow(); - - /** - * Returns the meta object for the reference ' {@link org.eclipse.papyrus.sashwindows.di.Window#getPosition - * Position}'. - * - * @return the meta object for the reference 'Position'. - * @see org.eclipse.papyrus.sashwindows.di.Window#getPosition() - * @see #getWindow() - * @generated - */ - EReference getWindow_Position(); - - /** - * Returns the meta object for the reference ' {@link org.eclipse.papyrus.sashwindows.di.Window#getSize Size}'. - * - * - * @return the meta object for the reference 'Size'. - * @see org.eclipse.papyrus.sashwindows.di.Window#getSize() - * @see #getWindow() - * @generated - */ - EReference getWindow_Size(); - - /** - * Returns the meta object for the reference ' {@link org.eclipse.papyrus.sashwindows.di.Window#getPanel Panel} '. - * - * @return the meta object for the reference 'Panel'. - * @see org.eclipse.papyrus.sashwindows.di.Window#getPanel() - * @see #getWindow() - * @generated - */ - EReference getWindow_Panel(); - - /** - * Returns the meta object for class ' {@link org.eclipse.papyrus.sashwindows.di.PanelParent - * Panel Parent}'. - * - * @return the meta object for class 'Panel Parent'. - * @see org.eclipse.papyrus.sashwindows.di.PanelParent - * @generated - */ - EClass getPanelParent(); - - /** - * Returns the meta object for the containment reference list ' {@link org.eclipse.papyrus.sashwindows.di.PanelParent#getChildren - * Children}'. - * - * @return the meta object for the containment reference list ' Children'. - * @see org.eclipse.papyrus.sashwindows.di.PanelParent#getChildren() - * @see #getPanelParent() - * @generated - */ - EReference getPanelParent_Children(); - - /** - * Returns the meta object for class ' {@link org.eclipse.papyrus.sashwindows.di.AbstractPanel - * Abstract Panel}'. - * - * @return the meta object for class 'Abstract Panel'. - * @see org.eclipse.papyrus.sashwindows.di.AbstractPanel - * @generated - */ - EClass getAbstractPanel(); - - /** - * Returns the meta object for the container reference ' {@link org.eclipse.papyrus.sashwindows.di.AbstractPanel#getParent - * Parent}'. - * - * @return the meta object for the container reference 'Parent'. - * @see org.eclipse.papyrus.sashwindows.di.AbstractPanel#getParent() - * @see #getAbstractPanel() - * @generated - */ - EReference getAbstractPanel_Parent(); - - /** - * Returns the meta object for class ' {@link org.eclipse.papyrus.sashwindows.di.Position Position}'. - * - * - * @return the meta object for class 'Position'. - * @see org.eclipse.papyrus.sashwindows.di.Position - * @generated - */ - EClass getPosition(); - - /** - * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.sashwindows.di.Position#getX X}'. - * - * - * @return the meta object for the attribute 'X'. - * @see org.eclipse.papyrus.sashwindows.di.Position#getX() - * @see #getPosition() - * @generated - */ - EAttribute getPosition_X(); - - /** - * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.sashwindows.di.Position#getY Y}'. - * - * - * @return the meta object for the attribute 'Y'. - * @see org.eclipse.papyrus.sashwindows.di.Position#getY() - * @see #getPosition() - * @generated - */ - EAttribute getPosition_Y(); - - /** - * Returns the meta object for class ' {@link org.eclipse.papyrus.sashwindows.di.Size Size}'. - * - * @return the meta object for class 'Size'. - * @see org.eclipse.papyrus.sashwindows.di.Size - * @generated - */ - EClass getSize(); - - /** - * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.sashwindows.di.Size#getWidth Width}'. - * - * - * @return the meta object for the attribute 'Width'. - * @see org.eclipse.papyrus.sashwindows.di.Size#getWidth() - * @see #getSize() - * @generated - */ - EAttribute getSize_Width(); - - /** - * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.sashwindows.di.Size#getLength Length} '. - * - * @return the meta object for the attribute 'Length'. - * @see org.eclipse.papyrus.sashwindows.di.Size#getLength() - * @see #getSize() - * @generated - */ - EAttribute getSize_Length(); - - /** - * Returns the meta object for class ' {@link org.eclipse.papyrus.sashwindows.di.TabFolder Tab Folder} '. - * - * @return the meta object for class 'Tab Folder'. - * @see org.eclipse.papyrus.sashwindows.di.TabFolder - * @generated - */ - EClass getTabFolder(); - - /** - * Returns the meta object for the containment reference list ' {@link org.eclipse.papyrus.sashwindows.di.TabFolder#getChildren - * Children}'. - * - * @return the meta object for the containment reference list ' Children'. - * @see org.eclipse.papyrus.sashwindows.di.TabFolder#getChildren() - * @see #getTabFolder() - * @generated - */ - EReference getTabFolder_Children(); - - /** - * Returns the meta object for class ' {@link org.eclipse.papyrus.sashwindows.di.PageRef Page Ref}'. - * - * - * @return the meta object for class 'Page Ref'. - * @see org.eclipse.papyrus.sashwindows.di.PageRef - * @generated - */ - EClass getPageRef(); - - /** - * Returns the meta object for the reference ' {@link org.eclipse.papyrus.sashwindows.di.PageRef#getEmfPageIdentifier - * Emf Page Identifier}'. - * - * @return the meta object for the reference 'Emf Page Identifier'. - * @see org.eclipse.papyrus.sashwindows.di.PageRef#getEmfPageIdentifier() - * @see #getPageRef() - * @generated - */ - EReference getPageRef_EmfPageIdentifier(); - - /** - * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.sashwindows.di.PageRef#getPageIdentifier - * Page Identifier}'. - * - * @return the meta object for the attribute 'Page Identifier'. - * @see org.eclipse.papyrus.sashwindows.di.PageRef#getPageIdentifier() - * @see #getPageRef() - * @generated - */ - EAttribute getPageRef_PageIdentifier(); - - /** - * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.sashwindows.di.PageRef#getObjectPageIdentifier - * Object Page Identifier}'. - * - * @return the meta object for the attribute ' Object Page Identifier'. - * @see org.eclipse.papyrus.sashwindows.di.PageRef#getObjectPageIdentifier() - * @see #getPageRef() - * @generated - */ - EAttribute getPageRef_ObjectPageIdentifier(); - - /** - * Returns the meta object for the container reference ' {@link org.eclipse.papyrus.sashwindows.di.PageRef#getParent - * Parent}'. - * - * @return the meta object for the container reference 'Parent'. - * @see org.eclipse.papyrus.sashwindows.di.PageRef#getParent() - * @see #getPageRef() - * @generated - */ - EReference getPageRef_Parent(); - - /** - * Returns the meta object for class ' {@link org.eclipse.papyrus.sashwindows.di.SashPanel Sash Panel} '. - * - * @return the meta object for class 'Sash Panel'. - * @see org.eclipse.papyrus.sashwindows.di.SashPanel - * @generated - */ - EClass getSashPanel(); - - /** - * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.sashwindows.di.SashPanel#getSashPosition - * Sash Position}'. - * - * @return the meta object for the attribute 'Sash Position'. - * @see org.eclipse.papyrus.sashwindows.di.SashPanel#getSashPosition() - * @see #getSashPanel() - * @generated - */ - EAttribute getSashPanel_SashPosition(); - - /** - * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.sashwindows.di.SashPanel#getDirection - * Direction}'. - * - * @return the meta object for the attribute 'Direction'. - * @see org.eclipse.papyrus.sashwindows.di.SashPanel#getDirection() - * @see #getSashPanel() - * @generated - */ - EAttribute getSashPanel_Direction(); - - /** - * Returns the meta object for class ' {@link org.eclipse.papyrus.sashwindows.di.AbstractPage - * Abstract Page}'. - * - * @return the meta object for class 'Abstract Page'. - * @see org.eclipse.papyrus.sashwindows.di.AbstractPage - * @generated - */ - EClass getAbstractPage(); - - /** - * Returns the meta object for the attribute ' {@link org.eclipse.papyrus.sashwindows.di.AbstractPage#getPageIdentifier - * Page Identifier}'. - * - * @return the meta object for the attribute 'Page Identifier'. - * @see org.eclipse.papyrus.sashwindows.di.AbstractPage#getPageIdentifier() - * @see #getAbstractPage() - * @generated - */ - EAttribute getAbstractPage_PageIdentifier(); - - /** - * Returns the meta object for class ' {@link org.eclipse.papyrus.sashwindows.di.PageList Page List}'. - * - * - * @return the meta object for class 'Page List'. - * @see org.eclipse.papyrus.sashwindows.di.PageList - * @generated - */ - EClass getPageList(); - - /** - * Returns the meta object for the containment reference list ' {@link org.eclipse.papyrus.sashwindows.di.PageList#getAvailablePage - * Available Page}'. - * - * @return the meta object for the containment reference list ' Available Page'. - * @see org.eclipse.papyrus.sashwindows.di.PageList#getAvailablePage() - * @see #getPageList() - * @generated - */ - EReference getPageList_AvailablePage(); - - /** - * Returns the meta object for class ' {@link org.eclipse.papyrus.sashwindows.di.SashWindowsMngr - * Sash Windows Mngr}'. - * - * @return the meta object for class 'Sash Windows Mngr'. - * @see org.eclipse.papyrus.sashwindows.di.SashWindowsMngr - * @generated - */ - EClass getSashWindowsMngr(); - - /** - * Returns the meta object for the containment reference ' {@link org.eclipse.papyrus.sashwindows.di.SashWindowsMngr#getPageList - * Page List}'. - * - * @return the meta object for the containment reference 'Page List '. - * @see org.eclipse.papyrus.sashwindows.di.SashWindowsMngr#getPageList() - * @see #getSashWindowsMngr() - * @generated - */ - EReference getSashWindowsMngr_PageList(); - - /** - * Returns the meta object for the containment reference ' {@link org.eclipse.papyrus.sashwindows.di.SashWindowsMngr#getSashModel - * Sash Model}'. - * - * @return the meta object for the containment reference ' Sash Model'. - * @see org.eclipse.papyrus.sashwindows.di.SashWindowsMngr#getSashModel() - * @see #getSashWindowsMngr() - * @generated - */ - EReference getSashWindowsMngr_SashModel(); - - /** - * Returns the meta object for data type 'int'. - * - * @return the meta object for data type 'int'. - * @model instanceClass="int" - * @generated - */ - EDataType getint(); - - /** - * Returns the meta object for data type '{@link java.lang.Object - * Java Object}'. - * - * @return the meta object for data type 'Java Object'. - * @see java.lang.Object - * @model instanceClass="java.lang.Object" - * @generated - */ - EDataType getJavaObject(); - - /** - * Returns the meta object for data type 'Float'. - * - * @return the meta object for data type 'Float'. - * @model instanceClass="float" - * @generated - */ - EDataType getFloat(); - - /** - * Returns the meta object for data type 'boolean'. - * - * @return the meta object for data type 'boolean'. - * @model instanceClass="boolean" - * @generated - */ - EDataType getboolean(); - - /** - * Returns the factory that creates the instances of the model. - * - * @return the factory that creates the instances of the model. - * @generated - */ - DiFactory getDiFactory(); - - /** - * Defines literals for the meta objects that - * represent - *
    - *
  • each class,
  • - *
  • each feature of each class,
  • - *
  • each enum,
  • - *
  • and each data type
  • - *
- * - * - * @generated - */ - interface Literals { - - /** - * The meta object literal for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.SashModelImpl - * Sash Model}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.SashModelImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getSashModel() - * @generated - */ - EClass SASH_MODEL = eINSTANCE.getSashModel(); - - /** - * The meta object literal for the 'Windows' containment - * reference list feature. - * - * @generated - */ - EReference SASH_MODEL__WINDOWS = eINSTANCE.getSashModel_Windows(); - - /** - * The meta object literal for the 'Current Selection' - * reference feature. - * - * @generated - */ - EReference SASH_MODEL__CURRENT_SELECTION = eINSTANCE.getSashModel_CurrentSelection(); - - /** - * The meta object literal for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.WindowImpl - * Window}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.WindowImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getWindow() - * @generated - */ - EClass WINDOW = eINSTANCE.getWindow(); - - /** - * The meta object literal for the 'Position' reference - * feature. - * - * @generated - */ - EReference WINDOW__POSITION = eINSTANCE.getWindow_Position(); - - /** - * The meta object literal for the 'Size' reference - * feature. - * - * @generated - */ - EReference WINDOW__SIZE = eINSTANCE.getWindow_Size(); - - /** - * The meta object literal for the 'Panel' reference - * feature. - * - * @generated - */ - EReference WINDOW__PANEL = eINSTANCE.getWindow_Panel(); - - /** - * The meta object literal for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.PanelParentImpl - * Panel Parent}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.PanelParentImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getPanelParent() - * @generated - */ - EClass PANEL_PARENT = eINSTANCE.getPanelParent(); - - /** - * The meta object literal for the 'Children' - * containment reference list feature. - * - * @generated - */ - EReference PANEL_PARENT__CHILDREN = eINSTANCE.getPanelParent_Children(); - - /** - * The meta object literal for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.AbstractPanelImpl - * Abstract Panel}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.AbstractPanelImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getAbstractPanel() - * @generated - */ - EClass ABSTRACT_PANEL = eINSTANCE.getAbstractPanel(); - - /** - * The meta object literal for the 'Parent' container - * reference feature. - * - * @generated - */ - EReference ABSTRACT_PANEL__PARENT = eINSTANCE.getAbstractPanel_Parent(); - - /** - * The meta object literal for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.PositionImpl - * Position}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.PositionImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getPosition() - * @generated - */ - EClass POSITION = eINSTANCE.getPosition(); - - /** - * The meta object literal for the 'X' attribute - * feature. - * - * @generated - */ - EAttribute POSITION__X = eINSTANCE.getPosition_X(); - - /** - * The meta object literal for the 'Y' attribute - * feature. - * - * @generated - */ - EAttribute POSITION__Y = eINSTANCE.getPosition_Y(); - - /** - * The meta object literal for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.SizeImpl - * Size}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.SizeImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getSize() - * @generated - */ - EClass SIZE = eINSTANCE.getSize(); - - /** - * The meta object literal for the 'Width' attribute - * feature. - * - * @generated - */ - EAttribute SIZE__WIDTH = eINSTANCE.getSize_Width(); - - /** - * The meta object literal for the 'Length' attribute - * feature. - * - * @generated - */ - EAttribute SIZE__LENGTH = eINSTANCE.getSize_Length(); - - /** - * The meta object literal for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.TabFolderImpl - * Tab Folder}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.TabFolderImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getTabFolder() - * @generated - */ - EClass TAB_FOLDER = eINSTANCE.getTabFolder(); - - /** - * The meta object literal for the 'Children' - * containment reference list feature. - * - * @generated - */ - EReference TAB_FOLDER__CHILDREN = eINSTANCE.getTabFolder_Children(); - - /** - * The meta object literal for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.PageRefImpl - * Page Ref}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.PageRefImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getPageRef() - * @generated - */ - EClass PAGE_REF = eINSTANCE.getPageRef(); - - /** - * The meta object literal for the 'Emf Page Identifier' - * reference feature. - * - * @generated - */ - EReference PAGE_REF__EMF_PAGE_IDENTIFIER = eINSTANCE.getPageRef_EmfPageIdentifier(); - - /** - * The meta object literal for the 'Page Identifier' - * attribute feature. - * - * @generated - */ - EAttribute PAGE_REF__PAGE_IDENTIFIER = eINSTANCE.getPageRef_PageIdentifier(); - - /** - * The meta object literal for the ' Object Page Identifier' attribute feature. - * - * @generated - */ - EAttribute PAGE_REF__OBJECT_PAGE_IDENTIFIER = eINSTANCE.getPageRef_ObjectPageIdentifier(); - - /** - * The meta object literal for the 'Parent' container - * reference feature. - * - * @generated - */ - EReference PAGE_REF__PARENT = eINSTANCE.getPageRef_Parent(); - - /** - * The meta object literal for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.SashPanelImpl - * Sash Panel}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.SashPanelImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getSashPanel() - * @generated - */ - EClass SASH_PANEL = eINSTANCE.getSashPanel(); - - /** - * The meta object literal for the 'Sash Position' - * attribute feature. - * - * @generated - */ - EAttribute SASH_PANEL__SASH_POSITION = eINSTANCE.getSashPanel_SashPosition(); - - /** - * The meta object literal for the 'Direction' attribute - * feature. - * - * @generated - */ - EAttribute SASH_PANEL__DIRECTION = eINSTANCE.getSashPanel_Direction(); - - /** - * The meta object literal for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.AbstractPageImpl - * Abstract Page}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.AbstractPageImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getAbstractPage() - * @generated - */ - EClass ABSTRACT_PAGE = eINSTANCE.getAbstractPage(); - - /** - * The meta object literal for the 'Page Identifier' - * attribute feature. - * - * @generated - */ - EAttribute ABSTRACT_PAGE__PAGE_IDENTIFIER = eINSTANCE.getAbstractPage_PageIdentifier(); - - /** - * The meta object literal for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.PageListImpl - * Page List}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.PageListImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getPageList() - * @generated - */ - EClass PAGE_LIST = eINSTANCE.getPageList(); - - /** - * The meta object literal for the 'Available Page' - * containment reference list feature. - * - * @generated - */ - EReference PAGE_LIST__AVAILABLE_PAGE = eINSTANCE.getPageList_AvailablePage(); - - /** - * The meta object literal for the ' {@link org.eclipse.papyrus.sashwindows.di.impl.SashWindowsMngrImpl - * Sash Windows Mngr}' class. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.SashWindowsMngrImpl - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getSashWindowsMngr() - * @generated - */ - EClass SASH_WINDOWS_MNGR = eINSTANCE.getSashWindowsMngr(); - - /** - * The meta object literal for the 'Page List' - * containment reference feature. - * - * @generated - */ - EReference SASH_WINDOWS_MNGR__PAGE_LIST = eINSTANCE.getSashWindowsMngr_PageList(); - - /** - * The meta object literal for the 'Sash Model' - * containment reference feature. - * - * @generated - */ - EReference SASH_WINDOWS_MNGR__SASH_MODEL = eINSTANCE.getSashWindowsMngr_SashModel(); - - /** - * The meta object literal for the 'int' data type. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getint() - * @generated - */ - EDataType INT = eINSTANCE.getint(); - - /** - * The meta object literal for the 'Java Object' data type. - * - * - * @see java.lang.Object - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getJavaObject() - * @generated - */ - EDataType JAVA_OBJECT = eINSTANCE.getJavaObject(); - - /** - * The meta object literal for the 'Float' data type. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getFloat() - * @generated - */ - EDataType FLOAT = eINSTANCE.getFloat(); - - /** - * The meta object literal for the 'boolean' data type. - * - * @see org.eclipse.papyrus.sashwindows.di.impl.DiPackageImpl#getboolean() - * @generated - */ - EDataType BOOLEAN = eINSTANCE.getboolean(); - - } - -} // DiPackage diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/PageList.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/PageList.java deleted file mode 100644 index 5adeab8fd16..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/PageList.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; - -/** - * A representation of the model object ' Page List'. - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.PageList#getAvailablePage Available Page}
  • - *
- *

- * - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getPageList() - * @model - * @generated - */ -public interface PageList extends EObject { - - /** - * Returns the value of the 'Available Page' containment - * reference list. The list contents are of type {@link org.eclipse.papyrus.sashwindows.di.PageRef}. - *

- * If the meaning of the 'Available Page' containment reference list isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Available Page' containment reference - * list. - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getPageList_AvailablePage() - * @model containment="true" ordered="false" - * @generated - */ - EList getAvailablePage(); - - /** - * - * - * @model - * pageIdentifierDataType="org.eclipse.papyrus.sashwindows.di.JavaObject" - * pageIdentifierRequired="true" pageIdentifierOrdered="false" - * @generated - */ - void addPage(Object pageIdentifier); - - /** - * - * - * @model - * pageIdentifierDataType="org.eclipse.papyrus.sashwindows.di.JavaObject" - * pageIdentifierRequired="true" pageIdentifierOrdered="false" - * @generated - */ - void removePage(Object pageIdentifier); - -} // PageList diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/PageRef.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/PageRef.java deleted file mode 100644 index ead3f96cba2..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/PageRef.java +++ /dev/null @@ -1,160 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di; - -import org.eclipse.emf.ecore.EObject; - -/** - * A representation of the model object ' Page Ref'. - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.PageRef#getEmfPageIdentifier - * Emf Page Identifier}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.PageRef#getPageIdentifier Page Identifier}
  • - *
  • - * {@link org.eclipse.papyrus.sashwindows.di.PageRef#getObjectPageIdentifier - * Object Page Identifier}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.PageRef#getParent Parent }
  • - *
- *

- * - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getPageRef() - * @model - * @generated - */ -public interface PageRef extends EObject { - - /** - * Returns the value of the 'Emf Page Identifier' reference. - * - *

- * If the meaning of the 'Emf Page Identifier' reference isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Emf Page Identifier' reference. - * @see #setEmfPageIdentifier(EObject) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getPageRef_EmfPageIdentifier() - * @model required="true" ordered="false" - * @generated - */ - EObject getEmfPageIdentifier(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.PageRef#getEmfPageIdentifier - * Emf Page Identifier}' reference. - * - * @param value - * the new value of the 'Emf Page Identifier' reference. - * @see #getEmfPageIdentifier() - * @generated - */ - void setEmfPageIdentifier(EObject value); - - /** - * Returns the value of the 'Page Identifier' attribute. - * - * pageIdentifier can be a plain JavaObject or an EObject. They are not - * stored in the same place. - * - * @return the value of the 'Page Identifier' attribute. - * @see #setPageIdentifier(Object) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getPageRef_PageIdentifier() - * @model unique="false" - * dataType="org.eclipse.papyrus.sashwindows.di.JavaObject" - * required="true" transient="true" volatile="true" derived="true" - * ordered="false" - * @generated - */ - Object getPageIdentifier(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.PageRef#getPageIdentifier - * Page Identifier}' attribute. - * - * @param value - * the new value of the 'Page Identifier' attribute. - * @see #getPageIdentifier() - * @generated - */ - void setPageIdentifier(Object value); - - /** - * Returns the value of the 'Object Page Identifier' - * attribute. Storage to store Identifier that are not EObject. - * - * - * @return the value of the 'Object Page Identifier' attribute. - * @see #setObjectPageIdentifier(Object) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getPageRef_ObjectPageIdentifier() - * @model unique="false" - * dataType="org.eclipse.papyrus.sashwindows.di.JavaObject" - * required="true" ordered="false" - * @generated - */ - Object getObjectPageIdentifier(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.PageRef#getObjectPageIdentifier - * Object Page Identifier}' attribute. - * - * @param value - * the new value of the 'Object Page Identifier' - * attribute. - * @see #getObjectPageIdentifier() - * @generated - */ - void setObjectPageIdentifier(Object value); - - /** - * Returns the value of the 'Parent' container reference. It - * is bidirectional and its opposite is ' {@link org.eclipse.papyrus.sashwindows.di.TabFolder#getChildren - * Children}'. - *

- * If the meaning of the 'Parent' container reference isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Parent' container reference. - * @see #setParent(TabFolder) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getPageRef_Parent() - * @see org.eclipse.papyrus.sashwindows.di.TabFolder#getChildren - * @model opposite="children" required="true" transient="false" - * ordered="false" - * @generated - */ - TabFolder getParent(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.PageRef#getParent - * Parent}' container reference. - * - * @param value - * the new value of the 'Parent' container reference. - * @see #getParent() - * @generated - */ - void setParent(TabFolder value); - - /** - * - * - * @model required="true" ordered="false" - * pageIdentifierDataType="org.eclipse.papyrus.sashwindows.di.JavaObject" - * pageIdentifierRequired="true" pageIdentifierOrdered="false" - * @generated - */ - boolean isForIdentifier(Object pageIdentifier); - -} // PageRef diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/PanelParent.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/PanelParent.java deleted file mode 100644 index d89e850c058..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/PanelParent.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; - -/** - * A representation of the model object ' Panel Parent'. - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.PanelParent#getChildren Children}
  • - *
- *

- * - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getPanelParent() - * @model abstract="true" - * @generated - */ -public interface PanelParent extends EObject { - - /** - * Returns the value of the 'Children' containment reference - * list. The list contents are of type {@link org.eclipse.papyrus.sashwindows.di.AbstractPanel}. It is - * bidirectional and its opposite is ' {@link org.eclipse.papyrus.sashwindows.di.AbstractPanel#getParent - * Parent}'. - *

- * If the meaning of the 'Children' containment reference list isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Children' containment reference list. - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getPanelParent_Children() - * @see org.eclipse.papyrus.sashwindows.di.AbstractPanel#getParent - * @model opposite="parent" containment="true" lower="2" upper="2" - * ordered="false" - * @generated - */ - EList getChildren(); - - /** - * - * Replace the specified child by the new value. Don't need to be - * implemented in TabFolder. Used to insert a new SashPanel. - * - * @model oldChildRequired="true" oldChildOrdered="false" - * newChildRequired="true" newChildOrdered="false" - * @generated - */ - void replaceChild(AbstractPanel oldChild, AbstractPanel newChild); - -} // PanelParent diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/Position.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/Position.java deleted file mode 100644 index bd5562514af..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/Position.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di; - -import org.eclipse.emf.ecore.EObject; - -/** - * A representation of the model object ' Position'. - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.Position#getX X}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.Position#getY Y}
  • - *
- *

- * - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getPosition() - * @model - * @generated - */ -public interface Position extends EObject { - - /** - * Returns the value of the 'X' attribute. - *

- * If the meaning of the 'X' attribute isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'X' attribute. - * @see #setX(int) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getPosition_X() - * @model unique="false" required="true" ordered="false" - * @generated - */ - int getX(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.Position#getX X}' - * attribute. - * - * @param value - * the new value of the 'X' attribute. - * @see #getX() - * @generated - */ - void setX(int value); - - /** - * Returns the value of the 'Y' attribute. - *

- * If the meaning of the 'Y' attribute isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Y' attribute. - * @see #setY(int) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getPosition_Y() - * @model unique="false" dataType="org.eclipse.papyrus.sashwindows.di.int" - * required="true" ordered="false" - * @generated - */ - int getY(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.Position#getY Y}' - * attribute. - * - * @param value - * the new value of the 'Y' attribute. - * @see #getY() - * @generated - */ - void setY(int value); - -} // Position diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/SashModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/SashModel.java deleted file mode 100644 index d3e4fa9f24b..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/SashModel.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; - -/** - * A representation of the model object ' Sash Model'. - * - * Root node of the model describing the sash windows, - * panels and pages. A SashModel can have several windows containing panels - * separated by sashes. Such panels can be folders containing pages. - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.SashModel#getWindows Windows}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.SashModel#getCurrentSelection - * Current Selection}
  • - *
- *

- * - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getSashModel() - * @model - * @generated - */ -public interface SashModel extends EObject { - - /** - * Returns the value of the 'Windows' containment reference - * list. The list contents are of type {@link org.eclipse.papyrus.sashwindows.di.Window}. - *

- * If the meaning of the 'Windows' containment reference list isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Windows' containment reference list. - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getSashModel_Windows() - * @model containment="true" ordered="false" - * @generated - */ - EList getWindows(); - - /** - * Returns the value of the 'Current Selection' reference. - * - *

- * If the meaning of the 'Current Selection' reference isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Current Selection' reference. - * @see #setCurrentSelection(TabFolder) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getSashModel_CurrentSelection() - * @model required="true" ordered="false" - * @generated - */ - TabFolder getCurrentSelection(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.SashModel#getCurrentSelection - * Current Selection}' reference. - * - * @param value - * the new value of the 'Current Selection' reference. - * @see #getCurrentSelection() - * @generated - */ - void setCurrentSelection(TabFolder value); - - /** - * - * - * @model - * pageIdentifierDataType="org.eclipse.papyrus.sashwindows.di.JavaObject" - * pageIdentifierRequired="true" pageIdentifierOrdered="false" - * @generated - */ - void addPage(Object pageIdentifier); - - /** - * - * - * @model - * pageIdentifierDataType="org.eclipse.papyrus.sashwindows.di.JavaObject" - * pageIdentifierRequired="true" pageIdentifierOrdered="false" - * @generated - */ - void removePage(Object pageIdentifier); - - /** - * - * Lookup the pageRef identified by the pageIdentifier. Return the pageRef - * or null if not found. Lookup in the entire SashModel structure. - * - * @model required="true" ordered="false" - * pageIdentifierDataType="org.eclipse.papyrus.sashwindows.di.JavaObject" - * pageIdentifierRequired="true" pageIdentifierOrdered="false" - * @generated - */ - PageRef lookupPage(Object pageIdentifier); - - /** - * - * - * @model srcParentFolderRequired="true" srcParentFolderOrdered="false" - * srcIndexDataType="org.eclipse.papyrus.sashwindows.di.int" - * srcIndexRequired="true" srcIndexOrdered="false" - * targetParentFolderRequired="true" - * targetParentFolderOrdered="false" targetIndexRequired="true" - * targetIndexOrdered="false" - * @generated - */ - void movePage(TabFolder srcParentFolder, int srcIndex, TabFolder targetParentFolder, int targetIndex); - - /** - * - * - * @model folderToInsertRequired="true" folderToInsertOrdered="false" - * refFolderRequired="true" refFolderOrdered="false" - * refFolderSideRequired="true" refFolderSideOrdered="false" - * @generated - */ - void insertFolder(TabFolder folderToInsert, TabFolder refFolder, int refFolderSide); - - /** - * - * - * @model srcParentFolderRequired="true" srcParentFolderOrdered="false" - * srcIndexDataType="org.eclipse.papyrus.sashwindows.di.int" - * srcIndexRequired="true" srcIndexOrdered="false" - * targetParentFolderRequired="true" - * targetParentFolderOrdered="false" - * @generated - */ - void movePage(TabFolder srcParentFolder, int srcIndex, TabFolder targetParentFolder); - - /** - * - * - * @model folderRequired="true" folderOrdered="false" - * @generated - */ - void removeEmptyFolder(TabFolder folder); - - /** - * - * Remove all pages from the model. Only left one empty top level folder. - * - * - * @model - * @generated - */ - void removeAllPages(); - - /** - * - * Remove pages other than the one specified from the model. Intermediate - * folders are also removed. - * - * @model - * pageIdentifierDataType="org.eclipse.papyrus.sashwindows.di.JavaObject" - * pageIdentifierRequired="true" pageIdentifierOrdered="false" - * @generated - */ - void removeOtherPages(Object pageIdentifier); - - /** - * - * Get the first available window. - * - * @model required="true" ordered="false" - * @generated - */ - Window lookupFirstWindow(); - - /** - * - * Lookup the first available folder. - * - * @model required="true" ordered="false" - * @generated - */ - TabFolder lookupFirstFolder(); - -} // SashModel diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/SashPanel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/SashPanel.java deleted file mode 100644 index 5b247621ced..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/SashPanel.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di; - -/** - * A representation of the model object ' Sash Panel'. - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.SashPanel#getSashPosition Sash Position}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.SashPanel#getDirection Direction}
  • - *
- *

- * - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getSashPanel() - * @model - * @generated - */ -public interface SashPanel extends AbstractPanel, PanelParent { - - /** - * Returns the value of the 'Sash Position' attribute. - * Position of the sash in the panel. The position is in percent. The value - * should be between 0 and 100. - * - * @return the value of the 'Sash Position' attribute. - * @see #setSashPosition(float) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getSashPanel_SashPosition() - * @model unique="false" dataType="org.eclipse.papyrus.sashwindows.di.Float" - * required="true" ordered="false" - * @generated - */ - float getSashPosition(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.SashPanel#getSashPosition - * Sash Position}' attribute. - * - * @param value - * the new value of the 'Sash Position' attribute. - * @see #getSashPosition() - * @generated - */ - void setSashPosition(float value); - - /** - * Returns the value of the 'Direction' attribute. - *

- * If the meaning of the 'Direction' attribute isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Direction' attribute. - * @see #setDirection(int) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getSashPanel_Direction() - * @model unique="false" required="true" ordered="false" - * @generated - */ - int getDirection(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.SashPanel#getDirection - * Direction}' attribute. - * - * @param value - * the new value of the 'Direction' attribute. - * @see #getDirection() - * @generated - */ - void setDirection(int value); - - /** - * - * - * @model leftChildRequired="true" leftChildOrdered="false" - * rightChildRequired="true" rightChildOrdered="false" - * directionDataType="org.eclipse.papyrus.sashwindows.di.int" - * directionRequired="true" directionOrdered="false" - * @generated - */ - void setChildren(AbstractPanel leftChild, AbstractPanel rightChild, int direction); - - /** - * - * - * @model childToDeleteRequired="true" childToDeleteOrdered="false" - * @generated - */ - void delete(AbstractPanel childToDelete); - -} // SashPanel diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/SashWindowsMngr.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/SashWindowsMngr.java deleted file mode 100644 index 748f20ad63f..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/SashWindowsMngr.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di; - -import org.eclipse.emf.ecore.EObject; - -/** - * A representation of the model object ' Sash Windows Mngr'. - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.SashWindowsMngr#getPageList - * Page List}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.SashWindowsMngr#getSashModel - * Sash Model}
  • - *
- *

- * - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getSashWindowsMngr() - * @model - * @generated - */ -public interface SashWindowsMngr extends EObject { - - /** - * Returns the value of the 'Page List' containment - * reference. - *

- * If the meaning of the 'Page List' containment reference isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Page List' containment reference. - * @see #setPageList(PageList) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getSashWindowsMngr_PageList() - * @model containment="true" required="true" ordered="false" - * @generated - */ - PageList getPageList(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.SashWindowsMngr#getPageList - * Page List}' containment reference. - * - * @param value - * the new value of the 'Page List' containment - * reference. - * @see #getPageList() - * @generated - */ - void setPageList(PageList value); - - /** - * Returns the value of the 'Sash Model' containment - * reference. - *

- * If the meaning of the 'Sash Model' containment reference isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Sash Model' containment reference. - * @see #setSashModel(SashModel) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getSashWindowsMngr_SashModel() - * @model containment="true" required="true" ordered="false" - * @generated - */ - SashModel getSashModel(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.SashWindowsMngr#getSashModel - * Sash Model}' containment reference. - * - * @param value - * the new value of the 'Sash Model' containment - * reference. - * @see #getSashModel() - * @generated - */ - void setSashModel(SashModel value); - -} // SashWindowsMngr diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/Size.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/Size.java deleted file mode 100644 index 68181915663..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/Size.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di; - -import org.eclipse.emf.ecore.EObject; - -/** - * A representation of the model object ' Size'. - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.Size#getWidth Width}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.Size#getLength Length}
  • - *
- *

- * - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getSize() - * @model - * @generated - */ -public interface Size extends EObject { - - /** - * Returns the value of the 'Width' attribute. - *

- * If the meaning of the 'Width' attribute isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Width' attribute. - * @see #setWidth(int) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getSize_Width() - * @model unique="false" dataType="org.eclipse.papyrus.sashwindows.di.int" - * required="true" ordered="false" - * @generated - */ - int getWidth(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.Size#getWidth Width}' - * attribute. - * - * @param value - * the new value of the 'Width' attribute. - * @see #getWidth() - * @generated - */ - void setWidth(int value); - - /** - * Returns the value of the 'Length' attribute. - *

- * If the meaning of the 'Length' attribute isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Length' attribute. - * @see #setLength(int) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getSize_Length() - * @model unique="false" dataType="org.eclipse.papyrus.sashwindows.di.int" - * required="true" ordered="false" - * @generated - */ - int getLength(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.Size#getLength Length} ' attribute. - * - * @param value - * the new value of the 'Length' attribute. - * @see #getLength() - * @generated - */ - void setLength(int value); - -} // Size diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/TabFolder.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/TabFolder.java deleted file mode 100644 index 404bf40d269..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/TabFolder.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di; - -import org.eclipse.emf.common.util.EList; - -/** - * A representation of the model object ' Tab Folder'. - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.TabFolder#getChildren Children}
  • - *
- *

- * - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getTabFolder() - * @model - * @generated - */ -public interface TabFolder extends AbstractPanel { - - /** - * Returns the value of the 'Children' containment reference - * list. The list contents are of type {@link org.eclipse.papyrus.sashwindows.di.PageRef}. It is bidirectional - * and its opposite is ' {@link org.eclipse.papyrus.sashwindows.di.PageRef#getParent - * Parent}'. - *

- * If the meaning of the 'Children' containment reference list isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Children' containment reference list. - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getTabFolder_Children() - * @see org.eclipse.papyrus.sashwindows.di.PageRef#getParent - * @model opposite="parent" containment="true" ordered="false" - * @generated - */ - EList getChildren(); - - /** - * - * - * @model oldIndexRequired="true" oldIndexOrdered="false" - * newIndexDataType="org.eclipse.papyrus.sashwindows.di.int" - * newIndexRequired="true" newIndexOrdered="false" - * @generated - */ - void movePage(int oldIndex, int newIndex); - - /** - * - * - * @model - * pageIdentifierDataType="org.eclipse.papyrus.sashwindows.di.JavaObject" - * pageIdentifierRequired="true" pageIdentifierOrdered="false" - * @generated - */ - void addPage(Object pageIdentifier); - - /** - * - * - * @model pageIndexDataType="org.eclipse.papyrus.sashwindows.di.int" - * pageIndexRequired="true" pageIndexOrdered="false" - * @generated - */ - void removePage(int pageIndex); - -} // TabFolder diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/Window.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/Window.java deleted file mode 100644 index 258468affef..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/Window.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di; - -/** - * A representation of the model object ' Window'. - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.Window#getPosition Position }
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.Window#getSize Size}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.Window#getPanel Panel}
  • - *
- *

- * - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getWindow() - * @model - * @generated - */ -public interface Window extends PanelParent { - - /** - * Returns the value of the 'Position' reference. - *

- * If the meaning of the 'Position' reference isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Position' reference. - * @see #setPosition(Position) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getWindow_Position() - * @model required="true" ordered="false" - * @generated - */ - Position getPosition(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.Window#getPosition - * Position}' reference. - * - * @param value - * the new value of the 'Position' reference. - * @see #getPosition() - * @generated - */ - void setPosition(Position value); - - /** - * Returns the value of the 'Size' reference. - *

- * If the meaning of the 'Size' reference isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Size' reference. - * @see #setSize(Size) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getWindow_Size() - * @model required="true" ordered="false" - * @generated - */ - Size getSize(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.Window#getSize Size}' - * reference. - * - * @param value - * the new value of the 'Size' reference. - * @see #getSize() - * @generated - */ - void setSize(Size value); - - /** - * Returns the value of the 'Panel' reference. - * Redefine children. - * - * @return the value of the 'Panel' reference. - * @see #setPanel(AbstractPanel) - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#getWindow_Panel() - * @model required="true" transient="true" volatile="true" derived="true" - * ordered="false" - * @generated - */ - AbstractPanel getPanel(); - - /** - * Sets the value of the ' {@link org.eclipse.papyrus.sashwindows.di.Window#getPanel Panel} ' reference. - * - * @param value - * the new value of the 'Panel' reference. - * @see #getPanel() - * @generated - */ - void setPanel(AbstractPanel value); - -} // Window diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/exception/SashEditorException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/exception/SashEditorException.java deleted file mode 100644 index 886dbac1bda..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/exception/SashEditorException.java +++ /dev/null @@ -1,53 +0,0 @@ -/***************************************************************************** - * 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.sashwindows.di.exception; - -/** - * Exception for the Sash editor system - * - * @author eperico - */ -public class SashEditorException extends Exception { - - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new sash editor exception. - */ - public SashEditorException() { - } - - /** - * @param message - */ - public SashEditorException(String message) { - super(message); - } - - /** - * @param cause - */ - public SashEditorException(Throwable cause) { - super(cause); - } - - /** - * @param message - * @param cause - */ - public SashEditorException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/AbstractPageImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/AbstractPageImpl.java deleted file mode 100644 index e23205ce530..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/AbstractPageImpl.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.papyrus.sashwindows.di.AbstractPage; -import org.eclipse.papyrus.sashwindows.di.DiPackage; - -/** - * An implementation of the model object ' Abstract Page'. - *

- * The following features are implemented: - *

    - *
  • - * {@link org.eclipse.papyrus.sashwindows.di.impl.AbstractPageImpl#getPageIdentifier - * Page Identifier}
  • - *
- *

- * - * @generated - */ -public class AbstractPageImpl extends EObjectImpl implements AbstractPage { - - /** - * The default value of the '{@link #getPageIdentifier() - * Page Identifier}' attribute. - * - * @see #getPageIdentifier() - * @generated - * @ordered - */ - protected static final Object PAGE_IDENTIFIER_EDEFAULT = null; - - /** - * The cached value of the '{@link #getPageIdentifier() - * Page Identifier}' attribute. - * - * @see #getPageIdentifier() - * @generated - * @ordered - */ - protected Object pageIdentifier = PAGE_IDENTIFIER_EDEFAULT; - - /** - * - * - * @generated - */ - protected AbstractPageImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return DiPackage.Literals.ABSTRACT_PAGE; - } - - /** - * - * - * @generated - */ - public Object getPageIdentifier() { - return pageIdentifier; - } - - /** - * - * - * @generated - */ - public void setPageIdentifier(Object newPageIdentifier) { - Object oldPageIdentifier = pageIdentifier; - pageIdentifier = newPageIdentifier; - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.ABSTRACT_PAGE__PAGE_IDENTIFIER, oldPageIdentifier, pageIdentifier)); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch(featureID) { - case DiPackage.ABSTRACT_PAGE__PAGE_IDENTIFIER: - return getPageIdentifier(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch(featureID) { - case DiPackage.ABSTRACT_PAGE__PAGE_IDENTIFIER: - setPageIdentifier(newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch(featureID) { - case DiPackage.ABSTRACT_PAGE__PAGE_IDENTIFIER: - setPageIdentifier(PAGE_IDENTIFIER_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch(featureID) { - case DiPackage.ABSTRACT_PAGE__PAGE_IDENTIFIER: - return PAGE_IDENTIFIER_EDEFAULT == null ? pageIdentifier != null : !PAGE_IDENTIFIER_EDEFAULT.equals(pageIdentifier); - } - return super.eIsSet(featureID); - } - - /** - * - * - * @generated - */ - @Override - public String toString() { - if(eIsProxy()) - return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (pageIdentifier: "); - result.append(pageIdentifier); - result.append(')'); - return result.toString(); - } - -} // AbstractPageImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/AbstractPanelImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/AbstractPanelImpl.java deleted file mode 100644 index b0ebf5d9571..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/AbstractPanelImpl.java +++ /dev/null @@ -1,198 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.papyrus.sashwindows.di.AbstractPanel; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PanelParent; - -/** - * An implementation of the model object ' Abstract Panel'. - *

- * The following features are implemented: - *

    - *
  • - * {@link org.eclipse.papyrus.sashwindows.di.impl.AbstractPanelImpl#getParent - * Parent}
  • - *
- *

- * - * @generated - */ -public abstract class AbstractPanelImpl extends EObjectImpl implements AbstractPanel { - - /** - * - * - * @generated - */ - protected AbstractPanelImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return DiPackage.Literals.ABSTRACT_PANEL; - } - - /** - * - * - * @generated - */ - public PanelParent getParent() { - if(eContainerFeatureID() != DiPackage.ABSTRACT_PANEL__PARENT) - return null; - return (PanelParent)eContainer(); - } - - /** - * - * - * @generated - */ - public NotificationChain basicSetParent(PanelParent newParent, NotificationChain msgs) { - msgs = eBasicSetContainer((InternalEObject)newParent, DiPackage.ABSTRACT_PANEL__PARENT, msgs); - return msgs; - } - - /** - * - * - * @generated - */ - public void setParent(PanelParent newParent) { - if(newParent != eInternalContainer() || (eContainerFeatureID() != DiPackage.ABSTRACT_PANEL__PARENT && newParent != null)) { - if(EcoreUtil.isAncestor(this, newParent)) - throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); - NotificationChain msgs = null; - if(eInternalContainer() != null) - msgs = eBasicRemoveFromContainer(msgs); - if(newParent != null) - msgs = ((InternalEObject)newParent).eInverseAdd(this, DiPackage.PANEL_PARENT__CHILDREN, PanelParent.class, msgs); - msgs = basicSetParent(newParent, msgs); - if(msgs != null) - msgs.dispatch(); - } else if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.ABSTRACT_PANEL__PARENT, newParent, newParent)); - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch(featureID) { - case DiPackage.ABSTRACT_PANEL__PARENT: - if(eInternalContainer() != null) - msgs = eBasicRemoveFromContainer(msgs); - return basicSetParent((PanelParent)otherEnd, msgs); - } - return super.eInverseAdd(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch(featureID) { - case DiPackage.ABSTRACT_PANEL__PARENT: - return basicSetParent(null, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { - switch(eContainerFeatureID()) { - case DiPackage.ABSTRACT_PANEL__PARENT: - return eInternalContainer().eInverseRemove(this, DiPackage.PANEL_PARENT__CHILDREN, PanelParent.class, msgs); - } - return super.eBasicRemoveFromContainerFeature(msgs); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch(featureID) { - case DiPackage.ABSTRACT_PANEL__PARENT: - return getParent(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch(featureID) { - case DiPackage.ABSTRACT_PANEL__PARENT: - setParent((PanelParent)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch(featureID) { - case DiPackage.ABSTRACT_PANEL__PARENT: - setParent((PanelParent)null); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch(featureID) { - case DiPackage.ABSTRACT_PANEL__PARENT: - return getParent() != null; - } - return super.eIsSet(featureID); - } - -} // AbstractPanelImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/DiFactoryImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/DiFactoryImpl.java deleted file mode 100644 index 4d5899f3956..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/DiFactoryImpl.java +++ /dev/null @@ -1,331 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.impl; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.impl.EFactoryImpl; -import org.eclipse.emf.ecore.plugin.EcorePlugin; -import org.eclipse.papyrus.sashwindows.di.AbstractPage; -import org.eclipse.papyrus.sashwindows.di.DiFactory; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PageList; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.papyrus.sashwindows.di.Position; -import org.eclipse.papyrus.sashwindows.di.SashModel; -import org.eclipse.papyrus.sashwindows.di.SashPanel; -import org.eclipse.papyrus.sashwindows.di.SashWindowsMngr; -import org.eclipse.papyrus.sashwindows.di.Size; -import org.eclipse.papyrus.sashwindows.di.TabFolder; -import org.eclipse.papyrus.sashwindows.di.Window; - -/** - * An implementation of the model Factory. - * - * @generated - */ -public class DiFactoryImpl extends EFactoryImpl implements DiFactory { - - /** - * Creates the default factory implementation. - * - * @generated - */ - public static DiFactory init() { - try { - DiFactory theDiFactory = (DiFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.eclipse.org/papyrus/0.7.0/sashdi"); - if(theDiFactory != null) { - return theDiFactory; - } - } catch (Exception exception) { - EcorePlugin.INSTANCE.log(exception); - } - return new DiFactoryImpl(); - } - - /** - * Creates an instance of the factory. - * - * @generated - */ - public DiFactoryImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - public EObject create(EClass eClass) { - switch(eClass.getClassifierID()) { - case DiPackage.SASH_MODEL: - return createSashModel(); - case DiPackage.WINDOW: - return createWindow(); - case DiPackage.POSITION: - return createPosition(); - case DiPackage.SIZE: - return createSize(); - case DiPackage.TAB_FOLDER: - return createTabFolder(); - case DiPackage.PAGE_REF: - return createPageRef(); - case DiPackage.SASH_PANEL: - return createSashPanel(); - case DiPackage.ABSTRACT_PAGE: - return createAbstractPage(); - case DiPackage.PAGE_LIST: - return createPageList(); - case DiPackage.SASH_WINDOWS_MNGR: - return createSashWindowsMngr(); - default: - throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); - } - } - - /** - * - * - * @generated - */ - @Override - public Object createFromString(EDataType eDataType, String initialValue) { - switch(eDataType.getClassifierID()) { - case DiPackage.INT: - return createintFromString(eDataType, initialValue); - case DiPackage.JAVA_OBJECT: - return createJavaObjectFromString(eDataType, initialValue); - case DiPackage.FLOAT: - return createFloatFromString(eDataType, initialValue); - case DiPackage.BOOLEAN: - return createbooleanFromString(eDataType, initialValue); - default: - throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); - } - } - - /** - * - * - * @generated - */ - @Override - public String convertToString(EDataType eDataType, Object instanceValue) { - switch(eDataType.getClassifierID()) { - case DiPackage.INT: - return convertintToString(eDataType, instanceValue); - case DiPackage.JAVA_OBJECT: - return convertJavaObjectToString(eDataType, instanceValue); - case DiPackage.FLOAT: - return convertFloatToString(eDataType, instanceValue); - case DiPackage.BOOLEAN: - return convertbooleanToString(eDataType, instanceValue); - default: - throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); - } - } - - /** - * - * - * @generated - */ - public SashModel createSashModel() { - SashModelImpl sashModel = new SashModelImpl(); - return sashModel; - } - - /** - * - * - * @generated - */ - public Window createWindow() { - WindowImpl window = new WindowImpl(); - return window; - } - - /** - * - * - * @generated - */ - public Position createPosition() { - PositionImpl position = new PositionImpl(); - return position; - } - - /** - * - * - * @generated - */ - public Size createSize() { - SizeImpl size = new SizeImpl(); - return size; - } - - /** - * - * - * @generated - */ - public TabFolder createTabFolder() { - TabFolderImpl tabFolder = new TabFolderImpl(); - return tabFolder; - } - - /** - * - * - * @generated - */ - public PageRef createPageRef() { - PageRefImpl pageRef = new PageRefImpl(); - return pageRef; - } - - /** - * - * - * @generated - */ - public SashPanel createSashPanel() { - SashPanelImpl sashPanel = new SashPanelImpl(); - return sashPanel; - } - - /** - * - * - * @generated - */ - public AbstractPage createAbstractPage() { - AbstractPageImpl abstractPage = new AbstractPageImpl(); - return abstractPage; - } - - /** - * - * - * @generated - */ - public PageList createPageList() { - PageListImpl pageList = new PageListImpl(); - return pageList; - } - - /** - * - * - * @generated - */ - public SashWindowsMngr createSashWindowsMngr() { - SashWindowsMngrImpl sashWindowsMngr = new SashWindowsMngrImpl(); - return sashWindowsMngr; - } - - /** - * - * - * @generated - */ - public Integer createintFromString(EDataType eDataType, String initialValue) { - return (Integer)super.createFromString(eDataType, initialValue); - } - - /** - * - * - * @generated - */ - public String convertintToString(EDataType eDataType, Object instanceValue) { - return super.convertToString(eDataType, instanceValue); - } - - /** - * - * - * @generated - */ - public Object createJavaObjectFromString(EDataType eDataType, String initialValue) { - return super.createFromString(eDataType, initialValue); - } - - /** - * - * - * @generated - */ - public String convertJavaObjectToString(EDataType eDataType, Object instanceValue) { - return super.convertToString(eDataType, instanceValue); - } - - /** - * - * - * @generated - */ - public Float createFloatFromString(EDataType eDataType, String initialValue) { - return (Float)super.createFromString(eDataType, initialValue); - } - - /** - * - * - * @generated - */ - public String convertFloatToString(EDataType eDataType, Object instanceValue) { - return super.convertToString(eDataType, instanceValue); - } - - /** - * - * - * @generated - */ - public Boolean createbooleanFromString(EDataType eDataType, String initialValue) { - return (Boolean)super.createFromString(eDataType, initialValue); - } - - /** - * - * - * @generated - */ - public String convertbooleanToString(EDataType eDataType, Object instanceValue) { - return super.convertToString(eDataType, instanceValue); - } - - /** - * - * - * @generated - */ - public DiPackage getDiPackage() { - return (DiPackage)getEPackage(); - } - - /** - * - * - * @deprecated - * @generated - */ - @Deprecated - public static DiPackage getPackage() { - return DiPackage.eINSTANCE; - } - -} // DiFactoryImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/DiPackageImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/DiPackageImpl.java deleted file mode 100644 index 186f5db9175..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/DiPackageImpl.java +++ /dev/null @@ -1,815 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.impl; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EOperation; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.emf.ecore.impl.EPackageImpl; -import org.eclipse.papyrus.sashwindows.di.AbstractPage; -import org.eclipse.papyrus.sashwindows.di.AbstractPanel; -import org.eclipse.papyrus.sashwindows.di.DiFactory; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PageList; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.papyrus.sashwindows.di.PanelParent; -import org.eclipse.papyrus.sashwindows.di.Position; -import org.eclipse.papyrus.sashwindows.di.SashModel; -import org.eclipse.papyrus.sashwindows.di.SashPanel; -import org.eclipse.papyrus.sashwindows.di.SashWindowsMngr; -import org.eclipse.papyrus.sashwindows.di.Size; -import org.eclipse.papyrus.sashwindows.di.TabFolder; -import org.eclipse.papyrus.sashwindows.di.Window; - -/** - * An implementation of the model Package. - * - * @generated - */ -public class DiPackageImpl extends EPackageImpl implements DiPackage { - - /** - * - * - * @generated - */ - private EClass sashModelEClass = null; - - /** - * - * - * @generated - */ - private EClass windowEClass = null; - - /** - * - * - * @generated - */ - private EClass panelParentEClass = null; - - /** - * - * - * @generated - */ - private EClass abstractPanelEClass = null; - - /** - * - * - * @generated - */ - private EClass positionEClass = null; - - /** - * - * - * @generated - */ - private EClass sizeEClass = null; - - /** - * - * - * @generated - */ - private EClass tabFolderEClass = null; - - /** - * - * - * @generated - */ - private EClass pageRefEClass = null; - - /** - * - * - * @generated - */ - private EClass sashPanelEClass = null; - - /** - * - * - * @generated - */ - private EClass abstractPageEClass = null; - - /** - * - * - * @generated - */ - private EClass pageListEClass = null; - - /** - * - * - * @generated - */ - private EClass sashWindowsMngrEClass = null; - - /** - * - * - * @generated - */ - private EDataType intEDataType = null; - - /** - * - * - * @generated - */ - private EDataType javaObjectEDataType = null; - - /** - * - * - * @generated - */ - private EDataType floatEDataType = null; - - /** - * - * - * @generated - */ - private EDataType booleanEDataType = null; - - /** - * Creates an instance of the model Package, registered with {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the - * package package URI value. - *

- * Note: the correct way to create the package is via the static factory method {@link #init init()}, which also performs initialization of the - * package, or returns the registered package, if one already exists. - * - * @see org.eclipse.emf.ecore.EPackage.Registry - * @see org.eclipse.papyrus.sashwindows.di.DiPackage#eNS_URI - * @see #init() - * @generated - */ - private DiPackageImpl() { - super(eNS_URI, DiFactory.eINSTANCE); - } - - /** - * - * - * @generated - */ - private static boolean isInited = false; - - /** - * Creates, registers, and initializes the Package for this model, - * and for any others upon which it depends. - * - *

- * This method is used to initialize {@link DiPackage#eINSTANCE} when that field is accessed. Clients should not invoke it directly. Instead, they - * should simply access that field to obtain the package. - * - * @see #eNS_URI - * @see #createPackageContents() - * @see #initializePackageContents() - * @generated - */ - public static DiPackage init() { - if(isInited) - return (DiPackage)EPackage.Registry.INSTANCE.getEPackage(DiPackage.eNS_URI); - - // Obtain or create and register package - DiPackageImpl theDiPackage = (DiPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof DiPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new DiPackageImpl()); - - isInited = true; - - // Initialize simple dependencies - EcorePackage.eINSTANCE.eClass(); - - // Create package meta-data objects - theDiPackage.createPackageContents(); - - // Initialize created meta-data - theDiPackage.initializePackageContents(); - - // Mark meta-data to indicate it can't be changed - theDiPackage.freeze(); - - // Update the registry and return the package - EPackage.Registry.INSTANCE.put(DiPackage.eNS_URI, theDiPackage); - return theDiPackage; - } - - /** - * - * - * @generated - */ - public EClass getSashModel() { - return sashModelEClass; - } - - /** - * - * - * @generated - */ - public EReference getSashModel_Windows() { - return (EReference)sashModelEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EReference getSashModel_CurrentSelection() { - return (EReference)sashModelEClass.getEStructuralFeatures().get(1); - } - - /** - * - * - * @generated - */ - public EClass getWindow() { - return windowEClass; - } - - /** - * - * - * @generated - */ - public EReference getWindow_Position() { - return (EReference)windowEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EReference getWindow_Size() { - return (EReference)windowEClass.getEStructuralFeatures().get(1); - } - - /** - * - * - * @generated - */ - public EReference getWindow_Panel() { - return (EReference)windowEClass.getEStructuralFeatures().get(2); - } - - /** - * - * - * @generated - */ - public EClass getPanelParent() { - return panelParentEClass; - } - - /** - * - * - * @generated - */ - public EReference getPanelParent_Children() { - return (EReference)panelParentEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EClass getAbstractPanel() { - return abstractPanelEClass; - } - - /** - * - * - * @generated - */ - public EReference getAbstractPanel_Parent() { - return (EReference)abstractPanelEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EClass getPosition() { - return positionEClass; - } - - /** - * - * - * @generated - */ - public EAttribute getPosition_X() { - return (EAttribute)positionEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EAttribute getPosition_Y() { - return (EAttribute)positionEClass.getEStructuralFeatures().get(1); - } - - /** - * - * - * @generated - */ - public EClass getSize() { - return sizeEClass; - } - - /** - * - * - * @generated - */ - public EAttribute getSize_Width() { - return (EAttribute)sizeEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EAttribute getSize_Length() { - return (EAttribute)sizeEClass.getEStructuralFeatures().get(1); - } - - /** - * - * - * @generated - */ - public EClass getTabFolder() { - return tabFolderEClass; - } - - /** - * - * - * @generated - */ - public EReference getTabFolder_Children() { - return (EReference)tabFolderEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EClass getPageRef() { - return pageRefEClass; - } - - /** - * - * - * @generated - */ - public EReference getPageRef_EmfPageIdentifier() { - return (EReference)pageRefEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EAttribute getPageRef_PageIdentifier() { - return (EAttribute)pageRefEClass.getEStructuralFeatures().get(1); - } - - /** - * - * - * @generated - */ - public EAttribute getPageRef_ObjectPageIdentifier() { - return (EAttribute)pageRefEClass.getEStructuralFeatures().get(2); - } - - /** - * - * - * @generated - */ - public EReference getPageRef_Parent() { - return (EReference)pageRefEClass.getEStructuralFeatures().get(3); - } - - /** - * - * - * @generated - */ - public EClass getSashPanel() { - return sashPanelEClass; - } - - /** - * - * - * @generated - */ - public EAttribute getSashPanel_SashPosition() { - return (EAttribute)sashPanelEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EAttribute getSashPanel_Direction() { - return (EAttribute)sashPanelEClass.getEStructuralFeatures().get(1); - } - - /** - * - * - * @generated - */ - public EClass getAbstractPage() { - return abstractPageEClass; - } - - /** - * - * - * @generated - */ - public EAttribute getAbstractPage_PageIdentifier() { - return (EAttribute)abstractPageEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EClass getPageList() { - return pageListEClass; - } - - /** - * - * - * @generated - */ - public EReference getPageList_AvailablePage() { - return (EReference)pageListEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EClass getSashWindowsMngr() { - return sashWindowsMngrEClass; - } - - /** - * - * - * @generated - */ - public EReference getSashWindowsMngr_PageList() { - return (EReference)sashWindowsMngrEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EReference getSashWindowsMngr_SashModel() { - return (EReference)sashWindowsMngrEClass.getEStructuralFeatures().get(1); - } - - /** - * - * - * @generated - */ - public EDataType getint() { - return intEDataType; - } - - /** - * - * - * @generated - */ - public EDataType getJavaObject() { - return javaObjectEDataType; - } - - /** - * - * - * @generated - */ - public EDataType getFloat() { - return floatEDataType; - } - - /** - * - * - * @generated - */ - public EDataType getboolean() { - return booleanEDataType; - } - - /** - * - * - * @generated - */ - public DiFactory getDiFactory() { - return (DiFactory)getEFactoryInstance(); - } - - /** - * - * - * @generated - */ - private boolean isCreated = false; - - /** - * Creates the meta-model objects for the package. This method is guarded to - * have no affect on any invocation but its first. - * - * - * @generated - */ - public void createPackageContents() { - if(isCreated) - return; - isCreated = true; - - // Create classes and their features - sashModelEClass = createEClass(SASH_MODEL); - createEReference(sashModelEClass, SASH_MODEL__WINDOWS); - createEReference(sashModelEClass, SASH_MODEL__CURRENT_SELECTION); - - windowEClass = createEClass(WINDOW); - createEReference(windowEClass, WINDOW__POSITION); - createEReference(windowEClass, WINDOW__SIZE); - createEReference(windowEClass, WINDOW__PANEL); - - panelParentEClass = createEClass(PANEL_PARENT); - createEReference(panelParentEClass, PANEL_PARENT__CHILDREN); - - abstractPanelEClass = createEClass(ABSTRACT_PANEL); - createEReference(abstractPanelEClass, ABSTRACT_PANEL__PARENT); - - positionEClass = createEClass(POSITION); - createEAttribute(positionEClass, POSITION__X); - createEAttribute(positionEClass, POSITION__Y); - - sizeEClass = createEClass(SIZE); - createEAttribute(sizeEClass, SIZE__WIDTH); - createEAttribute(sizeEClass, SIZE__LENGTH); - - tabFolderEClass = createEClass(TAB_FOLDER); - createEReference(tabFolderEClass, TAB_FOLDER__CHILDREN); - - pageRefEClass = createEClass(PAGE_REF); - createEReference(pageRefEClass, PAGE_REF__EMF_PAGE_IDENTIFIER); - createEAttribute(pageRefEClass, PAGE_REF__PAGE_IDENTIFIER); - createEAttribute(pageRefEClass, PAGE_REF__OBJECT_PAGE_IDENTIFIER); - createEReference(pageRefEClass, PAGE_REF__PARENT); - - sashPanelEClass = createEClass(SASH_PANEL); - createEAttribute(sashPanelEClass, SASH_PANEL__SASH_POSITION); - createEAttribute(sashPanelEClass, SASH_PANEL__DIRECTION); - - abstractPageEClass = createEClass(ABSTRACT_PAGE); - createEAttribute(abstractPageEClass, ABSTRACT_PAGE__PAGE_IDENTIFIER); - - pageListEClass = createEClass(PAGE_LIST); - createEReference(pageListEClass, PAGE_LIST__AVAILABLE_PAGE); - - sashWindowsMngrEClass = createEClass(SASH_WINDOWS_MNGR); - createEReference(sashWindowsMngrEClass, SASH_WINDOWS_MNGR__PAGE_LIST); - createEReference(sashWindowsMngrEClass, SASH_WINDOWS_MNGR__SASH_MODEL); - - // Create data types - intEDataType = createEDataType(INT); - javaObjectEDataType = createEDataType(JAVA_OBJECT); - floatEDataType = createEDataType(FLOAT); - booleanEDataType = createEDataType(BOOLEAN); - } - - /** - * - * - * @generated - */ - private boolean isInitialized = false; - - /** - * Complete the initialization of the package and its meta-model. This - * method is guarded to have no affect on any invocation but its first. - * - * @generated - */ - public void initializePackageContents() { - if(isInitialized) - return; - isInitialized = true; - - // Initialize package - setName(eNAME); - setNsPrefix(eNS_PREFIX); - setNsURI(eNS_URI); - - // Obtain other dependent packages - EcorePackage theEcorePackage = (EcorePackage)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI); - - // Create type parameters - - // Set bounds for type parameters - - // Add supertypes to classes - windowEClass.getESuperTypes().add(this.getPanelParent()); - tabFolderEClass.getESuperTypes().add(this.getAbstractPanel()); - sashPanelEClass.getESuperTypes().add(this.getAbstractPanel()); - sashPanelEClass.getESuperTypes().add(this.getPanelParent()); - - // Initialize classes and features; add operations and parameters - initEClass(sashModelEClass, SashModel.class, "SashModel", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getSashModel_Windows(), this.getWindow(), null, "windows", null, 0, -1, SashModel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - initEReference(getSashModel_CurrentSelection(), this.getTabFolder(), null, "currentSelection", null, 1, 1, SashModel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - - EOperation op = addEOperation(sashModelEClass, null, "addPage", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); - - op = addEOperation(sashModelEClass, null, "removePage", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); - - op = addEOperation(sashModelEClass, this.getPageRef(), "lookupPage", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); - - op = addEOperation(sashModelEClass, null, "movePage", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getTabFolder(), "srcParentFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getint(), "srcIndex", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getTabFolder(), "targetParentFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, ecorePackage.getEInt(), "targetIndex", 1, 1, IS_UNIQUE, !IS_ORDERED); - - op = addEOperation(sashModelEClass, null, "insertFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getTabFolder(), "folderToInsert", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getTabFolder(), "refFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, ecorePackage.getEInt(), "refFolderSide", 1, 1, IS_UNIQUE, !IS_ORDERED); - - op = addEOperation(sashModelEClass, null, "movePage", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getTabFolder(), "srcParentFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getint(), "srcIndex", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getTabFolder(), "targetParentFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); - - op = addEOperation(sashModelEClass, null, "removeEmptyFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getTabFolder(), "folder", 1, 1, IS_UNIQUE, !IS_ORDERED); - - addEOperation(sashModelEClass, null, "removeAllPages", 1, 1, IS_UNIQUE, !IS_ORDERED); - - op = addEOperation(sashModelEClass, null, "removeOtherPages", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); - - addEOperation(sashModelEClass, this.getWindow(), "lookupFirstWindow", 1, 1, IS_UNIQUE, !IS_ORDERED); - - addEOperation(sashModelEClass, this.getTabFolder(), "lookupFirstFolder", 1, 1, IS_UNIQUE, !IS_ORDERED); - - initEClass(windowEClass, Window.class, "Window", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getWindow_Position(), this.getPosition(), null, "position", null, 1, 1, Window.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - initEReference(getWindow_Size(), this.getSize(), null, "size", null, 1, 1, Window.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - initEReference(getWindow_Panel(), this.getAbstractPanel(), null, "panel", null, 1, 1, Window.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, IS_DERIVED, !IS_ORDERED); - - initEClass(panelParentEClass, PanelParent.class, "PanelParent", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getPanelParent_Children(), this.getAbstractPanel(), this.getAbstractPanel_Parent(), "children", null, 2, 2, PanelParent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - - op = addEOperation(panelParentEClass, null, "replaceChild", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getAbstractPanel(), "oldChild", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getAbstractPanel(), "newChild", 1, 1, IS_UNIQUE, !IS_ORDERED); - - initEClass(abstractPanelEClass, AbstractPanel.class, "AbstractPanel", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getAbstractPanel_Parent(), this.getPanelParent(), this.getPanelParent_Children(), "parent", null, 1, 1, AbstractPanel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - - initEClass(positionEClass, Position.class, "Position", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getPosition_X(), ecorePackage.getEInt(), "x", null, 1, 1, Position.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - initEAttribute(getPosition_Y(), this.getint(), "y", null, 1, 1, Position.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - - initEClass(sizeEClass, Size.class, "Size", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getSize_Width(), this.getint(), "width", null, 1, 1, Size.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - initEAttribute(getSize_Length(), this.getint(), "length", null, 1, 1, Size.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - - initEClass(tabFolderEClass, TabFolder.class, "TabFolder", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getTabFolder_Children(), this.getPageRef(), this.getPageRef_Parent(), "children", null, 0, -1, TabFolder.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - - op = addEOperation(tabFolderEClass, null, "movePage", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, ecorePackage.getEInt(), "oldIndex", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getint(), "newIndex", 1, 1, IS_UNIQUE, !IS_ORDERED); - - op = addEOperation(tabFolderEClass, null, "addPage", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); - - op = addEOperation(tabFolderEClass, null, "removePage", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getint(), "pageIndex", 1, 1, IS_UNIQUE, !IS_ORDERED); - - initEClass(pageRefEClass, PageRef.class, "PageRef", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getPageRef_EmfPageIdentifier(), theEcorePackage.getEObject(), null, "emfPageIdentifier", null, 1, 1, PageRef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - initEAttribute(getPageRef_PageIdentifier(), this.getJavaObject(), "pageIdentifier", null, 1, 1, PageRef.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, IS_DERIVED, !IS_ORDERED); - initEAttribute(getPageRef_ObjectPageIdentifier(), this.getJavaObject(), "objectPageIdentifier", null, 1, 1, PageRef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - initEReference(getPageRef_Parent(), this.getTabFolder(), this.getTabFolder_Children(), "parent", null, 1, 1, PageRef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - - op = addEOperation(pageRefEClass, ecorePackage.getEBoolean(), "isForIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); - - initEClass(sashPanelEClass, SashPanel.class, "SashPanel", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getSashPanel_SashPosition(), this.getFloat(), "sashPosition", null, 1, 1, SashPanel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - initEAttribute(getSashPanel_Direction(), ecorePackage.getEInt(), "direction", null, 1, 1, SashPanel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - - op = addEOperation(sashPanelEClass, null, "setChildren", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getAbstractPanel(), "leftChild", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getAbstractPanel(), "rightChild", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getint(), "direction", 1, 1, IS_UNIQUE, !IS_ORDERED); - - op = addEOperation(sashPanelEClass, null, "delete", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getAbstractPanel(), "childToDelete", 1, 1, IS_UNIQUE, !IS_ORDERED); - - initEClass(abstractPageEClass, AbstractPage.class, "AbstractPage", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getAbstractPage_PageIdentifier(), this.getJavaObject(), "pageIdentifier", null, 1, 1, AbstractPage.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - - initEClass(pageListEClass, PageList.class, "PageList", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getPageList_AvailablePage(), this.getPageRef(), null, "availablePage", null, 0, -1, PageList.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - - op = addEOperation(pageListEClass, null, "addPage", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); - - op = addEOperation(pageListEClass, null, "removePage", 1, 1, IS_UNIQUE, !IS_ORDERED); - addEParameter(op, this.getJavaObject(), "pageIdentifier", 1, 1, IS_UNIQUE, !IS_ORDERED); - - initEClass(sashWindowsMngrEClass, SashWindowsMngr.class, "SashWindowsMngr", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getSashWindowsMngr_PageList(), this.getPageList(), null, "pageList", null, 1, 1, SashWindowsMngr.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - initEReference(getSashWindowsMngr_SashModel(), this.getSashModel(), null, "sashModel", null, 1, 1, SashWindowsMngr.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); - - // Initialize data types - initEDataType(intEDataType, int.class, "int", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); - initEDataType(javaObjectEDataType, Object.class, "JavaObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); - initEDataType(floatEDataType, float.class, "Float", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); - initEDataType(booleanEDataType, boolean.class, "boolean", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); - - // Create resource - createResource(eNS_URI); - - // Create annotations - // resource=XMI - createResourceXMIAnnotations(); - } - - /** - * Initializes the annotations for resource=XMI. - * - * @generated - */ - protected void createResourceXMIAnnotations() { - String source = "resource=XMI"; - addAnnotation(this, source, new String[]{}); - } - -} // DiPackageImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PageListImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PageListImpl.java deleted file mode 100644 index 6892142dd75..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PageListImpl.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.impl; - -import java.util.Collection; - -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.papyrus.sashwindows.di.DiFactory; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PageList; -import org.eclipse.papyrus.sashwindows.di.PageRef; - -/** - * An implementation of the model object ' Page List'. - *

- * The following features are implemented: - *

    - *
  • - * {@link org.eclipse.papyrus.sashwindows.di.impl.PageListImpl#getAvailablePage - * Available Page}
  • - *
- *

- * - * @generated - */ -public class PageListImpl extends EObjectImpl implements PageList { - - /** - * The cached value of the '{@link #getAvailablePage() - * Available Page}' containment reference list. - * - * @see #getAvailablePage() - * @generated - * @ordered - */ - protected EList availablePage; - - /** - * - * - * @generated - */ - protected PageListImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return DiPackage.Literals.PAGE_LIST; - } - - /** - * - * - * @generated - */ - public EList getAvailablePage() { - if(availablePage == null) { - availablePage = new EObjectContainmentEList(PageRef.class, this, DiPackage.PAGE_LIST__AVAILABLE_PAGE); - } - return availablePage; - } - - /** - * - * - * @generated NOT - */ - public void addPage(Object pageIdentifier) { - - PageRef pageRef = DiFactory.eINSTANCE.createPageRef(); - pageRef.setPageIdentifier(pageIdentifier); - getAvailablePage().add(pageRef); - - } - - /** - * - * - * @generated NOT - */ - public void removePage(Object pageIdentifier) { - for(PageRef pageRef : getAvailablePage()) { - - if(pageRef.isForIdentifier(pageIdentifier)) { - getAvailablePage().remove(pageRef); - return; - } - } - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch(featureID) { - case DiPackage.PAGE_LIST__AVAILABLE_PAGE: - return ((InternalEList)getAvailablePage()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch(featureID) { - case DiPackage.PAGE_LIST__AVAILABLE_PAGE: - return getAvailablePage(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch(featureID) { - case DiPackage.PAGE_LIST__AVAILABLE_PAGE: - getAvailablePage().clear(); - getAvailablePage().addAll((Collection)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch(featureID) { - case DiPackage.PAGE_LIST__AVAILABLE_PAGE: - getAvailablePage().clear(); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch(featureID) { - case DiPackage.PAGE_LIST__AVAILABLE_PAGE: - return availablePage != null && !availablePage.isEmpty(); - } - return super.eIsSet(featureID); - } - -} // PageListImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PageRefImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PageRefImpl.java deleted file mode 100644 index 5cac4e48c5c..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PageRefImpl.java +++ /dev/null @@ -1,406 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.papyrus.sashwindows.di.TabFolder; - -/** - * An implementation of the model object ' Page Ref'. - *

- * The following features are implemented: - *

    - *
  • - * {@link org.eclipse.papyrus.sashwindows.di.impl.PageRefImpl#getEmfPageIdentifier - * Emf Page Identifier}
  • - *
  • - * {@link org.eclipse.papyrus.sashwindows.di.impl.PageRefImpl#getPageIdentifier - * Page Identifier}
  • - *
  • - * {@link org.eclipse.papyrus.sashwindows.di.impl.PageRefImpl#getObjectPageIdentifier - * Object Page Identifier}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.PageRefImpl#getParent Parent}
  • - *
- *

- * - * @generated - */ -public class PageRefImpl extends EObjectImpl implements PageRef { - - /** - * The cached value of the '{@link #getEmfPageIdentifier() - * Emf Page Identifier}' reference. - * - * @see #getEmfPageIdentifier() - * @generated - * @ordered - */ - protected EObject emfPageIdentifier; - - /** - * The default value of the '{@link #getPageIdentifier() - * Page Identifier}' attribute. - * - * @see #getPageIdentifier() - * @generated - * @ordered - */ - protected static final Object PAGE_IDENTIFIER_EDEFAULT = null; - - /** - * The default value of the '{@link #getObjectPageIdentifier() - * Object Page Identifier}' attribute. - * - * @see #getObjectPageIdentifier() - * @generated - * @ordered - */ - protected static final Object OBJECT_PAGE_IDENTIFIER_EDEFAULT = null; - - /** - * The cached value of the '{@link #getObjectPageIdentifier() - * Object Page Identifier}' attribute. - * - * @see #getObjectPageIdentifier() - * @generated - * @ordered - */ - protected Object objectPageIdentifier = OBJECT_PAGE_IDENTIFIER_EDEFAULT; - - /** - * - * - * @generated - */ - protected PageRefImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return DiPackage.Literals.PAGE_REF; - } - - /** - * - * - * @generated - */ - public EObject getEmfPageIdentifier() { - if(emfPageIdentifier != null && emfPageIdentifier.eIsProxy()) { - InternalEObject oldEmfPageIdentifier = (InternalEObject)emfPageIdentifier; - emfPageIdentifier = eResolveProxy(oldEmfPageIdentifier); - if(emfPageIdentifier != oldEmfPageIdentifier) { - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.RESOLVE, DiPackage.PAGE_REF__EMF_PAGE_IDENTIFIER, oldEmfPageIdentifier, emfPageIdentifier)); - } - } - return emfPageIdentifier; - } - - /** - * - * - * @generated - */ - public EObject basicGetEmfPageIdentifier() { - return emfPageIdentifier; - } - - /** - * - * - * @generated - */ - public void setEmfPageIdentifier(EObject newEmfPageIdentifier) { - EObject oldEmfPageIdentifier = emfPageIdentifier; - emfPageIdentifier = newEmfPageIdentifier; - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.PAGE_REF__EMF_PAGE_IDENTIFIER, oldEmfPageIdentifier, emfPageIdentifier)); - } - - /** - * - * - * @generated NOT - */ - public Object getPageIdentifier() { - Object res = getEmfPageIdentifier(); - - if(res != null) { - return res; - } else - return getObjectPageIdentifier(); - } - - /** - * - * - * @generated NOT - */ - public boolean isForIdentifier(Object pageIdentifier) { - if(getPageIdentifier() != null) { - return getPageIdentifier().equals(pageIdentifier); - } - return false; - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch(featureID) { - case DiPackage.PAGE_REF__PARENT: - if(eInternalContainer() != null) - msgs = eBasicRemoveFromContainer(msgs); - return basicSetParent((TabFolder)otherEnd, msgs); - } - return super.eInverseAdd(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch(featureID) { - case DiPackage.PAGE_REF__PARENT: - return basicSetParent(null, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { - switch(eContainerFeatureID()) { - case DiPackage.PAGE_REF__PARENT: - return eInternalContainer().eInverseRemove(this, DiPackage.TAB_FOLDER__CHILDREN, TabFolder.class, msgs); - } - return super.eBasicRemoveFromContainerFeature(msgs); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch(featureID) { - case DiPackage.PAGE_REF__EMF_PAGE_IDENTIFIER: - if(resolve) - return getEmfPageIdentifier(); - return basicGetEmfPageIdentifier(); - case DiPackage.PAGE_REF__PAGE_IDENTIFIER: - return getPageIdentifier(); - case DiPackage.PAGE_REF__OBJECT_PAGE_IDENTIFIER: - return getObjectPageIdentifier(); - case DiPackage.PAGE_REF__PARENT: - return getParent(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch(featureID) { - case DiPackage.PAGE_REF__EMF_PAGE_IDENTIFIER: - setEmfPageIdentifier((EObject)newValue); - return; - case DiPackage.PAGE_REF__PAGE_IDENTIFIER: - setPageIdentifier(newValue); - return; - case DiPackage.PAGE_REF__OBJECT_PAGE_IDENTIFIER: - setObjectPageIdentifier(newValue); - return; - case DiPackage.PAGE_REF__PARENT: - setParent((TabFolder)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch(featureID) { - case DiPackage.PAGE_REF__EMF_PAGE_IDENTIFIER: - setEmfPageIdentifier((EObject)null); - return; - case DiPackage.PAGE_REF__PAGE_IDENTIFIER: - setPageIdentifier(PAGE_IDENTIFIER_EDEFAULT); - return; - case DiPackage.PAGE_REF__OBJECT_PAGE_IDENTIFIER: - setObjectPageIdentifier(OBJECT_PAGE_IDENTIFIER_EDEFAULT); - return; - case DiPackage.PAGE_REF__PARENT: - setParent((TabFolder)null); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch(featureID) { - case DiPackage.PAGE_REF__EMF_PAGE_IDENTIFIER: - return emfPageIdentifier != null; - case DiPackage.PAGE_REF__PAGE_IDENTIFIER: - return PAGE_IDENTIFIER_EDEFAULT == null ? getPageIdentifier() != null : !PAGE_IDENTIFIER_EDEFAULT.equals(getPageIdentifier()); - case DiPackage.PAGE_REF__OBJECT_PAGE_IDENTIFIER: - return OBJECT_PAGE_IDENTIFIER_EDEFAULT == null ? objectPageIdentifier != null : !OBJECT_PAGE_IDENTIFIER_EDEFAULT.equals(objectPageIdentifier); - case DiPackage.PAGE_REF__PARENT: - return getParent() != null; - } - return super.eIsSet(featureID); - } - - /** - * - * - * @generated - */ - @Override - public String toString() { - if(eIsProxy()) - return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (objectPageIdentifier: "); - result.append(objectPageIdentifier); - result.append(')'); - return result.toString(); - } - - /** - * - * - * @generated NOT - */ - public void setPageIdentifier(Object newPageIdentifier) { - - if(newPageIdentifier instanceof EObject) { - setEmfPageIdentifier((EObject)newPageIdentifier); - return; - } - - // if null, unset all - if(newPageIdentifier == null && getEmfPageIdentifier() != null) { - setEmfPageIdentifier(null); - } - - // By default, consider newPageIdentifier as an Object - setObjectPageIdentifier(newPageIdentifier); - - } - - /** - * - * - * @generated - */ - public Object getObjectPageIdentifier() { - return objectPageIdentifier; - } - - /** - * - * - * @generated - */ - public void setObjectPageIdentifier(Object newObjectPageIdentifier) { - Object oldObjectPageIdentifier = objectPageIdentifier; - objectPageIdentifier = newObjectPageIdentifier; - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.PAGE_REF__OBJECT_PAGE_IDENTIFIER, oldObjectPageIdentifier, objectPageIdentifier)); - } - - /** - * - * - * @generated - */ - public TabFolder getParent() { - if(eContainerFeatureID() != DiPackage.PAGE_REF__PARENT) - return null; - return (TabFolder)eContainer(); - } - - /** - * - * - * @generated - */ - public NotificationChain basicSetParent(TabFolder newParent, NotificationChain msgs) { - msgs = eBasicSetContainer((InternalEObject)newParent, DiPackage.PAGE_REF__PARENT, msgs); - return msgs; - } - - /** - * - * - * @generated - */ - public void setParent(TabFolder newParent) { - if(newParent != eInternalContainer() || (eContainerFeatureID() != DiPackage.PAGE_REF__PARENT && newParent != null)) { - if(EcoreUtil.isAncestor(this, newParent)) - throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); - NotificationChain msgs = null; - if(eInternalContainer() != null) - msgs = eBasicRemoveFromContainer(msgs); - if(newParent != null) - msgs = ((InternalEObject)newParent).eInverseAdd(this, DiPackage.TAB_FOLDER__CHILDREN, TabFolder.class, msgs); - msgs = basicSetParent(newParent, msgs); - if(msgs != null) - msgs.dispatch(); - } else if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.PAGE_REF__PARENT, newParent, newParent)); - } - -} // PageRefImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PanelParentImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PanelParentImpl.java deleted file mode 100644 index 7c2267121ff..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PanelParentImpl.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.impl; - -import java.util.Collection; - -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.papyrus.sashwindows.di.AbstractPanel; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PanelParent; - -/** - * An implementation of the model object ' Panel Parent'. - *

- * The following features are implemented: - *

    - *
  • - * {@link org.eclipse.papyrus.sashwindows.di.impl.PanelParentImpl#getChildren - * Children}
  • - *
- *

- * - * @generated - */ -public abstract class PanelParentImpl extends EObjectImpl implements PanelParent { - - /** - * The cached value of the '{@link #getChildren() Children}' - * containment reference list. - * - * @see #getChildren() - * @generated - * @ordered - */ - protected EList children; - - /** - * - * - * @generated - */ - protected PanelParentImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return DiPackage.Literals.PANEL_PARENT; - } - - /** - * - * - * @generated - */ - public EList getChildren() { - if(children == null) { - children = new EObjectContainmentWithInverseEList(AbstractPanel.class, this, DiPackage.PANEL_PARENT__CHILDREN, DiPackage.ABSTRACT_PANEL__PARENT); - } - return children; - } - - /** - * - * - * @generated - */ - public void replaceChild(AbstractPanel oldChild, AbstractPanel newChild) { - // TODO: implement this method - // Ensure that you remove @generated or mark it @generated NOT - throw new UnsupportedOperationException(); - } - - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch(featureID) { - case DiPackage.PANEL_PARENT__CHILDREN: - return ((InternalEList)(InternalEList)getChildren()).basicAdd(otherEnd, msgs); - } - return super.eInverseAdd(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch(featureID) { - case DiPackage.PANEL_PARENT__CHILDREN: - return ((InternalEList)getChildren()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch(featureID) { - case DiPackage.PANEL_PARENT__CHILDREN: - return getChildren(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch(featureID) { - case DiPackage.PANEL_PARENT__CHILDREN: - getChildren().clear(); - getChildren().addAll((Collection)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch(featureID) { - case DiPackage.PANEL_PARENT__CHILDREN: - getChildren().clear(); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch(featureID) { - case DiPackage.PANEL_PARENT__CHILDREN: - return children != null && !children.isEmpty(); - } - return super.eIsSet(featureID); - } - -} // PanelParentImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PositionImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PositionImpl.java deleted file mode 100644 index a71cb442356..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/PositionImpl.java +++ /dev/null @@ -1,218 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.Position; - -/** - * An implementation of the model object ' Position'. - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.PositionImpl#getX X }
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.PositionImpl#getY Y }
  • - *
- *

- * - * @generated - */ -public class PositionImpl extends EObjectImpl implements Position { - - /** - * The default value of the '{@link #getX() X}' attribute. - * - * @see #getX() - * @generated - * @ordered - */ - protected static final int X_EDEFAULT = 0; - - /** - * The cached value of the '{@link #getX() X}' attribute. - * - * @see #getX() - * @generated - * @ordered - */ - protected int x = X_EDEFAULT; - - /** - * The default value of the '{@link #getY() Y}' attribute. - * - * @see #getY() - * @generated - * @ordered - */ - protected static final int Y_EDEFAULT = 0; - - /** - * The cached value of the '{@link #getY() Y}' attribute. - * - * @see #getY() - * @generated - * @ordered - */ - protected int y = Y_EDEFAULT; - - /** - * - * - * @generated - */ - protected PositionImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return DiPackage.Literals.POSITION; - } - - /** - * - * - * @generated - */ - public int getX() { - return x; - } - - /** - * - * - * @generated - */ - public void setX(int newX) { - int oldX = x; - x = newX; - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.POSITION__X, oldX, x)); - } - - /** - * - * - * @generated - */ - public int getY() { - return y; - } - - /** - * - * - * @generated - */ - public void setY(int newY) { - int oldY = y; - y = newY; - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.POSITION__Y, oldY, y)); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch(featureID) { - case DiPackage.POSITION__X: - return getX(); - case DiPackage.POSITION__Y: - return getY(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch(featureID) { - case DiPackage.POSITION__X: - setX((Integer)newValue); - return; - case DiPackage.POSITION__Y: - setY((Integer)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch(featureID) { - case DiPackage.POSITION__X: - setX(X_EDEFAULT); - return; - case DiPackage.POSITION__Y: - setY(Y_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch(featureID) { - case DiPackage.POSITION__X: - return x != X_EDEFAULT; - case DiPackage.POSITION__Y: - return y != Y_EDEFAULT; - } - return super.eIsSet(featureID); - } - - /** - * - * - * @generated - */ - @Override - public String toString() { - if(eIsProxy()) - return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (x: "); - result.append(x); - result.append(", y: "); - result.append(y); - result.append(')'); - return result.toString(); - } - -} // PositionImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SashModelImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SashModelImpl.java deleted file mode 100644 index 90536345fb0..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SashModelImpl.java +++ /dev/null @@ -1,587 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.impl; - -import java.util.Collection; -import java.util.List; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.papyrus.sashwindows.di.AbstractPanel; -import org.eclipse.papyrus.sashwindows.di.DiFactory; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.papyrus.sashwindows.di.PanelParent; -import org.eclipse.papyrus.sashwindows.di.SashModel; -import org.eclipse.papyrus.sashwindows.di.SashPanel; -import org.eclipse.papyrus.sashwindows.di.TabFolder; -import org.eclipse.papyrus.sashwindows.di.Window; -import org.eclipse.papyrus.sashwindows.di.util.DiSwitch; -import org.eclipse.swt.SWT; - -/** - * An implementation of the model object ' Sash Model'. - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.SashModelImpl#getWindows - * Windows}
  • - *
  • - * {@link org.eclipse.papyrus.sashwindows.di.impl.SashModelImpl#getCurrentSelection - * Current Selection}
  • - *
- *

- * - * @generated - */ -public class SashModelImpl extends EObjectImpl implements SashModel { - - /** - * The cached value of the '{@link #getWindows() Windows}' - * containment reference list. - * - * @see #getWindows() - * @generated - * @ordered - */ - protected EList windows; - - /** - * The cached value of the '{@link #getCurrentSelection() - * Current Selection}' reference. - * - * @see #getCurrentSelection() - * @generated - * @ordered - */ - protected TabFolder currentSelection; - - /** - * - * - * @generated - */ - protected SashModelImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return DiPackage.Literals.SASH_MODEL; - } - - /** - * - * - * @generated - */ - public EList getWindows() { - if(windows == null) { - windows = new EObjectContainmentEList(Window.class, this, DiPackage.SASH_MODEL__WINDOWS); - } - return windows; - } - - /** - * - * - * @generated - */ - public TabFolder getCurrentSelection() { - if(currentSelection != null && currentSelection.eIsProxy()) { - InternalEObject oldCurrentSelection = (InternalEObject)currentSelection; - currentSelection = (TabFolder)eResolveProxy(oldCurrentSelection); - if(currentSelection != oldCurrentSelection) { - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.RESOLVE, DiPackage.SASH_MODEL__CURRENT_SELECTION, oldCurrentSelection, currentSelection)); - } - } - return currentSelection; - } - - /** - * - * - * @generated - */ - public TabFolder basicGetCurrentSelection() { - return currentSelection; - } - - /** - * - * - * @generated - */ - public void setCurrentSelection(TabFolder newCurrentSelection) { - TabFolder oldCurrentSelection = currentSelection; - currentSelection = newCurrentSelection; - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.SASH_MODEL__CURRENT_SELECTION, oldCurrentSelection, currentSelection)); - } - - /** - * - * - * @generated NOT - */ - public void addPage(Object pageIdentifier) { - getCurrentSelection().addPage(pageIdentifier); - } - - /** - * - * - * @generated NOT - */ - public void removePage(Object pageIdentifier) { - PageRef pageRef = lookupPage(pageIdentifier); - if(pageRef == null) - return; - - // Remove it - pageRef.getParent().getChildren().remove(pageRef); - } - - /** - * - * - * @generated NOT - */ - public PageRef lookupPage(final Object pageIdentifier) { - - // Create appropriate visitor. - DiSwitch visitor = new DiSwitch() { - - /** - * Iterate over windows - * - * @see org.eclipse.papyrus.sashwindows.di.util.DiSwitch#caseSashModel(org.eclipse.papyrus.sashwindows.di.SashModel) - * - * @param object - * @return - */ - public PageRef caseSashModel(SashModel object) { - PageRef res = null; - for(Window window : object.getWindows()) { - res = this.doSwitch(window); - if(res != null) - return res; - } - - return super.caseSashModel(object); - } - - /** - * - * @see org.eclipse.papyrus.sashwindows.di.util.DiSwitch#caseWindow(org.eclipse.papyrus.sashwindows.di.Window) - * - * @param object - * @return - */ - public PageRef caseWindow(Window window) { - - AbstractPanel panel = window.getPanel(); - if(panel == null) - return null; - - PageRef res = this.doSwitch(panel); - if(res != null) - return res; - - return super.caseWindow(window); - } - - /** - * Iterate over children - * - * @see org.eclipse.papyrus.sashwindows.di.util.DiSwitch#caseSashPanel(org.eclipse.papyrus.sashwindows.di.SashPanel) - * - * @param object - * @return - */ - public PageRef caseSashPanel(SashPanel object) { - PageRef res = null; - for(AbstractPanel panel : object.getChildren()) { - res = this.doSwitch(panel); - if(res != null) - return res; - } - - return super.caseSashPanel(object); - } - - /** - * Iterate over PageRef - * - * @see org.eclipse.papyrus.sashwindows.di.util.DiSwitch#caseTabFolder(org.eclipse.papyrus.sashwindows.di.TabFolder) - * - * @param object - * @return - */ - public PageRef caseTabFolder(TabFolder object) { - for(PageRef pageRef : object.getChildren()) { - - if(pageRef.isForIdentifier(pageIdentifier)) - return pageRef; - } - - return super.caseTabFolder(object); - } - - }; - - // Do lookup - PageRef res = visitor.doSwitch(this); - - return res; - } - - /** - * TODO Add method to - * metamodel - * - * @generated NOT - */ - public TabFolder lookupFirstFolder() { - - // Create appropriate visitor. - DiSwitch visitor = new DiSwitch() { - - /** - * Iterate over windows - * - * @see org.eclipse.papyrus.sashwindows.di.util.DiSwitch#caseSashModel(org.eclipse.papyrus.sashwindows.di.SashModel) - * - * @param object - * @return - */ - public TabFolder caseSashModel(SashModel object) { - TabFolder res = null; - for(Window window : object.getWindows()) { - res = this.doSwitch(window); - if(res != null) - return res; - } - - return super.caseSashModel(object); - } - - /** - * - * @see org.eclipse.papyrus.sashwindows.di.util.DiSwitch#caseWindow(org.eclipse.papyrus.sashwindows.di.Window) - * - * @param object - * @return - */ - public TabFolder caseWindow(Window window) { - - AbstractPanel panel = window.getPanel(); - if(panel == null) - return null; - - TabFolder res = this.doSwitch(panel); - if(res != null) - return res; - - return super.caseWindow(window); - } - - /** - * Iterate over children - * - * @see org.eclipse.papyrus.sashwindows.di.util.DiSwitch#caseSashPanel(org.eclipse.papyrus.sashwindows.di.SashPanel) - * - * @param object - * @return - */ - public TabFolder caseSashPanel(SashPanel object) { - TabFolder res = null; - for(AbstractPanel panel : object.getChildren()) { - res = this.doSwitch(panel); - if(res != null) - return res; - } - - return super.caseSashPanel(object); - } - - /** - * Iterate over PageRef - * - * @see org.eclipse.papyrus.sashwindows.di.util.DiSwitch#caseTabFolder(org.eclipse.papyrus.sashwindows.di.TabFolder) - * - * @param object - * @return - */ - public TabFolder caseTabFolder(TabFolder object) { - return object; - } - - }; - - // Do lookup - TabFolder res = visitor.doSwitch(this); - - return res; - } - - /** - * TODO Add method to - * metamodel - * - * @generated NOT - */ - public Window lookupFirstWindow() { - - List list = getWindows(); - if(list.size() == 0) - return null; - - return list.get(0); - } - - /** - * - * - * @generated NOT - */ - public void movePage(TabFolder srcParentFolder, int srcIndex, TabFolder targetParentFolder, int targetIndex) { - - // Check if we move all pages of srcFolder - if(srcIndex == -1) { - // move all - List srcChildrens = srcParentFolder.getChildren(); - List targetChildrens = targetParentFolder.getChildren(); - while(srcChildrens.size() > 0) { - PageRef pageRef = srcChildrens.remove(0); - targetChildrens.add(pageRef); - } - return; - } - - // Move only one - PageRef pageRef = srcParentFolder.getChildren().remove(srcIndex); - - List targetChildrens = targetParentFolder.getChildren(); - // Check if out of target range. - if(targetIndex < 0 || targetIndex > targetChildrens.size()) - targetChildrens.add(pageRef); - else - targetChildrens.add(targetIndex, pageRef); - } - - /** - * - * - * @generated NOT - */ - public void insertFolder(TabFolder folderToInsert, TabFolder refFolder, int side) { - - // Get the parent under which the sash will be inserted - PanelParent refParent = refFolder.getParent(); - - SashPanel newSash; - int direction; - - // Compute sash direction - if(side == SWT.LEFT || side == SWT.RIGHT) - direction = SWT.HORIZONTAL; - else - direction = SWT.VERTICAL; - // Create sash - newSash = DiFactory.eINSTANCE.createSashPanel(); - // Insert in parent. Should be done before setting childrens, otherwise, - // the child can't be - // replaced as it will not belong to parent anymore. - refParent.replaceChild(refFolder, newSash); - - if(side == SWT.LEFT || side == SWT.UP) { // insert left - newSash.setChildren(folderToInsert, refFolder, direction); - } else { - newSash.setChildren(refFolder, folderToInsert, direction); - } - - } - - /** - * - * - * @generated NOT - */ - public void movePage(TabFolder srcParentFolder, int srcIndex, TabFolder targetParentFolder) { - - PageRef pageRef = srcParentFolder.getChildren().remove(srcIndex); - - List targetChildrens = targetParentFolder.getChildren(); - // Check if out of target range. - targetChildrens.add(pageRef); - } - - /** - * - * - * @generated NOT - */ - public void removeEmptyFolder(TabFolder folder) { - - EList children = folder.getChildren(); - - // Check if empty - if(children.size() > 0) - return; - - PanelParent parent = folder.getParent(); - // Forbid removing of the last folder - if(parent instanceof Window) - return; - - // Parent is a sash. Ask it to remove the child and itself - ((SashPanel)parent).delete(folder); - // adjust current selection if the old folder was the currentSelection - if(getCurrentSelection() == folder) { - setCurrentSelection(lookupFirstFolder()); - } - } - - /** - * - * - * @generated NOT - */ - public void removeAllPages() { - - // Get a the first window and a folder. - // Clear the folder and set it as the root folder. - // This disguard all other folder and pages ... - Window firstWindow = lookupFirstWindow(); - TabFolder folder = lookupFirstFolder(); - - folder.getChildren().clear(); - firstWindow.setPanel(folder); - } - - /** - * - * - * @generated NOT - */ - public void removeOtherPages(Object pageIdentifier) { - // Get a the first window and a folder. - // Clear the folder and set it as the root folder. - // This disguard all other folder and pages ... - Window firstWindow = lookupFirstWindow(); - TabFolder folder = lookupFirstFolder(); - PageRef page = lookupPage(pageIdentifier); - - folder.getChildren().clear(); - if(page != null) { - folder.getChildren().add(page); - } - firstWindow.setPanel(folder); - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch(featureID) { - case DiPackage.SASH_MODEL__WINDOWS: - return ((InternalEList)getWindows()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch(featureID) { - case DiPackage.SASH_MODEL__WINDOWS: - return getWindows(); - case DiPackage.SASH_MODEL__CURRENT_SELECTION: - if(resolve) - return getCurrentSelection(); - return basicGetCurrentSelection(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch(featureID) { - case DiPackage.SASH_MODEL__WINDOWS: - getWindows().clear(); - getWindows().addAll((Collection)newValue); - return; - case DiPackage.SASH_MODEL__CURRENT_SELECTION: - setCurrentSelection((TabFolder)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch(featureID) { - case DiPackage.SASH_MODEL__WINDOWS: - getWindows().clear(); - return; - case DiPackage.SASH_MODEL__CURRENT_SELECTION: - setCurrentSelection((TabFolder)null); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch(featureID) { - case DiPackage.SASH_MODEL__WINDOWS: - return windows != null && !windows.isEmpty(); - case DiPackage.SASH_MODEL__CURRENT_SELECTION: - return currentSelection != null; - } - return super.eIsSet(featureID); - } - -} // SashModelImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SashPanelImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SashPanelImpl.java deleted file mode 100644 index 27785ae9ea0..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SashPanelImpl.java +++ /dev/null @@ -1,389 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.impl; - -import java.util.Collection; -import java.util.List; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.papyrus.sashwindows.di.AbstractPanel; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PanelParent; -import org.eclipse.papyrus.sashwindows.di.SashPanel; - -/** - * An implementation of the model object ' Sash Panel'. - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.SashPanelImpl#getChildren - * Children}
  • - *
  • - * {@link org.eclipse.papyrus.sashwindows.di.impl.SashPanelImpl#getSashPosition - * Sash Position}
  • - *
  • - * {@link org.eclipse.papyrus.sashwindows.di.impl.SashPanelImpl#getDirection - * Direction}
  • - *
- *

- * - * @generated - */ -public class SashPanelImpl extends AbstractPanelImpl implements SashPanel { - - /** - * The cached value of the '{@link #getChildren() Children}' - * containment reference list. - * - * @see #getChildren() - * @generated - * @ordered - */ - protected EList children; - - /** - * The default value of the '{@link #getSashPosition() - * Sash Position}' attribute. - * - * @see #getSashPosition() - * @generated - * @ordered - */ - protected static final float SASH_POSITION_EDEFAULT = 0.0F; - - /** - * The cached value of the '{@link #getSashPosition() - * Sash Position}' attribute. - * - * @see #getSashPosition() - * @generated - * @ordered - */ - protected float sashPosition = SASH_POSITION_EDEFAULT; - - /** - * The default value of the '{@link #getDirection() Direction}' - * attribute. - * - * @see #getDirection() - * @generated - * @ordered - */ - protected static final int DIRECTION_EDEFAULT = 0; - - /** - * The cached value of the '{@link #getDirection() Direction}' - * attribute. - * - * @see #getDirection() - * @generated - * @ordered - */ - protected int direction = DIRECTION_EDEFAULT; - - /** - * - * - * @generated - */ - protected SashPanelImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return DiPackage.Literals.SASH_PANEL; - } - - /** - * - * - * @generated - */ - public EList getChildren() { - if(children == null) { - children = new EObjectContainmentWithInverseEList(AbstractPanel.class, this, DiPackage.SASH_PANEL__CHILDREN, DiPackage.ABSTRACT_PANEL__PARENT); - } - return children; - } - - /** - * - * - * @generated - */ - public float getSashPosition() { - return sashPosition; - } - - /** - * - * - * @generated - */ - public void setSashPosition(float newSashPosition) { - float oldSashPosition = sashPosition; - sashPosition = newSashPosition; - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.SASH_PANEL__SASH_POSITION, oldSashPosition, sashPosition)); - } - - /** - * - * - * @generated - */ - public int getDirection() { - return direction; - } - - /** - * - * - * @generated - */ - public void setDirection(int newDirection) { - int oldDirection = direction; - direction = newDirection; - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.SASH_PANEL__DIRECTION, oldDirection, direction)); - } - - /** - * - * - * - * - * @generated NOT - */ - public void setChildren(AbstractPanel leftChild, AbstractPanel rightChild, int direction) { - setDirection(direction); - List children = getChildren(); - - if(children.size() == 0) { - children.add(leftChild); - children.add(rightChild); - - } else { - children.set(0, leftChild); - children.set(1, rightChild); - } - - } - - /** - * - * - * @generated NOT - */ - public void delete(AbstractPanel childToDelete) { - // Get the other child - EList children = getChildren(); - AbstractPanel otherChild = (childToDelete == children.get(0) ? children.get(1) : children.get(0)); - - PanelParent parent = getParent(); - // Change parent - // otherChild.setParent( parent ); - parent.replaceChild(this, otherChild); - } - - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch(featureID) { - case DiPackage.SASH_PANEL__CHILDREN: - return ((InternalEList)(InternalEList)getChildren()).basicAdd(otherEnd, msgs); - } - return super.eInverseAdd(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch(featureID) { - case DiPackage.SASH_PANEL__CHILDREN: - return ((InternalEList)getChildren()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch(featureID) { - case DiPackage.SASH_PANEL__CHILDREN: - return getChildren(); - case DiPackage.SASH_PANEL__SASH_POSITION: - return getSashPosition(); - case DiPackage.SASH_PANEL__DIRECTION: - return getDirection(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch(featureID) { - case DiPackage.SASH_PANEL__CHILDREN: - getChildren().clear(); - getChildren().addAll((Collection)newValue); - return; - case DiPackage.SASH_PANEL__SASH_POSITION: - setSashPosition((Float)newValue); - return; - case DiPackage.SASH_PANEL__DIRECTION: - setDirection((Integer)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch(featureID) { - case DiPackage.SASH_PANEL__CHILDREN: - getChildren().clear(); - return; - case DiPackage.SASH_PANEL__SASH_POSITION: - setSashPosition(SASH_POSITION_EDEFAULT); - return; - case DiPackage.SASH_PANEL__DIRECTION: - setDirection(DIRECTION_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch(featureID) { - case DiPackage.SASH_PANEL__CHILDREN: - return children != null && !children.isEmpty(); - case DiPackage.SASH_PANEL__SASH_POSITION: - return sashPosition != SASH_POSITION_EDEFAULT; - case DiPackage.SASH_PANEL__DIRECTION: - return direction != DIRECTION_EDEFAULT; - } - return super.eIsSet(featureID); - } - - /** - * - * - * @generated - */ - @Override - public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) { - if(baseClass == PanelParent.class) { - switch(derivedFeatureID) { - case DiPackage.SASH_PANEL__CHILDREN: - return DiPackage.PANEL_PARENT__CHILDREN; - default: - return -1; - } - } - return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); - } - - /** - * - * - * @generated - */ - @Override - public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) { - if(baseClass == PanelParent.class) { - switch(baseFeatureID) { - case DiPackage.PANEL_PARENT__CHILDREN: - return DiPackage.SASH_PANEL__CHILDREN; - default: - return -1; - } - } - return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); - } - - /** - * - * - * @generated - */ - @Override - public String toString() { - if(eIsProxy()) - return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (sashPosition: "); - result.append(sashPosition); - result.append(", direction: "); - result.append(direction); - result.append(')'); - return result.toString(); - } - - /** - * Set both ends (parent and child). - * - * @generated NOT - */ - public void replaceChild(AbstractPanel oldChild, AbstractPanel newChild) { - - int index = getChildren().indexOf(oldChild); - if(index >= 0) { - // do replace - getChildren().set(index, newChild); - newChild.setParent(this); - } else - throw new IndexOutOfBoundsException("Child '" + oldChild + "' not found in sash. Can't replace it."); - } - -} // SashPanelImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SashWindowsMngrImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SashWindowsMngrImpl.java deleted file mode 100644 index 5eab0b6166e..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SashWindowsMngrImpl.java +++ /dev/null @@ -1,253 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PageList; -import org.eclipse.papyrus.sashwindows.di.SashModel; -import org.eclipse.papyrus.sashwindows.di.SashWindowsMngr; - -/** - * An implementation of the model object ' Sash Windows Mngr'. - *

- * The following features are implemented: - *

    - *
  • - * {@link org.eclipse.papyrus.sashwindows.di.impl.SashWindowsMngrImpl#getPageList - * Page List}
  • - *
  • - * {@link org.eclipse.papyrus.sashwindows.di.impl.SashWindowsMngrImpl#getSashModel - * Sash Model}
  • - *
- *

- * - * @generated - */ -public class SashWindowsMngrImpl extends EObjectImpl implements SashWindowsMngr { - - /** - * The cached value of the '{@link #getPageList() Page List}' - * containment reference. - * - * @see #getPageList() - * @generated - * @ordered - */ - protected PageList pageList; - - /** - * The cached value of the '{@link #getSashModel() Sash Model}' - * containment reference. - * - * @see #getSashModel() - * @generated - * @ordered - */ - protected SashModel sashModel; - - /** - * - * - * @generated - */ - protected SashWindowsMngrImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return DiPackage.Literals.SASH_WINDOWS_MNGR; - } - - /** - * - * - * @generated - */ - public PageList getPageList() { - return pageList; - } - - /** - * - * - * @generated - */ - public NotificationChain basicSetPageList(PageList newPageList, NotificationChain msgs) { - PageList oldPageList = pageList; - pageList = newPageList; - if(eNotificationRequired()) { - ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST, oldPageList, newPageList); - if(msgs == null) - msgs = notification; - else - msgs.add(notification); - } - return msgs; - } - - /** - * - * - * @generated - */ - public void setPageList(PageList newPageList) { - if(newPageList != pageList) { - NotificationChain msgs = null; - if(pageList != null) - msgs = ((InternalEObject)pageList).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST, null, msgs); - if(newPageList != null) - msgs = ((InternalEObject)newPageList).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST, null, msgs); - msgs = basicSetPageList(newPageList, msgs); - if(msgs != null) - msgs.dispatch(); - } else if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST, newPageList, newPageList)); - } - - /** - * - * - * @generated - */ - public SashModel getSashModel() { - return sashModel; - } - - /** - * - * - * @generated - */ - public NotificationChain basicSetSashModel(SashModel newSashModel, NotificationChain msgs) { - SashModel oldSashModel = sashModel; - sashModel = newSashModel; - if(eNotificationRequired()) { - ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL, oldSashModel, newSashModel); - if(msgs == null) - msgs = notification; - else - msgs.add(notification); - } - return msgs; - } - - /** - * - * - * @generated - */ - public void setSashModel(SashModel newSashModel) { - if(newSashModel != sashModel) { - NotificationChain msgs = null; - if(sashModel != null) - msgs = ((InternalEObject)sashModel).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL, null, msgs); - if(newSashModel != null) - msgs = ((InternalEObject)newSashModel).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL, null, msgs); - msgs = basicSetSashModel(newSashModel, msgs); - if(msgs != null) - msgs.dispatch(); - } else if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL, newSashModel, newSashModel)); - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch(featureID) { - case DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST: - return basicSetPageList(null, msgs); - case DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL: - return basicSetSashModel(null, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch(featureID) { - case DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST: - return getPageList(); - case DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL: - return getSashModel(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch(featureID) { - case DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST: - setPageList((PageList)newValue); - return; - case DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL: - setSashModel((SashModel)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch(featureID) { - case DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST: - setPageList((PageList)null); - return; - case DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL: - setSashModel((SashModel)null); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch(featureID) { - case DiPackage.SASH_WINDOWS_MNGR__PAGE_LIST: - return pageList != null; - case DiPackage.SASH_WINDOWS_MNGR__SASH_MODEL: - return sashModel != null; - } - return super.eIsSet(featureID); - } - -} // SashWindowsMngrImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SizeImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SizeImpl.java deleted file mode 100644 index c9f21d134b5..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/SizeImpl.java +++ /dev/null @@ -1,218 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.Size; - -/** - * An implementation of the model object ' Size'. - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.SizeImpl#getWidth Width}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.SizeImpl#getLength Length}
  • - *
- *

- * - * @generated - */ -public class SizeImpl extends EObjectImpl implements Size { - - /** - * The default value of the '{@link #getWidth() Width}' attribute. - * - * - * @see #getWidth() - * @generated - * @ordered - */ - protected static final int WIDTH_EDEFAULT = 0; - - /** - * The cached value of the '{@link #getWidth() Width}' attribute. - * - * - * @see #getWidth() - * @generated - * @ordered - */ - protected int width = WIDTH_EDEFAULT; - - /** - * The default value of the '{@link #getLength() Length}' - * attribute. - * - * @see #getLength() - * @generated - * @ordered - */ - protected static final int LENGTH_EDEFAULT = 0; - - /** - * The cached value of the '{@link #getLength() Length}' attribute. - * - * - * @see #getLength() - * @generated - * @ordered - */ - protected int length = LENGTH_EDEFAULT; - - /** - * - * - * @generated - */ - protected SizeImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return DiPackage.Literals.SIZE; - } - - /** - * - * - * @generated - */ - public int getWidth() { - return width; - } - - /** - * - * - * @generated - */ - public void setWidth(int newWidth) { - int oldWidth = width; - width = newWidth; - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.SIZE__WIDTH, oldWidth, width)); - } - - /** - * - * - * @generated - */ - public int getLength() { - return length; - } - - /** - * - * - * @generated - */ - public void setLength(int newLength) { - int oldLength = length; - length = newLength; - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.SIZE__LENGTH, oldLength, length)); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch(featureID) { - case DiPackage.SIZE__WIDTH: - return getWidth(); - case DiPackage.SIZE__LENGTH: - return getLength(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch(featureID) { - case DiPackage.SIZE__WIDTH: - setWidth((Integer)newValue); - return; - case DiPackage.SIZE__LENGTH: - setLength((Integer)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch(featureID) { - case DiPackage.SIZE__WIDTH: - setWidth(WIDTH_EDEFAULT); - return; - case DiPackage.SIZE__LENGTH: - setLength(LENGTH_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch(featureID) { - case DiPackage.SIZE__WIDTH: - return width != WIDTH_EDEFAULT; - case DiPackage.SIZE__LENGTH: - return length != LENGTH_EDEFAULT; - } - return super.eIsSet(featureID); - } - - /** - * - * - * @generated - */ - @Override - public String toString() { - if(eIsProxy()) - return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (width: "); - result.append(width); - result.append(", length: "); - result.append(length); - result.append(')'); - return result.toString(); - } - -} // SizeImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/TabFolderImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/TabFolderImpl.java deleted file mode 100644 index d34ae761bd8..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/TabFolderImpl.java +++ /dev/null @@ -1,212 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.impl; - -import java.util.Collection; - -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.papyrus.sashwindows.di.DiFactory; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.papyrus.sashwindows.di.TabFolder; - -/** - * An implementation of the model object ' Tab Folder'. - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.TabFolderImpl#getChildren - * Children}
  • - *
- *

- * - * @generated - */ -public class TabFolderImpl extends AbstractPanelImpl implements TabFolder { - - /** - * The cached value of the '{@link #getChildren() Children}' - * containment reference list. - * - * @see #getChildren() - * @generated - * @ordered - */ - protected EList children; - - /** - * - * - * @generated - */ - protected TabFolderImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return DiPackage.Literals.TAB_FOLDER; - } - - /** - * - * - * @generated - */ - public EList getChildren() { - if(children == null) { - children = new EObjectContainmentWithInverseEList(PageRef.class, this, DiPackage.TAB_FOLDER__CHILDREN, DiPackage.PAGE_REF__PARENT); - } - return children; - } - - /** - * - * - * @generated NOT - */ - public void addPage(Object pageIdentifier) { - PageRef newPage = DiFactory.eINSTANCE.createPageRef(); - newPage.setPageIdentifier(pageIdentifier); - getChildren().add(newPage); - } - - /** - * - * - * @generated NOT - */ - public void removePage(int pageIndex) { - getChildren().remove(pageIndex); - } - - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch(featureID) { - case DiPackage.TAB_FOLDER__CHILDREN: - return ((InternalEList)(InternalEList)getChildren()).basicAdd(otherEnd, msgs); - } - return super.eInverseAdd(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch(featureID) { - case DiPackage.TAB_FOLDER__CHILDREN: - return ((InternalEList)getChildren()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch(featureID) { - case DiPackage.TAB_FOLDER__CHILDREN: - return getChildren(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch(featureID) { - case DiPackage.TAB_FOLDER__CHILDREN: - getChildren().clear(); - getChildren().addAll((Collection)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch(featureID) { - case DiPackage.TAB_FOLDER__CHILDREN: - getChildren().clear(); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch(featureID) { - case DiPackage.TAB_FOLDER__CHILDREN: - return children != null && !children.isEmpty(); - } - return super.eIsSet(featureID); - } - - /** - * - * @see org.eclipse.papyrus.sashwindows.di.TabFolder#movePage(int, int) - * - * @param oldIndex - * @param newIndex - * @generated NOT - */ - public void movePage(int oldIndex, int newIndex) { - int listSize = getChildren().size(); - if(newIndex >= listSize) { - newIndex = listSize - 1; - } - if(newIndex < 0) { - newIndex = 0; - } - - if(oldIndex == newIndex) - return; - - if(listSize == 0) - return; - - getChildren().move(newIndex, oldIndex); - } - -} // TabFolderImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/WindowImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/WindowImpl.java deleted file mode 100644 index facc3f33e50..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/impl/WindowImpl.java +++ /dev/null @@ -1,280 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.papyrus.sashwindows.di.AbstractPanel; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.Position; -import org.eclipse.papyrus.sashwindows.di.Size; -import org.eclipse.papyrus.sashwindows.di.Window; - -/** - * An implementation of the model object ' Window'. - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.WindowImpl#getPosition - * Position}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.WindowImpl#getSize Size}
  • - *
  • {@link org.eclipse.papyrus.sashwindows.di.impl.WindowImpl#getPanel Panel}
  • - *
- *

- * - * @generated - */ -public class WindowImpl extends PanelParentImpl implements Window { - - /** - * The cached value of the '{@link #getPosition() Position}' - * reference. - * - * @see #getPosition() - * @generated - * @ordered - */ - protected Position position; - - /** - * The cached value of the '{@link #getSize() Size}' reference. - * - * - * @see #getSize() - * @generated - * @ordered - */ - protected Size size; - - /** - * - * - * @generated - */ - protected WindowImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return DiPackage.Literals.WINDOW; - } - - /** - * - * - * @generated - */ - public Position getPosition() { - if(position != null && position.eIsProxy()) { - InternalEObject oldPosition = (InternalEObject)position; - position = (Position)eResolveProxy(oldPosition); - if(position != oldPosition) { - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.RESOLVE, DiPackage.WINDOW__POSITION, oldPosition, position)); - } - } - return position; - } - - /** - * - * - * @generated - */ - public Position basicGetPosition() { - return position; - } - - /** - * - * - * @generated - */ - public void setPosition(Position newPosition) { - Position oldPosition = position; - position = newPosition; - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.WINDOW__POSITION, oldPosition, position)); - } - - /** - * - * - * @generated - */ - public Size getSize() { - if(size != null && size.eIsProxy()) { - InternalEObject oldSize = (InternalEObject)size; - size = (Size)eResolveProxy(oldSize); - if(size != oldSize) { - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.RESOLVE, DiPackage.WINDOW__SIZE, oldSize, size)); - } - } - return size; - } - - /** - * - * - * @generated - */ - public Size basicGetSize() { - return size; - } - - /** - * - * - * @generated - */ - public void setSize(Size newSize) { - Size oldSize = size; - size = newSize; - if(eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, DiPackage.WINDOW__SIZE, oldSize, size)); - } - - /** - * - * - * @generated - */ - public AbstractPanel getPanel() { - AbstractPanel panel = basicGetPanel(); - return panel != null && panel.eIsProxy() ? (AbstractPanel)eResolveProxy((InternalEObject)panel) : panel; - } - - /** - * - * - * @generated NOT - */ - public AbstractPanel basicGetPanel() { - EList list = getChildren(); - if(list.size() > 0) - return list.get(0); - else - return null; - } - - /** - * - * - * @generated NOT - */ - public void setPanel(AbstractPanel newPanel) { - EList list = getChildren(); - if(list.size() > 0) - list.set(0, newPanel); - else - list.add(newPanel); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch(featureID) { - case DiPackage.WINDOW__POSITION: - if(resolve) - return getPosition(); - return basicGetPosition(); - case DiPackage.WINDOW__SIZE: - if(resolve) - return getSize(); - return basicGetSize(); - case DiPackage.WINDOW__PANEL: - if(resolve) - return getPanel(); - return basicGetPanel(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch(featureID) { - case DiPackage.WINDOW__POSITION: - setPosition((Position)newValue); - return; - case DiPackage.WINDOW__SIZE: - setSize((Size)newValue); - return; - case DiPackage.WINDOW__PANEL: - setPanel((AbstractPanel)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch(featureID) { - case DiPackage.WINDOW__POSITION: - setPosition((Position)null); - return; - case DiPackage.WINDOW__SIZE: - setSize((Size)null); - return; - case DiPackage.WINDOW__PANEL: - setPanel((AbstractPanel)null); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch(featureID) { - case DiPackage.WINDOW__POSITION: - return position != null; - case DiPackage.WINDOW__SIZE: - return size != null; - case DiPackage.WINDOW__PANEL: - return basicGetPanel() != null; - } - return super.eIsSet(featureID); - } - - /** - * - * - * @generated NOT - */ - public void replaceChild(AbstractPanel oldChild, AbstractPanel newChild) { - setPanel(newChild); - } - -} // WindowImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiAdapterFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiAdapterFactory.java deleted file mode 100644 index dfbc7aa800d..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiAdapterFactory.java +++ /dev/null @@ -1,347 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.util; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.papyrus.sashwindows.di.AbstractPage; -import org.eclipse.papyrus.sashwindows.di.AbstractPanel; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PageList; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.papyrus.sashwindows.di.PanelParent; -import org.eclipse.papyrus.sashwindows.di.Position; -import org.eclipse.papyrus.sashwindows.di.SashModel; -import org.eclipse.papyrus.sashwindows.di.SashPanel; -import org.eclipse.papyrus.sashwindows.di.SashWindowsMngr; -import org.eclipse.papyrus.sashwindows.di.Size; -import org.eclipse.papyrus.sashwindows.di.TabFolder; -import org.eclipse.papyrus.sashwindows.di.Window; - -/** - * The Adapter Factory for the model. It provides - * an adapter createXXX method for each class of the model. - * - * @see org.eclipse.papyrus.sashwindows.di.DiPackage - * @generated - */ -public class DiAdapterFactory extends AdapterFactoryImpl { - - /** - * The cached model package. - * - * @generated - */ - protected static DiPackage modelPackage; - - /** - * Creates an instance of the adapter factory. - * - * @generated - */ - public DiAdapterFactory() { - if(modelPackage == null) { - modelPackage = DiPackage.eINSTANCE; - } - } - - /** - * Returns whether this factory is applicable for the type of the object. - * This implementation returns true if - * the object is either the model's package or is an instance object of the - * model. - * - * @return whether this factory is applicable for the type of the object. - * @generated - */ - @Override - public boolean isFactoryForType(Object object) { - if(object == modelPackage) { - return true; - } - if(object instanceof EObject) { - return ((EObject)object).eClass().getEPackage() == modelPackage; - } - return false; - } - - /** - * The switch that delegates to the createXXX methods. - * - * @generated - */ - protected DiSwitch modelSwitch = new DiSwitch() { - - @Override - public Adapter caseSashModel(SashModel object) { - return createSashModelAdapter(); - } - - @Override - public Adapter caseWindow(Window object) { - return createWindowAdapter(); - } - - @Override - public Adapter casePanelParent(PanelParent object) { - return createPanelParentAdapter(); - } - - @Override - public Adapter caseAbstractPanel(AbstractPanel object) { - return createAbstractPanelAdapter(); - } - - @Override - public Adapter casePosition(Position object) { - return createPositionAdapter(); - } - - @Override - public Adapter caseSize(Size object) { - return createSizeAdapter(); - } - - @Override - public Adapter caseTabFolder(TabFolder object) { - return createTabFolderAdapter(); - } - - @Override - public Adapter casePageRef(PageRef object) { - return createPageRefAdapter(); - } - - @Override - public Adapter caseSashPanel(SashPanel object) { - return createSashPanelAdapter(); - } - - @Override - public Adapter caseAbstractPage(AbstractPage object) { - return createAbstractPageAdapter(); - } - - @Override - public Adapter casePageList(PageList object) { - return createPageListAdapter(); - } - - @Override - public Adapter caseSashWindowsMngr(SashWindowsMngr object) { - return createSashWindowsMngrAdapter(); - } - - @Override - public Adapter defaultCase(EObject object) { - return createEObjectAdapter(); - } - }; - - /** - * Creates an adapter for the target. - * - * - * @param target - * the object to adapt. - * @return the adapter for the target. - * @generated - */ - @Override - public Adapter createAdapter(Notifier target) { - return modelSwitch.doSwitch((EObject)target); - } - - /** - * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.sashwindows.di.SashModel Sash Model} '. This default implementation returns null so - * that we can easily ignore cases; it's useful to ignore a case when - * inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.sashwindows.di.SashModel - * @generated - */ - public Adapter createSashModelAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.sashwindows.di.Window Window}'. This default implementation returns null so that we - * can easily ignore cases; it's useful to ignore a case when inheritance - * will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.sashwindows.di.Window - * @generated - */ - public Adapter createWindowAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.sashwindows.di.PanelParent - * Panel Parent}'. This default - * implementation returns null so that we can easily ignore cases; it's - * useful to ignore a case when inheritance will catch all the cases anyway. - * - * - * @return the new adapter. - * @see org.eclipse.papyrus.sashwindows.di.PanelParent - * @generated - */ - public Adapter createPanelParentAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.sashwindows.di.AbstractPanel - * Abstract Panel}'. This default - * implementation returns null so that we can easily ignore cases; it's - * useful to ignore a case when inheritance will catch all the cases anyway. - * - * - * @return the new adapter. - * @see org.eclipse.papyrus.sashwindows.di.AbstractPanel - * @generated - */ - public Adapter createAbstractPanelAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.sashwindows.di.Position Position}'. - * This default implementation returns null so that - * we can easily ignore cases; it's useful to ignore a case when inheritance - * will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.sashwindows.di.Position - * @generated - */ - public Adapter createPositionAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.sashwindows.di.Size Size}'. This default implementation returns null so that we - * can easily ignore cases; it's useful to ignore a case when inheritance - * will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.sashwindows.di.Size - * @generated - */ - public Adapter createSizeAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.sashwindows.di.TabFolder Tab Folder} '. This default implementation returns null so - * that we can easily ignore cases; it's useful to ignore a case when - * inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.sashwindows.di.TabFolder - * @generated - */ - public Adapter createTabFolderAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.sashwindows.di.PageRef Page Ref}'. - * This default implementation returns null so that - * we can easily ignore cases; it's useful to ignore a case when inheritance - * will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.sashwindows.di.PageRef - * @generated - */ - public Adapter createPageRefAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.sashwindows.di.SashPanel Sash Panel} '. This default implementation returns null so - * that we can easily ignore cases; it's useful to ignore a case when - * inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.sashwindows.di.SashPanel - * @generated - */ - public Adapter createSashPanelAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.sashwindows.di.AbstractPage - * Abstract Page}'. This default - * implementation returns null so that we can easily ignore cases; it's - * useful to ignore a case when inheritance will catch all the cases anyway. - * - * - * @return the new adapter. - * @see org.eclipse.papyrus.sashwindows.di.AbstractPage - * @generated - */ - public Adapter createAbstractPageAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.sashwindows.di.PageList Page List}'. - * This default implementation returns null so that - * we can easily ignore cases; it's useful to ignore a case when inheritance - * will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.sashwindows.di.PageList - * @generated - */ - public Adapter createPageListAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.sashwindows.di.SashWindowsMngr - * Sash Windows Mngr}'. This default - * implementation returns null so that we can easily ignore cases; it's - * useful to ignore a case when inheritance will catch all the cases anyway. - * - * - * @return the new adapter. - * @see org.eclipse.papyrus.sashwindows.di.SashWindowsMngr - * @generated - */ - public Adapter createSashWindowsMngrAdapter() { - return null; - } - - /** - * Creates a new adapter for the default case. This - * default implementation returns null. - * - * @return the new adapter. - * @generated - */ - public Adapter createEObjectAdapter() { - return null; - } - -} // DiAdapterFactory diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiResourceFactoryImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiResourceFactoryImpl.java deleted file mode 100644 index 6c5a9f534ad..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiResourceFactoryImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.util; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.resource.Resource; - -import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; - -import org.eclipse.emf.ecore.xmi.XMLResource; - -/** - * The Resource Factory associated with the - * package. - * - * @see org.eclipse.papyrus.sashwindows.di.util.DiResourceImpl - * @generated - */ -public class DiResourceFactoryImpl extends ResourceFactoryImpl { - - /** - * Creates an instance of the resource factory. - * - * @generated - */ - public DiResourceFactoryImpl() { - super(); - } - - /** - * Creates an instance of the resource. - * - * @generated - */ - @Override - public Resource createResource(URI uri) { - XMLResource result = new DiResourceImpl(uri); - return result; - } - -} // DiResourceFactoryImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiResourceImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiResourceImpl.java deleted file mode 100644 index 82185bd6c72..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiResourceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.util; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; - -/** - * The Resource associated with the package. - * - * - * @see org.eclipse.papyrus.sashwindows.di.util.DiResourceFactoryImpl - * @generated - */ -public class DiResourceImpl extends XMIResourceImpl { - - /** - * Creates an instance of the resource. - * - * @param uri - * the URI of the new resource. - * @generated - */ - public DiResourceImpl(URI uri) { - super(uri); - } - -} // DiResourceImpl diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiSwitch.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiSwitch.java deleted file mode 100644 index a3d1b247220..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiSwitch.java +++ /dev/null @@ -1,401 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.sashwindows.di.util; - -import java.util.List; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.papyrus.sashwindows.di.AbstractPage; -import org.eclipse.papyrus.sashwindows.di.AbstractPanel; -import org.eclipse.papyrus.sashwindows.di.DiPackage; -import org.eclipse.papyrus.sashwindows.di.PageList; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.papyrus.sashwindows.di.PanelParent; -import org.eclipse.papyrus.sashwindows.di.Position; -import org.eclipse.papyrus.sashwindows.di.SashModel; -import org.eclipse.papyrus.sashwindows.di.SashPanel; -import org.eclipse.papyrus.sashwindows.di.SashWindowsMngr; -import org.eclipse.papyrus.sashwindows.di.Size; -import org.eclipse.papyrus.sashwindows.di.TabFolder; -import org.eclipse.papyrus.sashwindows.di.Window; - -/** - * The Switch for the model's inheritance - * hierarchy. It supports the call {@link #doSwitch(EObject) doSwitch(object)} to invoke the caseXXX method for each class of the model, - * starting with the actual class of the object and proceeding up the - * inheritance hierarchy until a non-null result is returned, which is the - * result of the switch. - * - * @see org.eclipse.papyrus.sashwindows.di.DiPackage - * @generated - */ -public class DiSwitch { - - /** - * The cached model package - * - * @generated - */ - protected static DiPackage modelPackage; - - /** - * Creates an instance of the switch. - * - * @generated - */ - public DiSwitch() { - if(modelPackage == null) { - modelPackage = DiPackage.eINSTANCE; - } - } - - /** - * Calls caseXXX for each class of the model until one returns - * a non null result; it yields that result. - * - * @return the first non-null result returned by a caseXXX call. - * @generated - */ - public T doSwitch(EObject theEObject) { - return doSwitch(theEObject.eClass(), theEObject); - } - - /** - * Calls caseXXX for each class of the model until one returns - * a non null result; it yields that result. - * - * @return the first non-null result returned by a caseXXX call. - * @generated - */ - protected T doSwitch(EClass theEClass, EObject theEObject) { - if(theEClass.eContainer() == modelPackage) { - return doSwitch(theEClass.getClassifierID(), theEObject); - } else { - List eSuperTypes = theEClass.getESuperTypes(); - return eSuperTypes.isEmpty() ? defaultCase(theEObject) : doSwitch(eSuperTypes.get(0), theEObject); - } - } - - /** - * Calls caseXXX for each class of the model until one returns - * a non null result; it yields that result. - * - * @return the first non-null result returned by a caseXXX call. - * @generated - */ - protected T doSwitch(int classifierID, EObject theEObject) { - switch(classifierID) { - case DiPackage.SASH_MODEL: - { - SashModel sashModel = (SashModel)theEObject; - T result = caseSashModel(sashModel); - if(result == null) - result = defaultCase(theEObject); - return result; - } - case DiPackage.WINDOW: - { - Window window = (Window)theEObject; - T result = caseWindow(window); - if(result == null) - result = casePanelParent(window); - if(result == null) - result = defaultCase(theEObject); - return result; - } - case DiPackage.PANEL_PARENT: - { - PanelParent panelParent = (PanelParent)theEObject; - T result = casePanelParent(panelParent); - if(result == null) - result = defaultCase(theEObject); - return result; - } - case DiPackage.ABSTRACT_PANEL: - { - AbstractPanel abstractPanel = (AbstractPanel)theEObject; - T result = caseAbstractPanel(abstractPanel); - if(result == null) - result = defaultCase(theEObject); - return result; - } - case DiPackage.POSITION: - { - Position position = (Position)theEObject; - T result = casePosition(position); - if(result == null) - result = defaultCase(theEObject); - return result; - } - case DiPackage.SIZE: - { - Size size = (Size)theEObject; - T result = caseSize(size); - if(result == null) - result = defaultCase(theEObject); - return result; - } - case DiPackage.TAB_FOLDER: - { - TabFolder tabFolder = (TabFolder)theEObject; - T result = caseTabFolder(tabFolder); - if(result == null) - result = caseAbstractPanel(tabFolder); - if(result == null) - result = defaultCase(theEObject); - return result; - } - case DiPackage.PAGE_REF: - { - PageRef pageRef = (PageRef)theEObject; - T result = casePageRef(pageRef); - if(result == null) - result = defaultCase(theEObject); - return result; - } - case DiPackage.SASH_PANEL: - { - SashPanel sashPanel = (SashPanel)theEObject; - T result = caseSashPanel(sashPanel); - if(result == null) - result = caseAbstractPanel(sashPanel); - if(result == null) - result = casePanelParent(sashPanel); - if(result == null) - result = defaultCase(theEObject); - return result; - } - case DiPackage.ABSTRACT_PAGE: - { - AbstractPage abstractPage = (AbstractPage)theEObject; - T result = caseAbstractPage(abstractPage); - if(result == null) - result = defaultCase(theEObject); - return result; - } - case DiPackage.PAGE_LIST: - { - PageList pageList = (PageList)theEObject; - T result = casePageList(pageList); - if(result == null) - result = defaultCase(theEObject); - return result; - } - case DiPackage.SASH_WINDOWS_MNGR: - { - SashWindowsMngr sashWindowsMngr = (SashWindowsMngr)theEObject; - T result = caseSashWindowsMngr(sashWindowsMngr); - if(result == null) - result = defaultCase(theEObject); - return result; - } - default: - return defaultCase(theEObject); - } - } - - /** - * Returns the result of interpreting the object as an instance of ' Sash Model'. This implementation returns - * null; returning a non-null result will terminate the switch. - * - * @param object - * the target of the switch. - * @return the result of interpreting the object as an instance of ' Sash Model'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseSashModel(SashModel object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of ' Window'. This implementation returns - * null; returning a non-null result will terminate the switch. - * - * @param object - * the target of the switch. - * @return the result of interpreting the object as an instance of ' Window'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseWindow(Window object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of ' Panel Parent'. This implementation - * returns null; returning a non-null result will terminate the switch. - * - * @param object - * the target of the switch. - * @return the result of interpreting the object as an instance of ' Panel Parent'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T casePanelParent(PanelParent object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of ' Abstract Panel'. This implementation - * returns null; returning a non-null result will terminate the switch. - * - * @param object - * the target of the switch. - * @return the result of interpreting the object as an instance of ' Abstract Panel'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseAbstractPanel(AbstractPanel object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of ' Position'. This implementation returns - * null; returning a non-null result will terminate the switch. - * - * @param object - * the target of the switch. - * @return the result of interpreting the object as an instance of ' Position'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T casePosition(Position object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of ' Size'. This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object - * the target of the switch. - * @return the result of interpreting the object as an instance of ' Size'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseSize(Size object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of ' Tab Folder'. This implementation returns - * null; returning a non-null result will terminate the switch. - * - * @param object - * the target of the switch. - * @return the result of interpreting the object as an instance of ' Tab Folder'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseTabFolder(TabFolder object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of ' Page Ref'. This implementation returns - * null; returning a non-null result will terminate the switch. - * - * @param object - * the target of the switch. - * @return the result of interpreting the object as an instance of ' Page Ref'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T casePageRef(PageRef object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of ' Sash Panel'. This implementation returns - * null; returning a non-null result will terminate the switch. - * - * @param object - * the target of the switch. - * @return the result of interpreting the object as an instance of ' Sash Panel'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseSashPanel(SashPanel object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of ' Abstract Page'. This implementation - * returns null; returning a non-null result will terminate the switch. - * - * @param object - * the target of the switch. - * @return the result of interpreting the object as an instance of ' Abstract Page'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseAbstractPage(AbstractPage object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of ' Page List'. This implementation returns - * null; returning a non-null result will terminate the switch. - * - * @param object - * the target of the switch. - * @return the result of interpreting the object as an instance of ' Page List'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T casePageList(PageList object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of ' Sash Windows Mngr'. This implementation - * returns null; returning a non-null result will terminate the switch. - * - * @param object - * the target of the switch. - * @return the result of interpreting the object as an instance of ' Sash Windows Mngr'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseSashWindowsMngr(SashWindowsMngr object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of ' EObject'. This implementation returns - * null; returning a non-null result will terminate the switch, but this is - * the last case anyway. - * - * @param object - * the target of the switch. - * @return the result of interpreting the object as an instance of ' EObject'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) - * @generated - */ - public T defaultCase(EObject object) { - return null; - } - -} // DiSwitch diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiUtils.java deleted file mode 100644 index 143152efdd5..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/src/org/eclipse/papyrus/sashwindows/di/util/DiUtils.java +++ /dev/null @@ -1,188 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * Emilien Perico emilien.perico@atosorigin.com - add methods to manage di resource - * - *****************************************************************************/ - -package org.eclipse.papyrus.sashwindows.di.util; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.papyrus.sashwindows.di.DiFactory; -import org.eclipse.papyrus.sashwindows.di.PageList; -import org.eclipse.papyrus.sashwindows.di.PageRef; -import org.eclipse.papyrus.sashwindows.di.SashModel; -import org.eclipse.papyrus.sashwindows.di.SashWindowsMngr; -import org.eclipse.papyrus.sashwindows.di.TabFolder; -import org.eclipse.papyrus.sashwindows.di.Window; -import org.eclipse.papyrus.sashwindows.di.exception.SashEditorException; - -/** - * Set of utility methods - * - * @author dumoulin - */ -public class DiUtils { - - /** - * Create a default SashModel with one window and one folder. Set the - * current folder. - * - * @param diResource - * @return - */ - static public SashModel createDefaultSashModel() { - - // SashModel - SashModel sashModel = DiFactory.eINSTANCE.createSashModel(); - Window window = DiFactory.eINSTANCE.createWindow(); - sashModel.getWindows().add(window); - - TabFolder folder = DiFactory.eINSTANCE.createTabFolder(); - window.setPanel(folder); - // Default folder - sashModel.setCurrentSelection(folder); - - return sashModel; - } - - /** - * Create a default SashWindowsMngr with one PageLit and one default - * SashModel. Set the current folder. - * - * @param diResource - * @return - */ - static public SashWindowsMngr createDefaultSashWindowsMngr() { - SashWindowsMngr model; - - model = DiFactory.eINSTANCE.createSashWindowsMngr(); - - // SashModel - SashModel layout = createDefaultSashModel(); - - model.setSashModel(layout); - - // PageList - PageList pageList = DiFactory.eINSTANCE.createPageList(); - model.setPageList(pageList); - return model; - } - - /** - * Lookup for the SashModel object in the resource. - * - * @param diResource - * @return The {@link DiSashModel} or null if not found. - */ - static public SashWindowsMngr lookupSashWindowsMngr(Resource diResource) { - - for(Object node : diResource.getContents()) { - if(node instanceof SashWindowsMngr) - return (SashWindowsMngr)node; - } - return null; - } - - /** - * Gets the page reference of the specified eObject - * - * @param diResource - * @param eObject - * - * @return the page ref of eObject, null if not found TODO This method use - * too low level mechanism for its implementation. Consider to move - * it in a more appropriate class. Furthermore, some similar methods - * already exist. Can't we use them instead ? - */ - static public PageRef getPageRef(Resource diResource, EObject eObject) { - SashWindowsMngr windowsMngr = lookupSashWindowsMngr(diResource); - if(windowsMngr != null && windowsMngr.getPageList() != null) { - - for(PageRef pageRef : windowsMngr.getPageList().getAvailablePage()) { - - EObject emfPageIdentifier = pageRef.getEmfPageIdentifier(); - if(eObject != null && eObject.equals(emfPageIdentifier)) { - return pageRef; - } - } - } - return null; - } - - /** - * Adds page to the page list of the sash windows manager - * - * @param diResource - * @param pageRef - * @throws SashEditorException - * TODO This method use too low level mechanism for its - * implementation. Consider to move it in a more appropriate - * class. Furthermore, some similar methods already exist. Can't - * we use them instead ? - */ - static public void addPageToPageList(Resource diResource, PageRef pageRef) throws SashEditorException { - SashWindowsMngr windowsMngr = lookupSashWindowsMngr(diResource); - addPageToPageList(windowsMngr, pageRef); - } - - /** - * Adds page to the page list of the sash windows manager. - * - * @param pageRef - * @param windowsMngr - * @throws SashEditorException - * TODO This method use too low level mechanism for its - * implementation. Consider to move it in a more appropriate - * class. Furthermore, some similar methods already exist. Can't - * we use them instead ? - */ - static public void addPageToPageList(SashWindowsMngr windowsMngr, PageRef pageRef) throws SashEditorException { - if(windowsMngr != null && windowsMngr.getPageList() != null) { - windowsMngr.getPageList().addPage(pageRef.getPageIdentifier()); - } else { - throw new SashEditorException("Unable to add the page to the windows manager"); - } - } - - /** - * Adds page to tab folder. - * - * @param windowsMngr - * @param pageRef - * @throws SashEditorException - * TODO This method use too low level mechanism for its - * implementation. Consider to move it in a more appropriate - * class. Furthermore, some similar methods already exist. Can't - * we use them instead ? - */ - static public void addPageToTabFolder(SashWindowsMngr windowsMngr, PageRef pageRef) throws SashEditorException { - - // Check parameters - if(pageRef == null || pageRef.getPageIdentifier() == null) - throw new SashEditorException("Unable to add the page to the tab folder: parameters are null"); - - SashModel sashModel = windowsMngr.getSashModel(); - if(sashModel == null) { - throw new SashEditorException("Unable to add the page to the tab folder: can't find SashModel"); - } - - // Get the currently active folder in order to add the page. - TabFolder tabFolder = sashModel.getCurrentSelection(); - if(tabFolder == null) { - throw new SashEditorException("Unable to add the page to the tab folder: No active folder"); - } - - tabFolder.addPage(pageRef.getPageIdentifier()); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/.project b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/.project index e063ebdd0ba..c456b7b004d 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/.project +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/.project @@ -1,6 +1,6 @@ - org.eclipse.papyrus.infra.sasheditor + org.eclipse.papyrus.infra.core.sasheditor diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/META-INF/MANIFEST.MF index 3fc38c15051..b44549d50b4 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/META-INF/MANIFEST.MF +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/META-INF/MANIFEST.MF @@ -1,11 +1,11 @@ Manifest-Version: 1.0 -Export-Package: org.eclipse.papyrus.sasheditor, - org.eclipse.papyrus.sasheditor.contentprovider, - org.eclipse.papyrus.sasheditor.contentprovider.simple, - org.eclipse.papyrus.sasheditor.editor, - org.eclipse.papyrus.sasheditor.editor.actionbarcontributor, - org.eclipse.papyrus.sasheditor.editor.gef, - org.eclipse.papyrus.sasheditor.multipage.editor +Export-Package: org.eclipse.papyrus.infra.core.sasheditor, + org.eclipse.papyrus.infra.core.sasheditor.contentprovider, + org.eclipse.papyrus.infra.core.sasheditor.contentprovider.simple, + org.eclipse.papyrus.infra.core.sasheditor.editor, + org.eclipse.papyrus.infra.core.sasheditor.editor.actionbarcontributor, + org.eclipse.papyrus.infra.core.sasheditor.editor.gef, + org.eclipse.papyrus.infra.core.sasheditor.multipage.editor Bundle-ActivationPolicy: lazy Bundle-ClassPath: . Bundle-Name: %pluginName @@ -19,6 +19,6 @@ Require-Bundle: org.eclipse.ui, Bundle-Vendor: %providerName Bundle-Version: 0.9.0.qualifier Bundle-ManifestVersion: 2 -Bundle-Activator: org.eclipse.papyrus.sasheditor.Activator -Bundle-SymbolicName: org.eclipse.papyrus.infra.sasheditor;singleton:=true +Bundle-Activator: org.eclipse.papyrus.infra.core.sasheditor.Activator +Bundle-SymbolicName: org.eclipse.papyrus.infra.core.sasheditor;singleton:=true diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/plugin.xml b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/plugin.xml index 7b37e3d36b8..1154f2335a6 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/plugin.xml +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/plugin.xml @@ -9,14 +9,14 @@ + class="org.eclipse.papyrus.infra.core.sasheditor.internal.preferences.TabTooltipPreferenceInitializer"> diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/schema/nestedEditor.exsd b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/schema/nestedEditor.exsd index da28e6dcb61..6f6270abade 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/schema/nestedEditor.exsd +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/schema/nestedEditor.exsd @@ -1,9 +1,9 @@ - + - + Define a nested editor descriptor. This descriptor is used to add instance of the described editor to a multi diagram editor. @@ -61,10 +61,10 @@ The factory used to create an instance of the editor. -The factory must implements org.eclipse.papyrus.sasheditor.extension.IEditorFactory +The factory must implements org.eclipse.papyrus.infra.core.sasheditor.extension.IEditorFactory - + @@ -128,7 +128,7 @@ The factory must implements org.eclipse.papyrus.sasheditor.extension.IEditorFact The action class implementing the creation of the root object. - + diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/Activator.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/Activator.java new file mode 100644 index 00000000000..8ccf67d7458 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/Activator.java @@ -0,0 +1,69 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor; + +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 + */ +public class Activator extends AbstractUIPlugin { + + /** Plugin ID */ + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.core.sasheditor"; + + /** shared instance of the plugin */ + private static Activator plugin; + + /** Logging helper */ + public static LogHelper log = new LogHelper(); + + /** + * The constructor + */ + public Activator() { + } + + /** + * {@inheritDoc} + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + // register the login helper + log.setPlugin(plugin); + } + + /** + * {@inheritDoc} + */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared eINSTANCE + * + * @return the shared eINSTANCE + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IAbstractPanelModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IAbstractPanelModel.java new file mode 100644 index 00000000000..09e99acb271 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IAbstractPanelModel.java @@ -0,0 +1,15 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; + +/** + * A Panel represent a SashPanel or a TabFolder. This interface is the common + * ancestor of the Panel models used in sash system. + * + * @author dumoulin + * + */ +public abstract interface IAbstractPanelModel { + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IComponentModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IComponentModel.java new file mode 100644 index 00000000000..cee689ab34d --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IComponentModel.java @@ -0,0 +1,25 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; + +import org.eclipse.swt.widgets.Composite; + +/** + * This model represent a ui Component to be shown in a sash window folder. + * + * @author dumoulin + * + */ +public interface IComponentModel extends IPageModel { + + /** + * Create the Control corresponding to this model. + * + * @param parent + * The parent of the created container. + * @return + */ + public Composite createPartControl(Composite parent); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedListener.java new file mode 100644 index 00000000000..aa94ebacea2 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedListener.java @@ -0,0 +1,79 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; + +/** + * Interface to be implemented by classes needing to be notified when the + * SashContent model has changed. This interface is not used by the + * sashesWindows itself. It exists to allows ContentProvider implementation to + * provide a common notification mechanism. + * + * @author dumoulin + */ +public interface IContentChangedListener { + + /** + * Event indicating the change. TODO The types are not set correctly from + * user like DI model. But anyway there aren't used by clients. + * + * @author dumoulin + */ + public class ContentEvent { + + public static final int ADDED = 0; + + public static final int REMOVED = 1; + + public static final int CHANGED = 2; + + public static final int MOVED = 3; + + /** type of event */ + private int type; + + /** model to which the event apply */ + private Object model; + + /** object added or removed or modified */ + private Object object; + + /** + * @param type + * @param model + * @param object + */ + public ContentEvent(int type, Object model, Object object) { + this.type = type; + this.model = model; + this.object = object; + } + + /** + * @return the type + */ + public int getType() { + return type; + } + + /** + * @return the model + */ + public Object getModel() { + return model; + } + + /** + * @return the object + */ + public Object getObject() { + return object; + } + + } + + /** + * Method called when the content has changed. + */ + public void contentChanged(ContentEvent event); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedProvider.java new file mode 100644 index 00000000000..f286b3afc54 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IContentChangedProvider.java @@ -0,0 +1,28 @@ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; + +/** + * Interface implemented by classes firing events when the ContentProvider + * content change. This interface can be used by client of ContentProvider. It + * is not use directly by the SashSystem. + * + * @author dumoulin + */ +public interface IContentChangedProvider { + + /** + * Add a listener listening on content changed. This listener will be + * notified each time the content change. + * + * @param listener + */ + public abstract void addListener(IContentChangedListener listener); + + /** + * Add a listener listening on content changed. This listener will be + * notified each time the content change. + * + * @param listener + */ + public abstract void removeListener(IContentChangedListener listener); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IEditorModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IEditorModel.java new file mode 100644 index 00000000000..d0af56907a0 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IEditorModel.java @@ -0,0 +1,44 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; + +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.part.EditorActionBarContributor; + +/** + * This model indicate that an Editor should be drawn in the sash window folder. + * + * @author dumoulin + * + */ +public interface IEditorModel extends IPageModel { + + /** + * Create the IEditor that should be shown. Editor life cycle methods are + * not called. + * + * @return A new instance of the IEditor. + */ + public IEditorPart createIEditorPart() throws PartInitException; + + /** + * Get the EditorActionBarContributor that should be associated with the + * editor . + * + * @return + */ + public EditorActionBarContributor getActionBarContributor(); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageMngr.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageMngr.java new file mode 100644 index 00000000000..0ff2e2607b5 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageMngr.java @@ -0,0 +1,141 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * Anass Radouani (Atos) - Add History management + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; + +import java.util.List; + +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener; +import org.eclipse.papyrus.infra.core.sasheditor.editor.SashContainerEventsListener; +import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; + +/** + * Interface providing method to manage pages in the Sash Windows system. This + * interface can be provided by ContentProvider whishing to provide a standard + * way to manage pages. This interface is not mandatory for the Sasheditor. This + * interface provide basic access to the Sash Windows system. It is intended to + * be used from the application in order to interact with the ContentProvider. + * Then, the {@link SashWindowsContainer} will refresh its views. + * + * + * @author dumoulin + */ +public interface IPageMngr extends IPageChangedListener, SashContainerEventsListener { + + /** + * Add a Page identifier to the list of pages, do not open it. + * + * @param page + * The object identifying the page to add. This object will be + * passed to the {@link IPageModelFactory#createIPageModel(EObject)}. This + * identifier is stored in the sash model. It should be a + * reference on a EMF object identifying the page. + */ + public void addPage(Object pageIdentifier); + + /** + * Remove the page from the SashWindows system and from the list of page. + * The page will not be available anymore. + * + * @param pageIdentifier + * The object identifying the page + */ + public void removePage(Object pageIdentifier); + + /** + * Close the page corresponding to the identifier. The identifier is removed + * from the Sash Windows, but not from the list of pages. + * + * @param pageIdentifier + * The object identifying the page + */ + public void closePage(Object pageIdentifier); + + /** + * Close all opened pages. + * + */ + public void closeAllOpenedPages(); + + /** + * Close all opened pages except the one provided as parameter. + * + * @param pageIdentifier + */ + public void closeOtherPages(Object pageIdentifier); + + /** + * Open a Page corresponding to the identifier. If the page is not in the + * list of pages, add it. The identifier is first added to the current + * folder model. Then the Sash Windows should react and ask the {@link IPageModelFactory} to create the IPageModel. This later is then + * used to create the SWT page. If + * + * @param page + * The object identifying the page to add. This object will be + * passed to the {@link IPageModelFactory#createIPageModel(EObject)}. This + * identifier is stored in the sash model. It should be a + * reference on a EMF object identifying the page. + */ + public void openPage(Object pageIdentifier); + + /** + * Return all available page identifiers (open and closed pages). + * + * @return List of registered page identifiers. + */ + public List allPages(); + + /** + * Return true if a page is open for the specified pageIdentifier. + * + * @param diagram + * @return + */ + public boolean isOpen(Object pageIdentifier); + + /** + * Open the previously opened page + */ + public void openPrevious(); + + /** + * Open the next page after a previous + */ + public void openNext(); + + /** + * Verify if the PageMngr car backward in history + * + * @return + */ + public boolean hasPreviousHistory(); + + /** + * Verify if the PageMngr car forward in history + * + * @return + */ + public boolean hasNextHistory(); + + /** + * add a page to PageMngr History + * + * @param pageIdentifier + * identifying the page to add + * @return + */ + public int isInHsitory(Object pageIdentifier); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageModel.java new file mode 100644 index 00000000000..98739beaf17 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageModel.java @@ -0,0 +1,41 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; + +import org.eclipse.swt.graphics.Image; + +/** + * This interface is the root of the hierarchy of models representing Pages. + * This represent the final element shown in the sashes window. It can be an + * Editor or a simple control. This interface is used by the sashes window to + * interact with the model describing the element to be shown in the TabItem. + * + * @author dumoulin + * + */ +public abstract interface IPageModel { + + /** + * Get the title to be shown in the tab + * + * @return + */ + public String getTabTitle(); + + /** + * Get the icon to be shown in the tab + * + * @return + */ + public Image getTabIcon(); + + /** + * Get the raw model corresponding to this node. This is the object provided + * to {@link ITabFolderModel.getChildren()} + * + * @return + */ + public Object getRawModel(); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashPanelModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashPanelModel.java new file mode 100644 index 00000000000..af353c760b8 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashPanelModel.java @@ -0,0 +1,38 @@ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; + +import java.util.List; + +/** + * A sash node contains two children separated by a sash. The sash can be moved, + * resizing the children. This interface is used to specify that a sash with two + * children should be drawn. + * + * @author dumoulin + * + */ +public interface ISashPanelModel extends IAbstractPanelModel { + + /** + * Get the list of children that should be displayed in the folder. + * + * @return + */ + public List getChildren(); + + /** + * Create the Interface used to access the real model. This method is called + * by the sashes window to get the interface. The method is called only once + * for a given object. + * + * @param child + * A child returned by getChildren(). + * @return + */ + public IAbstractPanelModel createChildSashModel(Object child); + + /** + * Get the sash direction. Can be SWT.VERTICAL or SWT.HORIZONTAL. + */ + public int getSashDirection(); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashWindowsContentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashWindowsContentProvider.java new file mode 100644 index 00000000000..eb8c17206b6 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ISashWindowsContentProvider.java @@ -0,0 +1,132 @@ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; + +/** + * This interface is used by the sash windows system to discover its content. It + * is considered as the root of the sash windows models. The sashsystem is able + * to retrieve all its content from this interface, and associated interfaces {@link ITabFolderModel}, {@link ISashPanelModel}, {@link IPageModel}. + * The + * interface is also used by the sashsystem to communicate, by sending event, + * with the effective implementation or upper level. + * + * @author dumoulin + * + */ +public interface ISashWindowsContentProvider { + + /** + * Get the root object shown in the sashes window. The type of the returned + * object is left to the implementation. The sashes window will ask for an + * interface used to interact with the object. In normal implementation, + * this method should return the model used by the implementation. + * + * @return The object representing the root of the sashes window. + */ + public Object getRootModel(); + + /** + * create the interface used by the sashes window to access the root model. + * This method is called by the sashes window to get the interface. The + * method is called only once for a given object. + * + * @param root + * @return The SashModel corresponding to the specified root object. + */ + public IAbstractPanelModel createChildSashModel(Object root); + + /** + * Add a page to the current TabFolder. The Page is added at the end of the + * tab list. + * + * @param page + * An object identifying the page to add. The object could be + * anything. It will be passed to the {@link ITabFolderModel#createChildSashModel(Object)} method. + */ + public void addPage(Object page); + + /** + * Add a page at the specified index of TabFolder. + * + * @param page + * An object identifying the page to add. The object could be + * anything. It will be passed to the {@link ITabFolderModel#createChildSashModel(Object)} method. + * @param index + * Index to where the tabItem should be added. + */ + public void addPage(Object page, int index); + + /** + * Move a tab inside the specified folder. + * + * @param model + * @param oldIndex + * @param newIndex + */ + public void movePage(ITabFolderModel folderModel, int oldIndex, int newIndex); + + /** + * Move a tab from folder to folder. + * + * @param model + * @param sourceIndex + * @param model2 + * @param targetIndex + */ + public void movePage(ITabFolderModel srcFolderModel, int sourceIndex, ITabFolderModel targetFolderModel, int targetIndex); + + /** + * Remove the page at the specified index of the current tabFolder + * + * @param index + */ + public void removePage(int index); + + /** + * Remove the page from the sashes window. Look for the folder containing + * the page. + * + * @param page + * The Object identifying the page. This is the object used in {@link #addPage(Object)}. + */ + public void removePage(Object page); + + /** + * Remove the specified page from the parentFolder. + * + * @param tabItem + */ + public void removePage(ITabFolderModel parentFolder, int tabIndex); + + /** + * Ask the model to move the specified tab to the specified side of the + * specified targetFolder. This method is called by the the + * SashTileContainer when the user have drag a tab in a correct place. The + * SashTileContainer has not change is presentation yet. This will be done + * when the corresponding event will occur. + * + * @param tabFolder + * The folder containing the tab to move + * @param tabIndex + * The index of the tab to move + * @param targetFolder + * The folder to which the side refer to + * @param side + * Side where node should be inserted : SWT.LEFT, SWT.RIGHT, + * SWT.TOP, SWT.DOWN. + */ + public void createFolder(ITabFolderModel tabFolder, int tabIndex, ITabFolderModel targetFolder, int side); + + /** + * Ask the model to keep trace of the Current Folder. The notion of Current + * Folder is used by {@link #addPage(Object)}. Calling this method should + * not fire a Change Event. + * + * This method is used by the SashSystem when the user select a new folder + * by clicking on one of the tabs. + * + * @param rawModel + * The Raw model identifying the folder. This is the same object + * as the one returned by {@link ISashPanelModel#getChildren()} when the child denote a folder. + */ + public void setCurrentFolder(Object rawModel); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ITabFolderModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ITabFolderModel.java new file mode 100644 index 00000000000..c1238b958f1 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/ITabFolderModel.java @@ -0,0 +1,34 @@ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider; + +import java.util.List; + +/** + * A folder containing tabItem. This interface is used to specify that a + * TabFolder should be drawn. + * + * @author dumoulin + * + * @param + * Type of the children of the folder. This is the type returned by + * getChildren(). + */ +public interface ITabFolderModel extends IAbstractPanelModel { + + /** + * Get the list of children that should be displayed in the folder. + * + * @return + */ + public List getChildren(); + + /** + * Create the Interface used to access the real model. This method is called + * by the sashes window to get the interface. The method is called only once + * for a given object. + * + * @param child + * A child returned by getChildren(). + * @return + */ + public IPageModel createChildSashModel(Object child); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractModel.java new file mode 100644 index 00000000000..ce6f2fcda62 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractModel.java @@ -0,0 +1,42 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider.simple; + +/** + * @author dumoulin + */ +public abstract class AbstractModel { + + /** + * Return the parent of the model. Can be null in the case of rootModel. + * + * @return the parent + */ + abstract public AbstractModel getParent(); + + /** + * @param parent + * the parent to set + */ + abstract public void setParent(AbstractModel parent); + + /** + * Replace the oldChild by the newChild + * + * @param oldChild + * @param newChild + */ + abstract public void replaceChild(AbstractPanelModel oldChild, AbstractPanelModel newChild); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractPanelModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractPanelModel.java new file mode 100644 index 00000000000..c9cb164e529 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/AbstractPanelModel.java @@ -0,0 +1,63 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider.simple; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; + +/** + * @author dumoulin + */ +public abstract class AbstractPanelModel extends AbstractModel implements IAbstractPanelModel { + + /** + * Parent of the model. Can be null in the case of rootModel. + */ + protected AbstractModel parent; + + /** + * Constructor. + * + * @param parent2 + */ + public AbstractPanelModel(AbstractModel parent) { + this.parent = parent; + } + + /** + * Return the parent of the model. Can be null in the case of rootModel. + * + * @return the parent + */ + public AbstractModel getParent() { + return parent; + } + + /** + * @param parent + * the parent to set + */ + public void setParent(AbstractModel parent) { + this.parent = parent; + } + + /** + * Lookup the folder containing the specified tabItem. + * + * @param tabItem + * @return + */ + abstract protected TabFolderModel lookupTabFolder(IPageModel tabItem); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/RootModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/RootModel.java new file mode 100644 index 00000000000..4fe1d8e97e4 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/RootModel.java @@ -0,0 +1,79 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider.simple; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; + +/** + * @author dumoulin + */ +public class RootModel extends AbstractModel { + + /** + * Child of this root model. + */ + private AbstractPanelModel child; + + /** + * Constructor. + * + * @param child + */ + public RootModel(AbstractPanelModel child) { + this.child = child; + child.setParent(this); + } + + /** + * Return the parent of the model. Can be null in the case of rootModel. + * + * @return the parent + */ + public AbstractModel getParent() { + return null; + } + + /** + * @param parent + * the parent to set + */ + public void setParent(AbstractModel parent) { + } + + /** + * Replace the actual child by the new child. + * + */ + public void replaceChild(AbstractPanelModel oldChild, AbstractPanelModel newChild) { + + assert (child == oldChild); + child = newChild; + + } + + /** + * Lookup the folder containing the specified tabItem. + * + * @param tabItem + * @return + */ + protected TabFolderModel lookupTabFolder(IPageModel tabItem) { + return child.lookupTabFolder(tabItem); + } + + protected AbstractPanelModel getChild() { + return child; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SashPanelModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SashPanelModel.java new file mode 100644 index 00000000000..e36ae91c710 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SashPanelModel.java @@ -0,0 +1,153 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider.simple; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel; + +/** + * Simple implementation of the {@link ISashPanelModel}. + * + * @author dumoulin + */ +public class SashPanelModel extends AbstractPanelModel implements ISashPanelModel { + + /** Ordered set of childs (a left and right child, or upper and lower) */ + protected AbstractPanelModel[] children = new AbstractPanelModel[2]; + + // The children array as a list + protected List childrenList = Arrays.asList(children); + + protected int sashDirection; + + /** + * @param children + * @param sashDirection + */ + public SashPanelModel(AbstractModel parent, AbstractPanelModel leftChild, AbstractPanelModel rightChild, int sashDirection) { + super(parent); + this.children[0] = leftChild; + this.children[1] = rightChild; + + this.sashDirection = sashDirection; + } + + /** + * Set the left child. + * + * @param child + */ + public void setLeftChild(AbstractPanelModel child) { + this.children[0] = child; + } + + /** + * Get the left child + * + * @return + */ + private AbstractPanelModel getLeftChild() { + return children[0]; + } + + /** + * Set the left child. + * + * @param child + */ + public void setRightChild(AbstractPanelModel child) { + this.children[1] = child; + } + + /** + * Get the right child + * + * @return + */ + private AbstractPanelModel getRightChild() { + return children[1]; + } + + /** + * Create the SashPanelModel from the raw model. In this implementation, the + * rawModel is the SashPanelModel. This default implementation return + * directly the child which is already of the appropriate type. + */ + public IAbstractPanelModel createChildSashModel(Object rawModel) { + return (IAbstractPanelModel)rawModel; + } + + /** + * {@inheritDoc} + */ + public List getChildren() { + return childrenList; + } + + /** + * Return the direction of the sash: + * + */ + public int getSashDirection() { + return sashDirection; + } + + /** + * Replace specified child with the new child. {@inheritDoc} + */ + public void replaceChild(AbstractPanelModel oldChild, AbstractPanelModel newChild) { + + if(getLeftChild() == oldChild) + setLeftChild(newChild); + else if(getRightChild() == oldChild) + setRightChild(newChild); + + } + + /** + * + * {@inheritDoc} + */ + @Override + protected TabFolderModel lookupTabFolder(IPageModel tabItem) { + TabFolderModel parent = getLeftChild().lookupTabFolder(tabItem); + if(parent != null) + return parent; + + return getRightChild().lookupTabFolder(tabItem); + } + + /** + * Delete the sashModel. The childToDelete is removed from the tree, bypass + * the sashnode : the other child parent is set to sashnode parent. + * + * @param tabFolder + */ + protected void delete(AbstractPanelModel childToDelete) { + + // Get the other child + AbstractPanelModel otherChild = (childToDelete == getLeftChild() ? getRightChild() : getLeftChild()); + + AbstractModel parent = getParent(); + // Change parent + otherChild.setParent(parent); + parent.replaceChild(this, otherChild); + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SimpleSashWindowsContentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SimpleSashWindowsContentProvider.java new file mode 100644 index 00000000000..d87ee839e65 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/SimpleSashWindowsContentProvider.java @@ -0,0 +1,500 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider.simple; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedListener; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedProvider; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedListener.ContentEvent; +import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; +import org.eclipse.swt.SWT; + +/** + * A simple implementation of providers allowing sashes and folders. The tabs + * can be added and removed. + * + * @author dumoulin + * + */ +public class SimpleSashWindowsContentProvider implements ISashWindowsContentProvider, IContentChangedProvider { + + /** The currently selected tab folder */ + private TabFolderModel currentTabFolder; + + /** The root model. */ + private RootModel rootModel; + + /** */ + private ContentChangeListenerManager contentChangedListenerManager = new ContentChangeListenerManager(); + + /** + * Constructor. + */ + public SimpleSashWindowsContentProvider() { + + // Create a tree with one single folder + currentTabFolder = new TabFolderModel(this); + rootModel = new RootModel(currentTabFolder); + } + + /** + * Add a listener listening on content changed. This listener will be + * notified each time the content change. + * + * @param listener + */ + public void addListener(IContentChangedListener listener) { + contentChangedListenerManager.addContentChangedListener(listener); + } + + /** + * Add a listener listening on content changed. This listener will be + * notified each time the content change. + * + * @param listener + */ + public void removeListener(IContentChangedListener listener) { + contentChangedListenerManager.removeContentChangedListener(listener); + } + + /** + * Add a listener listening on content changed. This listener will be + * notified each time the content change. + * + * @param listener + */ + protected void firePropertyChanged(ContentEvent event) { + contentChangedListenerManager.fireContentChanged(event); + } + + /** + * Add the page which should be an IPageModel instance. {@inheritDoc} + */ + public void addPage(Object newModel) { + addPage((IPageModel)newModel); + } + + /** + * Add the page which should be an IPageModel instance. {@inheritDoc} + */ + public void addPage(Object newModel, int index) { + addPage((IPageModel)newModel, index); + } + + /** + * + * {@inheritDoc} + */ + public void addPage(IPageModel newModel) { + currentTabFolder.doAddItem(newModel); + firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, newModel)); + } + + /** + * + * {@inheritDoc} + */ + public void addPage(int index, IPageModel newModel) { + currentTabFolder.doAddItem(index, newModel); + firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, newModel)); + } + + /** + * Move a Page inside the folder. {@inheritDoc} + */ + public void movePage(ITabFolderModel folderModel, int oldIndex, int newIndex) { + org.eclipse.papyrus.infra.core.sasheditor.Activator.log.debug("movePage()"); + ((TabFolderModel)folderModel).moveTab(oldIndex, newIndex); + + } + + /** + * Move a tab from folder to folder. The change event is sent only once + * after the complete operation is performed. {@inheritDoc} + */ + public void movePage(ITabFolderModel srcFolderModel, int sourceIndex, ITabFolderModel targetFolderModel, int targetIndex) { + // This implementation use (TabFolderModel), so we can cast safely + org.eclipse.papyrus.infra.core.sasheditor.Activator.log.debug("movePage()"); + if(sourceIndex == -1) { + moveAllPages(srcFolderModel, targetFolderModel); + return; + } + IPageModel movedTab = doMoveTab((TabFolderModel)srcFolderModel, sourceIndex, (TabFolderModel)targetFolderModel, targetIndex); + removeEmptyFolder((TabFolderModel)srcFolderModel); + doSetCurrentFolder((TabFolderModel)targetFolderModel); + contentChangedListenerManager.fireContentChanged(new ContentEvent(ContentEvent.MOVED, this, movedTab)); + } + + /** + * Move all tabs from source to target + * + * @param srcFolderModel + * @param targetFolderModel + */ + public void moveAllPages(ITabFolderModel srcFolderModel, ITabFolderModel targetFolderModel) { + TabFolderModel srcFolder = (TabFolderModel)srcFolderModel; + TabFolderModel targetFolder = (TabFolderModel)targetFolderModel; + List toMove = srcFolder.doRemoveAll(); + targetFolder.doAddAllTab(toMove); + removeEmptyFolder((TabFolderModel)srcFolderModel); + doSetCurrentFolder((TabFolderModel)targetFolderModel); + contentChangedListenerManager.fireContentChanged(new ContentEvent(ContentEvent.MOVED, this, srcFolderModel)); + } + + /** + * Set the Current Folder to the newCurrentFolder. + * + * @param targetFolderModel + */ + private void doSetCurrentFolder(TabFolderModel newCurrentFolder) { + currentTabFolder = (TabFolderModel)newCurrentFolder; + } + + /** + * Create a new folder and insert it at the specified side. Move the + * specified tab into the created Folder. + * + * The change event is sent only once after the complete operation is + * performed. {@inheritDoc} + * + * @param referenceFolder + * The folder used as reference to insert the newly created + * Folder. + * @param side + * The side to which the created folder is inserted. Can be + * SWT.TOP, DOWN, LEFT, RIGHT. + */ + public void createFolder(ITabFolderModel sourceFolder, int tabIndex, ITabFolderModel referenceFolder, int side) { + org.eclipse.papyrus.infra.core.sasheditor.Activator.log.debug("createFolder()"); + + ITabFolderModel newFolder = doCreateFolder((TabFolderModel)sourceFolder, tabIndex, (TabFolderModel)referenceFolder, side); + contentChangedListenerManager.fireContentChanged(new ContentEvent(ContentEvent.CHANGED, this, sourceFolder)); + // return newFolder; + } + + /** + * Create a new folder and insert it at the specified side of the reference + * folder. The change event is sent only once after the complete operation + * is performed. + * + * This method is not part of the {@link SashWindowsContainer} API. It is + * here to help writing junit tests. + * + * @param referenceFolder + * The folder used as reference to insert the newly created + * Folder. + * @param side + * The side to which the created folder is inserted. Can be + * SWT.TOP, DOWN, LEFT, RIGHT. + */ + public ITabFolderModel createFolder(ITabFolderModel referenceFolder, int side) { + org.eclipse.papyrus.infra.core.sasheditor.Activator.log.debug("createFolder()"); + + ITabFolderModel newFolder = doCreateFolder((TabFolderModel)referenceFolder, side); + contentChangedListenerManager.fireContentChanged(new ContentEvent(ContentEvent.CHANGED, this, referenceFolder)); + return newFolder; + } + + /** + * Move a tab from folder to folder. The change event is sent only once + * after the complete operation is performed. + * + * @return The moved tab. + */ + private IPageModel doMoveTab(TabFolderModel srcFolderModel, int sourceIndex, TabFolderModel targetFolderModel, int targetIndex) { + + IPageModel tab = srcFolderModel.doRemoveTab(sourceIndex); + targetFolderModel.doAddItem(targetIndex, tab); + return tab; + } + + /** + * Move a tab from folder to folder. The tab is added at the end of the + * target folder. The change event is sent only once after the complete + * operation is performed. {@inheritDoc} + */ + private void doMoveTab(TabFolderModel srcFolderModel, int sourceIndex, TabFolderModel targetFolderModel) { + + IPageModel tab = srcFolderModel.doRemoveTab(sourceIndex); + targetFolderModel.doAddItem(tab); + } + + /** + * Create a new folder and insert it at the specified side. + * + */ + private TabFolderModel doCreateFolder(TabFolderModel tabFolder, int tabIndex, TabFolderModel targetFolder, int side) { + + // Create new folder. Parent will be set when inserted. + TabFolderModel newFolder = new TabFolderModel(this); + // Inset folder + doInsertFolder(newFolder, targetFolder, side); + // Move tab from folder to folder + doMoveTab(tabFolder, tabIndex, newFolder); + // Remove unused folder if necessary + removeEmptyFolder(tabFolder); + doSetCurrentFolder(targetFolder); + + return newFolder; + } + + /** + * Create a new folder and insert it at the specified side. + * + */ + private TabFolderModel doCreateFolder(TabFolderModel referenceFolder, int side) { + + // Create new folder. Parent will be set when inserted. + TabFolderModel newFolder = new TabFolderModel(this); + // Insert folder + doInsertFolder(newFolder, referenceFolder, side); + doSetCurrentFolder(referenceFolder); + + return newFolder; + } + + /** + * Remove the folder if it is empty. + * + * @param tabFolder + */ + private void removeEmptyFolder(TabFolderModel tabFolder) { + // Check if empty + if(tabFolder.getChildren().size() > 0) + return; + + AbstractModel parent = tabFolder.getParent(); + // Forbid removing of the last folder + if(parent == rootModel) + return; + + // Parent is a sash. Ask it to remove the child and itself + ((SashPanelModel)parent).delete(tabFolder); + } + + /** + * Insert the folderToInsert on the specified side of the refFolder. Create + * and insert the requested SashModel. + * + * @param folderToInsert + * @param refFolder + * @param side + */ + private void doInsertFolder(TabFolderModel folderToInsert, TabFolderModel refFolder, int side) { + // Get the parent under which the sash will be inserted + AbstractModel refParent = refFolder.getParent(); + SashPanelModel newSash; + + int direction; + // Compute sash direction + if(side == SWT.LEFT || side == SWT.RIGHT) + direction = SWT.HORIZONTAL; + else + direction = SWT.VERTICAL; + // Create sash + if(side == SWT.LEFT || side == SWT.UP) { + newSash = new SashPanelModel(refParent, folderToInsert, refFolder, direction); + } else { + newSash = new SashPanelModel(refParent, refFolder, folderToInsert, direction); + } + + // Change sash childs parent + refFolder.setParent(newSash); + folderToInsert.setParent(newSash); + + // Change sash parent + refParent.replaceChild(refFolder, newSash); + } + + /** + * Get the root used as root to be shown in the editor. {@inheritDoc} + */ + public IAbstractPanelModel getRootModel() { + return rootModel.getChild(); + } + + /** + * Create the interface used to access the rootModel {@inheritDoc} + */ + public IAbstractPanelModel createChildSashModel(Object root) { + // The root object should be of type IAbstractPanelModel. + // This is normally the object returned by getRootPanel + return (IAbstractPanelModel)root; + } + + /** + * + * {@inheritDoc} + */ + public void removePage(int index) { + currentTabFolder.removeTab(index); + } + + /** + * Remove the specified page which should be an instance of IPageModel. {@inheritDoc} + */ + public void removePage(Object page) { + + removePage((IPageModel)page); + } + + /** + * Remove the specified tab from its parent. {@inheritDoc} + */ + public void removePage(IPageModel tabItem) { + + TabFolderModel folder = lookupPageFolder(tabItem); + if(folder != null) + folder.removeTab(tabItem); + } + + /** + * Remove the tab at the specified index. + * + */ + public void removePage(ITabFolderModel parentFolder, int tabIndex) { + TabFolderModel folder = (TabFolderModel)parentFolder; + IPageModel removed = folder.doRemoveTab(tabIndex); + removeEmptyFolder(folder); + doSetCurrentFolder(lookupPageFolder()); + contentChangedListenerManager.fireContentChanged(new ContentEvent(ContentEvent.REMOVED, this, removed)); + } + + /** + * Lookup the folder containing the specified tabItem. + * + * @param tabItem + * Item for which a folder is looked for. If the item is null, + * return the first folder encountered. + * @return The folder containing the item, or the first encountered folder + * if item is null. + */ + private TabFolderModel lookupPageFolder(IPageModel tabItem) { + return rootModel.lookupTabFolder(tabItem); + } + + /** + * Lookup for the first folder in the model. + * + * @return The first encountered folder. + */ + private TabFolderModel lookupPageFolder() { + return rootModel.lookupTabFolder(null); + } + + /** + * Get the parent of the specified tabItem, or null + * + * @param tabItem + * @return The parent tabFolder or null if not found. + */ + public ITabFolderModel getParentFolder(IPageModel tabItem) { + return lookupPageFolder(tabItem); + } + + /** + * Return the currently selected TabFolder. + * + * @return + */ + public ITabFolderModel getCurrentTabFolder() { + return currentTabFolder; + } + + /** + * Set the the current Folder. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#setCurrentFolder(java.lang.Object) + * + * @param rawModel + * Object identifying the current folder. In this implementation, + * the object is the FolderModel. + */ + public void setCurrentFolder(Object rawModel) { + if(!(rawModel instanceof TabFolderModel)) { + return; + } + doSetCurrentFolder((TabFolderModel)rawModel); + } + + /** + * A class managing a list of listeners. + * + * @author dumoulin + */ + protected class ContentChangeListenerManager { + + private List listeners; + + /** + * Add a listener listening on content changed. This listener will be + * notified each time the content change. + * + * @param listener + */ + public void addContentChangedListener(IContentChangedListener listener) { + if(listeners == null) + createListeners(); + + // Check if already exists. + if(listeners.contains(listener)) + return; + + listeners.add(listener); + } + + /** + * Add a listener listening on content changed. This listener will be + * notified each time the content change. + * + * @param listener + */ + public void removeContentChangedListener(IContentChangedListener listener) { + if(listeners == null) + return; + + listeners.remove(listener); + } + + /** + * Create the list of listeners. + */ + private void createListeners() { + if(listeners == null) + listeners = new ArrayList(); + + } + + /** + * Fire the changed event. + * + * @param event + */ + public void fireContentChanged(ContentEvent event) { + if(listeners == null) + return; + + for(IContentChangedListener listener : listeners) { + listener.contentChanged(event); + } + } + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/TabFolderModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/TabFolderModel.java new file mode 100644 index 00000000000..67ce0bff0ed --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/simple/TabFolderModel.java @@ -0,0 +1,233 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider.simple; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedListener.ContentEvent; + +/** + * Basic implementation allowing to add item to be shown. + * + * @author dumoulin + * + */ +public class TabFolderModel extends AbstractPanelModel implements ITabFolderModel { + + /** + * List of items to be shown + */ + private List children = new ArrayList(); + + /** + * The root of the sash models + */ + private SimpleSashWindowsContentProvider contentProvider; + + /** + * Constructor. + */ + public TabFolderModel(SimpleSashWindowsContentProvider contentProvider) { + // Parent should be set later. + super(null); + this.contentProvider = contentProvider; + } + + /** + * + */ + public List getChildren() { + return children; + } + + /** + * This default implementation return directly the child which is already of + * the appropriate type. + */ + public IPageModel createChildSashModel(Object child) { + // In this default implementation, the child is already of the + // appropriate type. + return (IPageModel)child; + } + + /** + * Add a new model. + * + * @param newModel + */ + private void addItem(IPageModel newModel) { + doAddItem(newModel); + contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, newModel)); + } + + /** + * Add a model at the specified position. + * + * @param index + * @param newModel + */ + private void addItem(int index, IPageModel newModel) { + doAddItem(index, newModel); + contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, newModel)); + } + + /** + * Remove the specified tab. + * + * @param index + * @return + */ + public IPageModel removeTab(int index) { + IPageModel removed = doRemoveTab(index); + contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.REMOVED, this, removed)); + return removed; + + } + + /** + * Remove the specified tab. + * + * @param tabItem + */ + public void removeTab(IPageModel tabItem) { + doRemoveTab(tabItem); + contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, tabItem)); + } + + /** + * Move a tab inside the folder. Moves the tab from the old position to the + * new position. + * + * @param oldIndex + * the position of the tab before the move. + * @param newIndex + * the position of the tab after the move. + */ + public void moveTab(int oldIndex, int newIndex) { + int listSize = children.size(); + if(newIndex >= listSize) { + newIndex = listSize - 1; + } + if(newIndex < 0) { + newIndex = 0; + } + + if(oldIndex == newIndex) + return; + + if(listSize == 0) + return; + + // Move + IPageModel toMove = children.remove(oldIndex); + children.add(newIndex, toMove); + contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.MOVED, this, toMove)); + } + + /** + * Add a new model. Do not fire change Event + * + * @param newModel + */ + protected void doAddItem(IPageModel newModel) { + children.add(newModel); + } + + /** + * Add a model at the specified position. Do not fire change Event + * + * @param index + * @param newModel + */ + protected void doAddItem(int index, IPageModel newModel) { + if(index > children.size() || index < 0) + children.add(newModel); + else + children.add(index, newModel); + } + + /** + * Remove the specified tab. Do not fire change Event + * + * @param index + * @return + */ + protected IPageModel doRemoveTab(int index) { + IPageModel removed = children.remove(index); + return removed; + + } + + /** + * Remove all tabs from the folder. + * + * @return A list of removed tabs. + */ + protected List doRemoveAll() { + List removed = new ArrayList(children); + children.clear(); + return removed; + } + + /** + * Add all tabs to the folder. + * + * @param newTabs + */ + protected void doAddAllTab(List newTabs) { + children.addAll(newTabs); + } + + /** + * Remove the specified tab. Do not fire change Event + * + * @param tabItem + */ + protected void doRemoveTab(IPageModel tabItem) { + children.remove(tabItem); + contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, tabItem)); + } + + /** + * Do nothing as this method should never be called on this class. {@inheritDoc} + */ + @Override + public void replaceChild(AbstractPanelModel oldChild, AbstractPanelModel newChild) { + throw new UnsupportedOperationException("This method should not be called on this class."); + } + + /** + * Get a folder by one of its tab. + * + * @param tabItem + * Item for which a folder is looked for. If the item is null, + * return the first folder encountered. + * @return The folder if it contains the item, or if item is null. + */ + @Override + protected TabFolderModel lookupTabFolder(IPageModel tabItem) { + + if(tabItem == null) + return this; + + if(children.contains(tabItem)) + return this; + // not found + return null; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderContentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderContentProvider.java new file mode 100644 index 00000000000..6ac26058385 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderContentProvider.java @@ -0,0 +1,262 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider.singlefolder; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedListener; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedProvider; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedListener.ContentEvent; + +/** + * A simple implementation of providers allowing only one single folder + * containing tabs. The tabs can be added and removed. + * + * @author dumoulin + */ +public class SingleFolderContentProvider implements ISashWindowsContentProvider, IContentChangedProvider { + + /** The currently selected tab folder */ + private SingleFolderModel currentTabFolder; + + /** */ + private ContentChangeListenerManager contentChangedListenerManager = new ContentChangeListenerManager(); + + /** + * Constructor. + */ + public SingleFolderContentProvider() { + currentTabFolder = new SingleFolderModel(this); + } + + /** + * Add a listener listening on content changed. This listener will be + * notified each time the content change. + * + * @param listener + */ + public void addListener(IContentChangedListener listener) { + contentChangedListenerManager.addContentChangedListener(listener); + } + + /** + * Add a listener listening on content changed. This listener will be + * notified each time the content change. + * + * @param listener + */ + public void removeListener(IContentChangedListener listener) { + contentChangedListenerManager.removeContentChangedListener(listener); + } + + /** + * Add a listener listening on content changed. This listener will be + * notified each time the content change. + * + * @param listener + */ + protected void firePropertyChanged(ContentEvent event) { + contentChangedListenerManager.fireContentChanged(event); + } + + /** + * Add the page which should be an IPageModel instance. {@inheritDoc} + */ + public void addPage(Object newModel) { + addPage((IPageModel)newModel); + } + + /** + * Add the page which should be an IPageModel instance. {@inheritDoc} + */ + public void addPage(Object newModel, int index) { + addPage((IPageModel)newModel, index); + } + + /** + * + * {@inheritDoc} + */ + public void addPage(IPageModel newModel) { + currentTabFolder.addItem(newModel); + + } + + /** + * + * {@inheritDoc} + */ + public void addPage(int index, IPageModel newModel) { + currentTabFolder.addItem(index, newModel); + } + + /** + * Do nothing because this implementation doesn't allows folders. {@inheritDoc} + */ + public void createFolder(ITabFolderModel tabFolder, int tabIndex, ITabFolderModel targetFolder, int side) { + // TODO Auto-generated method stub + } + + /** + * Get the root used as root to be shown in the editor. {@inheritDoc} + */ + public SingleFolderModel getRootModel() { + return currentTabFolder; + } + + /** + * Create the interface used to access the rootModel. {@inheritDoc} + */ + public IAbstractPanelModel createChildSashModel(Object root) { + // The root object should be of type IAbstractPanelModel. + // This is normally the object returned by getRootPanel + return (IAbstractPanelModel)root; + } + + /** + * Remove the specified page which should be an instance of IPageModel. {@inheritDoc} + */ + public void removePage(Object page) { + + removePage((IPageModel)page); + } + + /** + * + * {@inheritDoc} + */ + public void removePage(int index) { + currentTabFolder.removeTab(index); + } + + /** + * + * {@inheritDoc} + */ + public void removePage(IPageModel tabItem) { + currentTabFolder.removeTab(tabItem); + } + + /** + * Remove the specified tab. As we have only one folder, this should be from + * the currentFolder {@inheritDoc} + */ + public void removePage(ITabFolderModel parentFolder, int tabIndex) { + removePage(tabIndex); + } + + /** + * Return the currently selected TabFolder. + * + * @return + */ + public ITabFolderModel getCurrentTabFolder() { + return currentTabFolder; + } + + /** + * Do nothing as we can't have other folders. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider#setCurrentFolder(java.lang.Object) + * + * @param rawModel + */ + public void setCurrentFolder(Object rawModel) { + } + + /** + * A class managing a list of listeners. + * + * @author dumoulin + */ + protected class ContentChangeListenerManager { + + private List listeners; + + /** + * Add a listener listening on content changed. This listener will be + * notified each time the content change. + * + * @param listener + */ + public void addContentChangedListener(IContentChangedListener listener) { + if(listeners == null) + createListeners(); + + // Check if already exists. + if(listeners.contains(listener)) + return; + + listeners.add(listener); + } + + /** + * Add a listener listening on content changed. This listener will be + * notified each time the content change. + * + * @param listener + */ + public void removeContentChangedListener(IContentChangedListener listener) { + if(listeners == null) + return; + + listeners.remove(listener); + } + + /** + * Create the list of listeners. + */ + private void createListeners() { + if(listeners == null) + listeners = new ArrayList(); + + } + + /** + * Fire the changed event. + * + * @param event + */ + public void fireContentChanged(ContentEvent event) { + if(listeners == null) + return; + + for(IContentChangedListener listener : listeners) { + listener.contentChanged(event); + } + } + } + + /** + * Move a tab inside the folder. {@inheritDoc} + */ + public void movePage(ITabFolderModel folderModel, int oldIndex, int newIndex) { + currentTabFolder.moveTab(oldIndex, newIndex); + + } + + /** + * Move a tab from folder to folder. As this implementation has only one + * folder, this can't happen. Do nothing. {@inheritDoc} + */ + public void movePage(ITabFolderModel srcFolderModel, int sourceIndex, ITabFolderModel targetFolderModel, int targetIndex) { + return; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderModel.java new file mode 100644 index 00000000000..482b7391783 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/singlefolder/SingleFolderModel.java @@ -0,0 +1,139 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.contentprovider.singlefolder; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedListener.ContentEvent; + +/** + * Basic implementation allowing to add item to be shown. + * + * @author dumoulin + * + */ +public class SingleFolderModel implements ITabFolderModel { + + /** + * List of items to be shown + */ + private List itemModels = new ArrayList(); + + /** + * The root of the sash models + */ + private SingleFolderContentProvider contentProvider; + + /** + * Constructor. + */ + public SingleFolderModel(SingleFolderContentProvider contentProvider) { + this.contentProvider = contentProvider; + } + + /** + * + */ + public List getChildren() { + return itemModels; + } + + /** + * This default implementation return directly the child which is already of + * the appropriate type. + */ + public IPageModel createChildSashModel(Object child) { + // In this default implementation, the child is already of the + // appropriate type. + return (IPageModel)child; + } + + /** + * Add a new model. + * + * @param newModel + */ + public void addItem(IPageModel newModel) { + itemModels.add(newModel); + contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, newModel)); + } + + /** + * Add a model at the specified position. + * + * @param index + * @param newModel + */ + public void addItem(int index, IPageModel newModel) { + itemModels.add(index, newModel); + contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, newModel)); + } + + /** + * Remove the specified tab. + * + * @param index + * @return + */ + public IPageModel removeTab(int index) { + IPageModel removed = itemModels.remove(index); + contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, removed)); + return removed; + + } + + /** + * Remove the specified tab. + * + * @param tabItem + */ + public void removeTab(IPageModel tabItem) { + itemModels.remove(tabItem); + contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, tabItem)); + } + + /** + * Move a tab inside the folder. Moves the tab from the old position to the + * new position. + * + * @param oldIndex + * the position of the tab before the move. + * @param newIndex + * the position of the tab after the move. + */ + public void moveTab(int oldIndex, int newIndex) { + + int listSize = itemModels.size(); + if(newIndex >= listSize) { + newIndex = listSize - 1; + } + if(newIndex < 0) { + newIndex = 0; + } + + if(oldIndex == newIndex) + return; + + if(listSize == 0) + return; + + // Move + IPageModel toMove = itemModels.remove(oldIndex); + itemModels.add(newIndex, toMove); + contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.MOVED, this, toMove)); + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java new file mode 100644 index 00000000000..d36c81f83b9 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java @@ -0,0 +1,323 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.editor; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy.MultiPageSelectionProvider; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.internal.util.Util; +import org.eclipse.ui.part.EditorPart; + +/** + * Base editor that can be subclassed to provide a multi page editor with sash + * windows. + * + * @author dumoulin + */ +public abstract class AbstractMultiPageSashEditor extends EditorPart implements IMultiPageEditorPart, IMultiEditorManager { + + /** The pageProvider */ + private ISashWindowsContentProvider pageProvider; + + /** The sash windows system :-) */ + private SashWindowsContainer sashContainer; + + /** + * Synchronizer in charge of synchronizing tab names with IEditorPart title. + */ + private SashTabDecorationSynchronizer tabsSynchronizer; + + /** + * get the contentProvider. Create it if necessary. + * + * @return + */ + protected ISashWindowsContentProvider getContentProvider() { + if(pageProvider == null) { + pageProvider = createPageProvider(); + } + + return pageProvider; + } + + /** + * Set the contentProvider if not set. If it is already set, this method do + * not change it. + * + * @param contentProvider + */ + protected void setContentProvider(ISashWindowsContentProvider contentProvider) { + if(pageProvider == null) { + pageProvider = contentProvider; + } + } + + /** + * Create the provider. Subclass must implements this method. It should + * return the provider used by the editor. + * + */ + abstract protected ISashWindowsContentProvider createPageProvider(); + + /** + * Handles a property change notification from a nested editor. The default + * implementation simply forwards the change to listeners on this multi-page + * editor by calling firePropertyChange with the same property + * id. For example, if the dirty state of a nested editor changes (property + * id IEditorPart.PROP_DIRTY), this method handles it by firing + * a property change event for IEditorPart.PROP_DIRTY to + * property listeners on this multi-page editor. + *

+ * Subclasses may extend or reimplement this method. + *

+ * + * @copiedfrom + * org.eclipse.ui.part.MultiPageEditorPart.handlePropertyChange(int + * ) + * + * @param propertyId + * the id of the property that changed + */ + protected void handlePropertyChange(int propertyId) { + firePropertyChange(propertyId); + } + + /** + * The MultiPageEditorPart implementation of this IEditorPart method sets its site to the given site, its + * input to the given input, and the site's selection provider to a MultiPageSelectionProvider. Subclasses may extend this + * method. + * + * @copiedfrom org.eclipse.ui.part.MultiPageEditorPart + * @param site + * The site for which this part is being created; must not be null. + * @param input + * The input on which this editor should be created; must not be null. + * @throws PartInitException + * If the initialization of the part fails -- currently never. + */ + @Override + public void init(IEditorSite site, IEditorInput input) throws PartInitException { + setSite(site); + setInput(input); + site.setSelectionProvider(new MultiPageSelectionProvider(this)); + } + + /** + * Create the part controls. {@inheritDoc} + */ + @Override + public void createPartControl(Composite parent) { + + // Create and intialize sash windows + sashContainer = new SashWindowsContainer(this); + sashContainer.setContentProvider(getContentProvider()); + sashContainer.createPartControl(parent); + activate(); + } + + /** + * Method to activate the editor. Called immediately after + * createPartControl() is complete. To be implemented by subclasses. Default + * implementation do nothing. + */ + protected void activate() { + + tabsSynchronizer = new SashTabDecorationSynchronizer(sashContainer); + } + + /** + * Method to deactivate the editor. Called when dispose() is called. To be + * implemented by subclasses. Default implementation do nothing. + */ + protected void deactivate() { + + tabsSynchronizer.dispose(); + } + + /** + * Dispose the Editor. Also dispose the sashsystem. + * + * @see org.eclipse.ui.part.WorkbenchPart#dispose() + * + */ + @Override + public void dispose() { + deactivate(); + super.dispose(); + } + + /** + * Refresh the sash windows system + */ + protected void refreshTabs() { + if(sashContainer != null) { + sashContainer.refreshTabs(); + } + + } + + /** + * If there is an adapter registered against the subclass of + * MultiPageEditorPart return that. Otherwise, delegate to the internal + * editor. + * + * @copiedfrom org.eclipse.ui.part.MultiPageEditorPart + * + * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class) + */ + @Override + public Object getAdapter(Class adapter) { + + // Get the content provider if requested. + if(ISashWindowsContentProvider.class == adapter) { + return getContentProvider(); + } + + // Get the content provider if requested. + if(ISashWindowsContainer.class == adapter) { + return sashContainer; + } + + // Look in hierarchy + Object result = super.getAdapter(adapter); + // restrict delegating to the UI thread for bug 144851 + if(result == null && Display.getCurrent() != null) { + IEditorPart innerEditor = getActiveEditor(); + // see bug 138823 - prevent some subclasses from causing + // an infinite loop + if(innerEditor != null && innerEditor != this) { + result = Util.getAdapter(innerEditor, adapter); + } + } + return result; + } + + /** + * Needed by MultiPageActionBarContributor and MultiPageSelectionProvider. + */ + public IEditorPart getActiveEditor() { + return sashContainer.getActiveEditor(); + } + + /** + * Get the {@link ISashWindowsContainer}. Note the the ISashWindowsContainer + * can also be acuired with getAdapter(ISashWindowsContainer.class). + */ + public ISashWindowsContainer getISashWindowsContainer() { + return sashContainer; + } + + /** + * + * {@inheritDoc} + */ + @Override + public void setFocus() { + sashContainer.setFocus(); + + } + + /** + * Overrides isDirty. + * + * {@inheritDoc} + * + * TODO Move this method aways. This method is too tightly coupled to the + * Papyrus GMF UML IEditor. It doesn't work on other kind of IEditor. It + * introduce problems in IEditor of other kinds + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#isDirty() + * @deprecated A SaveAndDirtyService is used instead. + */ + @Override + public boolean isDirty() { + // return sashContainer.isDirty(); + EditorVisitor visitor = new EditorVisitor(); + sashContainer.visit(visitor); + + for(IEditorPart editorPart : visitor.getPages()) { + if(editorPart.isDirty()) { + return true; + } + } + + return false; + } + + /** + * Notify all the editors that the multi editor has been saved.
+ * Fires the PROP_DIRTY property change. + * + * TODO Move this method aways. This method is too tightly coupled to the + * Papyrus GMF UML IEditor. It doesn't work on other kind of IEditor. It + * introduce problems in IEditor of other kinds + * + * @deprecated A SaveAndDirtyService is used instead. + */ + protected void markSaveLocation() { + // return sashContainer.isDirty(); + EditorVisitor visitor = new EditorVisitor(); + sashContainer.visit(visitor); + + for(IEditorPart editorPart : visitor.getPages()) { + editorPart.doSave(new NullProgressMonitor()); + } + firePropertyChange(PROP_DIRTY); + } + + /** + * A visitor allowing to collect the available IEditor. TODO : Remove + * + * @author dumoulin + * + */ + protected class EditorVisitor implements IPageVisitor { + + private List pages = new ArrayList(); + + /** + * Get collected pages. + * + * @return + */ + public List getPages() { + return pages; + } + + /** + * + */ + public void accept(IComponentPage page) { + // Do nothing + } + + /** + * + */ + public void accept(IEditorPage page) { + + IEditorPart editor = page.getIEditorPart(); + pages.add(editor); + } + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IComponentPage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IComponentPage.java new file mode 100644 index 00000000000..f7a49058ead --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IComponentPage.java @@ -0,0 +1,17 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.editor; + +/** + * Allows to access to properties of a Sash ComponentPage. This interface allows + * to read the data. User should not attent to modifiy or write the data in + * anyway. This interface is provided as parameter of the {@link IPageChangedListener#pageChanged(IPage)} event and in the + * SashContainer Visitor. + * + * @author cedric dumoulin + * + */ +public interface IComponentPage extends IPage { + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IEditorPage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IEditorPage.java new file mode 100644 index 00000000000..5254420bdc9 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IEditorPage.java @@ -0,0 +1,26 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.editor; + +import org.eclipse.ui.IEditorPart; + +/** + * Allows to access to properties of a Sash IEditor Page. This interface allows + * to read the data. User should not attent to modifiy or write the data in + * anyway. This interface is provided as parameter of the {@link IPageChangedListener#pageChanged(IPage)} event and in the + * SashContainer Visitor. + * + * @author cedric dumoulin + * + */ +public interface IEditorPage extends IPage { + + /** + * Returns the active nested editor if there is one. + * + * @return the active nested editor, or null if none + */ + public IEditorPart getIEditorPart(); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IMultiEditorManager.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IMultiEditorManager.java new file mode 100644 index 00000000000..b85e8f00fc8 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IMultiEditorManager.java @@ -0,0 +1,74 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.editor; + +import org.eclipse.papyrus.infra.core.sasheditor.internal.EditorPart; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.IWorkbenchPartSite; + +/** + * This interface allows EditorPart to access objects provided by the real + * editor. Implementation of this interface is provided to the {@link SashWindowsContainer} and used by {@link EditorPart}. The EditorPart + * will call {@link #getEditorInput()} and pass the result to input of the + * created nested IEditorPart. The site provided by {@link #getEditorSite()} is + * used to initialize a specific site for the nested IEditorPart. It is also + * used by the {@link SashWindowsContainer}. + * + * @author dumoulin + */ +public interface IMultiEditorManager { + + /** + * Get the EditorActionBarContributor for the editor associated to the + * specified model. + * + * @param editorModel + * @return + * @throws MultiDiagramException + */ + // public EditorActionBarContributor getActionBarContributor(Object + // editorModel); + + /** + * Fires a property changed event. + * + * @param propertyId + * the id of the property that changed + */ + // public void firePropertyChange(int propertyId); + + /** + * Get the editor input associated to the main IMultiPageEditorPart. + * + * @return + */ + public IEditorInput getEditorInput(); + + /** + * Get the main site of the MultiPageEditorPart. + * + * @return + */ + public IWorkbenchPartSite getSite(); + + /** + * Get the IEditorSite associated to this MultiPageEditorPart. This return + * the same object as getSite(). + * + * @return + */ + public IEditorSite getEditorSite(); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IMultiPageEditorPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IMultiPageEditorPart.java new file mode 100644 index 00000000000..d6bbcabdbe8 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IMultiPageEditorPart.java @@ -0,0 +1,48 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.editor; + +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.IWorkbenchPartSite; + +/** + * Marker to mark a EditorPart as a MultiPartEditor. Provides methods needed by + * classes like MultiPageActionBarContributor and MultiPageSelectionProvider. + */ +public interface IMultiPageEditorPart { + + /** + * Get the currently active editor of the MultiPageEditorPart. + * + * @return + */ + public IEditorPart getActiveEditor(); + + /** + * Get the main site of the MultiPageEditorPart. + * + * @return + */ + public IWorkbenchPartSite getSite(); + + /** + * Get the IEditorSite associated to this MultiPageEditorPart. This return + * the same object as getSite(). + * + * @return + */ + public IEditorSite getEditorSite(); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPage.java new file mode 100644 index 00000000000..d2a683905fe --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPage.java @@ -0,0 +1,47 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.editor; + +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Control; + +/** + * Allows to access to properties of a Sash Page. This interface allows to read + * the data. User should not attent to modifiy or write the data in anyway. This + * interface is provided as parameter of the {@link IPageChangedListener#pageChanged(IPage)} event. + * + * @author cedric dumoulin + * + */ +public interface IPage { + + /** + * Get the title to be shown in the tab + * + * @return + */ + public String getPageTitle(); + + /** + * Get the icon to be shown in the tab + * + * @return + */ + public Image getPageIcon(); + + /** + * Get the raw model corresponding to this node. This is the object provided + * to {@link ITabFolderModel.getChildren()} + * + * @return + */ + public Object getRawModel(); + + /** + * Get the control associated to this page. + * + * @return + */ + public Control getControl(); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageChangedListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageChangedListener.java new file mode 100644 index 00000000000..0037bc7be0b --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageChangedListener.java @@ -0,0 +1,20 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.editor; + +/** + * @author cedric dumoulin + * + */ +public interface IPageChangedListener { + + /** + * Method called when the page is changed + * + * @param newPage + * The new page, or null if there is no container. + */ + public void pageChanged(IPage newPage); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageImageUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageImageUtils.java new file mode 100644 index 00000000000..e83f22af035 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageImageUtils.java @@ -0,0 +1,63 @@ +/***************************************************************************** + * Copyright (c) 2011 Cedric Dumoulin. + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.sasheditor.editor; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Control; + + +/** + * Utility class to get an Image from an IPage. + * + * @author cedric dumoulin + * + */ +public class IPageImageUtils { + + + /** + * Get an Image of the page. + * The Image is build from the Control. + * + * @param The IPage for which an Image is requested. + * @return The Image of the page, or null if no Image can be built. + */ + static public Image getPageImage(IPage page) { + Rectangle size; + Control control = page.getControl(); + + size = control.getBounds(); + if(size.width == 0 && size.height == 0) { + Point pt = control.computeSize(SWT.DEFAULT, SWT.DEFAULT); + size = new Rectangle(0, 0, pt.x, pt.y); + } + + Image image = new Image(control.getDisplay(), size); + GC gc = new GC(image); + + boolean success = control.print(gc); + gc.dispose(); + if(!success) { + image.dispose(); + return null; + } + + return image; + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageVisitor.java new file mode 100644 index 00000000000..e2e41c10eeb --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/IPageVisitor.java @@ -0,0 +1,28 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.editor; + +/** + * A Visitor used to visit all the {@link IPage} of a {@link SashWindowsContainer}. + * + * @author cedric dumoulin + * + */ +public interface IPageVisitor { + + /** + * Visit the provided page of type {@link IComponentPage}. + * + * @param page + */ + void accept(IComponentPage page); + + /** + * Visit the provided page of type {@link IEditorPage}. + * + * @param page + */ + void accept(IEditorPage page); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainer.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainer.java new file mode 100644 index 00000000000..8f75f476643 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainer.java @@ -0,0 +1,98 @@ +package org.eclipse.papyrus.infra.core.sasheditor.editor; + +import java.util.List; + +import org.eclipse.jface.action.MenuManager; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.ui.IEditorPart; + +public interface ISashWindowsContainer { + + /** + * Get the currently active editor, or null if none is active. + * + * @return + */ + public abstract IEditorPart getActiveEditor(); + + /** + * Get the currently active SashWindows Page. This is s + * + * @return An {@link IPage} allowing to access current page data. + */ + public abstract IPage getActiveSashWindowsPage(); + + /** + * Get the list of visible IPages. The visible IPages are the one that have + * there diagram area visible. + * + * @return + */ + public List getVisiblePages(); + + /** + * Get the list of visible IEditorPart obtain from the pages of type + * IEditorPage. The visible IPages are the one that have there diagram area + * visible. + * + * @return + */ + public List getVisibleIEditorParts(); + + /** + * The AbstractMultiPageSashEditor implementation of this IWorkbenchPart method sets focus on the active nested + * editor, if there is one. + *

+ * Subclasses may extend or reimplement. + *

+ */ + public abstract void setFocus(); + + /** + * Refresh the SashWindows. Synchronize the internal structure with the {@link ISashWindowsContentProvider}. + */ + public abstract void refreshTabs(); + + /** + * Add a PageChangedListener to the list of listeners. + * + * @param pageEventsManager + */ + public abstract void addPageChangedListener(IPageChangedListener pageChangedListener); + + /** + * Remove the PageChangedListener from the list of listeners. + * + * @param pageEventsManager + */ + public abstract void removePageChangedListener(IPageChangedListener pageChangedListener); + + /** + * Add a listener on Page LifeCycle events. This implementation delegates to + * the internal PageTracker. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#addPageChangedListener(org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener) + * @param listener + * + */ + public void addLifeCycleListener(SashContainerEventsListener listener); + + /** + * Remove a listener on Page LifeCycle events. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#removePageChangedListener(org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener) + * @param listener + * + */ + public void removeLifeCycleListener(SashContainerEventsListener listener); + + /** + * Set a {@link MenuManager} used to manage a contextual menu that is shown + * on the tabs area of the folders. + * + * @param menuManager + * The {@link MenuManager} used to create the menu on the tab + * area. + */ + public abstract void setFolderTabMenuManager(MenuManager menuManager); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainerChangedListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainerChangedListener.java new file mode 100644 index 00000000000..4b9e0f5c99d --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/ISashWindowsContainerChangedListener.java @@ -0,0 +1,19 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.editor; + +/** + * @author dumoulin + * + */ +public interface ISashWindowsContainerChangedListener { + + /** + * Method called when the container changed + * + * @param newContainer + * The new container, or null if there is no container. + */ + public void sashWindowsContainerChanged(ISashWindowsContainer newContainer); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashContainerEventsListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashContainerEventsListener.java new file mode 100644 index 00000000000..f1ddd4e4524 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashContainerEventsListener.java @@ -0,0 +1,58 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.editor; + +/** + * Interface to be implemented by listeners on {@link SashWindowsContainer} life + * cycle events. + * + * @author cedric dumoulin + * + */ +public interface SashContainerEventsListener extends IPageChangedListener { + + /** + * + * @param page + * The page firing the event. + */ + public void pageOpened(IPage page); + + /** + * + * @param page + * The page firing the event. + */ + public void pageClosed(IPage page); + + /** + * The specify page is activated. It become the current active page. + * + * @param page + * The page firing the event. + */ + public void pageActivated(IPage page); + + /** + * The specify page is deactivated. + * + * @param page + * The page firing the event. + */ + public void pageDeactivated(IPage page); + + /** + * + * @param page + * The page firing the event. + */ + public void pageAboutToBeOpened(IPage page); + + /** + * + * @param page + * The page firing the event. + */ + public void pageAboutToBeClosed(IPage page); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashTabDecorationSynchronizer.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashTabDecorationSynchronizer.java new file mode 100644 index 00000000000..5e480d5f43e --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashTabDecorationSynchronizer.java @@ -0,0 +1,211 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.editor; + +import java.util.logging.Logger; + +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IPropertyListener; +import org.eclipse.ui.IWorkbenchPart; + +/** + * This class take care to refresh a Sash Tab (name and icon) when its model + * change. The class listen to IEditor property change, and refresh the + * corresponding tab accordingly. The class also listen on {@link SashWindowsContainer} page's life cycle in order to attach/remove the + * listener on pages. + * + * The class can be extended. + * + * @author cedric dumoulin + * + */ +public class SashTabDecorationSynchronizer { + + /** + * Logger for debug purpose. + */ + Logger log = Logger.getLogger(this.getClass().getName()); + + /** + * The container to synchronize. + */ + private SashWindowsContainer container; + + /** + * Listener on Container'pages life cycle. + */ + SashContainerEventsListener pageLifeCycleListener = new SashContainerEventsListener() { + + public void pageChanged(IPage newPage) { + } + + public void pageOpened(IPage page) { + attachPage(page); + + } + + public void pageDeactivated(IPage page) { + } + + public void pageClosed(IPage page) { + detachPage(page); + + } + + public void pageActivated(IPage page) { + } + + public void pageAboutToBeOpened(IPage page) { + } + + public void pageAboutToBeClosed(IPage page) { + } + }; + + /** + * Listener on changes of an {@link IEditorPart} + */ + private IPropertyListener editorPartPropertyListener = new IPropertyListener() { + + public void propertyChanged(Object source, int propId) { + if(propId == IWorkbenchPart.PROP_TITLE && source instanceof IEditorPart) { + refreshContainerTabForPage((IEditorPart)source); + } + + } + }; + + /** + * + * Constructor. + * + * @param container + * The container to synchronize. + * + */ + public SashTabDecorationSynchronizer(SashWindowsContainer container) { + this.container = container; + attachContainerPages(); + attachListeners(); + } + + /** + * Detach any listeners. + */ + public void dispose() { + detachListeners(); + detachContainerPages(); + } + + /** + * Attach listeners requested by the class. + */ + protected void attachListeners() { + container.addLifeCycleListener(pageLifeCycleListener); + } + + /** + * Detach listeners requested by the class. + */ + protected void detachListeners() { + container.removeLifeCycleListener(pageLifeCycleListener); + } + + /** + * Start listening on change for the specified page. + * + * @param page + */ + protected void attachPage(IPage page) { + if(page instanceof IEditorPage) { + log.fine("attachPage( " + page + " )"); + IEditorPage editorPage = (IEditorPage)page; + editorPage.getIEditorPart().addPropertyListener(editorPartPropertyListener); + } + + } + + /** + * Stop listening onchange for the specified page. + * + * @param page + */ + protected void detachPage(IPage page) { + if(page instanceof IEditorPage) { + log.fine("attachPage( " + page + " )"); + IEditorPage editorPage = (IEditorPage)page; + editorPage.getIEditorPart().removePropertyListener(editorPartPropertyListener); + } + } + + protected void refreshContainerTabForPage(IEditorPart source) { + // lookup page + IPage page = container.lookupIPageByIEditorPart(source); + refreshContainerTabForPage(page); + + } + + /** + * Refresh the tab for the specified page + * + * @param page + */ + protected void refreshContainerTabForPage(IPage page) { + container.refreshPageTab(page); + } + + /** + * Iterate on pages owned by the container, and call detachPage for each. + */ + private void detachContainerPages() { + // Visit all pages of the container. + container.visit(new DetachVisitor()); + + } + + /** + * Iterate on pages owned by the container, and call detachPage for each. + */ + private void attachContainerPages() { + // Visit all pages of the container. + container.visit(new AttachVisitor()); + + } + + /** + * Visitor to visit all pages of the container and attach the page. + * + * @author dumoulin + * + */ + private class AttachVisitor implements IPageVisitor { + + public void accept(IComponentPage page) { + } + + public void accept(IEditorPage page) { + attachPage(page); + + } + + } + + /** + * Visitor to visit all pages of the container and attach the page. + * + * @author dumoulin + * + */ + private class DetachVisitor implements IPageVisitor { + + public void accept(IComponentPage page) { + } + + public void accept(IEditorPage page) { + detachPage(page); + + } + + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashWindowsContainer.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashWindowsContainer.java new file mode 100644 index 00000000000..09c0f835087 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashWindowsContainer.java @@ -0,0 +1,1024 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.editor; + +import static org.eclipse.papyrus.infra.core.sasheditor.Activator.log; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.util.Geometry; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IComponentModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.internal.AbstractPanelPart; +import org.eclipse.papyrus.infra.core.sasheditor.internal.AbstractPart; +import org.eclipse.papyrus.infra.core.sasheditor.internal.ActiveEditorServicesSwitcher; +import org.eclipse.papyrus.infra.core.sasheditor.internal.ActivePageTracker; +import org.eclipse.papyrus.infra.core.sasheditor.internal.ComponentPart; +import org.eclipse.papyrus.infra.core.sasheditor.internal.EditorPart; +import org.eclipse.papyrus.infra.core.sasheditor.internal.IPartVisitor; +import org.eclipse.papyrus.infra.core.sasheditor.internal.LookupIPageByIEditorPartVisitor; +import org.eclipse.papyrus.infra.core.sasheditor.internal.LookupModelPageVisitor; +import org.eclipse.papyrus.infra.core.sasheditor.internal.PTabFolder; +import org.eclipse.papyrus.infra.core.sasheditor.internal.PagePart; +import org.eclipse.papyrus.infra.core.sasheditor.internal.PageVisitorWrapper; +import org.eclipse.papyrus.infra.core.sasheditor.internal.PartLists; +import org.eclipse.papyrus.infra.core.sasheditor.internal.PartVisitor; +import org.eclipse.papyrus.infra.core.sasheditor.internal.RootPart; +import org.eclipse.papyrus.infra.core.sasheditor.internal.SashContainerEventsProvider; +import org.eclipse.papyrus.infra.core.sasheditor.internal.ShowPartStatusVisitor; +import org.eclipse.papyrus.infra.core.sasheditor.internal.TabFolderPart; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.internal.DragCursors; +import org.eclipse.ui.internal.dnd.DragUtil; +import org.eclipse.ui.internal.dnd.IDragOverListener; +import org.eclipse.ui.internal.dnd.IDropTarget; + +/** + * Main entry class of the SashWindows system. This class allows to have a + * multitab window with sashes. The class require a ContentProvider describing + * the content to be shown. + * + * @author dumoulin + */ +@SuppressWarnings("restriction") +public class SashWindowsContainer implements ISashWindowsContainer { + + /** + * The content provider describing the sashes, folders and tabs. + */ + private ISashWindowsContentProvider contentProvider; + + /** + * The manager used to get Main editor properties like Site, ActionBars, ... + */ + private IMultiEditorManager multiEditorManager; + + /** + * Tracker tracking the current active page. The tracker also disconnect + * last active page and connect the new one. + */ + private ActivePageTracker activePageTracker; + + /** + * Event provider firing Pages life cycle events to registered listeners. + * Inner parts call the fireXxxEvents when appropriate. + */ + private SashContainerEventsProvider lifeCycleEventProvider; + + /** + * The part used as root. We use an extra class as root in order to separate + * the code dedicated to ITilePart. + */ + private RootPart rootPart; + + /** + * The SWT container associated to this part. This is generally the + * container of the parent. + */ + private Composite container; + + /** + * The drop target. + */ + protected DropTarget dropTarget; + + /** A flag that indicates that the model is being synchronized. */ + private AtomicBoolean isRefreshing = new AtomicBoolean(false); + + /** + * The cached value of the menu manager, if any. + */ + private MenuManager folderTabMenuManager; + + /** + * Constructor. Build a Container without IEditor management. Trying to add + * a EditorPart will result in an Exception. The ContentProvider should not + * contain IEditorModel. + */ + public SashWindowsContainer() { + this(null); + } + + /** + * Constructor. Build a container with EditorPart management. The container + * will allow to add EditorPart (and thus IEditorModel to the + * ContentProvider). + * + * @param multiEditorManager + * The manager allowing to use {@link IEditorModel} in the model. + * If null, the sash will not render IEditorModel. + * + */ + public SashWindowsContainer(IMultiEditorManager multiEditorManager) { + this.multiEditorManager = multiEditorManager; + activePageTracker = new ActivePageTracker(); + + if(multiEditorManager != null) { + // Add listener on activePageChange. + // This listener will take in charge editor services switching. + activePageTracker.addActiveEditorChangedListener(new ActiveEditorServicesSwitcher(multiEditorManager.getEditorSite())); + } + + // Life cycle event provider + lifeCycleEventProvider = new SashContainerEventsProvider(); + } + + /** + * @return the contentProvider + */ + public ISashWindowsContentProvider getContentProvider() { + // Content provider should have been set. + assert (contentProvider != null); + // Double check for developement + if(contentProvider == null) + throw new IllegalStateException("ContentProvider should be set before calling any method requiring it."); + + return contentProvider; + } + + /** + * Set the content provider describing the sashes, folders and tabs. + * + * @param contentProvider + * the contentProvider to set + */ + public void setContentProvider(ISashWindowsContentProvider contentProvider) { + this.contentProvider = contentProvider; + } + + /** + * Creates control associated to this Container. This method should be + * called when the parent is build. + * + * @param parent + * The parent in which the editor should be created; must not be null. + */ + public void createPartControl(Composite parent) { + this.container = parent; + + rootPart = createRootPart(); + // Create the tree of tile part. + rootPart.createPartControl(container); + // Create children + refreshTabs(); + // Set selection + selectPage(lookupFirstValidPage()); + + // postCreatePartControl(); + // TODO reactivate next + initDrag(container); + // activate(); + } + + /** + * Create the root part for the model. + */ + private RootPart createRootPart() { + RootPart part = new RootPart(this); + return part; + } + + /** + * Notifies this page container that the specified page has been activated. + * This method is called after the current tabs has been changed, either by + * refreshing the tabs, or by a user UI action. This method just set + * correctly the active page value in the Container, and fire pageChanged + * events if needed. It does not change the selected page in the Part. + * + * Propagate the event to activePageTracker. + * + * @param childPart + */ + public void pageChanged(PagePart childPart) { + activePageTracker.setActiveEditor(childPart); + lifeCycleEventProvider.firePageActivatedEvent(childPart); + } + + /** + * Notifies this page container that a pageChanged event has been fired by + * one swt Control. This method is usually called after the user selects a + * different tab. + * + * The method record the new active folder in the ContentProvider, and calls {@link #pageChanged(PagePart)}. + * + * @param childPart + */ + public void pageChangedEvent(PagePart childPart) { + + // Check if it is really a change before changing the model (which can + // throw change event) + // The folder model change is done before the tracker fires the + // listeners, like this + // listeners can check the model. + if(getActivePage() == childPart) + return; + + contentProvider.setCurrentFolder(childPart.getParent().getRawModel()); + pageChanged(childPart); + } + + /** + * Set the active page. The current active page will be the specified page. + * Do not record the new active folder in the ContentProvider + * + * The method record the new CurrentFolder, and calls {@link #pageChanged(PagePart)}. + * + * @param childPart + */ + protected void setActivePage(PagePart childPart) { + pageChanged(childPart); + } + + /** + * A change has happen in one of the inner parts. Relay the event. This + * method is called by inner parts whenever the event happen in one of the + * part. It collects and relay the firePropertyChange(int propertyId) calls + * from the inner IEditor. + * + * @param propertyId + */ + public void firePropertyChange(int propertyId) { + // For now, we do nothing with this event. + } + + /** + * Create the part for the specified newModel. + * + * @param parent + * The parent of the created part. + * @param partModel + * The model for which a part should be created. + * @return + */ + public PagePart createPagePart(TabFolderPart parent, IPageModel partModel, Object rawModel) { + + if(partModel instanceof IEditorModel) { + // Check if we can use IEditorModel + if(multiEditorManager == null) + throw new IllegalArgumentException("Container can't accept IEditorModel as no IMultiEditorManager is set. Please set a IMultiEditorManager."); + + return new EditorPart(parent, (IEditorModel)partModel, rawModel, multiEditorManager); + } else if(partModel instanceof IComponentModel) { + return new ComponentPart(parent, (IComponentModel)partModel, rawModel); + } else { + // Return a default part + } + + // TODO return a default part showing an error instead. + throw new IllegalArgumentException("No Part found for the model '" + rawModel + "'"); + } + + /** + * Get the active page. + * + * @return + */ + private PagePart getActivePage() { + return activePageTracker.getActiveEditor(); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#getActiveEditor() + * @return + * + */ + public IEditorPart getActiveEditor() { + PagePart pagePart = getActivePage(); + if(pagePart instanceof EditorPart) + return ((EditorPart)pagePart).getIEditorPart(); + else + return null; + } + + /** + * Get the active page public API. + * + * @return + */ + public IPage getActiveSashWindowsPage() { + return getActivePage(); + } + + /** + * Get the list of visible IPages. The visible IPages are the one that have + * there diagram area visible. + * + * @return + */ + public List getVisiblePages() { + CollectVisiblePageVisitor visitor = new CollectVisiblePageVisitor(); + + rootPart.visit(visitor); + + return visitor.getVisiblePages(); + } + + /** + * Get the list of visible IPages. The visible IPages are the one that have + * there diagram area visible. + * + * @return + */ + // public List getVisibleIEditorPages() { + // CollectVisiblePageVisitor visitor = new CollectVisiblePageVisitor( + // IEditorPage.class); + // + // rootPart.visit(visitor); + // + // return visitor.getVisiblePages(); + // } + + /** + * Get the list of visible IPages. The visible IPages are the one that have + * there diagram area visible. + * + * @return + */ + public List getVisibleIEditorParts() { + CollectVisibleIEditorPart visitor = new CollectVisibleIEditorPart(); + rootPart.visit(visitor); + + return visitor.getVisiblePages(); + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#setFocus() + * + */ + public void setFocus() { + setFocus(getActivePage()); + } + + /** + * Sets focus to the control for the given page. If the page has an editor, + * this calls its setFocus() method. Otherwise, this calls setFocus on the control for the page. + * + * @param pageIndex + * the index of the page + */ + private void setFocus(PagePart part) { + if(part != null) + part.setFocus(); + } + + /** + * Refresh the tabs. Is we are already currently refreshing, simply return. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#refreshTabs() + * + */ + public void refreshTabs() { + + // Check if we arent already refreshing + if(isRefreshing.compareAndSet(false, true)) { + try { + refreshTabsInternal(); + } finally { + isRefreshing.set(false); + } + } else { + log.warn("refresh inside refresh !"); + } + + } + + /** + * Refresh the tab of the page, (i.e the name and icon in the page's tab). + * + * @param page + * The page for which the name and icon should be refreshed. + */ + public void refreshPageTab(IPage page) { + if(page instanceof PagePart) { + ((PagePart)page).refreshTab(); + } else { + // TODO : lookup for the corresponding PagePart, and call refresh. + + } + } + + /** + * Real implementation of refreshTab. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#refreshTabs() + * + */ + private void refreshTabsInternal() { + // System.out.println("start synchronize2() ------------------------"); + // showTilesStatus(); + + // Get the currently selected folder + PagePart oldActivePage = getActivePage(); + + // Do refresh + container.setRedraw(false); + // Create map of parts + // PartMap partMap = new PartMap(); + PartLists garbageMaps = new PartLists(); + rootPart.fillPartMap(garbageMaps); + + // Synchronize parts + rootPart.synchronize2(garbageMaps); + + // Remove orphaned parts (no more used) + garbageMaps.garbage(); + + // set active page if needed + setActivePage(checkAndGetActivePage(oldActivePage, garbageMaps)); + + // Reenable SWT and force layout + container.setRedraw(true); + container.layout(true, true); + // System.out.println("end synchronize2() ------------------------"); + // showTilesStatus(); + } + + /** + * Select the specified page in the Parts. The specified page will becomes + * the active one. Appropriate events are fired. This is the programatic + * counterpart of selecting a page in the UI. If the provided page is null, + * do nothing. + * + * @param page + * The page to select or null. + */ + protected void selectPage(PagePart page) { + if(page == null) + return; + TabFolderPart folder = page.getParent(); + folder.setActiveEditor(page); + } + + /** + * Select the specified page in the Parts. The specified page will becomes + * the active one. Appropriate events are fired. This is the programatic + * counterpart of selecting a page in the UI. If the provided page is null, + * do nothing. + * + * @param page + * The page to select or null. The IPage should be an instance + * previously returned by the SashContainer. + */ + public void selectPage(IPage page) { + if(page == null) + return; + + // check if we are a correct instance. + if(!(page instanceof PagePart)) + return; + + selectPage((PagePart)page); + } + + /** + * Lookup the {@link IPage} used to render the specified rawModel. + * + * @param rawModel + * The model for which the IPage is requested. If the model is + * not rendered, return null; + * + * @return The corresponding IPage or null if not found. + */ + public IPage lookupModelPage(Object rawModel) { + // Use a visitor to lookup the first IPage + LookupModelPageVisitor visitor = new LookupModelPageVisitor(rawModel); + rootPart.visit(visitor); + return visitor.result(); + } + + /** + * Lookup the {@link IPage} used to render the specified IEditorPart. + * + * @param editor + * The IEditorPart for which the IPage is requested. If the + * IEditorPart is not rendered, return null; + * + * @return The corresponding IPage or null if not found. + */ + public IPage lookupIPageByIEditorPart(IEditorPart editor) { + // Use a visitor to lookup the first IPage + LookupIPageByIEditorPartVisitor visitor = new LookupIPageByIEditorPartVisitor(editor); + rootPart.visit(visitor); + return visitor.result(); + } + + /** + * Check if the oldActivePage still alive, and set it if needed. If the + * oldActivePage is null, set an active page if one exist. If the + * oldActivePage still alive, let it as the active one. If it is disposed, + * get arbitrarily an active page if one exist. + * + * @param oldActivePage + * @param partLists + * @param garbageMaps + * @return A valid active page or null if none exists. + */ + private PagePart checkAndGetActivePage(PagePart oldActivePage, PartLists partLists) { + + // Check if there is a created page + PagePart activePage = partLists.getFirstCreatedPage(); + if(activePage != null) + return activePage; + + // Check oldActivePage validity (in case it has been deleted) + if(oldActivePage != null && !(oldActivePage.isOrphaned() || oldActivePage.isUnchecked())) + return oldActivePage; + + // Get an active page if any + return lookupFirstValidPage(); + } + + /** + * Lookup for a valid active Page. Return null if none is found. TODO Use a + * visitor to implements this method. + * + * @return + */ + private PagePart lookupFirstValidPage() { + // First get a list of active editors + PartLists garbageMaps = new PartLists(); + rootPart.fillPartMap(garbageMaps); + return garbageMaps.getFirstValidPage(); + } + + /** + * Set a {@link MenuManager} used to manage a contextual menu that is shown + * on the tabs area of the folders. + * + * @param menuManager + * The {@link MenuManager} used to create the menu on the tab + * area. + */ + public void setFolderTabMenuManager(MenuManager menuManager) { + this.folderTabMenuManager = menuManager; + // Set the MenuManager in each existing folder. + // Use a visitor. + SetFolderTabMenuVisitor visitor = new SetFolderTabMenuVisitor(menuManager); + rootPart.visit(visitor); + } + + /** + * @return the menuManager + */ + public MenuManager getFolderTabMenuManager() { + return folderTabMenuManager; + } + + /** + * Show the status of the different Tiles composing the sash system. Used + * for debug purpose. + */ + public void showTilesStatus() { + ShowPartStatusVisitor visitor = new ShowPartStatusVisitor(); + rootPart.visit(visitor); + } + + /** + * Visit all the Pages (IEditorPage and IComponentPage), allowing to access + * to the public interface. + */ + public void visit(IPageVisitor pageVisitor) { + PageVisitorWrapper visitor = new PageVisitorWrapper(pageVisitor); + rootPart.visit(visitor); + } + + /** + * Visit the Part associated to the container. This method visibility is + * protected in order to be able to access it from junit tests. It is not + * intended to be used by public API or from outside. + */ + protected void visit(IPartVisitor visitor) { + rootPart.visit(visitor); + } + + /* ***************************************************** */ + /* Drag and Drop methods */ + /* ***************************************************** */ + + /** + * + */ + private void initDrag(Composite container) { + DragUtil.addDragTarget(container, dragOverListener); + + } + + IDragOverListener dragOverListener = new IDragOverListener() { + + /** + * + * @see org.eclipse.ui.internal.dnd.IDragOverListener#drag(org.eclipse.swt.widgets.Control, java.lang.Object, org.eclipse.swt.graphics.Point, + * org.eclipse.swt.graphics.Rectangle) + */ + public IDropTarget drag(Control currentControl, Object draggedObject, Point position, Rectangle dragRectangle) { + // TODO remove the cast by changing the method. Only folder can be + // source and target + final TabFolderPart sourcePart = (TabFolderPart)rootPart.findPart(draggedObject); // (ITilePart) draggedObject; + // Compute src tab index + // TODO move that and previous in the sender of drag event. Use a + // class containing both as draggedObject. + final int srcTabIndex = PTabFolder.getDraggedObjectTabIndex(draggedObject); + + // System.out.println("drag to position=" + position); + Rectangle containerDisplayBounds = DragUtil.getDisplayBounds(container); + AbstractPanelPart targetPart = null; + + // Check if the cursor is inside the container + if(containerDisplayBounds.contains(position)) { + + if(rootPart != null) { + targetPart = (AbstractPanelPart)rootPart.findPart(position); + // System.out.println("targetPart=" + targetPart + // + ", position=" + position + // + "container.toControl(position)=" + + // container.toControl(position)); + } + + if(targetPart != null) { + final Control targetControl = targetPart.getControl(); + + final Rectangle targetBounds = DragUtil.getDisplayBounds(targetControl); + + int side = Geometry.getClosestSide(targetBounds, position); + int distance = Geometry.getDistanceFromEdge(targetBounds, position, side); + + // Reserve the 5 pixels around the edge of the part for the + // drop-on-edge cursor + // Check if the target can handle the drop. + if(distance >= 5) { + // Otherwise, ask the part if it has any special meaning + // for this drop location + // TODO remove cast; change return type of findPart() + IDropTarget target = targetPart.getDropTarget(draggedObject, (TabFolderPart)sourcePart, position); + if(target != null) { + return target; + } + } else { + // We are on the boarder, try to drop on the parent + // Warning : the parent could be the rootPart + // System.out.println("DropTarget near the border"); + } + // + if(distance > 30) { + side = SWT.CENTER; + } + // + // // If the part doesn't want to override this drop + // location then drop on the edge + // + // // A "pointless drop" would be one that will put the + // dragged object back where it started. + // // Note that it should be perfectly valid to drag an + // object back to where it came from -- however, + // // the drop should be ignored. + // + @SuppressWarnings("unused") + boolean pointlessDrop = false; + + if(sourcePart == targetPart) { + pointlessDrop = true; + } + + return createDropTarget(sourcePart, srcTabIndex, side, side, targetPart); + } + } else { + // Cursor is outside the container + // System.out.println("Outside container bounds"); + // This will be used to create a new Window. + // We only allow dropping into a stack, not creating one + // if (differentWindows) + // return null; + + int side = Geometry.getClosestSide(containerDisplayBounds, position); + + boolean pointlessDrop = false; + int cursor = Geometry.getOppositeSide(side); + + if(pointlessDrop) { + side = SWT.NONE; + } + + return createDropTarget(sourcePart, srcTabIndex, side, cursor, null); + } + return null; + } + + }; + + /** + * Create the drop target + */ + private DropTarget createDropTarget(final TabFolderPart sourcePart, int srcTabIndex, int side, int cursor, AbstractPart targetPart) { + if(dropTarget == null) { + dropTarget = new DropTarget(sourcePart, srcTabIndex, side, cursor, targetPart); + } else { + dropTarget.setTarget(sourcePart, srcTabIndex, side, cursor, targetPart); + } + return dropTarget; + } + + /** + * Class implementing methods required by drop targets. + */ + protected class DropTarget implements IDropTarget { + + int count = 0; + + int cursor = SWT.TOP; + + private int side; + + private AbstractPanelPart targetPart; + + private int srcTabIndex; + + private TabFolderPart sourcePart; + + /** + * Constructor. + */ + public DropTarget(TabFolderPart sourcePart, int srcTabIndex, int cursor, int side, AbstractPart targetPart) { + this.cursor = cursor; + this.side = side; + this.sourcePart = sourcePart; + this.srcTabIndex = srcTabIndex; + this.targetPart = (AbstractPanelPart)targetPart; + } + + public void setTarget(TabFolderPart sourcePart, int srcTabIndex, int cursor, int side, AbstractPart targetPart) { + this.cursor = cursor; + this.side = side; + this.sourcePart = sourcePart; + this.srcTabIndex = srcTabIndex; + this.targetPart = (AbstractPanelPart)targetPart; + } + + /** + * A folder is dropped. + * + * @see org.eclipse.ui.internal.dnd.IDropTarget#drop() + */ + public void drop() { + // @TODO remove next cast + if(side == SWT.CENTER) { // Add to target folder + contentProvider.movePage(sourcePart.getPartModel(), srcTabIndex, ((TabFolderPart)targetPart).getPartModel(), -1); + } else { // Create a new folder + contentProvider.createFolder(sourcePart.getPartModel(), srcTabIndex, ((TabFolderPart)targetPart).getPartModel(), side); + } + } + + /** + * Return the cursor used during drag. + * + * @see org.eclipse.ui.internal.dnd.IDropTarget#getCursor() + */ + public Cursor getCursor() { + // System.out.println(SashWindowsContainer.this.getClass().getSimpleName() + // + ".getCursor()-" + count++); + return DragCursors.getCursor(DragCursors.positionToDragCursor(cursor)); + + } + + public Rectangle getSnapRectangle() { + // System.out.println(SashWindowsContainer.this.getClass().getSimpleName() + // + ".getSnapRectangle(" + "sourcePart=" + sourcePart + + // ", targetPart=" + targetPart + ", side=" + side); + Rectangle targetDisplayBounds; + + if(targetPart != null) { + targetDisplayBounds = DragUtil.getDisplayBounds(targetPart.getControl()); + } else { + // targetBounds = DragUtil.getDisplayBounds(getParent()); + targetDisplayBounds = DragUtil.getDisplayBounds(container); + } + + if(side == SWT.CENTER || side == SWT.NONE) { + return targetDisplayBounds; + } + + int distance = Geometry.getDimension(targetDisplayBounds, !Geometry.isHorizontal(side)); + + return Geometry.getExtrudedEdge(targetDisplayBounds, (int)(distance * getDockingRatio(sourcePart, targetPart)), side); + } + + protected float getDockingRatio(AbstractPart dragged, AbstractPart target) { + return 0.5f; + } + + } + + /** + * @return the lifeCycleEventProvider + */ + public SashContainerEventsProvider getLifeCycleEventProvider() { + return lifeCycleEventProvider; + } + + /** + * Add a listener on pageChanged event. This implementation delegates to the + * internal PageTracker. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#addPageChangedListener(org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener) + * @param pageChangedListener + * + */ + public void addPageChangedListener(IPageChangedListener pageChangedListener) { + activePageTracker.addPageChangedListener(pageChangedListener); + } + + /** + * Remove a listener on pageChanged event. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#removePageChangedListener(org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener) + * @param pageChangedListener + * + */ + public void removePageChangedListener(IPageChangedListener pageChangedListener) { + activePageTracker.removePageChangedListener(pageChangedListener); + } + + /** + * Add a listener on Page LifeCycle events. This implementation delegates to + * the internal PageTracker. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#addPageChangedListener(org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener) + * @param listener + * + */ + public void addLifeCycleListener(SashContainerEventsListener listener) { + lifeCycleEventProvider.addListener(listener); + } + + /** + * Remove a listener on Page LifeCycle events. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer#removePageChangedListener(org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener) + * @param listener + * + */ + public void removeLifeCycleListener(SashContainerEventsListener listener) { + lifeCycleEventProvider.removeListener(listener); + } + + /* ***************************************************** */ + /* Internal Visitors */ + /* ***************************************************** */ + + /** + * Inner class. A visitor setting the {@link MenuManager} on each folder. + */ + private class SetFolderTabMenuVisitor extends PartVisitor { + + private MenuManager menuManager; + + /** + * Constructor. + * + * @param menuManager + */ + public SetFolderTabMenuVisitor(MenuManager menuManager) { + this.menuManager = menuManager; + } + + /** + * Set the menu if the visited node is a folder. + */ + @Override + public boolean accept(TabFolderPart part) { + part.setFolderTabMenuManager(menuManager); + return true; + } + + } + + /** + * Inner class. A visitor used to collect all visible page in the + * sashcontainer. A visible page is a page whose the diagram area is + * visible. + */ + private class CollectVisiblePageVisitor extends PartVisitor { + + private List visiblePages = new ArrayList(); + + private Class expectedClass; + + /** + * Constructor. + * + * @param menuManager + */ + public CollectVisiblePageVisitor() { + + } + + /** + * Constructor. + * + * @param menuManager + */ + @SuppressWarnings("unused") + public CollectVisiblePageVisitor(Class expectedClass) { + this.expectedClass = expectedClass; + } + + /** + * Get the result list. + * + * @param + * @return + */ + @SuppressWarnings("unchecked") + public List getVisiblePages() { + return (List)visiblePages; + } + + /** + * Set the menu if the visited node is a folder. + */ + @Override + public boolean accept(TabFolderPart part) { + + IPage page = part.getVisiblePagePart(); + if(part != null) { + if(expectedClass != null && expectedClass.isInstance(page)) { + visiblePages.add(page); + } else { + visiblePages.add(page); + } + + } + + return true; + } + + } + + /** + * Inner class. A visitor used to collect all visible page in the + * sashcontainer. A visible page is a page whose the diagram area is + * visible. + */ + private class CollectVisibleIEditorPart extends PartVisitor { + + private List visiblePages = new ArrayList(); + + /** + * Constructor. + * + * @param menuManager + */ + public CollectVisibleIEditorPart() { + + } + + /** + * Get the result list. + * + * @param + * @return + */ + public List getVisiblePages() { + return visiblePages; + } + + /** + * Set the menu if the visited node is a folder. + */ + @Override + public boolean accept(TabFolderPart part) { + + IPage page = part.getVisiblePagePart(); + if(page != null && page instanceof IEditorPage) { + IEditorPage editorPage = (IEditorPage)page; + visiblePages.add(editorPage.getIEditorPart()); + + } + // continue searching + return true; + } + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashWindowsEventsProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashWindowsEventsProvider.java new file mode 100644 index 00000000000..537a2c5656e --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/SashWindowsEventsProvider.java @@ -0,0 +1,432 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.editor; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IPartListener; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; + +/** + * This class allows to listen on events from the {@link SashWindowsContainer}: + *
    + *
  • pageChanged - a page has changed in the current container
  • + *
  • - containerChanged - the active editor has changed, and so the currently active container.
  • + *
+ * + * This class require the current Eclipse page in order to listen on active + * editor changed. This class connect itself to the Workbench editor changed + * event. Then, it ask the current editor for a ISashWindowsContainer (using + * getAdaptor() ). If the editor return a ISashWindowsContainer, this class + * listen to the pageChanged events. This class takes care to connect itself to + * the new ISashWindowsContainer when the editor changes. + * + * @TODO rename as SashWindowsEventsNotifier + * @author cedric dumoulin + * + */ +public class SashWindowsEventsProvider { + + /** + * List of listeners that will be notified when the current Sash Page has + * changed. + */ + private PageChangedListeners pageEventsManager = new PageChangedListeners(); + + /** + * List of listeners that will be notified when the SashWindowsContainer has + * changed. + */ + private SashWindowsContainerChangedListeners containerEventsManager = new SashWindowsContainerChangedListeners(); + + /** + * Workbench page to which this mngr listen for {@link IEditorPart} changes. + */ + private IWorkbenchPage workbenchPage; + + /** + * The last active editor read by a call to workbenchPage.getActiveEditor(); + */ + private IEditorPart lastActiveEditor = null; + + /** + * Currently active SashContainer, or null if none is active. + */ + private ISashWindowsContainer currentContainer = null; + + /** Currently active page, or null if no container is active */ + private IPage activePage = null; + + private IPartListener workbenchPartListener = new IPartListener() { + + public void partOpened(IWorkbenchPart part) { + // System.out.println("partOpened("+ part +")"); + + } + + public void partDeactivated(IWorkbenchPart part) { + // System.out.println("partDeactivated("+ part +")"); + } + + public void partClosed(IWorkbenchPart part) { + // System.out.println("("+ part +")"); + } + + public void partBroughtToTop(IWorkbenchPart part) { + // System.out.println("partClosed("+ part +")"); + } + + public void partActivated(IWorkbenchPart part) { + // System.out.println("partActivated(" + part + ") - activeEditor: " + // + workbenchPage.getActiveEditor()); + checkActiveEditorChange(); + } + }; + + /** + * Permanent listener on sash pageChanged event. + */ + private IPageChangedListener sashPageChangedListener = new IPageChangedListener() { + + public void pageChanged(IPage newPage) { + firePageChanged(newPage); + } + }; + + /** + * + * Constructor. Page can be acquired with : + * IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + */ + public SashWindowsEventsProvider(IWorkbenchPage page) { + + // Initialize activePave and current Sash Container. + init(page); + // Register changed event listeners + registerEditorChangedListener(); + checkActiveEditorChange(); + } + + /** + * Initialize the first values. + * + * @param page + */ + private void init(IWorkbenchPage page) { + if(page == null) + throw new IllegalArgumentException("page should not be null."); + + workbenchPage = page; + + // Get the currently active container, if any. + ISashWindowsContainer newContainer = null; + IEditorPart editorPart = page.getActiveEditor(); + if(editorPart != null) { + newContainer = (ISashWindowsContainer)editorPart.getAdapter(ISashWindowsContainer.class); + } + + // // Set SashContainer and ActivePage + // currentContainer = newContainer; + // if( currentContainer != null) + // { + // activePage = newContainer.getActiveSashWindowsPage(); + // System.err.println("activePage=" + activePage.getPageTitle() + // + ", tab index=" + currentContainer.); + // } + } + + /** + * Return the currently active ISashWindowsContainer or null if none is + * actif. + * + * @return + */ + public ISashWindowsContainer activeSashWindowsContainer() { + return currentContainer; + } + + /** + * Return the currently active {@link IEditorPart} owning the currently + * active ISashWindowsContaineror. Return null if no container is actif. + * + * @return + */ + public IEditorPart activeSashWindowsContainerOwner() { + if(currentContainer == null) + return null; + return workbenchPage.getActiveEditor(); + } + + /** + * Return the currently active page associated to the currently active + * Container. Return null if no container is actif. + * + * @return + */ + public IPage activeSashWindowsPage() { + return activePage; + } + + /** + * Check if the active editor has changed. If true, send appropriate event. + */ + private void checkActiveEditorChange() { + // If the currently active editor has changed, send an event. + IEditorPart editor = workbenchPage.getActiveEditor(); + if(editor != lastActiveEditor) { + lastActiveEditor = editor; + activeEditorChanged(editor); + } + lastActiveEditor = editor; + } + + /** + * Dispose this manager. Cleanup listeners. + */ + public void dispose() { + workbenchPage.removePartListener(workbenchPartListener); + } + + /** + * Register a listener listeneing on editor change. Page can be acuired with + * : IWorkbenchPage page = + * PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + */ + private void registerEditorChangedListener() { + + workbenchPage.addPartListener(workbenchPartListener); + } + + /** + * This method is called when the active editor has change. The method + * checks the new editor and send appropriate events. The editor can be + * null. + * + * @param newEditor + * The new editor of null if none is set. + */ + private void activeEditorChanged(IEditorPart newEditor) { + + // Editor has changed. It can be null. + // Compute new container. + ISashWindowsContainer newContainer = null; + if(newEditor != null) { + newContainer = (ISashWindowsContainer)newEditor.getAdapter(ISashWindowsContainer.class); + } + + // Throw event if necessary + if(newContainer != currentContainer) + activeContainerChanged(newContainer); + } + + /** + * This method is called when the active container has changed. The + * pageChangedListener is removed from the oldContainer, and attached to the + * newContainer. + * + * @param newContainer + */ + private void activeContainerChanged(ISashWindowsContainer newContainer) { + // Detach listener from the old container + if(currentContainer != null) + currentContainer.removePageChangedListener(sashPageChangedListener); + + // record new container + currentContainer = newContainer; + + // attach listener to new container + if(currentContainer != null) { + currentContainer.addPageChangedListener(sashPageChangedListener); + firePageChanged(newContainer.getActiveSashWindowsPage()); + } + + // Fire events. + fireContainerChanged(newContainer); + IPage newPage = (newContainer != null ? newContainer.getActiveSashWindowsPage() : null); + firePageChanged(newPage); + } + + /** + * Send an event indicating a containerChanged. Propagate the event to all + * the listeners. + * + * @param activeEditor + */ + private void fireContainerChanged(ISashWindowsContainer newContainer) { + // Propagate to all the listeners + containerEventsManager.fireEvent(newContainer); + } + + /** + * Send an event indicating a pageChanged. Propagate the event to all the + * listeners. + * + * @param activeEditor + */ + private void firePageChanged(IPage newPage) { + + activePage = newPage; + // Propagate to all the listeners + pageEventsManager.fireEvent(newPage); + } + + /** + * Add a listener on pageChanged event. + * + * @param listener + */ + public void addPageChangedListener(IPageChangedListener listener) { + pageEventsManager.addListener(listener); + } + + /** + * Remove listener on pageChanged event. + * + * @param listener + */ + public void removePageChangedListener(IPageChangedListener listener) { + pageEventsManager.removeListener(listener); + } + + /** + * Add a listener on pageChanged event. + * + * @param listener + */ + public void addSashWindowsContainerChangedListener(ISashWindowsContainerChangedListener listener) { + containerEventsManager.addListener(listener); + } + + /** + * Remove listener on pageChanged event. + * + * @param listener + */ + public void removeSashWindowsContainerChangedListener(ISashWindowsContainerChangedListener listener) { + containerEventsManager.removeListener(listener); + } + + /** + * + * @author dumoulin + * + */ + private abstract class ListenersList { + + List listeners; + + /** + * Add specified listener. + * + * @param listener + */ + public void addListener(Listener listener) { + // Lazy creation + if(listeners == null) + listeners = new ArrayList(); + + // do not add if already present. + if(listeners.contains(listener)) + return; + + listeners.add(listener); + } + + /** + * Remove specified listener. + * + * @param listener + */ + public void removeListener(Listener listener) { + // Lazy creation + if(listeners == null) + return; + + listeners.remove(listener); + } + + /** + * Fire the event on each listener + * + * @param event + */ + public void fireEvent(Event event) { + // Lazy creation + if(listeners == null) + return; + + for(Listener listener : listeners) { + propertyChanged(listener, event); + } + } + + /** + * Call the listener appropriate property. + * + * @param listener + * @param event + */ + public abstract void propertyChanged(Listener listener, Event event); + } + + /** + * A list of {@link IPageChangedListener}. + * + * @author dumoulin + * + */ + public class PageChangedListeners extends ListenersList { + + /** + * Call the appropriate method on the listener. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsEventsProvider.ListenersList#propertyChanged(java.lang.Object, java.lang.Object) + * @param listener + * @param newPage + * + */ + @Override + public void propertyChanged(IPageChangedListener listener, IPage newPage) { + + try { + listener.pageChanged(newPage); + } catch (Exception e) { + // catch error in case a listener send an exception. + // Still show the exception for debug purpose + e.printStackTrace(); + } + + } + + } + + /** + * A list of {@link ISashWindowsContainerChangedListener} listening on + * container changed event. + * + * @author dumoulin + * + */ + public class SashWindowsContainerChangedListeners extends ListenersList { + + /** + * Call the appropriate method on the listener. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsEventsProvider.ListenersList#propertyChanged(java.lang.Object, java.lang.Object) + * @param listener + * @param newPage + * + */ + @Override + public void propertyChanged(ISashWindowsContainerChangedListener listener, ISashWindowsContainer newContainer) { + listener.sashWindowsContainerChanged(newContainer); + + } + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java new file mode 100644 index 00000000000..a5c7626003e --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java @@ -0,0 +1,155 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.editor.actionbarcontributor; + +import java.util.logging.Level; + +import org.eclipse.ui.IEditorActionBarContributor; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.part.EditorActionBarContributor; + +/** + * + * An ActionBarContributor composed of ActionBarContributor from multi editor. + * This ActionBarContributor switch to the contributor dedicated to the active + * editor in a MultiPageEditor environement. + * + * @author dumoulin + * + */ +public class ComposedActionBarContributor extends MultiPageEditorActionBarContributor { + + // /** + // * List of contributors. + // */ + // protected ContributorMap, + // EditorActionBarContributor> contributors = new ContributorMap, EditorActionBarContributor>(); + // + // + // /** + // * Contributor used as default. + // */ + // protected EditorActionBarContributor defaultContributor; + // + // /** + // * The currently active contributor. + // */ + // protected EditorActionBarContributor activeContributor; + + /** The currently active nested editor */ + protected IEditorPart activeNestedEditor; + + /** + * Constructor. + */ + public ComposedActionBarContributor() { + } + + /** + * Sets the active page of the the multi-page editor to be the given editor. + * Switch the currently active editor. + *

+ * This method is called whenever the page changes. Subclasses must implement this method to redirect actions to the given editor (if not already + * directed to it). + *

+ * + * @param activeEditor + * the new active editor, or null if there is no + * active page, or if the active page does not have a + * corresponding editor + */ + @Override + public void setActivePage(IEditorPart activeEditor) { + // Check if we are already initialized + // Return if we are not + if(getPage() == null) + return; + + // skip if the activeEditor doesn't change. + if(activeEditor == activeNestedEditor) + return; + + if(log.isLoggable(Level.FINE)) { + log.fine("setActivePage(" + activeEditor + " " + ")"); + } + + activeNestedEditor = activeEditor; + + // System.out.println(this.getClass().getSimpleName() + // + ".setActivePage(" + activeEditor + // + ") :" + getActiveContributor()); + + // Propagate call if possible + // Call setActiveEditor() on nested contributor. + IEditorActionBarContributor contributor = getActiveContributor(); + if(contributor != this && contributor instanceof EditorActionBarContributor) + ((EditorActionBarContributor)contributor).setActiveEditor(activeEditor); + + // if(contributor != this && contributor instanceof + // IMultiPageEditorActionBarContributor) + // ((IMultiPageEditorActionBarContributor)contributor).setActivePage(activeEditor); + + } + + /** + * Sets the active editor for the contributor. + *

+ * The EditorActionBarContributor implementation of this method does nothing. Subclasses may reimplement. This generally entails + * disconnecting from the old editor, connecting to the new editor, and updating the actions to reflect the new editor. + *

+ * + * @param part + * the new target editor + */ + public void setActiveEditor(IEditorPart part) { + if(log.isLoggable(Level.FINE)) { + log.fine("setActiveEditor(" + part + " " + ")"); + } + + // Switch the editor and activeContributor. + super.setActiveEditor(part); + // Now, propagate to the new activeContributor + // IEditorActionBarContributor activeContributor = + // getActiveContributor(); + // + // if(activeContributor!=this) + // activeContributor.setActiveEditor(part); + } + + /** + * Get the active nested contributor, if any. + * + * @return the active nested contributor, or null if any. + */ + protected IEditorActionBarContributor getActiveContributor() { + + // If there is no nestedEditor, this contributor is used. + if(activeNestedEditor == null) + return this; + + // + return activeNestedEditor.getEditorSite().getActionBarContributor(); + } + + // ************************************************ // + // Propagate method calls // + // ************************************************ // + + /** + * Returns this contributor's action bars. + * + * @return the action bars + */ + // public IActionBars getActionBars() { + // IEditorActionBarContributor activeContributor = getActiveContributor(); + // if( activeContributor!=this && activeContributor instanceof + // EditorActionBarContributor) + // return + // ((EditorActionBarContributor)getActiveContributor()).getActionBars(); + // else + // return super.getActionBars(); + // } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/IMultiPageEditorActionBarContributor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/IMultiPageEditorActionBarContributor.java new file mode 100644 index 00000000000..51d294c99a0 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/IMultiPageEditorActionBarContributor.java @@ -0,0 +1,46 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.editor.actionbarcontributor; + +import org.eclipse.ui.IEditorPart; + +/** + * Interface implemented by ActionBarContributor dedicated to MultiEditor. + * ActionBarContributor that want to be advised of a page change should + * implement this interface. Another way should be to use a Observer/Observee + * mechanism, allowing to remove the dependancy from the editor to the + * ActionBarContributor ? + * + * @author dumoulin + * + */ +public interface IMultiPageEditorActionBarContributor { + + /** + * Sets the active page of the the multi-page editor to be the given editor. + * Redirect actions to the given editor if actions are not already being + * sent to it. + *

+ * This method is called whenever the page changes. Subclasses must implement this method to redirect actions to the given editor (if not already + * directed to it). + *

+ * + * @param activeEditor + * the new active editor, or null if there is no + * active page, or if the active page does not have a + * corresponding editor + */ + public abstract void setActivePage(IEditorPart activeEditor); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/MultiPageEditorActionBarContributor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/MultiPageEditorActionBarContributor.java new file mode 100644 index 00000000000..ef6e754d645 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/actionbarcontributor/MultiPageEditorActionBarContributor.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.editor.actionbarcontributor; + +import java.util.logging.Logger; + +import org.eclipse.papyrus.infra.core.sasheditor.editor.IMultiPageEditorPart; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.part.EditorActionBarContributor; + +/** + * Abstract base class for managing the installation/deinstallation of global + * actions for multi-page editors. + *

+ * Subclasses must implement setActivePage, and may reimplement any of the following methods: + *

    + *
  • contributeToMenu - reimplement to contribute to menu
  • + *
  • contributeToToolBar - reimplement to contribute to tool bar
  • + *
  • contributeToStatusLine - reimplement to contribute to status line
  • + *
+ *

+ * This class is copied from {@link org.eclipse.ui.part.MultiPageEditorActionBarContributor} + */ +public abstract class MultiPageEditorActionBarContributor extends EditorActionBarContributor implements IMultiPageEditorActionBarContributor { + + /** Log object */ + Logger log = Logger.getLogger(getClass().getName()); + + /** + * Creates a multi-page editor action contributor. + */ + protected MultiPageEditorActionBarContributor() { + super(); + } + + /** + * Method declared on EditorActionBarContributor. Registers the contributor + * with the multi-page editor for future editor action redirection when the + * active page is changed, and sets the active page. + */ + public void setActiveEditor(IEditorPart part) { + + IEditorPart activeNestedEditor = null; + if(part instanceof IMultiPageEditorPart) { + activeNestedEditor = ((IMultiPageEditorPart)part).getActiveEditor(); + setActivePage(activeNestedEditor); + } + + } + + /** + * Called by the MultiEditor whenever the active page change. + * + * @param activeEditor + */ + public abstract void setActivePage(IEditorPart activeEditor); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/gef/MultiDiagramEditorGefDelegate.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/gef/MultiDiagramEditorGefDelegate.java new file mode 100644 index 00000000000..4d044f510ae --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/gef/MultiDiagramEditorGefDelegate.java @@ -0,0 +1,108 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.editor.gef; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.gef.ui.actions.ActionRegistry; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; + +/** + * Provide methods and services needed for Gef Editors. This class is intended + * to be used as a delegate inside classes providing MultiDiagramEditor. + * + * @author dumoulin + * + */ +public class MultiDiagramEditorGefDelegate { + + /** The registry holding actions associated to the main editor */ + protected ActionRegistry actionRegistry; + + /** Synchronizer object */ + // private MultiPageSelectionSynchronizer synchronizer; + + /** List of listeners on SelectionChanged event */ + private List selectionListeners = new ArrayList(1); + + /** + * This method should be called by the containing class. + */ + public void dispose() { + selectionListeners.clear(); + if(actionRegistry != null) { + actionRegistry.dispose(); + } + } + + /** + * Adds a listener for selection changes in this selection provider. Has no + * effect if an identical listener is already registered. + * + * @param listener + * a selection changed listener + */ + public void addSelectionChangedListener(ISelectionChangedListener listener) { + selectionListeners.add(listener); + } + + /** + * Lazily creates and returns the action registry. + * + * @return the action registry + */ + public ActionRegistry getActionRegistry() { + if(actionRegistry == null) + actionRegistry = new ActionRegistry(); + return actionRegistry; + } + + // /** + // * Returns the selection synchronizer object. The synchronizer can be used + // to sync the selection of 2 or more EditPartViewers. + // * + // * @return the syncrhonizer + // */ + // public MultiPageSelectionSynchronizer getSelectionSynchronizer() { + // if (synchronizer == null) { + // synchronizer = new MultiPageSelectionSynchronizer(); + // // Hook this editor. + // // synchronizer.addViewer(this); + // } + // return synchronizer; + // } + + /** + * Removes the given selection change listener from this selection provider. + * Has no affect if an identical listener is not registered. + * + * @param listener + * the selection changed listener to be removed + */ + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + selectionListeners.remove(listener); + } + + /** + * Sets the current selection for this selection provider. + * + * @param selection + * the new selection + */ + public void setSelection(ISelection selection) { + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPanelPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPanelPart.java new file mode 100644 index 00000000000..1e9ef702e0c --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPanelPart.java @@ -0,0 +1,170 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.internal.dnd.IDropTarget; + +/** + * Common ancestor of Panel Parts. Panels are sashes and folders. + * + * @author cedric dumoulin + */ +public abstract class AbstractPanelPart extends AbstractPart { + + /** + * Parent of this part. + */ + protected IPanelParent parent; + + /** + * Constructor. + * + * @param parent + * Parent of the Pane. + */ + public AbstractPanelPart(IPanelParent parent) { + super(parent.getSashWindowContainer()); + } + + /** + * Create the SWT controls. This method is called by the SWT parent. + * + * @param container + */ + abstract public void createPartControl(Composite container); + + /** + * Dispose all nested SWT controls. + */ + abstract public void dispose(); + + /** + * Visit the part. + * + * @param visitor + */ + abstract public boolean visit(IPartVisitor visitor); + + /** + * Synchronize the part and its children with the models in contentProvider. + * + * @param existingParts + * List of already existing part before the synchronization. + */ + abstract public void synchronize2(PartLists existingParts); + + /** + * Return true is the part is for the specified raw model. Return false + * otherwise. + * + * @param rawModel + * @return + */ + abstract public boolean isPartFor(Object rawModel); + + /** + * Orphan this node. The parent is set to null, but control is left + * unchanged. The node can be reattached with reparent(). Change garbage + * state to {@link GarbageState.ORPHANED}. This method as no effect if the + * Tile has already been reparented. + */ + public void orphan() { + // orphan only if we are in UNCHANGED state + if(garbageState == GarbageState.UNVISITED) { + garbageState = GarbageState.ORPHANED; + parent = null; + } + } + + /** + * Mark this Page as UNCHANGED. The PAge should be in the COLLECTED state. + * + * @see + * @return the parent + */ + public void unchanged() { + // orphan only if we are in COLLECTED state + if(garbageState == GarbageState.UNVISITED || garbageState == GarbageState.ORPHANED) { + garbageState = GarbageState.UNCHANGED; + } else { + // Bad state, this is an internal error + // TODO : log a warning ? + throw new IllegalStateException("Try to change state from " + garbageState.toString() + " to UNCHANGED. This is forbidden."); + } + } + + /** + * Change the parent of the Part. The parent is changed, and the control is + * attached to the parent control. Change garbage state to {@link GarbageState.REPARENTED}. + * + * @param newParent + * The new parent to which the part should be attached. + */ + abstract public void reparent(IPanelParent newParent, Composite swtParent); + + /** + * Collect all the parts. The method is called recursively in the tree of + * parts. + * + * @param parts + * The list into which parts are added. + */ + abstract public void fillPartMap(PartLists parts); + + /** + * Traverses the tree to find the part that intersects the given point + * + * @param toFind + * Point in display coordinate + * @return the part that intersects the given point + * @throws NotFoundException + */ + abstract public AbstractPart findPart(Point toFind) throws NotFoundException; + + /** + * Find the part associated to the provided control. + * + * @param control + * @return + */ + abstract public AbstractPart findPart(Object control); + + /** + * Locates the part that intersects the given point and that have the + * expected type + * + * @param toFind + * Position in Display coordinate. + * @return + */ + abstract public AbstractPart findPartAt(Point toFind, Class expectedTileType); + + /* ***************************************************** */ + /* Drag and Drop methods */ + /* ***************************************************** */ + + /** + * Return the swt Control associated to this part. + */ + abstract public Composite getControl(); + + /** + * Get the drop target. Used by the drag tab mechanism. + */ + abstract public IDropTarget getDropTarget(Object draggedObject, TabFolderPart sourcePart, Point position); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPart.java new file mode 100644 index 00000000000..a7d8ba2f5bf --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/AbstractPart.java @@ -0,0 +1,101 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; + +/** + * Base class of the Part hierarchy. This class provides common methods for + * sashwindows Parts. + * + * + * @author dumoulin + */ +public abstract class AbstractPart { + + /** + * Enumeration used when the parts are synchronized. + *
    + *
  • UNVISITED - The part not yet visited. This is the initial state when synchronizing. The part can stay in this state after synchronization + * if one of its parent is ORPHANED.
  • + *
  • ORPHANED - The part is orphaned from its direct parent.
  • + *
  • REPARENTED - The part parent has changed
  • + *
  • CREATED - The part is newly created
  • + *
  • UNCHANGED - The part is visited, and its parent is unchanged.
  • + *
+ */ + public enum GarbageState { + UNVISITED, ORPHANED, REPARENTED, CREATED, UNCHANGED + } + + /** + * The main container. + */ + protected SashWindowsContainer sashWindowsContainer; + + /** Garbage state used during refresh */ + protected GarbageState garbageState = GarbageState.CREATED; + + /** + * @param sashWindowsContainer + */ + public AbstractPart(SashWindowsContainer sashWindowsContainer) { + this.sashWindowsContainer = sashWindowsContainer; + } + + /** + * Get the {@link SashWindowsContainer}. + * + * @return + */ + public SashWindowsContainer getSashWindowContainer() { + return sashWindowsContainer; + } + + /** + * Get the content provider of the sashwindows. + * + * @return + */ + public ISashWindowsContentProvider getContentProvider() { + return sashWindowsContainer.getContentProvider(); + } + + /** + * + * @return + */ + public boolean isOrphaned() { + return garbageState == GarbageState.ORPHANED; + } + + /** + * Return true if the page state == {@link GarbageState#UNVISITED}. + * + * @return + */ + public boolean isUnchecked() { + + return garbageState == GarbageState.UNVISITED; + } + + /** + * @return + */ + public GarbageState getGarbageState() { + return garbageState; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActiveEditorServicesSwitcher.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActiveEditorServicesSwitcher.java new file mode 100644 index 00000000000..1c994ac127b --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActiveEditorServicesSwitcher.java @@ -0,0 +1,270 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; +import org.eclipse.papyrus.infra.core.sasheditor.editor.actionbarcontributor.IMultiPageEditorActionBarContributor; +import org.eclipse.papyrus.infra.core.sasheditor.internal.ActivePageTracker.IActiveEditorChangedListener; +import org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy.MultiPageSelectionProvider; +import org.eclipse.ui.IEditorActionBarContributor; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.IKeyBindingService; +import org.eclipse.ui.INestableKeyBindingService; +import org.eclipse.ui.IPartService; +import org.eclipse.ui.internal.WorkbenchPlugin; +import org.eclipse.ui.internal.services.INestable; +import org.eclipse.ui.part.MultiPageEditorActionBarContributor; +import org.eclipse.ui.services.IServiceLocator; + +/** + * This class is used to switch the services of a nested editor when the active + * nested editor change. This class is a {@link IActiveEditorChangedListener} registered to the {@link ActivePageTracker} by the + * {@link SashWindowsContainer}. + * + * When a new Editor is set active, by calling {@link #setActiveEditor(PagePart)}, following actions are performed: + *
    + *
  • deactivate services: nested site and keybinding
  • + *
  • An event is sent to the ActionBarContributor if it accept it (by implementing {@link IMultiPageEditorActionBarContributor})
  • + *
  • Send {@link SelectionChangedEvent} to the main editor. The event contains the current selection of the new active editor.
  • + *
  • Connect the keybinding service to the new Editor.
  • + *
+ * + * + * @author cedric dumoulin + * + */ +public class ActiveEditorServicesSwitcher implements IActiveEditorChangedListener { + + /** Log object */ + Logger log = Logger.getLogger(getClass().getName()); + + /** The currently active editor */ + protected PagePart activeEditor; + + /** + * The {@link IEditorSite} of the outerMost editor (the main editor) ... + */ + private IEditorSite outerEditorSite; + + /** + * The active service locator. This value may be null if there + * is no selected page, or if the selected page is a control with no site. + */ + private INestable activeServiceLocator; + + /** + * Constructor. + * + * @param outerEditorSite + * {@link IEditorSite} of the main editor. + */ + public ActiveEditorServicesSwitcher(IEditorSite outerEditorSite) { + this.outerEditorSite = outerEditorSite; + } + + /** + * Get the currently active IEditorPart, if any. Return null if there is no + * active IeditorPart. Method check if the active leaf encapsulate an + * IEditorPart. Return it if true. + * + * @return The currentlyactive IEditorPart or null. + */ + private IEditorPart getActiveIEditorPart() { + return getIEditorPart(activeEditor); + } + + /** + * Get IEditorPart of the specified PagePart, if any. Return null if there + * is no IeditorPart. Method check if the leaf encapsulate an IEditorPart. + * Return it if true. + * + * @return The IEditorPart or null. + */ + private IEditorPart getIEditorPart(PagePart pagePart) { + if(pagePart == null) + return null; + + if(pagePart instanceof EditorPart) { + return ((EditorPart)pagePart).getIEditorPart(); + } + // not found + return null; + } + + /** + * Called when the active editor is changed. Perform requested operations. + * + * @param oldEditor + * @param newEditor + */ + public void activeEditorChanged(PagePart oldEditor, PagePart newEditor) { + if(activeEditor == newEditor) { + return; + } + + // System.out.println(getClass().getSimpleName() + + // ".activeEditorChange('" + (newEditor != null ? + // newEditor.getPageTitle() : "null") + "')"); + + activeEditor = newEditor; + + // Set focus + IPartService partService = (IPartService)getOuterEditorSite().getService(IPartService.class); + if(newEditor != null && partService.getActivePart() == getOuterEditorSite().getPart()) { + newEditor.setFocus(); + } + + // Switch services + deactivateServices(false); + fireChangeEventToActionBarContributor(); + propagateSelectionChanged(); + activateServices(); + + // + if(newEditor != null) + newEditor.setFocus(); + } + + /** + * Change the current selection of the outermost editor (the main editor). + * Send a {@link SelectionChangedEvent} event to the outerProvider. The + * event contains the current selection of the new activeEditor. + * + * @param editor + * The new activeEditor. + */ + private void propagateSelectionChanged() { + + // Get the IEditor + IEditorPart editorPart = getActiveIEditorPart(); + + // Propagate the selection change event. + // Get the selection of the new activeEditor and send an + // SelectionChangedEvent to the outerProvider (provider of the main + // editor) with the selection. + if(editorPart != null) { + ISelectionProvider selectionProvider = editorPart.getSite().getSelectionProvider(); + if(selectionProvider != null) { + ISelectionProvider outerProvider = getOuterEditorSite().getSelectionProvider(); + if(outerProvider instanceof MultiPageSelectionProvider) { + SelectionChangedEvent event = new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()); + + MultiPageSelectionProvider provider = (MultiPageSelectionProvider)outerProvider; + provider.fireSelectionChanged(event); + provider.firePostSelectionChanged(event); + } else { + if(log.isLoggable(Level.WARNING)) { + log.warning(this.getClass().getSimpleName() + " did not propogate selection for " //$NON-NLS-1$ + + editorPart.getTitle()); + } + } + } + } + } + + /** + * Activates services of the active editor: site, keybinding deactivate old + * active site. + */ + @SuppressWarnings({ "restriction", "deprecation" }) + private void activateServices() { + // Deactivate old active site + if(activeServiceLocator != null) { + activeServiceLocator.deactivate(); + activeServiceLocator = null; + } + + // Get the service + final IKeyBindingService service = getOuterEditorSite().getKeyBindingService(); + + final IEditorPart editor = getActiveIEditorPart(); + + if(editor != null) { + // active the service for this inner editor + if(service instanceof INestableKeyBindingService) { + final INestableKeyBindingService nestableService = (INestableKeyBindingService)service; + nestableService.activateKeyBindingService(editor.getEditorSite()); + + } else { + WorkbenchPlugin.log("MultiPageEditorPart.activateSite() Parent key binding service was not an instance of INestableKeyBindingService. It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$ + } + // Activate the services for the new service locator. + final IServiceLocator serviceLocator = editor.getEditorSite(); + if(serviceLocator instanceof INestable) { + activeServiceLocator = (INestable)serviceLocator; + activeServiceLocator.activate(); + } + + } + } + + /** + * Deactivate services: old nested site if any and keybinding service if + * there is no active editor. Deactivate the key binding service. Deactivate + * it only if there is no editor selected. + */ + @SuppressWarnings({ "restriction", "deprecation" }) + private void deactivateServices(boolean immediate) { + // Deactivate the nested services from the last active service locator. + if(activeServiceLocator != null) { + activeServiceLocator.deactivate(); + activeServiceLocator = null; + } + + final IEditorPart editor = getActiveIEditorPart(); + final IKeyBindingService service = getOuterEditorSite().getKeyBindingService(); + if(editor != null || immediate) { + // There is no selected page, so deactivate the active service. + if(service instanceof INestableKeyBindingService) { + final INestableKeyBindingService nestableService = (INestableKeyBindingService)service; + nestableService.activateKeyBindingService(null); + } else { + WorkbenchPlugin.log("MultiPageEditorPart.deactivateSite() Parent key binding service was not an instance of INestableKeyBindingService. It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + } + + /** + * Send message to the ActionBarContributor, like this it can switch the + * active editor. + */ + private void fireChangeEventToActionBarContributor() { + IEditorActionBarContributor contributor = getOuterEditorSite().getActionBarContributor(); + if(contributor != null && contributor instanceof IMultiPageEditorActionBarContributor) { + ((IMultiPageEditorActionBarContributor)contributor).setActivePage(getActiveIEditorPart()); + } + + // Ensure compatibility with Eclipse MultiPageEditorActionBarContributor + else if(contributor != null && contributor instanceof MultiPageEditorActionBarContributor) { + ((MultiPageEditorActionBarContributor)contributor).setActivePage(getActiveIEditorPart()); + } + + } + + /** + * Return the MultipageEditorSite + * + * @return + */ + private IEditorSite getOuterEditorSite() { + return outerEditorSite; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActivePageTracker.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActivePageTracker.java new file mode 100644 index 00000000000..78c6304a481 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ActivePageTracker.java @@ -0,0 +1,182 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPageChangedListener; +import org.eclipse.papyrus.infra.core.sasheditor.internal.ActivePageTracker.IActiveEditorChangedListener; + +/** + * Instance of this class track the active Page. When the active Page change, + * the tracker receive an event on {@link #setActiveEditor(PagePart)}, and + * perform following tasks: + *
    + *
  • - call {@link #fireEditorChangeEvent(PagePart, PagePart)}
  • + *
  • - fire events to all registered listeners.
  • + *
+ * + * This class allows tow kind of listeners: + * + *
    + *
  • {@link IActiveEditorChangedListener} for internal use (ex: {@link ActiveEditorServicesSwitcher})
  • + *
  • {@link IPageChangedListener} for public API use.
  • + *
+ * This class allows to set externally the active editor. + * + * @author dumoulin + * + */ +public class ActivePageTracker { + + /** Log object */ + Logger log = Logger.getLogger(getClass().getName()); + + /** List of listeners */ + private List activeEditorChangedListeners = new ArrayList(); + + /** List of public listeners */ + private List publicPageChangedListeners; + + /** The currently active editor */ + protected PagePart activeEditor; + + /** + * Interface that must be implemented by listeners on activeEditorChange + * event. + * + * @author dumoulin + * + */ + public interface IActiveEditorChangedListener { + + /** + * This method is called whenever the active editor is changed. + * + * @param oldEditor + * @param newEditor + */ + public void activeEditorChanged(PagePart oldEditor, PagePart newEditor); + } + + /** + * Constructor. The activeEditor will be set by the first TabFolder that + * will call TabFolderPart.setPage(). + * + * @param multiPartEditor + */ + public ActivePageTracker() { + } + + /** + * Get the activeEditor. + * + * @return The active editor or null if there is none. + */ + public PagePart getActiveEditor() { + return activeEditor; + } + + /** + * Set the active editor with the specified editor. This will notify all + * registered listeners + * + * @param editor + */ + public void setActiveEditor(PagePart editor) { + // Skip if there is no change + if(activeEditor == editor) + return; + + PagePart oldEditor = activeEditor; + activeEditor = editor; + fireEditorChangeEvent(oldEditor, editor); + } + + /** + * Add a listener on the activeEditorChange event. + * + * @param listener + */ + public void addActiveEditorChangedListener(IActiveEditorChangedListener listener) { + // no duplicate + if(activeEditorChangedListeners.contains(listener)) + return; + activeEditorChangedListeners.add(listener); + } + + /** + * Add a listener on the activeEditorChange event. + * + * @param listener + */ + public void removeActiveEditorChangedListener(IActiveEditorChangedListener listener) { + activeEditorChangedListeners.remove(listener); + } + + /** + * Add a listener on the activeEditorChange event. + * + * @param listener + */ + public void addPageChangedListener(IPageChangedListener listener) { + // no duplicate + if(publicPageChangedListeners == null) + publicPageChangedListeners = new ArrayList(); + + if(publicPageChangedListeners.contains(listener)) + return; + publicPageChangedListeners.add(listener); + } + + /** + * Add a listener on the activeEditorChange event. + * + * @param listener + */ + public void removePageChangedListener(IPageChangedListener listener) { + if(publicPageChangedListeners == null) + return; + + publicPageChangedListeners.remove(listener); + } + + /** + * Notify all listener with event. + * + * @param oldEditor + * @param newEditor + */ + private void fireEditorChangeEvent(PagePart oldEditor, PagePart newEditor) { + // Fire only if really change + // if(oldEditor == newEditor) + // return; + + // Fire events to internal listeners + for(IActiveEditorChangedListener listener : activeEditorChangedListeners) { + listener.activeEditorChanged(oldEditor, newEditor); + } + + // Fire event to public listeners + if(publicPageChangedListeners != null) { + for(IPageChangedListener listener : publicPageChangedListeners) { + listener.pageChanged(newEditor); + } + } + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ComponentPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ComponentPart.java new file mode 100644 index 00000000000..7bf799422fc --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ComponentPart.java @@ -0,0 +1,274 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.papyrus.infra.core.sasheditor.Activator; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IComponentModel; +import org.eclipse.papyrus.infra.core.sasheditor.editor.IComponentPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.internal.dnd.IDropTarget; + +/** + * This is a controler/part for an SWT Control. It is associated to a {@link IComponentModel}. This Part encapsulate a SWT Control. + * + * @author dumoulin + * + */ +@SuppressWarnings("restriction") +public class ComponentPart extends PagePart implements IComponentPage { + + /** + * The model representing the control. + */ + private IComponentModel partModel; + + /** + * The SWT Control. + */ + private Composite editorControl; + + /** + * Constructor. + * + * @param partModel + * The model of the editor. + */ + public ComponentPart(TabFolderPart parent, IComponentModel partModel, Object rawModel) { + super(parent, rawModel); + this.partModel = partModel; + } + + /** + * Create the control of this Part, and children's controls. + * + * @param parent + */ + public void createPartControl(Composite parent) { + + try { + // Initialize it and create its controls. + editorControl = createEditorPartControl(parent); + // attachListeners(editorControl, true); + + } catch (PartInitException e) { + Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage())); + } + } + + /** + * Create the controls required by the editor. Init the editor. + * + * @param viewer + * @param editorInput + * @param model + * @return + * @throws PartInitException + */ + private Composite createEditorPartControl(Composite parentControl) throws PartInitException { + Composite editorParent = new Composite(parentControl, SWT.NONE); + editorParent.setLayout(new FillLayout()); + partModel.createPartControl(editorParent); + + return editorParent; + } + + /** + * @param isRecursive + */ + public void dispose() { + + // detachListeners(editorControl, true); + // dispose the SWT root control + editorControl.dispose(); + } + + /** + * As we are a final Tile, we should be the requested part. Return this + * TilePart. + * + * @param toFind + * @return + */ + public PagePart findPart(Point toFind) { + return this; + } + + /** + * Locates the part that intersects the given point and that have the + * expected type + * + * @param toFind + * @return + */ + public PagePart findPartAt(Point toFind, Class expectedTileType) { + + if(expectedTileType == this.getClass()) + return this; + + // Not found !! + // The tile contains the position, but the type is not found. + throw new UnsupportedOperationException("Tile match the expected position '" + toFind + "' but there is no Tile of requested type '" + expectedTileType.getClass().getName() + "'"); + } + + /** + * @param control + * @return + */ + public PagePart findPart(Object control) { + if(getControl() == control) + return this; + + // Not found + return null; + } + + /** + * Get associated SWT Control. + * + * @return + */ + public Composite getControl() { + return editorControl; + } + + /** + * This is a container method. Not necessary in Leaf Tile. TODO: change the + * interface. + * + * @param draggedObject + * @param sourcePart + * @param position + * @return + */ + public IDropTarget getDropTarget(Object draggedObject, TabFolderPart sourcePart, Point position) { + return null; + } + + /** + * Change the parent of the Tile. The parent is changed, and the control is + * attached to the parent control. Change garbage state to {@link GarbageState.REPARENTED}. Do not detach the Tile from its old + * parent. + * + * @param newParent + * The tilePart that should be used as part parent. + * @param compositeParent + * The composite that should be used as parent. + */ + public void reparent(TabFolderPart newParent) { + + // Change the tile parent + this.parent = newParent; + // Change the SWT parent. + editorControl.setParent(newParent.getControl()); + + // Change state + if(garbageState == GarbageState.UNVISITED || garbageState == GarbageState.ORPHANED) { + garbageState = GarbageState.REPARENTED; + } else { + // Bad state, this is an internal error + // TODO : log a warning ? + throw new IllegalStateException("Try to change state from " + garbageState.toString() + " to REPARENTED. This is forbidden."); + } + } + + /** + * Asks this part to take focus within the workbench. Set the focus on the + * active nested part if the part is a container. + */ + public void setFocus() { + editorControl.setFocus(); + } + + /** + * Synchronize the Part, and its children. PartMap contains a snapshot of + * the available part before the synchronization. After synchronization, + * unreachable parts should be marked "orphaned" (= no parent). Do nothing + * in this implementation, as we are a final leaf, and there is nothing to + * synchronize with the underlying model. + * + * @param partMap + */ + public void synchronize2(PartLists partMap) { + + } + + /** + * Garbage this part. The part is already marked as ORPHANED. It is not used + * anymore. It is already detached from its parent. + * + */ + public void garbage() { + dispose(); + // fire appropriate life cycle event + getSashWindowContainer().getLifeCycleEventProvider().firePageClosedEvent(this); + } + + /** + * Accept the provided visitor. Call the corresponding accept method in the + * visitor. + * + * @param visitor + * @return + */ + public boolean visit(IPartVisitor visitor) { + return visitor.accept(this); + } + + /** + * Visit the children of this Tile. There is no child, so do nothing. + * + * @param visitor + */ + public boolean visitChildren(IPartVisitor visitor) { + return true; + } + + /** + * Show item status. + */ + protected void showStatus() { + // System.out.println( "EditorTile: " + // + " disposed=" + editorControl.isDisposed() + // + ", visible=" + editorControl.isVisible() + // + ", garbState=" + garbageState + // + ", '" + editorPart.getTitle() + // + "', " + this); + + System.out.printf("ComponentPart: disposed=%-5b, visible=%-5b, garbState=%-10s, %s, %s\n", editorControl.isDisposed(), (editorControl.isDisposed() ? false : editorControl.isVisible()), garbageState, getPageTitle(), this); + + } + + /** + * Get the title for this part. {@inheritDoc} + */ + @Override + public String getPageTitle() { + return partModel.getTabTitle(); + } + + /** + * Return an icon for this part. {@inheritDoc} + */ + @Override + public Image getPageIcon() { + return partModel.getTabIcon(); + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/Copyright.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/Copyright.java new file mode 100644 index 00000000000..bf356d466f1 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/Copyright.java @@ -0,0 +1,22 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +/** + * @author dumoulin + */ +public class Copyright { + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/EditorPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/EditorPart.java new file mode 100644 index 00000000000..5cb1d6d9afc --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/EditorPart.java @@ -0,0 +1,624 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.infra.core.sasheditor.Activator; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel; +import org.eclipse.papyrus.infra.core.sasheditor.editor.IEditorPage; +import org.eclipse.papyrus.infra.core.sasheditor.editor.IMultiEditorManager; +import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; +import org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy.MultiPageEditorSite; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.IPropertyListener; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.internal.ErrorEditorPart; +import org.eclipse.ui.internal.dnd.IDropTarget; +import org.eclipse.ui.internal.misc.StatusUtil; +import org.eclipse.ui.part.EditorActionBarContributor; +import org.eclipse.ui.part.IWorkbenchPartOrientation; + +/** + * This is a controler/part for an Editor. It is associated to a {@link IEditorModel}. This Part encapsulate an Eclipse Editor implementing + * {@link IEditorPart}. + * + * @author dumoulin + * @author Thomas SZADEL + * Improve the error text (avoid NPE) + */ +@SuppressWarnings("restriction") +public class EditorPart extends PagePart implements IEditorPage { + + /** + * The model representing the editor. + */ + private IEditorModel editorModel; + + /** + * The created Eclipse editor. + */ + private IEditorPart editorPart; + + /** + * The SWT Control containning the editor's controls. + */ + private Composite editorControl; + + /** + * The MultiPageContainer system. This is the manager of all tiles. + */ + private SashWindowsContainer tilesContainer; + + /** + * The manager used to access main editor properties like site, actionbars, + * ... + */ + private IMultiEditorManager multiEditorManager; + + /** + * Parent owning this PagePart. Can be null if the Part is orphaned. Even if + * it is orphaned, the Item still set. + */ + // protected TabFolderPart parent; + + /** + * Listen on mouse enter event. Try to get an event indicating that the + * mouse enter over the editor. This can be used to switch the active + * editor. TODO This doesn't work yet. + */ + private Listener mouseEnterListener = new Listener() { + + /** + * (non-Javadoc) + * + * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) + */ + public void handleEvent(Event event) { + // Point globalPos = new Point(event.x, event.y); + // System.out.println(this.getClass().getSimpleName() + + // ".handleEvent(" + eventName(event.type) + ", " + globalPos + + // ")"); + } + }; + + private String eventName(int eventType) { + switch(eventType) { + case SWT.MouseEnter: + return "MouseEnter"; + case SWT.MouseDown: + return "MouseDown"; + case SWT.MouseExit: + return "MouseExit"; + case SWT.MouseHover: + return "MouseHover"; + case SWT.FocusIn: + return "FocusIn"; + case SWT.FocusOut: + return "FocusOut"; + case SWT.MouseMove: + return "MouseMove"; + case SWT.MouseUp: + return "MouseUp"; + case SWT.Activate: + return "Activate"; + default: + return Integer.toString(eventType); + } + } + + /** + * Constructor. + * + * @param editorModel + * The model of the editor. + */ + public EditorPart(TabFolderPart parent, IEditorModel editorModel, Object rawModel, IMultiEditorManager multiEditorManager) { + super(parent, rawModel); + this.editorModel = editorModel; + this.multiEditorManager = multiEditorManager; + } + + /** + * Create the control of this part. For a this implementations, also create + * the children's controls. This method forward to {@link + * createPartControl(Composite)}. + * + * @param parent + * TODO remove ? + */ + // public void createControl(Composite parent) { + // createPartControl(parent); + // } + + /** + * Create the control of this Part, and children's controls. + * + * @param parent + */ + @Override + public void createPartControl(Composite parent) { + + try { + // Create the editor. + editorPart = createIEditorPart(); + // Initialize it and create its controls. + editorControl = createEditorPartControl(parent, editorPart); + attachListeners(editorControl, true); + } catch (PartInitException e) { + Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage(), e)); + // TODO Create a fake Error Page and initialize this part with. + // editorPart = new ErrorEditorPart(); + // editorControl = createEditorPartControl(parent, editorPart); + // editorControl = createErrorPartControl(parent, e); + createErrorEditorPart(parent, e); + } catch (Exception e) { + Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage(), e)); + // TODO Create a fake Error Page and initialize this part with. + // editorControl = createErrorPartControl(parent, e); + createErrorEditorPart(parent, e); + } + } + + /** + * Create a Control showing the error. + * + * @param parent + * Parent Control to which the Created Control should be attached + * @param e + * Exception containing the error. + */ + private Composite createErrorPartControl(Composite parent, Exception e) { + + Composite comp = new Composite(parent, SWT.NONE); + comp.setLayout(new FillLayout()); + // Show the stack trace + StringWriter strOut = new StringWriter(); + PrintWriter out = new PrintWriter(strOut); + e.printStackTrace(out); + out.flush(); + out.close(); + + Text diag = new Text(comp, SWT.MULTI); + diag.setSize(64, 32); + + diag.setText(strOut.toString()); + return comp; + } + + /** + * Create an EditorPart showing the Exception. This is used when the + * creation of the regular IEditorPart failed. + * + * @param e + */ + private void createErrorEditorPart(Composite parent, Exception e) { + + try { + PartInitException partInitException = new PartInitException(StatusUtil.getLocalizedMessage(e), StatusUtil.getCause(e)); + editorPart = new ErrorEditorPart(partInitException.getStatus()); + // Initialize it and create its controls. + editorControl = createEditorPartControl(parent, editorPart); + + } catch (Exception ex) { + // Even the ErrorEditorPart creation fail. + // Use a more simple renderer. + Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage(), e)); + // TODO Create a fake Error Page and initialize this part with. + editorControl = createErrorPartControl(parent, e); + } + + } + + /** + * Create the editor associated to this TabPart. + * + * @return + * @throws PartInitException + */ + private IEditorPart createIEditorPart() throws PartInitException { + + return editorModel.createIEditorPart(); + } + + /** + * Create the controls required by the editor. Init the editor. + * + * @param viewer + * @param editorInput + * @param model + * @return + * @throws PartInitException + */ + private Composite createEditorPartControl(Composite parentControl, IEditorPart editor) throws PartInitException { + IEditorSite site = createSite(editor); + // call init first so that if an exception is thrown, we have created no + // new widgets + editor.init(site, getIMultiEditorManager().getEditorInput()); + Composite editorParent = new Composite(parentControl, getOrientation(editor)); + editorParent.setLayout(new FillLayout()); + editor.createPartControl(editorParent); + editor.addPropertyListener(new IPropertyListener() { + + public void propertyChanged(Object source, int propertyId) { + EditorPart.this.handlePropertyChange(propertyId); + } + }); + + // TODO test to be removed + // attachListeners(editorParent, false); + return editorParent; + } + + /** + * Attach SWT listeners. + */ + private void attachListeners(Control theControl, boolean recursive) { + + // All following methods listen to the same event. + // So use only one of them + // theControl.addListener(SWT.MouseEnter, mouseEnterListener); + // + // theControl.addListener(SWT.FocusIn, mouseEnterListener); + // theControl.addListener(SWT.MouseMove, mouseEnterListener); + // theControl.addListener(SWT.MouseHover, mouseEnterListener); + // theControl.addListener(SWT.MouseUp, mouseEnterListener); + // theControl.addListener(SWT.MouseDown, mouseEnterListener); + theControl.addListener(SWT.Activate, mouseEnterListener); + + // if (recursive && theControl instanceof Composite) { + // Composite composite = (Composite) theControl; + // Control[] children = composite.getChildren(); + // + // for (int i = 0; i < children.length; i++) { + // Control control = children[i]; + // + // attachListeners(control, true); + // } + // } + } + + /** + * Detach SWT listeners + */ + private void detachListeners(Control theControl, boolean recursive) { + // theControl.removeListener(SWT.MouseEnter, mouseEnterListener); + // theControl.removeListener(SWT.FocusIn, mouseEnterListener); + // theControl.removeListener(SWT.MouseMove, mouseEnterListener); + // theControl.removeListener(SWT.MouseHover, mouseEnterListener); + // theControl.removeListener(SWT.MouseUp, mouseEnterListener); + // theControl.removeListener(SWT.MouseDown, mouseEnterListener); + theControl.removeListener(SWT.Activate, mouseEnterListener); + + // if (recursive && theControl instanceof Composite) { + // Composite composite = (Composite) theControl; + // Control[] children = composite.getChildren(); + // + // for (int i = 0; i < children.length; i++) { + // Control control = children[i]; + // + // detachListeners(control, false); + // } + // } + } + + /** + * Handles a property change notification from a nested editor. The default + * implementation simply forwards the change to listeners on this multi-page + * editor by calling firePropertyChange with the same property + * id. For example, if the dirty state of a nested editor changes (property + * id IEditorPart.PROP_DIRTY), this method handles it by firing + * a property change event for IEditorPart.PROP_DIRTY to + * property listeners on this multi-page editor. + *

+ * Subclasses may extend or reimplement this method. + *

+ * + * @param propertyId + * the id of the property that changed + */ + private void handlePropertyChange(int propertyId) { + getSashWindowContainer().firePropertyChange(propertyId); + } + + /** + * Creates the site for the given nested editor. The MultiPageEditorPart implementation of this method creates an + * instance of MultiPageEditorSite. Subclasses may reimplement + * to create more specialized sites. + * + * @param editor + * the nested editor + * @return the editor site + */ + protected IEditorSite createSite(IEditorPart editor) { + EditorActionBarContributor contributor = createEditorActionBarContributor(); + return new MultiPageEditorSite(multiEditorManager.getEditorSite(), editor, contributor); + } + + /** + * Create the EditorActionBarContributor requested by the editor. Creation + * is done by delegating to the IMultiEditorNestedPartManager. + * + * @return + */ + private EditorActionBarContributor createEditorActionBarContributor() { + EditorActionBarContributor contributor = editorModel.getActionBarContributor(); + return contributor; + } + + /** + * Get the orientation of the editor. + * + * @param editor + * @return int the orientation flag + * @see SWT#RIGHT_TO_LEFT + * @see SWT#LEFT_TO_RIGHT + * @see SWT#NONE + */ + private int getOrientation(IEditorPart editor) { + if(editor instanceof IWorkbenchPartOrientation) { + return ((IWorkbenchPartOrientation)editor).getOrientation(); + } + return Window.getDefaultOrientation(); + } + + /** + * Get the nested part manager. + * + * @return + */ + private IMultiEditorManager getIMultiEditorManager() { + return multiEditorManager; + } + + /** + * @param isRecursive + */ + public void dispose() { + + detachListeners(editorControl, true); + // dispose the SWT root control + editorControl.dispose(); + // Dispose the editor. + editorPart.dispose(); + } + + /** + * As we are a final Tile, we should be the requested part. Return this + * TilePart. + * + * @param toFind + * @return + */ + public PagePart findPart(Point toFind) { + return this; + } + + /** + * Locates the part that intersects the given point and that have the + * expected type + * + * @param toFind + * @return + */ + @Override + public PagePart findPartAt(Point toFind, Class expectedTileType) { + + if(expectedTileType == this.getClass()) { + return this; + } + + // Not found !! + // The tile contains the position, but the type is not found. + throw new UnsupportedOperationException("Tile match the expected position '" + toFind + "' but there is no Tile of requested type '" + expectedTileType.getClass().getName() + "'"); + } + + /** + * @param control + * @return + */ + public PagePart findPart(Object control) { + if(getControl() == control) { + return this; + } + + // Not found + return null; + } + + /** + * Returns the active nested editor if there is one. + *

+ * Subclasses should not override this method + *

+ * + * @return the active nested editor, or null if none + */ + public IEditorPart getIEditorPart() { + return editorPart; + } + + /** + * Get associated SWT Control. + * + * @return + */ + @Override + public Composite getControl() { + return editorControl; + } + + /** + * This is a container method. Not necessary in Leaf Tile. TODO: change the + * interface. + * + * @param draggedObject + * @param sourcePart + * @param position + * @return + */ + public IDropTarget getDropTarget(Object draggedObject, TabFolderPart sourcePart, Point position) { + return null; + } + + /** + * @return + */ + @Override + public GarbageState getGarbageState() { + return garbageState; + } + + /** + * Is the associated editor dirty ? Delegate to {@link + * IEditorPart.isDirty()} + * + * @return true if the associated editor is dirty. + * + * @unused + */ + public boolean isDirty() { + return editorPart.isDirty(); + } + + /** + * Change the parent of the Tile. The parent is changed, and the control is + * attached to the parent control. Change garbage state to {@link GarbageState.REPARENTED}. Do not detach the Tile from its old + * parent. + * + * @param newParent + * The tilePart that should be used as part parent. + * @param compositeParent + * The composite that should be used as parent. + */ + @Override + public void reparent(TabFolderPart newParent) { + + // Change the tile parent + this.parent = newParent; + // Change the SWT parent. + editorControl.setParent(newParent.getControl()); + + // Change state + if(garbageState == GarbageState.UNVISITED || garbageState == GarbageState.ORPHANED) { + garbageState = GarbageState.REPARENTED; + } else { + // Bad state, this is an internal error + // TODO : log a warning ? + throw new IllegalStateException("Try to change state from " + garbageState.toString() + " to REPARENTED. This is forbidden."); + } + + } + + /** + * Asks this part to take focus within the workbench. Set the focus on the + * active nested part if the part is a container. + */ + @Override + public void setFocus() { + editorPart.setFocus(); + } + + /** + * Synchronize the Part, and its children. PartMap contains a snapshot of + * the available part before the synchronization. After synchronization, + * unreachable parts should be marked "orphaned" (= no parent). Do nothing + * in this implementation, as we are a final leaf, and there is nothing to + * synchronize with the underlying model. + * + * @param partMap + */ + public void synchronize2(PartLists partMap) { + + } + + /** + * Garbage this part. This part will be not used anymore. The part is + * already marked as ORPHANED. It is not used anymore. It is already + * detached from its parent. + * + */ + @Override + public void garbage() { + dispose(); + // fire appropriate life cycle event + getSashWindowContainer().getLifeCycleEventProvider().firePageClosedEvent(this); + } + + /** + * Accept the provided visitor. Call the corresponding accept method in the + * visitor. + * + * @param visitor + * @return + */ + @Override + public boolean visit(IPartVisitor visitor) { + return visitor.accept(this); + } + + /** + * Visit the children of this Tile. There is no child, so do nothing. + * + * @param visitor + */ + public boolean visitChildren(IPartVisitor visitor) { + return true; + } + + /** + * Show item status. + */ + protected void showStatus() { + // System.out.println( "EditorTile: " + // + " disposed=" + editorControl.isDisposed() + // + ", visible=" + editorControl.isVisible() + // + ", garbState=" + garbageState + // + ", '" + editorPart.getTitle() + // + "', " + this); + String title = (editorPart != null ? editorPart.getTitle() : "no editorPart"); + System.out.printf("EditorTile: disposed=%-5b, visible=%-5b, garbState=%-10s, %s, %s\n", editorControl.isDisposed(), (editorControl.isDisposed() ? false : editorControl.isVisible()), garbageState, title, this); + + } + + /** + * Get the title for this part. {@inheritDoc} + */ + @Override + public String getPageTitle() { + return editorModel.getTabTitle(); + } + + /** + * Return an icon for this part. {@inheritDoc} + */ + @Override + public Image getPageIcon() { + return editorModel.getTabIcon(); + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPanelParent.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPanelParent.java new file mode 100644 index 00000000000..0df25da7607 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPanelParent.java @@ -0,0 +1,43 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; +import org.eclipse.swt.widgets.Composite; + +/** + * Interface implemented by Part that can be parent of a Panel (Sashes or + * Folders). The interface allows to restrict the classes that can be parent of + * a Panel. For now, only {@link RootPart} and {@link SashPanelPart} can be + * parent of a Panel. + * + * @author dumoulin + */ +public interface IPanelParent { + + /** + * Get the {@link SashWindowsContainer}. + * + * @return + */ + public SashWindowsContainer getSashWindowContainer(); + + /** + * Get the parent SWT control. + * + * @return + */ + public Composite getControl(); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPartVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPartVisitor.java new file mode 100644 index 00000000000..fa8a2cd3075 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/IPartVisitor.java @@ -0,0 +1,80 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +/** + * Visitor used to visit the hierarchy of Parts. Visit can be stopped by + * returning false from the visit() method. + * + * @author dumoulin + * + */ +public interface IPartVisitor { + + /** + * Accept the node of specified type. + * + * @param folder + * @return true if the visit should continue, false if the visit should be + * stopped. + */ + + public boolean accept(RootPart tile); + + /** + * Accept the node of specified type. + * + * @param folder + * @return true if the visit should continue, false if the visit should be + * stopped. + */ + public boolean accept(SashPanelPart tile); + + /** + * Accept the node of specified type. + * + * @param folder + * @return true if the visit should continue, false if the visit should be + * stopped. + */ + public boolean accept(TabFolderPart folder); + + /** + * Accept the node of specified type. + * + * @param folder + * @return true if the visit should continue, false if the visit should be + * stopped. + */ + public boolean accept(TabItemPart tile); + + /** + * Accept the node of specified type. + * + * @param folder + * @return true if the visit should continue, false if the visit should be + * stopped. + */ + public boolean accept(EditorPart tile); + + /** + * Accept the node of specified type. + * + * @param componentPart + * @return true if the visit should continue, false if the visit should be + * stopped. + */ + public boolean accept(ComponentPart componentPart); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ImageToolTipManager.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ImageToolTipManager.java new file mode 100644 index 00000000000..bff6c86abb3 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ImageToolTipManager.java @@ -0,0 +1,346 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import java.util.logging.Logger; + +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPageImageUtils; +import org.eclipse.papyrus.infra.core.sasheditor.internal.preferences.ITabTooltipPreferences; +import org.eclipse.papyrus.infra.core.sasheditor.internal.preferences.TabTooltipPreferences; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Device; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.graphics.Transform; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + + +/** + * A class managing tooltips as Part. + * + * @author dumoulin + */ +public class ImageToolTipManager { + + /** Log object */ + Logger log = Logger.getLogger(getClass().getName()); + + protected ITabTooltipPreferences settings = new TabTooltipPreferences(); + + /** */ + private Control toolTipedControl; + + /** + * Size of the image to show. + */ + private Rectangle toolTipExpectedSize = new Rectangle(0, 0, 100, 80); + + private int offsetX = 20; + + private int offsetY = 20; + + /** + * Position of the tooltip relative to the tooltiped swt.Control. + */ + private int toolTipAlignement = SWT.TOP; + + /** + * + */ + private Shell tip = null; + + /** + * Cached value of the image. Use to do dispose when closing. + */ + private Image image = null; + + /** + * Constructor. + */ + public ImageToolTipManager() { + // TODO Auto-generated constructor stub + } + + private void resetTimer() { + if( settings.getTooltipAutoCloseDelay() == -1) + return; + + // do reset timer + } + /** + * Close the tooltip and dispose it. + */ + public void closeToolTip() { + if(tip != null) { + tip.dispose(); + tip = null; + } + if(image != null) { + image.dispose(); + image = null; + } + toolTipedControl = null; + + } + + /** + * Disable the tooltip. + * If the tooltip is shown, hide it. + * In the disable state, calls to showTooltip() with the same Control will not + * show the tooltip again untill another control is proposed. + * A call to closeToolTip() is required to show the same Control again. + */ + public void disableToolTip() { + // Close the tooltip. + if(tip != null) { + tip.dispose(); + tip = null; + } + if(image != null) { + image.dispose(); + image = null; + } + // Keep the control for future checking. + } + + /** + * dispose the tooltip and its resources. + * + */ + public void dispose() { + if(tip != null) { + tip.dispose(); + tip = null; + } + if(image != null) { + image.dispose(); + image = null; + } + toolTipedControl = null; + } + + /** + * Ask to show the tooltip. + * First check if preferences allows to show tooltip. + * + * @param pagePart The PagePart for which a ToolTip should be opened. + * @param flyedControl The control that trigger the tooltip opening + * @param mousePos + */ + public void showToolTip(PagePart pagePart, Rectangle flyedControlBounds, Point mousePos) { + + // If tooltip is already showing for this control, skip. + if(toolTipedControl == pagePart.getControl()) { + resetTimer(); + return; + } + + if( ! settings.isTooltipEnable() ) + return; + + // Check if we are showing the tooltip for current tab. + if( ! settings.isTooltipForCurrentTabShown() && pagePart.getParent().getVisiblePagePart() == pagePart ) { + // close current tooltip if any + closeToolTip(); + return; + } + + doShowToolTip(pagePart, flyedControlBounds, mousePos); + } + + /** + * Do show th tooltip, unless we can't get an image for the part. + * @param pagePart + * @param flyedControlBounds + * @param mousePos + */ + private void doShowToolTip(PagePart pagePart, Rectangle flyedControlBounds, Point mousePos) { + Image image = getPageImage(pagePart); + if(image == null) + return; + + toolTipedControl = pagePart.getControl(); + // Change image scale + float scaleFactor = settings.getScaledFactor(); //.5f; + Image scaledImage = scaledImage(pagePart.getControl().getDisplay(), image, scaleFactor); + image.dispose(); + + // Remember the image to be able to dispose it. + this.image = scaledImage; + + Point pos = computeToolTipPosition(flyedControlBounds, mousePos, scaledImage.getBounds()); + openToolTip(pagePart.getControl(), scaledImage, pos); + } + + /** + * Compute the tooltip position. + * + * @param relatedControlBounds + * Bounds of the item to which the tooltip apply + * @param mousePos + * Position of the mouse inside the relatedControlBounds. + * @param toolTipSize + * Size of the ToolTip. + * + * @return Position of the tooltip + */ + private Point computeToolTipPosition(Rectangle relatedControlBounds, Point mousePos, Rectangle toolTipSize) { + + int x, y; + if(toolTipAlignement == SWT.TOP) { + // Position.x = mousePoint.x + // Position.y = itemBounds - (toolTipSize.y + offsetY) + x = mousePos.x; + y = relatedControlBounds.y - (toolTipSize.height + offsetY); + } else if(toolTipAlignement == SWT.BOTTOM) { + x = mousePos.x; + y = relatedControlBounds.y + (relatedControlBounds.height + offsetY); + } else { + throw new UnsupportedOperationException("Not yet implemented for this alignement."); + } + return new Point(x, y); + } + + /** + * Open a tooltip like window containing the image. + * + * @param device + * The control from which atPoint is specified. + * @param scaledImage + * @param atPoint + */ + private void openToolTip(Control device, Image scaledImage, Point atPoint) { + if(tip != null && !tip.isDisposed()) + tip.dispose(); + tip = new Shell(device.getShell(), SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); + FillLayout layout = new FillLayout(); + layout.marginWidth = 2; + tip.setLayout(layout); + Label label = new Label(tip, SWT.NONE); + label.setImage(scaledImage); + Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT); + Point pt = device.toDisplay(atPoint.x + 20, atPoint.y); + tip.setBounds(pt.x, pt.y, size.x, size.y); + tip.setVisible(true); + } + + /** + * Create an image corresponding to the control. + * + * @param control + * The control for which an image is to be built. + * @return + */ + private Image createControlImage(Control control) { + // Create an image of the part. + + Rectangle size; + + size = control.getBounds(); + if(size.width == 0 && size.height == 0) { + Point pt = control.computeSize(SWT.DEFAULT, SWT.DEFAULT); + size = new Rectangle(0, 0, pt.x, pt.y); + } + + Image image = new Image(control.getDisplay(), size); + GC gc = new GC(image); + + boolean success = control.print(gc); + gc.dispose(); + if(!success) { + image.dispose(); + // log.warning("Can't create Snapshot for the control of '" + part + "'."); + return null; + } + + return image; + } + + /** + * Create an image corresponding to the control. + * + * @param control + * The control for which an image is to be built. + * @return + */ + private Image scaledImage2(Device device, Image image, float factor) { + Rectangle imageBounds = image.getBounds(); + Rectangle size = computeToolTipSize(image, factor); + Image scaledImage = new Image(device, size); + GC gc = new GC(scaledImage); + + gc.drawImage(image, 0, 0, imageBounds.width, imageBounds.height, 0, 0, size.width, size.height); + + return scaledImage; + } + + /** + * Compute the expected size of the tooltip. + * For now, simply return the expected size. + * + * @param image + * @param factor + * @return + */ + private Rectangle computeToolTipSize(Image image, float factor) { + + // Rectangle imageBounds = image.getBounds(); + // Rectangle size; + + return toolTipExpectedSize; + } + + /** + * Create a new image which is the input image scaled. + * + * @param image + * @param factor + * @return + */ + private Image scaledImage(Device device, Image image, float factor) { + + Rectangle bounds = image.getBounds(); + // Float factor = 0.5f; + + Rectangle newBounds = new Rectangle(0, 0, Math.round(bounds.width * factor), Math.round(bounds.height * factor)); + Image scaledImage = new Image(device, newBounds); + GC gc = new GC(scaledImage); + + gc.setAdvanced(true); + gc.setAntialias(SWT.ON); + Transform tr = new Transform(device); + tr.scale(factor, factor); + gc.setTransform(tr); + gc.drawImage(image, 0, 0); + gc.dispose(); + tr.dispose(); + return scaledImage; + } + + /** + * get the Image for the page. + * @param pagePart + * @return + */ + private Image getPageImage( PagePart pagePart ) { + + return IPageImageUtils.getPageImage(pagePart); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupFolderPartByRawModelVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupFolderPartByRawModelVisitor.java new file mode 100644 index 00000000000..2cff40eeee8 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupFolderPartByRawModelVisitor.java @@ -0,0 +1,59 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +/** + * A visitor used to lookup a {@link TabFolderPart} by its raw model. + * + * @author cedric dumoulin + * + */ +public class LookupFolderPartByRawModelVisitor extends PartVisitor { + + private Object rawModel; + + private TabFolderPart result; + + public LookupFolderPartByRawModelVisitor(Object rawModel) { + this.rawModel = rawModel; + } + + /** + * Get the result of the lookup. + * + * @return + */ + public TabFolderPart result() { + return result; + } + + /** + * Check if the part is for the specified rawModel. + * + * @param part + * @return + */ + private boolean isModelFor(TabFolderPart part) { + + if(part.getRawModel() == rawModel) { + result = part; + return true; + } + // stop looking + return false; + } + + /** + * Check if it is this Component + */ + @Override + protected boolean acceptTabFolderPart(TabFolderPart part) { + if(isModelFor(part)) + return false; + + // Continue looking + return true; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupIPageByIEditorPartVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupIPageByIEditorPartVisitor.java new file mode 100644 index 00000000000..705e888abd1 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupIPageByIEditorPartVisitor.java @@ -0,0 +1,62 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage; +import org.eclipse.ui.IEditorPart; + +/** + * A visitor used to lookup a PagePart by its IEditorPart. + * + * @author cedric dumoulin + * + */ +public class LookupIPageByIEditorPartVisitor extends PartVisitor { + + private IEditorPart editorPart; + + private IPage result; + + public LookupIPageByIEditorPartVisitor(IEditorPart editorPart) { + this.editorPart = editorPart; + } + + /** + * Get the result of the lookup. + * + * @return + */ + public IPage result() { + return result; + } + + /** + * Check if the part is for the specified rawModel. + * + * @param part + * @return + */ + private boolean isModelFor(EditorPart part) { + + if(part.getIEditorPart() == editorPart) { + result = part; + return true; + } + // stop looking + return false; + } + + /** + * Check if it is this IEditor + */ + @Override + protected boolean acceptEditorTile(EditorPart part) { + if(isModelFor(part)) + return false; + + // Continue looking + return true; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupModelPageVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupModelPageVisitor.java new file mode 100644 index 00000000000..a6d64983758 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/LookupModelPageVisitor.java @@ -0,0 +1,73 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage; + +/** + * A visitor used to lookup a PagePart from its raw model. + * + * @author cedric dumoulin + * + */ +public class LookupModelPageVisitor extends PartVisitor { + + private Object rawModel; + + private IPage result; + + public LookupModelPageVisitor(Object rawModel) { + this.rawModel = rawModel; + } + + /** + * Get the result of the lookup. + * + * @return + */ + public IPage result() { + return result; + } + + /** + * Check if the part is for the specified rawModel. + * + * @param part + * @return + */ + private boolean isModelFor(PagePart part) { + + if(part.getRawModel() == rawModel) { + result = part; + return true; + } + // stop looking + return false; + } + + /** + * Check if it is this Component + */ + @Override + protected boolean acceptEditorTile(ComponentPart part) { + if(isModelFor(part)) + return false; + + // Continue looking + return true; + } + + /** + * Check if it is this IEditor + */ + @Override + protected boolean acceptEditorTile(EditorPart part) { + if(isModelFor(part)) + return false; + + // Continue looking + return true; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/NotFoundException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/NotFoundException.java new file mode 100644 index 00000000000..8fd684b6554 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/NotFoundException.java @@ -0,0 +1,60 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +/** + * Exception thrown when a search or lookup fails. + * + * @author dumoulin + */ +public class NotFoundException extends SashWindowsException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * + */ + public NotFoundException() { + // TODO Auto-generated constructor stub + } + + /** + * @param message + */ + public NotFoundException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + /** + * @param cause + */ + public NotFoundException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + + /** + * @param message + * @param cause + */ + public NotFoundException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PTabFolder.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PTabFolder.java new file mode 100644 index 00000000000..3cb5eb3cd66 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PTabFolder.java @@ -0,0 +1,495 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.jface.util.Geometry; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabFolder2Adapter; +import org.eclipse.swt.custom.CTabFolderEvent; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.swt.events.MenuDetectEvent; +import org.eclipse.swt.events.MenuDetectListener; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.ui.internal.dnd.DragUtil; +import org.eclipse.ui.presentations.PresentationUtil; + +/** + * Papyrus wrapper for CTabFolder. Provides miscelaneous methods for dragging. + * Provides different fireEvents for: menu detected, pageChange, itemClosed. + * TODO : add listeners mechanism to listen on events ? + */ +@SuppressWarnings("restriction") +public class PTabFolder { + + /** + * The underlying tabfolder. + */ + protected CTabFolder tabFolder; + + /** + * This object allows to register listeners on event from this class. + */ + private EventsManager listenersManager = new EventsManager(); + + private Listener dragListener = new Listener() { + + public void handleEvent(Event e) { + Point globalPos = ((Control)e.widget).toDisplay(e.x, e.y); + handleDragStarted(globalPos, e); + } + }; + + /** + * Listener on control activated event. This event is used to set the tab as + * the active page. + */ + private Listener activateListener = new Listener() { + + public void handleEvent(Event e) { + Point globalPos = ((Control)e.widget).toDisplay(e.x, e.y); + handleFolderReselected(globalPos, null); + } + }; + + /** + * Listen on menu detect. The event is forwarded. TODO [20100417] deprecated + * ? + */ + private MenuDetectListener menuDetectListener = new MenuDetectListener() { + + public void menuDetected(MenuDetectEvent e) { + // Point globalPos = ((Control) e.widget).toDisplay(e.x, e.y); + Point globalPos = new Point(e.x, e.y); + handleMenuDetect(globalPos, e); + } + + }; + + /** + * Get the underlying control. + */ + public Composite getControl() { + return tabFolder; + } + + /** + * Create the corresponding SWT Control + */ + public void createPartControl(Composite parent) { + tabFolder = createContainer(parent); + + // Attach listeners + attachListeners(tabFolder, false); + } + + /** + * Creates an empty container. Creates a CTabFolder with no style bits set, + * and hooks a selection listener which calls pageChange() whenever the selected tab changes. + * + * @param parent + * The composite in which the container tab folder should be + * created; must not be null. + * @return a new container + */ + private CTabFolder createContainer(Composite parent) { + // use SWT.FLAT style so that an extra 1 pixel border is not reserved + // inside the folder + parent.setLayout(new FillLayout()); + final CTabFolder newContainer = new CTabFolder(parent, SWT.BOTTOM | SWT.FLAT | SWT.CLOSE); + + // TODO Move listener init in appropriate method. + newContainer.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + int newPageIndex = newContainer.indexOf((CTabItem)e.item); + firePageChange(newPageIndex); + } + }); + + // Test for the close icon. Need style=SWT.CLOSE + // addCTabFolderListener is required :-( + newContainer.setUnselectedCloseVisible(false); + newContainer.addCTabFolder2Listener(new CTabFolder2Adapter() { + + @Override + public void close(CTabFolderEvent event) { + int pageIndex = newContainer.indexOf((CTabItem)event.item); + event.doit = false; + fireItemClosed(event, pageIndex); + } + }); + return newContainer; + } + + /** + * Dispose internal resources. + */ + public void dispose() { + if(tabFolder.isDisposed()) + return; + + detachListeners(tabFolder); + tabFolder.dispose(); + } + + /** + * Copied from org.eclipse.ui.internal.presentations.util.AbstractTabFolder. + * attachListeners(Control, boolean) + */ + protected void attachListeners(CTabFolder theControl, boolean recursive) { + + // Listen to menu event + theControl.addMenuDetectListener(menuDetectListener); + // Listen to drag event + PresentationUtil.addDragListener(theControl, dragListener); + + theControl.addListener(SWT.Activate, activateListener); + + } + + /** + * Copied from org.eclipse.ui.internal.presentations.util.AbstractTabFolder. + * detachListeners(Control, boolean) + */ + private void detachListeners(Control theControl) { + theControl.removeMenuDetectListener(menuDetectListener); + // + PresentationUtil.removeDragListener(theControl, dragListener); + // theControl.removeDragDetectListener(dragDetectListener); + // theControl.removeListener(SWT.MouseUp, mouseUpListener); + theControl.removeListener(SWT.Activate, activateListener); + } + + /** + * The context menu event has been fired, handle it. Actually, it is + * forwarded to the {@link EventsManager}. + * + * @param displayPos + * @param e + */ + protected void handleContextMenu(Point displayPos, Event e) { + + CTabItem tab = getItem(displayPos); + listenersManager.fireContextMenuEvent(tab, e); + } + + /** + * Called when drag start. From here, DragUtil.performDrag() is called, + * which start the dragging process. DragUtil.performDrag() will contains + * the tabFolder or the dragged tab. + */ + protected void handleDragStarted(Point displayPos, Event e) { + + CTabItem tab = getItem(displayPos); + + boolean allowSnapping = true; + Rectangle sourceBounds = Geometry.toDisplay(tabFolder.getParent(), tabFolder.getBounds()); + if(tab == null) { // drag folder + DragUtil.performDrag(tabFolder, sourceBounds, displayPos, allowSnapping); + } else { // drag item + DragUtil.performDrag(tab, sourceBounds, displayPos, allowSnapping); + } + } + + /** + * Handle menu detect. TODO Connect menu staff here. + * + * @param displayPos + * @param e + */ + private void handleMenuDetect(Point displayPos, MenuDetectEvent e) { + + // if(isOnBorder(displayPos)) { + // return; + // } + + CTabItem tab = getItem(displayPos); + listenersManager.fireMenuDetectEvent(tab, e); + } + + /** + * Handle folder reselected. A folder is reselected by clicking on the + * active tabs, on the page or on the empty tabs area. In each case a + * PageChangeEvent is fired. When mouse click happen on the empty area, or + * on the page, the last selected tabs is used. Used to switch the Active + * tab when user click on already opened tabs. + * + * @param displayPos + * @param e + */ + private void handleFolderReselected(Point displayPos, MouseEvent e) { + int itemIndex = getItemIndex(displayPos); + // If click is not from an item, it can come from a click on border. + // restore the last selected item + if(itemIndex == -1) + itemIndex = tabFolder.getSelectionIndex(); + if(itemIndex == -1) + return; + + listenersManager.firePageChange(itemIndex); + } + + /** + * Returns true iff the given point is on the border of the folder. By + * default, double-clicking, context menus, and drag/drop are disabled on + * the folder's border. + * + * @param toTest + * a point (display coordinates) + * @return true iff the point is on the presentation border + * @since 3.1 + */ + private boolean isOnBorder(Point toTest) { + Control content = getControl(); + if(content != null) { + Rectangle displayBounds = DragUtil.getDisplayBounds(content); + + if(tabFolder.getTabPosition() == SWT.TOP) { + return toTest.y >= displayBounds.y; + } + + if(toTest.y >= displayBounds.y && toTest.y < displayBounds.y + displayBounds.height) { + return true; + } + } + + return false; + } + + /** + * Get the item under the specified position. + */ + public CTabItem getItem(Point toFind) { + CTabItem[] items = tabFolder.getItems(); + + for(CTabItem item : items) { + if(getItemBounds(item).contains(toFind)) { + return item; + } + } + + return null; + } + + public int getItemIndex(Point pt) { + CTabItem item = tabFolder.getItem(pt); + if(item == null) + return -1; + return getItemIndex(item); + } + + /** + * Get the rectangle bounding the item, in the parent coordinates. Utility + * method. Can be moved somewhere else. + */ + public Rectangle getItemBounds(CTabItem item) { + return Geometry.toDisplay(item.getParent(), item.getBounds()); + } + + /** + * Fire a page closed event. This event is fired when the close item is + * pressed. The item is not closed yet. By default, the item is closed after + * the event. The item is not closed if event.doit is set to false. + * + */ + protected void fireItemClosed(CTabFolderEvent event, int pageIndex) { + listenersManager.fireItemClosed(event, pageIndex); + + } + + /** + * Fire a PageChangeEvent. + */ + protected void firePageChange(int newPageIndex) { + listenersManager.firePageChange(newPageIndex); + } + + /** + * @return the tabFolder + */ + public CTabFolder getTabFolder() { + return tabFolder; + } + + /** + * Get bounds of the tabs area in display coordinate. + */ + public Rectangle getTabArea() { + Rectangle bounds = DragUtil.getDisplayBounds(tabFolder); + // + if(tabFolder.getTabPosition() == SWT.TOP) { + bounds.height = tabFolder.getTabHeight(); + } else { // bottom + bounds.y = bounds.y + bounds.height - tabFolder.getTabHeight(); + bounds.height = tabFolder.getTabHeight(); + } + + return bounds; + } + + /** + * Get the index of the draggedObject + * + * @param draggedObject + * draggedObject should be of type CTabFolder or CTabItem (as + * provided by handleDragStarted()) + */ + static public int getDraggedObjectTabIndex(Object draggedObject) { + if(draggedObject instanceof CTabItem) { + CTabItem item = (CTabItem)draggedObject; + int index = getItemIndex(item); + return index; + } else if(draggedObject instanceof CTabFolder) { + return -1; + } + + return -2; + } + + /** + * Get the item index or -1 if not found. + */ + static private int getItemIndex(CTabItem item) { + CTabItem[] items = item.getParent().getItems(); + + for(int i = 0; i < items.length; i++) { + CTabItem cur = items[i]; + + if(cur == item) { + return i; + } + } + + return -1; + } + + /** + * Get the event manager. The event manager can be used to listen to events. + * + * @return + */ + public EventsManager getEventManager() { + return listenersManager; + } + + /** + * Interface to ne implemented by listeners on PTabFodler events. + * + * @author dumoulin + * + */ + public interface IPTabFolderListener { + + /** + * + * @param tab + * @param event + */ + public void menuDetectEvent(CTabItem tab, MenuDetectEvent event); + + public void contextMenuDetectEvent(CTabItem tab, Event event); + + public void itemClosedEvent(CTabFolderEvent event, int pageIndex); + + public void pageChangeEvent(int newPageIndex); + } + + /** + * Internal implementations. Implements a list of listeners. + * + * @author dumoulin + * + */ + public class EventsManager { + + /** + * List of event listeners. + */ + Set listeners = new HashSet(); + + /** + * Add a listener + * + * @param listener + */ + public void addListener(IPTabFolderListener listener) { + listeners.add(listener); + } + + /** + * Remove a listener + * + * @param listener + */ + public void removeListener(IPTabFolderListener listener) { + listeners.remove(listener); + } + + /** + * @param tab + * @param e + */ + public void fireContextMenuEvent(CTabItem tab, Event event) { + for(IPTabFolderListener cur : listeners) { + cur.contextMenuDetectEvent(tab, event); + } + } + + /** + * @param event + * @param pageIndex + */ + private void fireItemClosed(CTabFolderEvent event, int pageIndex) { + for(IPTabFolderListener cur : listeners) { + cur.itemClosedEvent(event, pageIndex); + } + } + + /** + * @param newPageIndex + */ + private void firePageChange(int newPageIndex) { + for(IPTabFolderListener cur : listeners) { + cur.pageChangeEvent(newPageIndex); + } + } + + /** + * Fire the event to all listeners + * + * @param e + * @param tab + */ + private void fireMenuDetectEvent(CTabItem tab, MenuDetectEvent e) { + for(IPTabFolderListener cur : listeners) { + cur.menuDetectEvent(tab, e); + } + } + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PagePart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PagePart.java new file mode 100644 index 00000000000..ffef343925b --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PagePart.java @@ -0,0 +1,209 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +/** + * This class represent a leaf part that is a part containing an editor or a + * component. + * + * @author dumoulin + */ +public abstract class PagePart extends AbstractPart implements IPage { + + /** + * Raw model associated to this part. We store it because the PartModel do + * not provide it + */ + protected Object rawModel; + + /** Parent part of this Part */ + protected TabFolderPart parent; + + /** + * Constructor. + * + * @param sashWindowsContainer + */ + public PagePart(TabFolderPart parent, Object rawModel) { + super(parent.getSashWindowContainer()); + this.parent = parent; + this.rawModel = rawModel; + } + + /** + * @return the parent + */ + public TabFolderPart getParent() { + return parent; + } + + /** + * Orphan this node. The parent is set to null, but control is left + * unchanged. The node can be reattached with reparent(). Change garbage + * state to {@link GarbageState.ORPHANED}. This method as no effect if the + * Page has already been reparented. + * + * @see + * @return the parent + */ + public void orphan() { + // orphan only if we are in COLLECTED state + if(garbageState == GarbageState.UNVISITED) { + garbageState = GarbageState.ORPHANED; + parent = null; + } + } + + /** + * Mark this Page as UNCHANGED. The PAge should be in the COLLECTED state. + * + * @see + * @return the parent + */ + public void unchanged() { + // orphan only if we are in COLLECTED state + if(garbageState == GarbageState.UNVISITED || garbageState == GarbageState.ORPHANED) { + garbageState = GarbageState.UNCHANGED; + } else { + // Bad state, this is an internal error + // TODO : log a warning ? + throw new IllegalStateException("Try to change state from " + garbageState.toString() + " to UNCHANGED. This is forbidden."); + } + } + + /** + * Visit this part. + * + * @param visitor + * @return true if the visit should continue, false otherwise. + */ + abstract boolean visit(IPartVisitor visitor); + + /** + * Locates the part that intersects the given point and that have the + * expected type. For a leaf, return the leaf if it is of the expected type. + * + * @param position + * @param expectedTileType + * @return + */ + public AbstractPart findPartAt(Point position, Class expectedTileType) { + + if(expectedTileType == this.getClass()) + return this; + + return null; + } + + /** + * Create the control of this Part, and children's controls. + * + * @param parent + */ + abstract public void createPartControl(Composite parent); + + /** + * Get the control associated to this Part. + * + * @return + */ + abstract public Control getControl(); + + /** + * reparent this Part with the specified new parent. The part is marked as + * reparented. + * + * @param parent + */ + abstract public void reparent(TabFolderPart parent); + + /** + * Add the tree of parts starting from this part. As we are a leaf, add + * itself only. + * + * @param partMap + */ + public void fillPartMap(PartLists partMap) { + partMap.addLeaf(this); + garbageState = GarbageState.UNVISITED; + } + + /** + * Get the raw model associated to this Part. + * + * @return + */ + public Object getRawModel() { + return rawModel; + } + + /** + * Return a title for this part. This title can be used by parent to be + * shown in tabs ... To be implemented by subclasses. + * + * @return The title or null. + */ + public String getPageTitle() { + return null; + } + + /** + * Return a icon for this part. This title can be used by parent to be shown + * in tabs ... To be implemented by subclasses. + * + * @return The icon or null. + */ + public Image getPageIcon() { + return null; + } + + /** + * Refresh the tab of this page (I.e the name and icon in the tab). + */ + public void refreshTab() { + getParent().refreshPageTab(this); + } + + /** + * Set focus on the SWT control associated to this PagePart. Used by the + * ActivePageTracker. + */ + abstract public void setFocus(); + + /** + * Garbage the part. + */ + abstract public void garbage(); + + /** + * Return true if the part is associated to the specified rawModel. Return + * false otherwise. + * + * @param realModel + * @return + */ + public boolean isPartFor(Object realModel) { + return this.rawModel == realModel; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PageVisitorWrapper.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PageVisitorWrapper.java new file mode 100644 index 00000000000..69aed4c2c5c --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PageVisitorWrapper.java @@ -0,0 +1,48 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import org.eclipse.papyrus.infra.core.sasheditor.editor.IEditorPage; +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPageVisitor; + +/** + * A wrapper used to let the provided public visitor use the internal visitor to + * visit {@link ComponentPart} and {@link EditorPart}. + * + * @author Cedric dumoulin + * + */ +public class PageVisitorWrapper extends PartVisitor { + + /** + * The public visitor. + */ + private IPageVisitor pageVisitor; + + /** + * @param pageVisitor + */ + public PageVisitorWrapper(IPageVisitor pageVisitor) { + super(); + this.pageVisitor = pageVisitor; + } + + /** + * We visit a Component part + */ + @Override + public boolean acceptEditorTile(ComponentPart part) { + pageVisitor.accept(part); + return true; + } + + /** + * We visit an {@link EditorPart}. + */ + @Override + public boolean acceptEditorTile(EditorPart part) { + pageVisitor.accept((IEditorPage)part); + return true; + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartLists.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartLists.java new file mode 100644 index 00000000000..8c19ef3719e --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartLists.java @@ -0,0 +1,155 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import java.util.ArrayList; +import java.util.List; + +/** + * This class contains lists of parts, regardless of the part parents. There are + * two lists: one for the pane Parts and one for the Page Parts (leafs). This + * class is used when refreshing the SashContainer: a new instance is created + * and filled with existing parts. Then the list is carried in each pane refresh + * method. + * + * @author cedric dumoulin + */ +public class PartLists { + + private List pageParts = new ArrayList(); + + private List panelParts = new ArrayList(); + + /** List of created pages during synchronization */ + private List createdPages /* = new ArrayList() */; + + /** + * Search for a Part associated to the specified newModel. Return the part + * or null if none is found. + * + * @param rawModel + * @return + */ + public PagePart findPagePartFor(Object rawModel) { + + for(PagePart part : pageParts) { + if(part.isPartFor(rawModel)) + return part; + } + return null; + } + + /** + * Find the pane part for the specified rawModel. Return the found part or + * null + * + * @param rawModel + * The raw model for which a part is lookup. + * @return + */ + public AbstractPanelPart findPartFor(Object rawModel) { + + for(AbstractPanelPart part : panelParts) { + if(part.isPartFor(rawModel)) + return part; + } + + return null; + } + + /** + * Add a leaf part to the lists. + * + * @param pagePart + */ + public void addLeaf(PagePart pagePart) { + pageParts.add(pagePart); + } + + /** + * Add the partPane to the lists. + * + * @param panelPart + */ + public void addPart(AbstractPanelPart panelPart) { + panelParts.add(panelPart); + + } + + /** + * Garbage orphaned elements. + */ + public void garbage() { + // Remove orphaned part (no more used) + for(AbstractPanelPart part : panelParts) { + if(part.isOrphaned()) + part.dispose(); + } + + // Remove orphaned part (no more used) + for(PagePart part : pageParts) { + if(part.isOrphaned()) + part.garbage(); + } + } + + /** + * Get the first non orphaned page, or null if none exists. + * + * @return a valid active page, or null if none exists. + */ + public PagePart getFirstValidPage() { + + for(PagePart part : pageParts) { + if(!part.isOrphaned()) + return part; + } + + // No page + return null; + } + + /** + * Get the first created page if any. + * + * @return a valid active page, or null if none exists. + */ + public PagePart getFirstCreatedPage() { + + if(createdPages == null) + return null; + + if(createdPages.size() > 0) + return createdPages.get(0); + + // No page + return null; + } + + /** + * Add a PagePart to the list of created Page. This is called from the + * TabFolder when a new page is created. + * + * @param modelPart + */ + public void addCreatedPage(PagePart newPage) { + + if(createdPages == null) + createdPages = new ArrayList(); + + createdPages.add(newPage); + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartVisitor.java new file mode 100644 index 00000000000..74851810727 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/PartVisitor.java @@ -0,0 +1,167 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +/** + * Visitor implementation allowing to visit the hierarchy of Parts. + * + * @author dumoulin + * + */ +public class PartVisitor implements IPartVisitor { + + /** + * Visit the specified type, and then visit the children ... + * + * @param folder + */ + public boolean accept(TabFolderPart part) { + + if(acceptTabFolderPart(part)) { + // Visit the children + return part.visitChildren(this); + } + + // stop visiting + return false; + } + + /** + * Visit the specified type, and then visit the childs.. + * + * @param folder + */ + public boolean accept(RootPart part) { + + if(acceptRootPart(part)) { + // Visit the children + return part.visitChildren(this); + } + // stop visiting + return false; + } + + /** + * Visit the specified type, and then visit the children.. + * + * @param folder + */ + public boolean accept(SashPanelPart part) { + if(acceptSashPanelPart(part)) { + // Visit the children + return part.visitChildren(this); + } + // stop visiting + return false; + } + + /** + * Visit the specified type, and then visit the children.. + * + * @param folder + */ + public boolean accept(TabItemPart part) { + if(acceptTabItemPart(part)) { + // Visit the children + return part.visitChildren(this); + } + // stop visiting + return false; + } + + /** + * Visit the specified type, and then visit the children.. + * + * @param part + */ + public boolean accept(EditorPart part) { + if(acceptEditorTile(part)) { + // Visit the children + return part.visitChildren(this); + } + // stop visiting + return false; + } + + /** + * Visit the specified type, and then visit the children .. + * + * @param part + */ + public boolean accept(ComponentPart part) { + if(acceptEditorTile(part)) { + // Visit the children + return part.visitChildren(this); + } + // stop visiting + return false; + } + + // ---------------------------------------------- + + /** + * Visit the specified type. + * + * @param part + */ + protected boolean acceptRootPart(RootPart part) { + return true; + } + + /** + * Visit the specified type. + * + * @param part + */ + protected boolean acceptSashPanelPart(SashPanelPart part) { + return true; + } + + /** + * Visit the specified type. + * + * @param part + */ + protected boolean acceptTabFolderPart(TabFolderPart part) { + return true; + } + + /** + * Visit the specified type. + * + * @param part + */ + protected boolean acceptTabItemPart(TabItemPart part) { + return true; + } + + /** + * Visit the specified type. + * + * @param part + */ + protected boolean acceptEditorTile(EditorPart part) { + return true; + } + + /** + * Visit the specified type. + * + * @param part + */ + protected boolean acceptEditorTile(ComponentPart part) { + return true; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ReplaceableSashForm.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ReplaceableSashForm.java new file mode 100644 index 00000000000..fa7dbfcddac --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ReplaceableSashForm.java @@ -0,0 +1,71 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +/** + * Allows to replace one of the window + */ +public class ReplaceableSashForm extends SashForm { + + private Composite leftComposite; + + private Composite rightComposite; + + public ReplaceableSashForm(Composite parent, int style) { + super(parent, style); + + leftComposite = new Composite(this, 0); + leftComposite.setLayout(new FillLayout()); + rightComposite = new Composite(this, 0); + rightComposite.setLayout(new FillLayout()); + } + + public Composite getLeftParent() { + return leftComposite; + } + + public Composite getRightParent() { + return rightComposite; + } + + /** + * Reparent the provided control to have the leftPart parent. + */ + public void setLeftControl(Control control) { + if(leftComposite == null) { + leftComposite = new Composite(this, 0); + } + + // reparent the control + control.setParent(leftComposite); + } + + /** + * Reparent the provided control to have the leftPart parent. + */ + public void setRightControl(Control control) { + if(rightComposite == null) { + rightComposite = new Composite(this, 0); + } + + // reparent the control + control.setParent(rightComposite); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/RootPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/RootPart.java new file mode 100644 index 00000000000..ec0437d6bed --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/RootPart.java @@ -0,0 +1,324 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel; +import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Composite; + +/** + * Part used as root. This is the one with no parent and no model. This class is + * intended for local use only. + * + * @author dumoulin + * + * @param T + * Common ancestor for the model provided for the sash windows by the + * application. This is the type used externally by the application. + * Sash implementation don't use this type, it just carry it to ask + * for the appropriate wrapper. Concrete implementation can specify a + * type. + */ +@SuppressWarnings("restriction") +public class RootPart extends AbstractPart implements IPanelParent { + + /** The SWT container used as parent of all */ + private Composite container; + + /** + * The first SWT controled part; + */ + private AbstractPanelPart child; + + /** + * Raw model associated to this part. We store it because the PartModel do + * not provide it + */ + private Object rawModel; + + /** + * Constructor. + */ + public RootPart(SashWindowsContainer sashWindowsContainer) { + super(sashWindowsContainer); + } + + /** + * Create the SWT controls. This Root as no control. Create the child part + * and call the same method on the child. + */ + public void createPartControl(Composite parent) { + this.container = parent; + Object rawModel = getContentProvider().getRootModel(); + + // Create child part + // child = createChildPart(rawModel); + } + + /** + * Dispose this part. + */ + public void dispose() { + if(child != null) + child.dispose(); + } + + /** + * Get control associated to this part. + */ + public Composite getControl() { + return container; + } + + /** + * Create the part for the specified child model. The controls are also + * builds. + * + * TODO: delegate to sashContainer. + * + * @param rootPart + * @param partModel + * @return + */ + private AbstractPanelPart createChildPart(Object rawModel) { + + // Create the child PartModel. Delegate creation to the root PartModel. + IAbstractPanelModel model = getPartModel().createChildSashModel(rawModel); + + AbstractPanelPart createdPart; + if(model instanceof ITabFolderModel) { + createdPart = new TabFolderPart(this, (ITabFolderModel)model, rawModel); + } else if(model instanceof ISashPanelModel) { + createdPart = new SashPanelPart(this, (ISashPanelModel)model, rawModel); + } else { + // error + throw new IllegalArgumentException("Can't create child part for model of type '" + model.getClass().getName() + "'"); + // TODO: Return an error Part showing the exception instead of + // throwing it ? + } + + // Create controls + createdPart.createPartControl(getControl()); + return createdPart; + + } + + /** + * Get the PartModel associated to this Part. + * + * @return + */ + private ISashWindowsContentProvider getPartModel() { + // The associated model for a root is the ContentProvider. + return getSashWindowContainer().getContentProvider(); + } + + /** + * Synchronize the part and its children. + * + * @param partMap + */ + public void synchronize2(PartLists partMap) { + + // Synchronize locally the child + synchronizeChild(partMap); + // Synchronize recursively subchilds. + if(child != null) + child.synchronize2(partMap); + + } + + /** + * Synchronize locally the child + * + * @param partMap + */ + private void synchronizeChild(PartLists partMap) { + + // Get the new raw model + Object rawModel = getContentProvider().getRootModel(); + + // Check if old child exist + // If exist, check if the current part is associated to the checked + // model + // + if(child != null) { + // If the tile is already for the model, there is nothing to do. + if(child.isPartFor(rawModel)) { + child.unchanged(); + return; + } + // The current tile is not for the model: mark it as orphan + child.orphan(); + } + + // The child tile need to be updated. Do it. + // First check if already exist in the map + AbstractPanelPart newPart = partMap.findPartFor(rawModel); + if(newPart != null) { + // Reparent the tile + newPart.reparent(this, getControl()); + } else { + // create the tile and its control + newPart = createChildPart(rawModel); + } + + // Now, put the tile on the right side + setChild(newPart); + } + + /** + * Set the child. If a child already exist at the specified index, it is + * lost. + * + * @param newTile + */ + private void setChild(AbstractPanelPart newTile) { + child = newTile; + } + + /** + * Get the Composite used as parent for childs. + * + * @return + */ + private Composite getChildParent() { + // This is the rootContainer + return container; + } + + /** + * Fill partMap with the children. + * + * @param partMap + */ + public void fillPartMap(PartLists partMap) { + if(child != null) + child.fillPartMap(partMap); + + } + + /** + * Find The AbstractPart under the specified position. + */ + public AbstractPart findPart(Point toFind) { + if(child != null) + try { + return child.findPart(toFind); + } catch (NotFoundException e) { + System.err.println(e.getMessage()); + return null; + } + else + return null; + } + + // /** + // * Locates the part that intersects the given point and that have the + // expected type + // * + // * @param toFind + // * @return + // */ + // public AbstractPart findPartAt(Point toFind, Class tileType) { + // return child.findPartAt(toFind, tileType); + // } + + /** + * + */ + public AbstractPart findPart(Object control) { + if(child != null) + return child.findPart(control); + else + return null; + } + + // /** + // * @see + // org.eclipse.papyrus.infra.core.sasheditor.sash.ITilePart#getDropTarget(java.lang.Object, + // org.eclipse.papyrus.infra.core.sasheditor.sash.TabFolderPart, + // org.eclipse.swt.graphics.Point) + // */ + // public IDropTarget getDropTarget(Object draggedObject, TabFolderPart + // sourcePart, Point position) { + // return child.getDropTarget(draggedObject, sourcePart, position); + // } + + /** + * Do nothing. This node can't be orphaned + * + */ + public void orphan() { + // Do nothing. This node can't be orphaned + } + + /** + * Always return false. This Part can't be orphaned. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.internal.AbstractPart#isOrphaned() + * + * @return + */ + public boolean isOrphaned() { + return false; + } + + /** + * Get the Garbage state. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.internal.AbstractPart#getGarbageState() + * + * @return + */ + public GarbageState getGarbageState() { + return GarbageState.UNVISITED; + } + + /** + * Accept the provided visitor. Call the corresponding accept method in the + * visitor. + * + * @param visitor + * @return + */ + public boolean visit(IPartVisitor visitor) { + return visitor.accept(this); + } + + /** + * Visit the children of this Tile. + * + * @param visitor + */ + public boolean visitChildren(IPartVisitor visitor) { + if(child != null) + return child.visit(visitor); + + // Return the default value + return true; + } + + /** + * Show tile status. + */ + protected void showStatus() { + org.eclipse.papyrus.infra.core.sasheditor.Activator.log.debug("rootPart (1)" + ", disposed=" + container.isDisposed() + ", visible=" + container.isVisible() + ", " + this); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashContainerEventsProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashContainerEventsProvider.java new file mode 100644 index 00000000000..c26e5279504 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashContainerEventsProvider.java @@ -0,0 +1,118 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.papyrus.infra.core.sasheditor.editor.SashContainerEventsListener; +import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; + +/** + * A class managing events of the {@link SashWindowsContainer}. This class + * dispatch events fired by the {@link SashWindowsContainer} to any listeners + * implementing {@link SashContainerEventsProvider}. + * + * @author cedric dumoulin + * + */ +public class SashContainerEventsProvider { + + /** List of listeners */ + private List listeners = new ArrayList(); + + /** + * Add a listener on the activeEditorChange event. + * + * @param listener + */ + public void addListener(SashContainerEventsListener listener) { + // no duplicate + if(listeners.contains(listener)) + return; + listeners.add(listener); + } + + /** + * Add a listener on the activeEditorChange event. + * + * @param listener + */ + public void removeListener(SashContainerEventsListener listener) { + listeners.remove(listener); + } + + /** + * Notify all listener with event. + * + * @param newEditor + */ + public void firePageOpenedEvent(PagePart page) { + // Fire events to internal listeners + for(SashContainerEventsListener listener : listeners) { + listener.pageOpened(page); + } + } + + /** + * Notify all listener with event. + * + * @param newEditor + */ + public void firePageClosedEvent(PagePart page) { + // Fire events to internal listeners + for(SashContainerEventsListener listener : listeners) { + listener.pageClosed(page); + } + } + + /** + * Notify all listener with event. + * + * @param newEditor + */ + public void firePageAboutToBeOpenedEvent(PagePart page) { + // Fire events to internal listeners + for(SashContainerEventsListener listener : listeners) { + listener.pageAboutToBeOpened(page); + } + } + + /** + * Notify all listener with event. + * + * @param newEditor + */ + public void firePageAboutToBeClosedEvent(PagePart page) { + // Fire events to internal listeners + for(SashContainerEventsListener listener : listeners) { + listener.pageAboutToBeClosed(page); + } + } + + /** + * Notify all listener with event. + * + * @param newEditor + */ + public void firePageActivatedEvent(PagePart page) { + // Fire events to internal listeners + for(SashContainerEventsListener listener : listeners) { + listener.pageActivated(page); + } + } + + /** + * Notify all listener with event. + * + * @param newEditor + */ + public void firePageDeactivatedEvent(PagePart page) { + // Fire events to internal listeners + for(SashContainerEventsListener listener : listeners) { + listener.pageDeactivated(page); + } + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashPanelPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashPanelPart.java new file mode 100644 index 00000000000..314c08d19e0 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashPanelPart.java @@ -0,0 +1,480 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import java.util.logging.Logger; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.internal.dnd.DragUtil; +import org.eclipse.ui.internal.dnd.IDropTarget; + +/** + * Controller for a sash panel. A sash panel contain 2 children. It shows them + * in two windows separated by a sash. Implementation use one model, a {@link ISashPanelModel}. This model encapsulate the real model which is of an + * unknown type. + * + * + * @author dumoulin + * + * @param T + * Type of the external model representing the sash. + */ +@SuppressWarnings({ "restriction" }) +public class SashPanelPart extends AbstractPanelPart implements IPanelParent { + + /** Log object */ + Logger log = Logger.getLogger(getClass().getName()); + + /** Interface to the model */ + protected ISashPanelModel model; + + /** + * Raw model associated to this part. We store it because the PartModel do + * not provide it + */ + private Object rawModel; + + /** + * Ordered set of currently shown diagrams (a left and right child, or upper + * and lower) TODO rename as children + */ + protected AbstractPanelPart[] currentChildParts = new AbstractPanelPart[2]; + + /** + * The container widget. + */ + private ReplaceableSashForm container; + + /** + * Direction of the sash: SWT.HORIZONTAL or SWT.VERTICAL. Default = + * SWT.HORIZONTAL + */ + private int sashDirection = SWT.HORIZONTAL; + + /** + * Constructor. + */ + public SashPanelPart(IPanelParent parent, ISashPanelModel model, Object rawModel) { + super(parent); + this.model = model; + this.rawModel = rawModel; + this.sashDirection = model.getSashDirection(); + } + + /** + * Get the associated model. + */ + public ISashPanelModel getPartModel() { + return model; + } + + /** + * Fill the provided part map with this parts and recursively call children + * to fillin. + * + * @param partMap + */ + public void fillPartMap(PartLists partMap) { + partMap.addPart(this); + for(AbstractPanelPart child : currentChildParts) { + child.fillPartMap(partMap); + } + garbageState = GarbageState.UNVISITED; + } + + /** + * Create local control, and the tree of children (TileParts AND controls). + * Create this TilePart control, and then Tile childs of this TilePart. + * + * @param parent + * @return Control + */ + public void createPartControl(Composite parent) { + + createControl(parent); + // activate(); + // createChildrenControl(); + } + + /** + * Create local control. Does not create children. + * + */ + protected void createControl(Composite parent) { + // container = new SashForm(parent, sashDirection); + container = new ReplaceableSashForm(parent, sashDirection); + } + + /** + * Create the part for the specified child model. The controls are NOT + * build. + * + * TODO: delegate to sashContainer, remove duplication from here and + * RootPart. + * + * @param rootPart + * @param partModel + * @return + */ + private AbstractPanelPart createChildPart(Object rawModel) { + + // Create the child PartModel. Delegate creation to this part PartModel. + IAbstractPanelModel model = getPartModel().createChildSashModel(rawModel); + + AbstractPanelPart createdPart; + if(model instanceof ITabFolderModel) { + createdPart = new TabFolderPart(this, (ITabFolderModel)model, rawModel); + } else if(model instanceof ISashPanelModel) { + createdPart = new SashPanelPart(this, (ISashPanelModel)model, rawModel); + } else { + // error + throw new IllegalArgumentException("Can't create child part for model of type '" + model.getClass().getName() + "'"); + // TODO: Return an error Part showing the exception instead of + // throwing it ? + } + + return createdPart; + } + + /** + * Create the part for the specified child model. The controls are build. + * + * TODO: delegate to sashContainer, remove duplication from here and + * RootPart. + * + * @param rootPart + * @param partModel + * @return + */ + private AbstractPanelPart createChildPart(Object rawModel, int childIndex) { + // Create parts + AbstractPanelPart createdPart = createChildPart(rawModel); + // Create controls + createdPart.createPartControl(getChildParent(childIndex)); + return createdPart; + } + + /** + * Get the sash container. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.internal.AbstractPanelPart#getControl() + * + * @return + */ + public Composite getControl() { + return container; + } + + /** + * Change the parent of this method. Reparent the Tile and the control. + * Normally, the control already exists. + * + */ + @Override + public void reparent(IPanelParent newParent, Composite swtParent) { + parent = newParent; + // Create control if needed + // This can happen if the TilePart is just created after a refresh + // if(getControl() == null) + // { + // container = createContainer(parent.getControl()); + // } + // Reparent the control + assert (getControl() != null); + // getControl().setParent(newParent.getControl()) ; + getControl().setParent(swtParent); + garbageState = GarbageState.REPARENTED; + } + + /** + * Orphan this node, and children. The parent is set to null, but control is + * left unchanged. The node can be reattached with reparent(). + * + * @see + * @return the parent + */ + public void orphan() { + + // orphan only if we are in UNCHANGED state + if(garbageState == GarbageState.UNVISITED) { + garbageState = GarbageState.ORPHANED; + parent = null; + } + } + + /** + * Dispose the TilePart and its controls. + */ + @Override + public void dispose() { + if(container != null && !container.isDisposed()) { + container.dispose(); + } + container = null; + } + + /** + * Traverses the tree to find the part that intersects the given point + * + * @param toFind + * Point in display coordinate + * @return the part that intersects the given point + * @throws NotFoundException + */ + @Override + public AbstractPart findPart(Point toFind) throws NotFoundException { + + Rectangle bounds = DragUtil.getDisplayBounds(container); // container.getBounds(); + + // Try the left/up pane + bounds = DragUtil.getDisplayBounds(container.getLeftParent()); + if(bounds.contains(toFind)) { + return currentChildParts[0].findPart(toFind); + } + bounds = DragUtil.getDisplayBounds(container.getRightParent()); + if(bounds.contains(toFind)) { + // Return right part + return currentChildParts[1].findPart(toFind); + } + + throw new NotFoundException("Can't find a part at '" + toFind + "'"); + + } + + /** + * Locates the part that intersects the given point and that have the + * expected type + * + * @param toFind + * Position in Display coordinate. + * @return + */ + public AbstractPart findPartAt(Point toFind, Class expectedTileType) { + + if(expectedTileType == this.getClass()) + return this; + + Rectangle bounds = DragUtil.getDisplayBounds(container); // container.getBounds(); + + if(isVertical()) { + if(toFind.y < bounds.y + (bounds.height / 2)) { + return currentChildParts[0].findPartAt(toFind, expectedTileType); + } + return currentChildParts[1].findPartAt(toFind, expectedTileType); + } else { + if(toFind.x < bounds.x + (bounds.width / 2)) { + return currentChildParts[0].findPartAt(toFind, expectedTileType); + } + return currentChildParts[1].findPartAt(toFind, expectedTileType); + } + } + + /** + * Return true if this sash is vertical, false otherwise. + */ + private boolean isVertical() { + return (container.getOrientation() == SWT.VERTICAL); + } + + /** + * Find the part associated to the provided control. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.sash.ITilePart#findPart(org.eclipse.swt.widgets.Control) + */ + @Override + public AbstractPart findPart(Object control) { + if(this.getControl() == control) { + return this; + } + + AbstractPart node = currentChildParts[0].findPart(control); + if(node != null) { + return node; + } + node = currentChildParts[1].findPart(control); + if(node != null) { + return node; + } + return null; + + } + + /** + * SashPanelPart can't be a DropTarget. Do nothing. + */ + public IDropTarget getDropTarget(Object draggedObject, TabFolderPart sourcePart, Point position) { + return null; + } + + /** + * Return true if the Part is for the specified real model. Return false + * otherwise. + * + * @param realModel + * The raw model to check + * @return + */ + public boolean isPartFor(Object realModel) { + return getRawModel() == realModel; + } + + /** + * Get the raw model associated to this part. + * + * @return + */ + protected Object getRawModel() { + return rawModel; + } + + /** + * Synchronize the sash. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.internal.AbstractPanelPart#synchronize2(org.eclipse.papyrus.infra.core.sasheditor.internal.PartLists) + * + * @param partMap + */ + public void synchronize2(PartLists partMap) { + + // Compare currentChildParts and node model + assert (model.getChildren().size() == 2); + + // Synchronize each child + for(int i = 0; i < 2 /* model.getChildModels().size() */; i++) { + synchronizeChild(i, partMap); + } + + // Now recursively call synchronize on childs. + for(int i = 0; i < currentChildParts.length; i++) { + currentChildParts[i].synchronize2(partMap); + // // Set the child controls at the right place + // if(i==0) + // container.moveAbove(currentChildParts[i].getControl()); + // else + // container.moveBelow(currentChildParts[i].getControl()); + // + } + + } + + /** + * Synchronize the specified child. + * + * @param childIndex + * index of the child to be synchronized + * @param existingParts + */ + private void synchronizeChild(int childIndex, PartLists existingParts) { + + Object newModel = model.getChildren().get(childIndex); + + // Check if old child exist + // If exist, check if the current part is associated to the checked + // model + // + AbstractPanelPart currentChildPart = currentChildParts[childIndex]; + if(currentChildPart != null) { + // If the tile is already for the model, there is nothing to do. + if(currentChildPart.isPartFor(newModel)) { + currentChildPart.unchanged(); + return; + } + // The current tile is not for the model: mark it as orphan + currentChildPart.orphan(); + } + + // The child part need to be updated. Do it. + // First check if already exist in the map + AbstractPanelPart newTile = existingParts.findPartFor(newModel); + if(newTile != null) { + // Reparent the tile + newTile.reparent(this, getChildParent(childIndex)); + } else { + // create the tile and its control + newTile = createChildPart(newModel, childIndex); + } + + // Now, put the tile on the right side + setChildToSide(newTile, childIndex); + + } + + /** + * Get the Composite parent that will be provided to the child. + * + * @param childIndex + * @return + */ + private Composite getChildParent(int childIndex) { + // return container; + if(childIndex == 0) + return container.getLeftParent(); + else + return container.getRightParent(); + + } + + /** + * Set the provided child at the specified index. If a child already exist + * at the specified index, it is lost. The controls are set accordingly + * + * @param newTile + * @param childIndex + */ + private void setChildToSide(AbstractPanelPart newTile, int childIndex) { + currentChildParts[childIndex] = newTile; + + } + + /** + * Accept the provided visitor. Call the corresponding accept method in the + * visitor. + * + * @param visitor + * @return + */ + public boolean visit(IPartVisitor visitor) { + return visitor.accept(this); + } + + /** + * Visit the children of this Tile. + * + * @param visitor + */ + public boolean visitChildren(IPartVisitor visitor) { + for(AbstractPanelPart child : currentChildParts) { + if(!child.visit(visitor)) + return false; + } + + // All children have accepter the visit, continue visiting. + return true; + + } + + /** + * Show tile status. Used for debug purpose + */ + protected void showStatus() { + org.eclipse.papyrus.infra.core.sasheditor.Activator.log.debug("sash[" + currentChildParts.length + "]:" + ", disposed=" + container.isDisposed() + ", visible=" + container.isVisible() + ", garbState=" + garbageState + ", " + this); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsException.java new file mode 100644 index 00000000000..0f259d58e67 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/SashWindowsException.java @@ -0,0 +1,56 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +/** + * Main Exception from the SashWindowsSystem. + * + * @author dumoulin + */ +public class SashWindowsException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * + */ + public SashWindowsException() { + } + + /** + * @param message + */ + public SashWindowsException(String message) { + super(message); + } + + /** + * @param cause + */ + public SashWindowsException(Throwable cause) { + super(cause); + } + + /** + * @param message + * @param cause + */ + public SashWindowsException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ShowPartStatusVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ShowPartStatusVisitor.java new file mode 100644 index 00000000000..0297ddf1637 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/ShowPartStatusVisitor.java @@ -0,0 +1,115 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +/** + * Visitor used to show the status of the different Tiles composing the sash + * system. + * + * @author dumoulin + * + */ +@SuppressWarnings("unchecked") +public class ShowPartStatusVisitor extends PartVisitor { + + int level = 1; + + /** + * @param tile + */ + + @Override + public boolean accept(RootPart tile) { + indent(); + tile.showStatus(); + // System.out.println( "root:" + tile ); + level++; + super.accept(tile); + level--; + return true; + } + + /** + * + */ + private void indent() { + if(level < 1) { + // error + return; + } + + for(int i = 0; i < level - 1; i++) { + System.out.print("| "); + } + // last segment + System.out.print("+ "); + } + + /** + * @param tile + */ + @Override + public boolean accept(SashPanelPart tile) { + indent(); + tile.showStatus(); + // System.out.println( "sash:" + tile ); + level++; + super.accept(tile); + level--; + return true; + } + + /** + * @param tile + */ + @Override + public boolean accept(TabFolderPart tile) { + indent(); + tile.showStatus(); + // System.out.println( "folder:" + tile ); + level++; + super.accept(tile); + level--; + return true; + } + + /** + * @param tile + */ + @Override + public boolean accept(EditorPart tile) { + indent(); + tile.showStatus(); + // System.out.println( "editor:" + tile ); + level++; + super.accept(tile); + level--; + return true; + } + + /** + * @param tile + */ + @Override + public boolean accept(ComponentPart tile) { + indent(); + tile.showStatus(); + // System.out.println( "editor:" + tile ); + level++; + super.accept(tile); + level--; + return true; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java new file mode 100644 index 00000000000..7636c55d0b3 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java @@ -0,0 +1,1230 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.util.Geometry; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel; +import org.eclipse.papyrus.infra.core.sasheditor.editor.SashWindowsContainer; +import org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy.AbstractTabFolderPart; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabFolderEvent; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.swt.events.MenuDetectEvent; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseTrackListener; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.ui.internal.DragCursors; +import org.eclipse.ui.internal.dnd.DragUtil; +import org.eclipse.ui.internal.dnd.IDragOverListener; +import org.eclipse.ui.internal.dnd.IDropTarget; + +/** + * Controller associated to a tabfolder. + * + * + * + * Extends MultiPageEditor to inherit methods implementations. + * + * @param T + * Common ancestor for the model provided for the sash windows by the + * application. This is the type used externally by the application. + * Sash implementation don't use this type, it just carry it to ask + * for the appropriate wrapper. Concrete implementation can specify a + * type. + * + * TODO : be more precise for the generic type ? TODO : Listen to the + * page change event, and call setActivePage(). + */ +@SuppressWarnings("restriction") +public class TabFolderPart extends AbstractTabFolderPart { + + /** Log object */ + Logger log = Logger.getLogger(getClass().getName()); + + /** Interface to the model */ + protected ITabFolderModel partModel; + + /** + * Raw model associated to this part. We store it because the PartModel do + * not provide it + */ + private Object rawModel; + + /** + * The wrapper around the CTabFolder. This represent the SWT control + * associated to this part. + */ + protected PTabFolder pTabFolder; + + /** + * Ordered set of currently shown diagrams (list of their models) TODO + * remove + */ + protected TabPartList currentTabItems = new TabPartList(); + + /** The drop target associated to this folderPart */ + private DropTarget dropTarget; + + /** + * Track the mouse hover and fire appropriate event. + */ + private MouseHoverTracker mouseHoverTracker; + + /** + * Listener on DragOver event. + */ + IDragOverListener dragOverListener = new IDragOverListener() { + + /** + * + * @see org.eclipse.ui.internal.dnd.IDragOverListener#drag(org.eclipse.swt.widgets.Control, java.lang.Object, org.eclipse.swt.graphics.Point, + * org.eclipse.swt.graphics.Rectangle) + */ + public IDropTarget drag(Control currentControl, Object draggedObject, Point position, Rectangle dragRectangle) { + // System.out.println(TabFolderPart.this.getClass().getSimpleName() + // + ".drag()"); + // System.out.println(this + ".drag()"); + return null; + } + }; + + /** + * Listener on CTabFolder events. + */ + private PTabFolder.IPTabFolderListener cTabFolderEventListener = new PTabFolder.IPTabFolderListener() { + + public void contextMenuDetectEvent(CTabItem tab, Event event) { + // System.out.println("contextMenuDetect()"); + } + + /** + * The close cross has been pressed. Remove the corresponding tab. {@inheritDoc} + */ + public void itemClosedEvent(CTabFolderEvent event, int pageIndex) { + // System.out.println("itemClosedEvent()"); + // TODO: call appropriate method (to be determine) + // model.removeTab(pageIndex); + // getSashWindowContainer().getContentProvider().removeTab(model, + // pageIndex); + getContentProvider().removePage(partModel, pageIndex); + } + + public void menuDetectEvent(CTabItem tab, MenuDetectEvent event) { + // System.out.println("menuDetectEvent()"); + } + + /** + * Listen to pageChange event, and propagate to TabFolderPart. + * + * @param newPageIndex + */ + public void pageChangeEvent(int newPageIndex) { + pageChangedEvent(newPageIndex); + } + + }; + + /** + * Constructor. + * + * @param nestedPartManager + * @param partModel + * @param rawModel + * + */ + public TabFolderPart(IPanelParent parent, ITabFolderModel partModel, Object rawModel) { + super(parent); + this.partModel = partModel; + this.rawModel = rawModel; + } + + /** + * Get the associated model. + */ + public ITabFolderModel getPartModel() { + return partModel; + } + + /** + * Activate the part. Register as listener to required services. + */ + private void activate() { + // Listen to page changes + pTabFolder.getEventManager().addListener(cTabFolderEventListener); + // Create the tracker that will show tooltips on tabs. + mouseHoverTracker = new MouseHoverTracker(pTabFolder.getControl(), new ImageToolTipManager()); + } + + /** + * Deactivate this part. Unregistered from required service. Do not dispose + * the part. + */ + private void deactivate() { + // Listen to page changes + pTabFolder.getEventManager().removeListener(cTabFolderEventListener); + mouseHoverTracker.deactivate(); + } + + /** + * Fill the provided part map with this parts and recursively call children + * to fillin. + * + * @param partMap + */ + public void fillPartMap(PartLists partMap) { + partMap.addPart(this); + garbageState = GarbageState.UNVISITED; + + for(TabItemPart child : currentTabItems) { + child.fillPartMap(partMap); + } + } + + /** + * Creates the control tree associated to this part. Create the control for + * this part, and eventually recursively call the method for the childs, if + * any. + * + */ + @Override + public void createPartControl(Composite parent) { + + createControl(parent); + // createPages(); + // model.addChangeListener(modelListener); + // model.activate(); + activate(); + } + + /** + * Add a new page at the end of pages. A new tab is created for the page, + * and the page control is created. + * + * @param pageModel + * @param index + */ + // private void addPage(Object pageModel) + // { + // int index = currentTabItems.size(); + // createTabItem(pageModel, index); + // } + + /** + * Create the control for this Part. Does not create children. This method + * is called by the parent after this folder is created. + * + */ + public void createControl(Composite parent) { + PTabFolder res = new PTabFolder(); + pTabFolder = res; + res.createPartControl(parent); + initDrag(res.getControl()); + // init menu + initMenuManager(); + } + + /** + * Init the menuManager after the control has been created. Get the {@link MenuManager} from the {@link SashWindowsContainer}. Set it to this + * folder if it is not null. + */ + private void initMenuManager() { + MenuManager menuManager = getSashWindowContainer().getFolderTabMenuManager(); + if(menuManager != null) { + setFolderTabMenuManager(menuManager); + } + + } + + /** + * Set a {@link MenuManager} used to manage a contextual menu that is shown + * on the tabs area of this folder. + * + * @param menuManager + * The {@link MenuManager} used to create the menu on the tab + * area. + */ + public void setFolderTabMenuManager(MenuManager menuManager) { + Composite folderControl = getControl(); + Menu menu = menuManager.createContextMenu(folderControl); + folderControl.setMenu(menu); + } + + /** + * The page has change. Propagate the event to the container. + * + * @param newPageIndex + */ + @Override + protected void pageChange(int newPageIndex) { + + // System.out.println(this.getClass().getSimpleName() + ".pageChange("+ + // newPageIndex +")"); + // Do nothing if out of range. + if(newPageIndex < 0 || newPageIndex > currentTabItems.size() - 1) + return; + + getSashWindowContainer().pageChanged(currentTabItems.get(newPageIndex).childPart); + } + + /** + * An event signaling that the selected page is changed has been caught. + * Propagate the event to the container. + * + * @param newPageIndex + */ + protected void pageChangedEvent(int newPageIndex) { + + // System.out.println(this.getClass().getSimpleName() + ".pageChange("+ + // newPageIndex +")"); + // Do nothing if out of range. + if(newPageIndex < 0 || newPageIndex > currentTabItems.size() - 1) + return; + + getSashWindowContainer().pageChangedEvent(currentTabItems.get(newPageIndex).childPart); + } + + /** + * Dispose the TilePart and its controls. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.eclipsecopy.MultiPageEditorTile#dispose() + */ + public void dispose() { + // detach menu as it is shared between folders. + getControl().setMenu(null); + + deactivate(); + +// getControl().dispose(); + pTabFolder.dispose(); + } + + /** + * + */ + private void initDrag(Composite container) { + DragUtil.addDragTarget(container, dragOverListener); + } + + /** + * Get the associated CTabFolder + */ + @Override + protected CTabFolder getTabFolder() { + return pTabFolder.getTabFolder(); + } + + /** + * Return the swt Control associated to this part. + */ + public Composite getControl() { + return getTabFolder(); + } + + /** + * The MultiPageEditor implementation of this IWorkbenchPart method sets focus on the active nested + * editor, if there is one. + *

+ * Subclasses may extend or reimplement. + *

+ */ + public void setFocus() { + setFocus(getActivePage()); + } + + /** + * Sets focus to the control for the given page. If the page has an editor, + * this calls its setFocus() method. Otherwise, this calls setFocus on the control for the page. + * + * @param pageIndex + * the index of the page + */ + private void setFocus(int pageIndex) { + if(pageIndex < 0 || pageIndex >= getPageCount()) { + // page index out of bounds, don't set focus. + return; + } + getPagePart(pageIndex).setFocus(); + } + + /** + * Set the active page of this multi-page editor to the page that contains + * the given editor part. This method has no effect of the given editor part + * is not contained in this multi-page editor. + * + * @param editorPart + * the editor part + * @since 3.3 + */ + public final void setActiveEditor(PagePart editorPart) { + int count = getPageCount(); + for(int i = 0; i < count; i++) { + PagePart editor = getPagePart(i); + if(editor == editorPart) { + setActivePage(i); + break; + } + } + } + + /** + * Return the part containing specified point. Normally return this part, + * because the caller has already determine that this contain the part. + * + */ + @Override + public AbstractPart findPart(Point toFind) { + return this; + } + + /** + * Locates the part that intersects the given point and that have the + * expected type + * + * @param toFind + * @return + */ + @Override + public AbstractPart findPartAt(Point toFind, Class expectedTileType) { + + if(expectedTileType == this.getClass()) + return this; + + // ask current active tab + TabItemPart activeTabPart = getActiveTab(); + if(activeTabPart == null) + return null; + + return getActiveTab().findPartAt(toFind, expectedTileType); + } + + /** + * Get the currently active tab. + * + * @return + */ + private TabItemPart getActiveTab() { + int index = getActivePage(); + if(index != -1) { + return currentTabItems.get(index); + } + return null; + } + + /** + * Get the specified childPart + * + * @param index + * Index of the requested childPart. + * @return + */ + protected PagePart getPagePart(int index) { + return currentTabItems.get(index).getChildPart(); + } + + /** + * Get the visible PagePart (from the Container point of view). The visible + * PagePart is the one that has its diagram area visible. From the folder + * point of view, this is the active PagePart. + * + * @return + */ + public PagePart getVisiblePagePart() { + int index = getActivePage(); + if(index != -1) { + return getPagePart(index); + } + return null; + } + + /** + * Find the part associated to the provided control. + * + */ + @Override + public AbstractPanelPart findPart(Object control) { + if(getControl() == control) + return this; + + // Check if it is one of the Item + if(control instanceof CTabItem && ((CTabItem)control).getParent() == getControl()) + return this; + + // Ask childs TODO + return null; + } + + /** + * + * @see org.eclipse.papyrus.infra.core.sasheditor.internal.AbstractPanelPart#getDropTarget(java.lang.Object, + * org.eclipse.papyrus.infra.core.sasheditor.internal.TabFolderPart, org.eclipse.swt.graphics.Point) + * + * @param draggedObject + * @param sourcePart + * @param position + * @return + */ + public IDropTarget getDropTarget(Object draggedObject, TabFolderPart sourcePart, Point position) { + // see org.eclipse.ui.internal.presentations.util.ReplaceDragHandler + // Determine which tab we're currently dragging over + CTabItem tabUnderPointer = pTabFolder.getItem(position); + + // Compute source tab index. If folder, index==-1 + int sourceIndex = PTabFolder.getDraggedObjectTabIndex(draggedObject); + // This drop target only deals with tabs... if we're not dragging over + // a tab, exit. + if(tabUnderPointer == null) { + Rectangle titleArea = pTabFolder.getTabArea(); + + // If we're dragging over the title area, treat this as a drop in + // the last + // tab position. + if(titleArea.contains(position) && pTabFolder.getTabFolder().getItemCount() > 0) { + int dragOverIndex = pTabFolder.getTabFolder().getItemCount(); + CTabItem lastTab = pTabFolder.getTabFolder().getItem(dragOverIndex - 1); + + // Can't drag to end unless you can see the end + if(!lastTab.isShowing()) { + return null; + } + + // If we are unable to compute the bounds for this tab, then + // ignore the drop + Rectangle lastTabBounds = lastTab.getBounds(); + if(lastTabBounds.isEmpty()) { + return null; + } + + // if (dragStart >= 0) { + // dragOverIndex--; + // + // return createDropTarget( sourcePart, lastTabBounds, + // dragOverIndex); + // // return new StackDropResult(lastTabBounds, new + // Integer(dragOverIndex)); + // } + + // Make the drag-over rectangle look like a tab at the end of + // the tab region. + // We don't actually know how wide the tab will be when it's + // dropped, so just + // make it 3 times wider than it is tall. + // titleArea is in Display coordinate, lastTabBounds in parent + // coordinate + Rectangle dropRectangle = titleArea; + + dropRectangle.x = dropRectangle.x + lastTabBounds.x + lastTabBounds.width; + dropRectangle.width = 3 * dropRectangle.height; + return createDropTarget(sourcePart, sourceIndex, dropRectangle, dragOverIndex); + // return new StackDropResult(dropRectangle, new + // Integer(dragOverIndex)); + + } else { + // If the closest side is the side with the tabs, consider this + // a stack operation. + // Otherwise, let the drop fall through to whatever the default + // behavior is + Rectangle displayBounds = DragUtil.getDisplayBounds(pTabFolder.getControl()); + int closestSide = Geometry.getClosestSide(displayBounds, position); + if(closestSide == pTabFolder.getTabFolder().getTabPosition()) { + return createDropTarget(sourcePart, sourceIndex, displayBounds, -1); + } + + return null; + } + } + + if(!tabUnderPointer.isShowing()) { + return null; + } + + // Get thumbnail bounds in display coordinates + Rectangle tabBounds = pTabFolder.getItemBounds(tabUnderPointer); + + if(tabBounds.isEmpty()) { + return null; + } + + return createDropTarget(sourcePart, sourceIndex, tabBounds, pTabFolder.getTabFolder().indexOf(tabUnderPointer)); + } + + /** + * Copied from org.eclipse.ui.internal.PartStack + */ + public IDropTarget createDropTarget(TabFolderPart sourcePart, int sourceIndex, Rectangle snapRectangle, int tabIndex) { + + if(dropTarget == null) { + dropTarget = new DropTarget(sourcePart, sourceIndex, snapRectangle, tabIndex); + return dropTarget; + } + + dropTarget.setTarget(sourcePart, sourceIndex, snapRectangle, tabIndex); + return dropTarget; + } + + /** + * Class implementing methods required by drop targets. Drop target use when + * the drop occur on one of the thumbnail of the folder. + */ + protected class DropTarget implements IDropTarget { + + int cursor = SWT.CENTER; + + private TabFolderPart sourcePart; + + private Rectangle snapRectangle; + + private int targetIndex; + + private int sourceIndex; + + /** + * Constructor. targetPart is the current folder. + * + * @param sourcePart + * The sourcePart of the drag + * @param sourceIndex + * Index of the tab from where the drop occur + * @param snapRectangle + * the drop area. + * @param targetIndex + * Index of the tab where the drop occur + */ + public DropTarget(TabFolderPart sourcePart, int sourceIndex, Rectangle snapRectangle, int targetIndex) { + this.sourceIndex = sourceIndex; + this.targetIndex = targetIndex; + this.sourcePart = sourcePart; + this.snapRectangle = snapRectangle; + } + + public void setTarget(TabFolderPart sourcePart, int sourceIndex, Rectangle snapRectangle, int targetIndex) { + this.sourceIndex = sourceIndex; + this.targetIndex = targetIndex; + this.sourcePart = sourcePart; + this.snapRectangle = snapRectangle; + } + + /** + * + * @see org.eclipse.ui.internal.dnd.IDropTarget#drop() + */ + public void drop() { + + // move from a folder to another + if(sourcePart == TabFolderPart.this) { + // move inside the same folder + getContentProvider().movePage(sourcePart.getPartModel(), sourceIndex, targetIndex); + } else { // move between folder + getContentProvider().movePage(sourcePart.getPartModel(), sourceIndex, TabFolderPart.this.getPartModel(), targetIndex); + } + } + + /** + * Return the cursor used during drag. + * + * @see org.eclipse.ui.internal.dnd.IDropTarget#getCursor() + */ + public Cursor getCursor() { + // System.out.println(TabFolderPart.this.getClass().getSimpleName() + // + ".getCursor()-" + count++); + return DragCursors.getCursor(DragCursors.positionToDragCursor(cursor)); + + } + + public Rectangle getSnapRectangle() { + // System.out.println(TabFolderPart.this.getClass().getSimpleName() + // + ".getSnapRectangle()-" + count); + return snapRectangle; + } + + } + + /** + * Orphan this node. The parent is set to null, but control is left + * unchanged. The node can be reattached with reparent(). + * + * @see + * @return the parent + */ + public void orphan() { + // orphan only if we are in UNCHANGED state + if(garbageState == GarbageState.UNVISITED) { + garbageState = GarbageState.ORPHANED; + parent = null; + + } + } + + /** + * + * @see org.eclipse.papyrus.infra.core.sasheditor.internal.AbstractPart#getGarbageState() + * + * @return + */ + public GarbageState getGarbageState() { + return garbageState; + } + + /** + * Change the parent of this method. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.sash.ITilePart#reparent(org.eclipse.papyrus.infra.core.sasheditor.sash.ITilePart) + */ + public void reparent(IPanelParent newParent, Composite swtParent) { + parent = newParent; + // Create control if needed + // This can happen if the TilePart is just created after a refresh + // if(getControl() == null) + // { + // return; + // // createContainer(parent.getControl()); + // } + // Reparent the control + assert (getControl() != null); + // getControl().setParent(newParent.getControl()) ; + getControl().setParent(swtParent); + garbageState = GarbageState.REPARENTED; + } + + /** + * Return true if the Part is for the specified real model. Return false + * otherwise. + * + * @param realModel + * The raw model to check + * @return + */ + public boolean isPartFor(Object realModel) { + return getRawModel() == realModel; + } + + /** + * Get the raw model associated to this part. + * + * @return + */ + public Object getRawModel() { + return rawModel; + } + + /** + * Refresh the tab of this page (I.e the name and icon in the tab). + * + * @param page + * The page to be refreshed + */ + public void refreshPageTab(PagePart page) { + TabItemPart itemPart = currentTabItems.getByPagePart(page); + if(itemPart == null) + return; + + itemPart.refreshTabDecorations(); + } + + /** + * Synchronize the TabFolder with the models. The Tabs order is fixed and + * can't be moved. So, we move the associated ITilepart if needed. For each + * existing Tab, compare its model and the requested model. Synchronize if + * necessary. If their is more new model, add new Tab If their is less + * newModel, remove unused Tabs. + * + * @param partLists + */ + public void synchronize2(PartLists partLists) { + + // get list of model to be displayed. This is a list of Object. + List newModels = (List)partModel.getChildren(); + + // Disable redraw + CTabFolder folder = getTabFolder(); + folder.setRedraw(false); + // Remember active page + int activePageIndex = getActivePage(); + + // Iterate over the minimum common size + // Synchronize each tab with the requested model + int minSize = Math.min(newModels.size(), currentTabItems.size()); + int index; + for(index = 0; index < minSize; index++) { + Object curModel = newModels.get(index); + TabItemPart curTab = currentTabItems.get(index); + if(!curTab.isTabItemFor(curModel)) { + resetTabItem(curTab, partLists, curModel); + // end + activePageIndex = index; + } else { + // Change curTab state + curTab.getChildPart().unchanged(); + } + } + + // Check for extra tabs or extra models + if(index < newModels.size()) { + // There is extra models, add new tabs + for(int i = index; i < newModels.size(); i++) { + Object curModel = newModels.get(i); + // Create a new TabItem associated to the curModel. + createTabItem(partLists, curModel, i); + // end + } + // Set the last as active + activePageIndex = newModels.size() - 1; + } else if(index < currentTabItems.size()) { + // There is too much tabs, remove them + List toRemove = new ArrayList(); + // Collect tab to be removed + for(int i = index; i < currentTabItems.size(); i++) { + TabItemPart curTab = currentTabItems.get(i); + toRemove.add(curTab); + } + // do remove + for(TabItemPart curTab : toRemove) { + // removeTab(curTab) + removeTabItem(curTab); + // end + } + // Set the active page as the last part if needed + if(activePageIndex >= currentTabItems.size()) + activePageIndex = currentTabItems.size() - 1; + } + + folder.setRedraw(true); + // folder.setSelection(activePageIndex); + folder.redraw(); + + if(activePageIndex >= 0 && activePageIndex < folder.getItemCount()) { + // System.err.println("setActivePage(" + activePageIndex + ") : " + + // this); + // Set the activeTab has visible. + // Do it here because otherwise the active tab could be not visible. + // This come from an undefined bug setting the tab.isVisible(false) + // in some case. + folder.getItem(activePageIndex).getControl().setVisible(true); + setActivePage(activePageIndex); + } else { + // Check if there is item in the CTabFolder. + // If true, we have a trouble + if(getTabFolder().getItemCount() > 0) { + // System.err.println("Active page not set while synchronizing !"); + // We have items, but none is selected. + // Select the first one. + if(getTabFolder().getSelectionIndex() < 0) { + setActivePage(0); + } + } + } + // folder.update(); + // folder.showSelection(); + + } + + /** + * Remove the specified tabItem. Also call appropriate remove() method on + * the tabItem. + * + * @param curTab + */ + private void removeTabItem(TabItemPart tabItem) { + currentTabItems.remove(tabItem); + tabItem.remove(); + } + + /** + * Create a new TabItem associated to the part corresponding to the + * specified newModel. The TabItem is created at the specified index. The + * associated parts is searched in the existingParts or created if none is + * found. + * + * @param existingParts + * List of existing parts. + * @param newModel + * @param index + * @param i + */ + private void createTabItem(PartLists existingParts, Object newModel, int index) { + TabItemPart newTab = null; + + PagePart modelPart = existingParts.findPagePartFor(newModel); + if(modelPart != null) { + // A part already exist for the model. Use it. + modelPart.reparent(this); + newTab = new TabItemPart(this, modelPart, index); + } else { + // No part found, create one + modelPart = createChildPart(newModel); + if(modelPart != null) { + existingParts.addCreatedPage(modelPart); + // Attach it to the tabItem + newTab = new TabItemPart(this, modelPart, index); + } + } + + // Add to the list of items. + if(newTab != null) { + currentTabItems.add(index, newTab); + } + } + + // /** + // * Create a new TabItem and associated part corresponding to the specified + // newModel. + // * The TabItem is created at the specified index. + // * The associated parts is created. + // * + // * @param existingParts List of existing parts. + // * @param newModel + // * @param index + // * @param i + // */ + // private void createTabItem(Object newModel, int index) { + // TabItemPart newTab; + // + // PagePart modelPart = createChildPart( newModel ); + // // Attach it to the tabItem + // newTab = new TabItemPart(this, modelPart, index); + // + // // Add to the list of items. + // currentTabItems.add(index, newTab); + // } + + /** + * Instruct the specified tabItem to use the new model. Check if a part + * already exist for the model and use it if any. Otherwise create a new + * Part. + * + * @param curTab + * @param existingParts + * @param newModel + */ + private void resetTabItem(TabItemPart tabItem, PartLists existingParts, Object newModel) { + + PagePart modelPart = existingParts.findPagePartFor(newModel); + if(modelPart != null) { + // A part already exist for the model. Use it. + tabItem.resetChild(modelPart); + } else { + // No part found, create one + modelPart = createChildPart(newModel); + existingParts.addCreatedPage(modelPart); + // Attach it to the tabItem + tabItem.resetChild(modelPart); + } + } + + /** + * Factory method to create a new Part for the specified newModel. The + * method should always return a valid Part. In case of error while creating + * the requested part, the method should return a default part, maybe + * showing the encountered error. The control for the child is created. + * + * @param newModel + * @return The new part + */ + private PagePart createChildPart(Object newModel) { + + // Create the child PartModel. Delegate creation to this part PartModel. + IPageModel partModel = getPartModel().createChildSashModel(newModel); + + if(partModel != null) { + // Delegate part creation to the container. This allow the container to + // provide appropriate + // objects not available from the part. + PagePart newPart = getSashWindowContainer().createPagePart(this, partModel, newModel); + // Create control. + // Fire events before and after + getSashWindowContainer().getLifeCycleEventProvider().firePageAboutToBeOpenedEvent(newPart); + newPart.createPartControl(getControl()); + getSashWindowContainer().getLifeCycleEventProvider().firePageOpenedEvent(newPart); + + return newPart; + } + + return null; + } + + /** + * Show tab status + * + * @debug This is fo debug purpose. + * @param msg + */ + private void showTabs(String msg) { + System.out.println("------- " + msg); + // Show items + CTabFolder folder = getTabFolder(); + CTabItem items[] = folder.getItems(); + System.out.printf("sel.index %2d :\n", folder.getSelectionIndex()); + System.out.printf("items %2d :", folder.getItemCount()); + for(CTabItem item : items) { + System.out.printf("%10s |", item.getControl()); + } + System.out.println(); + + System.out.printf("it.dispose:"); + for(CTabItem item : items) { + System.out.printf("%10b |", item.getControl().isDisposed()); + } + System.out.println(); + + System.out.printf("it.ctrl.vis:"); + for(CTabItem item : items) { + System.out.printf("%10s |", item.getControl().isVisible()); + } + System.out.println(); + + // + System.out.printf("it.ctrl :"); + for(CTabItem item : items) { + System.out.printf("%10s |", item.getControl()); + } + System.out.println(); + + // + // System.out.printf("tabs.ctrl :" ); + // for( TabItemPart tab : currentModels) + // { + // System.out.printf( "%10s |", tab.childPart.getControl()); + // } + // System.out.println(); + + // + // System.out.printf("tab.editor:" ); + // for( TabItemPart tab : currentModels) + // { + // System.out.printf( "%10s |", tab.childPart.getIEditorPart()); + // } + // System.out.println(); + + // + System.out.printf("tabs %2d :", currentTabItems.size()); + for(TabItemPart tab : currentTabItems) { + System.out.printf("%10s |", tab); + } + System.out.println(); + + } + + /** + * Show tile status. + */ + protected void showStatus() { + // System.out.println( "tabfolder[" + currentModels.size() + "]:" + // + ", disposed=" + getCTabFolder().isDisposed() + // + ", visible=" + getCTabFolder().isVisible() + // + ", garbState=" + garbageState + // + ", " + this); + + CTabFolder ctrl = getTabFolder(); + System.out.printf("tabfolder[%2d]: disposed=%-5b, visible=%-5b, garbState=%-10s, %s\n", currentTabItems.size(), ctrl.isDisposed(), (ctrl.isDisposed() ? false : getTabFolder().isVisible()), garbageState, this); + } + + /** + * Accept the provided visitor. Call the corresponding accept method in the + * visitor. + * + * @param visitor + * @return + */ + public boolean visit(IPartVisitor visitor) { + return visitor.accept(this); + } + + /** + * Visit the children of this Tile. + * + * @param visitor + */ + public boolean visitChildren(IPartVisitor visitor) { + + for(TabItemPart child : currentTabItems) { + if(!child.visit(visitor)) + return false; + } + // All children have accepter the visit, continue visiting. + return true; + } + + /** + * Collection of tabpart. Add miscelenaous methods. + * + * @author dumoulin + * + */ + @SuppressWarnings("serial") + public class TabPartList extends ArrayList { + + /** + * Does the list contains a part with the specified model. + * + * @param model + * @return + */ + public boolean containsModel(Object model) { + return indexOfModel(model) >= 0; + } + + /** + * Returns the index of the first occurrence of the specified element in + * this list, or -1 if this list does not contain the element. More + * formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) , or -1 if + * there is no such index. + */ + public int indexOfModel(Object o) { + if(o == null) { + for(int i = 0; i < size(); i++) + if(get(i) == null) + return i; + } else { + for(int i = 0; i < size(); i++) + if(o.equals(get(i).getChildPart().getRawModel())) + return i; + } + return -1; + } + + /** + * Get the TabPart by its model. + * + * @param model + * @return + */ + public TabItemPart getByModel(Object model) { + return get(indexOfModel(model)); + } + + /** + * Get the TabPart by its PagePart. + * + * @param page + * @return + */ + public TabItemPart getByPagePart(PagePart page) { + return get(indexOfModel(page.getRawModel())); + } + + } + + /** + * Track the mouse for flying over the tabs and show tooltip. Show the + * tooltip when the mouse stop over a tab. Disable the tooltip if mouse is + * clicked. Reenable the tooltip when exiting the tab. + * + * @author dumoulin + * + */ + public class MouseHoverTracker { + + /** + * Control for which a mouse tracker is requested. + */ + private Control control; + + /** Tooltip manager showing tooltip */ + private ImageToolTipManager toolTipManager; + + /** Anonymous mouse tracker */ + MouseTrackListener mouseTrackListener = new MouseTrackListener() { + + private int count = 0; + + public void mouseEnter(MouseEvent e) { + // System.out.println("MouseEnter()" + count++); + + } + + public void mouseExit(MouseEvent e) { + // System.out.println("MouseExit()" + count++); + toolTipManager.closeToolTip(); + } + + public void mouseHover(MouseEvent e) { + CTabFolder folder = getTabFolder(); + // Point pt = folder.toDisplay(e.x, e.y); + Point pt = new Point(e.x, e.y); + CTabItem item = folder.getItem(pt); + int index = pTabFolder.getItemIndex(pt); + if(index == -1) { + toolTipManager.closeToolTip(); + return; + } + + PagePart part = currentTabItems.get(index).getChildPart(); + // System.out.println("MouseHover(" + e.widget + // + ", part=" + part.getPartTitle() + // + ", item=" + item + // + ") - " + count++); + // TODO move it away + //toolTipManager.showToolTip(item.getBounds(), part.getControl(), pt); + toolTipManager.showToolTip(part, item.getBounds(), pt); + } + + + }; + + /** + * Listener on mouse clicked. Used to disable the current tooltip. + */ + private Listener mouseClickedListener = new Listener() { + + private int count = 0; + + public void handleEvent(Event event) { + switch(event.type) { + case SWT.MouseUp: + // System.out.println("MouseUp()" + count++); + toolTipManager.disableToolTip(); + break; + } + } + }; + + /** + * Build a tracker for the specified control. Constructor. + * + * @param control + */ + public MouseHoverTracker(Control control, ImageToolTipManager toolTipManager) { + this.control = control; + this.toolTipManager = toolTipManager; + activate(); + } + + public void activate() { + control.addMouseTrackListener(mouseTrackListener); + control.addListener(SWT.MouseUp, mouseClickedListener); + } + + public void deactivate() { + control.removeMouseTrackListener(mouseTrackListener); + control.removeListener(SWT.MouseUp, mouseClickedListener); + toolTipManager.dispose(); + } + + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabItemPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabItemPart.java new file mode 100644 index 00000000000..89dc1543ff1 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabItemPart.java @@ -0,0 +1,279 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal; + +import org.eclipse.papyrus.infra.core.sasheditor.internal.AbstractPart.GarbageState; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Control; + +/** + * A controller associated to a tabitem in a tabfolder. This controller contains + * a reference to a PagePart. This class is used exclusively by the + * TabFolderPart. It should be not used from elsewhere. + * + * @author dumoulin + * + */ +public class TabItemPart { + + /** + * The associated model TODO : change the type + */ + // protected Object model; + + /** + * The child associated to this tabitem. The child is rendered by the + * tabitem. + */ + protected PagePart childPart; + + /** + * Parent owning this TabItem. Can be null if the Part is orphaned. Even if + * it is orphaned, the SWT Item still set. + */ + protected TabFolderPart parent; + + /** + * The SWT item associated to this part. This item contains the control of + * the associated editor. + */ + protected CTabItem control; + + /** Garbage state used during refresh */ + protected GarbageState garbageState; + + /** + * Constructor. Create a TabItem for the provided modelPart. + * + * @param tabFolderPart + * @param modelPart + * @param index + */ + public TabItemPart(TabFolderPart parent, PagePart modelPart, int index) { + this.parent = parent; + this.childPart = modelPart; + + createItemControl(index); + } + + /** + * Create the part control and the control of the child. + * + * @param tabFolder + * @param index + */ + public void createItemControl(int index) { + // Create the item + CTabItem item = new CTabItem(getTabFolder(), SWT.NONE, index); + control = item; + if(childPart != null) { + item.setControl(childPart.getControl()); + refreshTabDecorations(); + } + } + + /** + * Set the tab decorations: label, icon. + */ + public void refreshTabDecorations() { + setTabText(childPart.getPageTitle()); + setTabImage(childPart.getPageIcon()); + } + + /** + * Reset this TabItem to use the new part. Reparent the new part and orphan + * the old part. + * + * @param modelPart + */ + protected void resetChild(PagePart newChild) { + childPart.orphan(); + newChild.reparent(parent); + childPart = newChild; + setItemControl(childPart.getControl()); + + refreshTabDecorations(); + } + + /** + * Get the container of the Parent. This container is used as root of the + * Controls associated to this editor. + * + * @return + */ + private CTabFolder getTabFolder() { + return (CTabFolder)parent.getControl(); + } + + /** + * Fill the provided part map with the child's parts. + * + * @param partMap + */ + public void fillPartMap(PartLists partMap) { + + childPart.fillPartMap(partMap); + garbageState = GarbageState.UNVISITED; + } + + /** + * Remove the TabPart. Dispose the associated SWT CTabItem. (TODO Remove + * from the parent list.) Orphan the associated ITilePart + * + * @see + * @return the parent + */ + protected void remove() { + + // setControl() change the visibility of the underlying SWT control + // (here the editor). + // This should not happen if the editor is already attached to another + // folder. + // check this case and remember the flag to put it back if needed + setItemControl(null); + parent = null; + control.dispose(); + // Orphan associates Tiles + childPart.orphan(); + } + + /** + * Set the item control. Setting the item control with the + * control.setControl() method has a side effect: the previous control is + * modified with previousControl.setVisible(false). This is annoying when + * the previous control has already been attached to another parent. This + * method take care to not change the visibility of the previous control if + * it is detached from the item's parent. + * + * @param newControl + */ + private void setItemControl(Control newControl) { + // setControl() change the visibility of the underlying SWT control + // (here the editor). + // This should not happen if the editor is already attached to another + // folder. + // check this case and remember the flag to put it back if needed + boolean editorIsVisible = false; + // Get previously attached editor's control + Control editorControl = control.getControl(); + if(editorControl != null && editorControl.getParent() != control.getParent()) { + // Editor has already been reattached + // Remember its visible flag + editorIsVisible = editorControl.getVisible(); + // Detach the item's control + control.setControl(newControl); + if(editorIsVisible) + editorControl.setVisible(editorIsVisible); + } else { + // Not reattached, do nothing else + control.setControl(newControl); + } + } + + /** + * Dispose the associated control. Only dispose this tabitem, not the + * childpart. + */ + public void dispose() { + Control itemControl = control.getControl(); + control.dispose(); + + // Dispose the inner control if any. + if(!itemControl.isDisposed()) + itemControl.dispose(); + + // + parent = null; + } + + /** + * Set the image of the associated tab. + * + * @param titleImage + */ + private void setTabImage(Image titleImage) { + control.setImage(titleImage); + } + + /** + * Set the text of the associated tab. + * + * @param title + */ + private void setTabText(String title) { + if(title == null) + title = ""; + control.setText(title); + control.setToolTipText(title); + } + + /** + * Return the associated EditorTile. + * + * @return + */ + public PagePart getChildPart() { + return childPart; + } + + /** + * Locates the part that intersects the given point and that have the + * expected type + * + * @param position + * @return + */ + public AbstractPart findPartAt(Point position, Class expectedTileType) { + + // if(expectedTileType == this.getClass()) + // return this; + + return childPart.findPartAt(position, expectedTileType); + } + + /** + * Accept the provided visitor. Call the corresponding accept method in the + * visitor. + * + * @param visitor + * @return + */ + public boolean visit(IPartVisitor visitor) { + return visitor.accept(this); + } + + /** + * Visit the children of this Tile. + * + * @param visitor + */ + public boolean visitChildren(IPartVisitor visitor) { + return childPart.visit(visitor); + } + + /** + * Return true if this TabItem is for the specified rawModel. + * + * @param curModel + * @return + */ + public boolean isTabItemFor(Object rawModel) { + return rawModel.equals(getChildPart().getRawModel()); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/AbstractTabFolderPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/AbstractTabFolderPart.java new file mode 100644 index 00000000000..293021bd59a --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/AbstractTabFolderPart.java @@ -0,0 +1,501 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy; + +import org.eclipse.papyrus.infra.core.sasheditor.internal.AbstractPanelPart; +import org.eclipse.papyrus.infra.core.sasheditor.internal.IPanelParent; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabItem; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +/** + * Copy of org.eclipse.ui.part.MultiPageEditorPart. Change if to be suitable has + * a sash leaf. A multi-page editor is an editor with multiple pages, each of + * which may contain an editor or an arbitrary SWT control. + *

+ * This class is intented to separate folder stuff into 2 classes. Subclasses must implement the following methods: + *

    + *
  • createPages - to create the required pages by calling one of the addPage methods
  • + *
  • IEditorPart.doSave - to save contents of editor
  • + *
  • IEditorPart.doSaveAs - to save contents of editor
  • + *
  • IEditorPart.isSaveAsAllowed - to enable Save As
  • + *
  • IEditorPart.gotoMarker - to scroll to a marker
  • + *
+ *

+ *

+ * Multi-page editors have a single action bar contributor, which manages contributions for all the pages. The contributor must be a subclass of + * AbstractMultiPageEditorActionBarContributor. Note that since any nested editors are created directly in code by callers of + * addPage(IEditorPart,IEditorInput), nested editors do not have their own contributors. + *

+ * + * @see org.eclipse.ui.part.MultiPageEditorActionBarContributor + */ +public abstract class AbstractTabFolderPart extends AbstractPanelPart { + + /** + * Subclasses that override {@link #createPageContainer(Composite)} can use + * this constant to get a site for the container that can be active while + * the current page is deactivated. + * + * @since 3.4 + * @see #activateSite() + * @see #deactivateSite(boolean, boolean) + * @see #getPageSite(int) + */ + protected static final int PAGE_CONTAINER_SITE = 65535; + + // /** + // * Private tracing output. + // */ + // private static final String TRACING_COMPONENT = "MPE"; //$NON-NLS-1$ + + // /** + // * The active service locator. This value may be null if + // there is no selected page, or if the selected page is a control with no + // site. + // */ + // private INestable activeServiceLocator; + // + // + // private IServiceLocator pageContainerSite; + + /** + * Creates an empty multi-page editor with no pages. + */ + protected AbstractTabFolderPart(IPanelParent parent) { + super(parent); + } + + /** + * The MultiPageEditor implementation of this IWorkbenchPart method creates the control for the multi-page + * editor by calling createContainer, then createPages. Subclasses should implement createPages rather than + * overriding this method. + * + * @param parent + * The parent in which the editor should be created; must not be null. + */ + @Override + abstract public void createPartControl(Composite parent); + + /** + * Returns the active nested editor if there is one. + *

+ * Subclasses should not override this method + *

+ * + * @return the active nested editor, or null if none + */ + // public IEditorPart getActiveEditor() { + // int index = getActivePage(); + // if (index != -1) { + // return getEditor(index); + // } + // return null; + // } + + /** + * Returns the index of the currently active page of this folder, or -1 if + * there is no active page. + *

+ * Subclasses should not override this method + *

+ * + * @return the index of the active page, or -1 if there is no active page + */ + protected int getActivePage() { + CTabFolder tabFolder = getTabFolder(); + if(tabFolder != null && !tabFolder.isDisposed()) { + return tabFolder.getSelectionIndex(); + } + return -1; + } + + /** + * Returns the control for the given page index, or null if no + * control has been set for the page. The page index must be valid. + *

+ * Subclasses should not override this method + *

+ * + * @param pageIndex + * the index of the page + * @return the control for the specified page, or null if none + * has been set + */ + protected Control getControl(int pageIndex) { + return getItem(pageIndex).getControl(); + } + + /** + * Returns the editor for the given page index. The page index must be + * valid. + * + * @param pageIndex + * the index of the page + * @return the editor for the specified page, or null if the + * specified page was not created with addPage(IEditorPart,IEditorInput) + */ + // abstract protected IEditorPart getEditor(int pageIndex); + + /** + * Returns the service locator for the given page index. This method can be + * used to create service locators for pages that are just controls. The + * page index must be valid. + *

+ * This will return the editor site service locator for an editor, and create one for a page that is just a control. + *

+ * + * @param pageIndex + * the index of the page + * @return the editor for the specified page, or null if the + * specified page was not created with addPage(IEditorPart,IEditorInput) + * @since 3.4 + */ + // protected final IServiceLocator getPageSite(int pageIndex) { + // if (pageIndex == PAGE_CONTAINER_SITE) { + // return getPageContainerSite(); + // } + // + // /** + // * Return the site associated to the editor. + // */ + // return getEditor(pageIndex).getSite(); + // } + + /** + * @return A site that can be used with a header. + * @since 3.4 + * @see #createPageContainer(Composite) + * @see #PAGE_CONTAINER_SITE + * @see #getPageSite(int) + */ + // private IServiceLocator getPageContainerSite() { + // if (pageContainerSite == null) { + // IServiceLocatorCreator slc = (IServiceLocatorCreator) + // getSite().getService(IServiceLocatorCreator.class); + // pageContainerSite = slc.createServiceLocator(getSite(), null, new + // IDisposable() { + // + // public void dispose() { + // final Control control = ((PartSite) getSite()).getPane().getControl(); + // if (control != null && !control.isDisposed()) { + // ((PartSite) getSite()).getPane().doHide(); + // } + // } + // }); + // } + // return pageContainerSite; + // } + + /** + * Returns the tab item for the given page index (page index is 0-based). + * The page index must be valid. + * + * @param pageIndex + * the index of the page + * @return the tab item for the given page index + */ + private CTabItem getItem(int pageIndex) { + return getTabFolder().getItem(pageIndex); + } + + /** + * Returns the number of pages in this multi-page editor. + * + * @return the number of pages + */ + protected int getPageCount() { + CTabFolder folder = getTabFolder(); + // May not have been created yet, or may have been disposed. + if(folder != null && !folder.isDisposed()) { + return folder.getItemCount(); + } + return 0; + } + + /** + * Returns the tab folder containing this multi-page editor's pages. + * + * @return the tab folder, or null if createPartControl has not been called yet + */ + protected abstract CTabFolder getTabFolder(); + + /** + * Notifies this multi-page editor that the page with the given id has been + * activated. This method is called when the user selects a different tab. + *

+ * The MultiPageEditorPart implementation of this method sets focus to the new page, and notifies the action bar contributor (if + * there is one). This checks whether the action bar contributor is an instance of MultiPageEditorActionBarContributor, and, if so, + * calls setActivePage with the active nested editor. This also fires a selection change event if required. + *

+ *

+ * Subclasses may extend this method. + *

+ * + * @param newPageIndex + * the index of the activated page + */ + protected void pageChange(int newPageIndex) { + // System.out.println(this.getClass().getSimpleName() + "pageChange()"); + // deactivateSite(false, false); + // + // IPartService partService = (IPartService) + // getSite().getService(IPartService.class); + // if (partService.getActivePart() == this) { + // setFocus(newPageIndex); + // } + // + // IEditorPart activeEditor = getEditor(newPageIndex); + // + // IEditorActionBarContributor contributor = + // getEditorSite().getActionBarContributor(); + // if (contributor != null && contributor instanceof + // MultiPageEditorActionBarContributor) { + // ((MultiPageEditorActionBarContributor) + // contributor).setActivePage(activeEditor); + // } + // + // if (activeEditor != null) { + // ISelectionProvider selectionProvider = + // activeEditor.getSite().getSelectionProvider(); + // if (selectionProvider != null) { + // ISelectionProvider outerProvider = getSite().getSelectionProvider(); + // if (outerProvider instanceof MultiPageSelectionProvider) { + // SelectionChangedEvent event = new + // SelectionChangedEvent(selectionProvider, + // selectionProvider.getSelection()); + // + // MultiPageSelectionProvider provider = (MultiPageSelectionProvider) + // outerProvider; + // provider.fireSelectionChanged(event); + // provider.firePostSelectionChanged(event); + // } else { + // if (Policy.DEBUG_MPE) { + // Tracing.printTrace(TRACING_COMPONENT, "MultiPageEditorPart " + getTitle() //$NON-NLS-1$ + // + " did not propogate selection for " //$NON-NLS-1$ + // + activeEditor.getTitle()); + // } + // } + // } + // } + // + // activateSite(); + } + + /** + * This method can be used by implementors of {@link AbstractTabFolderPart#createPageContainer(Composite)} to + * deactivate the active inner editor services while their header has focus. + * A deactivateSite() must have a matching call to activateSite() when + * appropriate. + *

+ * An new inner editor will have its site activated on a {@link AbstractTabFolderPart#pageChange(int)}. + *

+ *

+ * Note: This API is evolving in 3.4 and this might not be its final form. + *

+ * + * @param immediate + * immediately deactivate the legacy keybinding service + * @param containerSiteActive + * Leave the page container site active. + * @since 3.4 + * @see #activateSite() + * @see #createPageContainer(Composite) + * @see #getPageSite(int) + * @see #PAGE_CONTAINER_SITE + */ + // protected final void deactivateSite(boolean immediate, boolean + // containerSiteActive) { + // // Deactivate the nested services from the last active service locator. + // if (activeServiceLocator != null) { + // activeServiceLocator.deactivate(); + // activeServiceLocator = null; + // } + // + // final int pageIndex = getActivePage(); + // final IKeyBindingService service = getSite().getKeyBindingService(); + // if (pageIndex < 0 || pageIndex >= getPageCount() || immediate) { + // // There is no selected page, so deactivate the active service. + // if (service instanceof INestableKeyBindingService) { + // final INestableKeyBindingService nestableService = + // (INestableKeyBindingService) service; + // nestableService.activateKeyBindingService(null); + // } else { + // WorkbenchPlugin + // .log("MultiPageEditorPart.deactivateSite() Parent key binding service was not an instance of INestableKeyBindingService. It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$ + // } + // } + // + // if (containerSiteActive) { + // IServiceLocator containerSite = getPageContainerSite(); + // if (containerSite instanceof INestable) { + // activeServiceLocator = (INestable) containerSite; + // activeServiceLocator.activate(); + // } + // } + // } + + /** + * This method can be used by implementors of {@link #createPageContainer(Composite)} to activate the active inner + * editor services when their header loses focus. + *

+ * An new inner editor will have its site activated on a {@link #pageChange(int)}. + *

+ *

+ * Note: This API is evolving in 3.4 and this might not be its final form. + *

+ * + * @since 3.4 + * @see #deactivateSite(boolean,boolean) + * @see #createPageContainer(Composite) + * @see #getPageSite(int) + */ + // protected final void activateSite() { + // if (activeServiceLocator != null) { + // activeServiceLocator.deactivate(); + // activeServiceLocator = null; + // } + // + // final IKeyBindingService service = getSite().getKeyBindingService(); + // final int pageIndex = getActivePage(); + // final IEditorPart editor = getEditor(pageIndex); + // + // if (editor != null) { + // // active the service for this inner editor + // if (service instanceof INestableKeyBindingService) { + // final INestableKeyBindingService nestableService = + // (INestableKeyBindingService) service; + // nestableService.activateKeyBindingService(editor.getEditorSite()); + // + // } else { + // WorkbenchPlugin + // .log("MultiPageEditorPart.activateSite() Parent key binding service was not an instance of INestableKeyBindingService. It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$ + // } + // // Activate the services for the new service locator. + // final IServiceLocator serviceLocator = editor.getEditorSite(); + // if (serviceLocator instanceof INestable) { + // activeServiceLocator = (INestable) serviceLocator; + // activeServiceLocator.activate(); + // } + // + // } else { + // Item item = getItem(pageIndex); + // + // // There is no selected editor, so deactivate the active service. + // if (service instanceof INestableKeyBindingService) { + // final INestableKeyBindingService nestableService = + // (INestableKeyBindingService) service; + // nestableService.activateKeyBindingService(null); + // } else { + // WorkbenchPlugin + // .log("MultiPageEditorPart.activateSite() Parent key binding service was not an instance of INestableKeyBindingService. It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$ + // } + // + // if (item.getData() instanceof INestable) { + // activeServiceLocator = (INestable) item.getData(); + // activeServiceLocator.activate(); + // } + // } + // } + + // /** + // * Disposes the given part and its site. + // * + // * @param part + // * The part to dispose; must not be null. + // */ + // private void disposePart(final IWorkbenchPart part) { + // SafeRunner.run(new ISafeRunnable() { + // + // public void run() { + // IWorkbenchPartSite partSite = part.getSite(); + // part.dispose(); + // if (partSite instanceof MultiPageEditorSite) { + // ((MultiPageEditorSite) partSite).dispose(); + // } + // } + // + // public void handleException(Throwable e) { + // // Exception has already being logged by Core. Do nothing. + // } + // }); + // } + + /** + * Sets the currently active page for this folder. + * + * @param pageIndex + * the index of the page to be activated; the index must be valid + */ + public void setActivePage(int pageIndex) { + // Assert.isTrue(pageIndex >= 0 && pageIndex < getPageCount()); + if(!isValidPageIndex(pageIndex)) + return; + + getTabFolder().setSelection(pageIndex); + pageChange(pageIndex); + } + + /** + * Return true if the specified index is valid. The index should be between + * 0 and pageCount. If there is no page, return false. + * + * @param pageIndex + * @return + */ + private boolean isValidPageIndex(int pageIndex) { + + return pageIndex >= 0 && pageIndex < getPageCount(); + } + + /** + * Sets the control for the given page index. The page index must be valid. + * + * @param pageIndex + * the index of the page + * @param control + * the control for the specified page, or null to + * clear the control + */ + protected void setControl(int pageIndex, Control control) { + getItem(pageIndex).setControl(control); + } + + /* *************************************** */ + /* Added method. */ + /* *************************************** */ + + // /** + // * Title of this TilePart ? Needed by a trace message. + // */ + // protected String getTitle() { + // return getClass().toString(); + // } + // + // /** + // * + // */ + // protected IWorkbenchPartSite getSite() { + // return getEditorSite(); + // } + // + // /** + // * + // */ + // abstract protected void firePropertyChange(int propertyId); + // + // /** + // * + // */ + // abstract protected IEditorSite getEditorSite(); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java new file mode 100644 index 00000000000..e951ee899a5 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java @@ -0,0 +1,554 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy; + +import java.util.ArrayList; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.viewers.ILabelDecorator; +import org.eclipse.jface.viewers.IPostSelectionProvider; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IEditorActionBarContributor; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.IKeyBindingService; +import org.eclipse.ui.INestableKeyBindingService; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.internal.PartSite; +import org.eclipse.ui.internal.PopupMenuExtender; +import org.eclipse.ui.internal.WorkbenchPlugin; +import org.eclipse.ui.internal.services.INestable; +import org.eclipse.ui.internal.services.IServiceLocatorCreator; +import org.eclipse.ui.internal.services.IWorkbenchLocationService; +import org.eclipse.ui.internal.services.ServiceLocator; +import org.eclipse.ui.internal.services.WorkbenchLocationService; +import org.eclipse.ui.part.EditorActionBarContributor; +import org.eclipse.ui.services.IDisposable; +import org.eclipse.ui.services.IServiceLocator; +import org.eclipse.ui.services.IServiceScopes; + +/** + * Site for a nested editor within a multi-page editor. Selection is handled by + * forwarding the event to the multi-page editor's selection listeners; most + * other methods are forwarded to the multi-page editor's site. + *

+ * The base implementation of MultiPageEditor.createSite creates an instance of this class. This class may be instantiated or subclassed. + *

+ * + * @see org.eclipse.ui.part.MultiPageEditorSite.class + */ +public class MultiPageEditorSite implements IEditorSite, INestable { + + org.eclipse.ui.part.MultiPageEditorSite e; + + /** + * The actionBarContributor associated to the site. Can be null. In this + * case, use the multiEditor ActionBarContributor. + */ + protected EditorActionBarContributor actionBarContributor; + + /** + * The nested editor. + */ + private IEditorPart editor; + + /** + * The list of popup menu extenders; null if none registered. + */ + private ArrayList menuExtenders; + + /** + * The main editor EditorSite. + */ + private IEditorSite mainEditorSite; + + /** + * The post selection changed listener. + */ + private ISelectionChangedListener postSelectionChangedListener = null; + + /** + * The selection change listener, initialized lazily; null if + * not yet created. + */ + private ISelectionChangedListener selectionChangedListener = null; + + /** + * The selection provider; null if none. + * + * @see MultiPageEditorSite#setSelectionProvider(ISelectionProvider) + */ + private ISelectionProvider selectionProvider = null; + + /** + * The cached copy of the key binding service specific to this multi-page + * editor site. This value is null if it is not yet + * initialized. + */ + private IKeyBindingService service = null; + + /** + * The local service locator for this multi-page editor site. This value is + * never null. + */ + private final ServiceLocator serviceLocator; + + /** + * Creates a site for the given editor nested within the given multi-page + * editor. + * + * @param mainEditorSite + * the multi-page editor + * @param editor + * the nested editor + * @param editDomain + * The shared editDomain. + */ + public MultiPageEditorSite(IEditorSite mainEditorSite, IEditorPart editor, EditorActionBarContributor actionBarContributor) { + Assert.isNotNull(mainEditorSite); + Assert.isNotNull(editor); + this.mainEditorSite = mainEditorSite; + this.editor = editor; + this.actionBarContributor = actionBarContributor; + + final IServiceLocator parentServiceLocator = mainEditorSite; + IServiceLocatorCreator slc = (IServiceLocatorCreator)parentServiceLocator.getService(IServiceLocatorCreator.class); + this.serviceLocator = (ServiceLocator)slc.createServiceLocator(mainEditorSite, null, new IDisposable() { + + public void dispose() { + final Control control = ((PartSite)getMainEditorSite()).getPane().getControl(); + if(control != null && !control.isDisposed()) { + ((PartSite)getMainEditorSite()).getPane().doHide(); + } + } + }); + + initializeDefaultServices(); + } + + /** + * Return the site of the main editor. + * + * @return + */ + private IWorkbenchPartSite getMainEditorSite() { + return mainEditorSite; + } + + /** + * Return the EditorSite of the main editor. This is the same object as + * getMainEditorSite. TODO: Remove this one. + * + * @return + */ + private IEditorSite getMainEditorEditorSite() { + return mainEditorSite; + } + + /** + * Initialize the slave services for this site. + */ + private void initializeDefaultServices() { + serviceLocator.registerService(IWorkbenchLocationService.class, new WorkbenchLocationService(IServiceScopes.MPESITE_SCOPE, getWorkbenchWindow().getWorkbench(), getWorkbenchWindow(), getMainEditorSite(), this, null, 3)); + } + + /** + * Notifies the multi page editor service that the component within which it + * exists has become active. + * + * @since 3.2 + */ + public final void activate() { + serviceLocator.activate(); + } + + /** + * Notifies the multi page editor service that the component within which it + * exists has been deactived. + * + * @since 3.2 + */ + public final void deactivate() { + serviceLocator.deactivate(); + } + + /** + * Dispose the contributions. + */ + public void dispose() { + if(menuExtenders != null) { + for(int i = 0; i < menuExtenders.size(); i++) { + ((PopupMenuExtender)menuExtenders.get(i)).dispose(); + } + menuExtenders = null; + } + + // Remove myself from the list of nested key binding services. + if(service != null) { + // TODO : check original implem - use main editor site ! + IKeyBindingService parentService = getEditor().getSite().getKeyBindingService(); + if(parentService instanceof INestableKeyBindingService) { + INestableKeyBindingService nestableParent = (INestableKeyBindingService)parentService; + nestableParent.removeKeyBindingService(this); + } + // TODO : dispose service ? + + service = null; + } + + if(serviceLocator != null) { + serviceLocator.dispose(); + } + } + + /** + * The MultiPageEditorSite implementation of this IEditorSite method returns the EditorActionBarContributor + * associated to the site if one is defined, or the + * EditorActionBarContributor of the multiEditor. + * + * @return null + */ + public IEditorActionBarContributor getActionBarContributor() { + + // If we use an action bar contributor, look for a registered + // ActionBarContributor. + // TODO : enable next asap + // ActionBarContributor contributor = + // multiPageEditor.getEditorSite().getActionBarContributor(); + // if(contributor instanceof ComposedActionBarContributor) + // { + // ComposedActionBarContributor composedContributor = + // (ComposedActionBarContributor)contributor; + // return composedContributor.getContributorFor(editor); + // } + + // Return the main ActionBarContributor, usually + // ComposedActionBarContributor + + if(actionBarContributor != null) + return actionBarContributor; + else + return getMainEditorEditorSite().getActionBarContributor(); + // return null; + } + + /** + * The MultiPageEditorSite implementation of this IEditorSite method forwards to the multi-page editor to + * return the action bars. + * + * @return The action bars from the parent multi-page editor. + */ + public IActionBars getActionBars() { + return getMainEditorEditorSite().getActionBars(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + */ + public Object getAdapter(Class adapter) { + return null; + } + + /** + * The MultiPageEditorSite implementation of this IWorkbenchPartSite method forwards to the multi-page editor + * to return the decorator manager. + * + * @return The decorator from the workbench window. + * @deprecated use IWorkbench.getDecoratorManager() + */ + public ILabelDecorator getDecoratorManager() { + return getWorkbenchWindow().getWorkbench().getDecoratorManager().getLabelDecorator(); + } + + /** + * Returns the nested editor. + * + * @return the nested editor + */ + public IEditorPart getEditor() { + return editor; + } + + /** + * The MultiPageEditorSite implementation of this IWorkbenchPartSite method returns an empty string since the + * nested editor is not created from the registry. + * + * @return An empty string. + */ + public String getId() { + return ""; //$NON-NLS-1$ + } + + /* + * (non-Javadoc) Method declared on IEditorSite. + */ + public IKeyBindingService getKeyBindingService() { + if(service == null) { + service = getMainEditorEditorSite().getKeyBindingService(); + if(service instanceof INestableKeyBindingService) { + INestableKeyBindingService nestableService = (INestableKeyBindingService)service; + service = nestableService.getKeyBindingService(this); + + } else { + /* + * This is an internal reference, and should not be copied by + * client code. If you are thinking of copying this, DON'T DO + * IT. + */ + WorkbenchPlugin.log("MultiPageEditorSite.getKeyBindingService() Parent key binding service was not an instance of INestableKeyBindingService. It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + return service; + } + + /** + * The MultiPageEditorSite implementation of this IWorkbenchPartSite method forwards to the multi-page editor + * to return the workbench page. + * + * @return The workbench page in which this editor site resides. + */ + public IWorkbenchPage getPage() { + return getMainEditorSite().getPage(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IWorkbenchPartSite#getPart() + */ + public IWorkbenchPart getPart() { + return editor; + } + + /** + * The MultiPageEditorSite implementation of this IWorkbenchPartSite method returns an empty string since the + * nested editor is not created from the registry. + * + * @return An empty string. + */ + public String getPluginId() { + return ""; //$NON-NLS-1$ + } + + /** + * Returns the post selection change listener which listens to the nested + * editor's selection changes. + * + * @return the post selection change listener. + */ + private ISelectionChangedListener getPostSelectionChangedListener() { + if(postSelectionChangedListener == null) { + postSelectionChangedListener = new ISelectionChangedListener() { + + public void selectionChanged(SelectionChangedEvent event) { + MultiPageEditorSite.this.handlePostSelectionChanged(event); + } + }; + } + return postSelectionChangedListener; + } + + /** + * The MultiPageEditorSite implementation of this IWorkbenchPartSite method returns an empty string since the + * nested editor is not created from the registry. + * + * @return An empty string. + */ + public String getRegisteredName() { + return ""; //$NON-NLS-1$ + } + + /** + * Returns the selection changed listener which listens to the nested + * editor's selection changes, and calls handleSelectionChanged . + * + * @return the selection changed listener + */ + private ISelectionChangedListener getSelectionChangedListener() { + if(selectionChangedListener == null) { + selectionChangedListener = new ISelectionChangedListener() { + + public void selectionChanged(SelectionChangedEvent event) { + MultiPageEditorSite.this.handleSelectionChanged(event); + } + }; + } + return selectionChangedListener; + } + + /** + * The MultiPageEditorSite implementation of this IWorkbenchPartSite method returns the selection provider set + * by setSelectionProvider. + * + * @return The current selection provider. + */ + public ISelectionProvider getSelectionProvider() { + return selectionProvider; + } + + public final Object getService(final Class key) { + return serviceLocator.getService(key); + } + + /** + * The MultiPageEditorSite implementation of this IWorkbenchPartSite method forwards to the multi-page editor + * to return the shell. + * + * @return The shell in which this editor site resides. + */ + public Shell getShell() { + return getMainEditorSite().getShell(); + } + + /** + * The MultiPageEditorSite implementation of this IWorkbenchPartSite method forwards to the multi-page editor + * to return the workbench window. + * + * @return The workbench window in which this editor site resides. + */ + public IWorkbenchWindow getWorkbenchWindow() { + return getMainEditorSite().getWorkbenchWindow(); + } + + /** + * Handles a post selection changed even from the nexted editor. + *

+ * Subclasses may extend or reimplement this method + * + * @param event + * the event + * + * @since 3.2 + */ + protected void handlePostSelectionChanged(SelectionChangedEvent event) { + ISelectionProvider parentProvider = getMainEditorSite().getSelectionProvider(); + + // TODO : use org.eclipse.ui.part.MultiPageSelectionProvider ? + if(parentProvider instanceof MultiPageSelectionProvider) { + SelectionChangedEvent newEvent = new SelectionChangedEvent(parentProvider, event.getSelection()); + MultiPageSelectionProvider prov = (MultiPageSelectionProvider)parentProvider; + prov.firePostSelectionChanged(newEvent); + } + } + + /** + * Handles a selection changed event from the nested editor. The default + * implementation gets the selection provider from the multi-page editor's + * site, and calls fireSelectionChanged on it (only if it is an + * instance of MultiPageSelectionProvider), passing a new event + * object. + *

+ * Subclasses may extend or reimplement this method. + *

+ * + * @param event + * the event + */ + protected void handleSelectionChanged(SelectionChangedEvent event) { + ISelectionProvider parentProvider = getMainEditorSite().getSelectionProvider(); + if(parentProvider instanceof MultiPageSelectionProvider) { + SelectionChangedEvent newEvent = new SelectionChangedEvent(parentProvider, event.getSelection()); + MultiPageSelectionProvider prov = (MultiPageSelectionProvider)parentProvider; + prov.fireSelectionChanged(newEvent); + } + } + + public final boolean hasService(final Class key) { + return serviceLocator.hasService(key); + } + + /** + * The MultiPageEditorSite implementation of this IWorkbenchPartSite method forwards to the multi-page editor + * for registration. + * + * @param menuManager + * The menu manager + * @param selProvider + * The selection provider. + */ + public void registerContextMenu(MenuManager menuManager, ISelectionProvider selProvider) { + getMainEditorSite().registerContextMenu(menuManager, selProvider); + } + + public final void registerContextMenu(final MenuManager menuManager, final ISelectionProvider selectionProvider, final boolean includeEditorInput) { + registerContextMenu(getId(), menuManager, selectionProvider, includeEditorInput); + } + + /** + * The MultiPageEditorSite implementation of this IWorkbenchPartSite method forwards to the multi-page editor + * for registration. + * + * @param menuID + * The identifier for the menu. + * @param menuMgr + * The menu manager + * @param selProvider + * The selection provider. + */ + public void registerContextMenu(String menuID, MenuManager menuMgr, ISelectionProvider selProvider) { + if(menuExtenders == null) { + menuExtenders = new ArrayList(1); + } + PartSite.registerContextMenu(menuID, menuMgr, selProvider, true, editor, menuExtenders); + } + + public final void registerContextMenu(final String menuId, final MenuManager menuManager, final ISelectionProvider selectionProvider, final boolean includeEditorInput) { + if(menuExtenders == null) { + menuExtenders = new ArrayList(1); + } + PartSite.registerContextMenu(menuId, menuManager, selectionProvider, includeEditorInput, editor, menuExtenders); + } + + /** + * The MultiPageEditorSite implementation of this IWorkbenchPartSite method remembers the selection provider, + * and also hooks a listener on it, which calls handleSelectionChanged when a selection changed event + * occurs. + * + * @param provider + * The selection provider. + * @see MultiPageEditorSite#handleSelectionChanged(SelectionChangedEvent) + */ + public void setSelectionProvider(ISelectionProvider provider) { + ISelectionProvider oldSelectionProvider = selectionProvider; + selectionProvider = provider; + if(oldSelectionProvider != null) { + // see code WindowSelectionService (line287) + // in some case as GraphicalView do not implement + // IPostSelectionProvider + oldSelectionProvider.removeSelectionChangedListener(getSelectionChangedListener()); + if(oldSelectionProvider instanceof IPostSelectionProvider) { + ((IPostSelectionProvider)oldSelectionProvider).removePostSelectionChangedListener(getPostSelectionChangedListener()); + } else { + oldSelectionProvider.removeSelectionChangedListener(getPostSelectionChangedListener()); + } + } + if(selectionProvider != null) { + selectionProvider.addSelectionChangedListener(getSelectionChangedListener()); + if(selectionProvider instanceof IPostSelectionProvider) { + ((IPostSelectionProvider)selectionProvider).addPostSelectionChangedListener(getPostSelectionChangedListener()); + } else { + selectionProvider.addSelectionChangedListener(getPostSelectionChangedListener()); + + } + } + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageSelectionProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageSelectionProvider.java new file mode 100644 index 00000000000..8030ae5cea4 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageSelectionProvider.java @@ -0,0 +1,176 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.ListenerList; +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.jface.util.SafeRunnable; +import org.eclipse.jface.viewers.IPostSelectionProvider; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.papyrus.infra.core.sasheditor.editor.IMultiPageEditorPart; +import org.eclipse.ui.IEditorPart; + +/** + * Manages the current selection in a multi-page editor by tracking the active + * nested editor within the multi-page editor. When the selection changes, + * notifications are sent to all registered listeners. + *

+ * This class may be instantiated; it is not intended to be subclassed. The base implementation of MultiPageEditor.init creates an + * instance of this class. + *

+ * + * @noextend This class is not intended to be subclassed by clients. + */ +public class MultiPageSelectionProvider implements IPostSelectionProvider { + + /** + * Registered selection changed listeners (element type: ISelectionChangedListener). + */ + private ListenerList listeners = new ListenerList(); + + /** + * Registered post selection changed listeners. + */ + private ListenerList postListeners = new ListenerList(); + + /** + * The multi-page editor. + */ + private IMultiPageEditorPart multiPageEditor; + + /** + * Creates a selection provider for the given multi-page editor. + * + * @param multiPageEditor + * the multi-page editor + */ + public MultiPageSelectionProvider(IMultiPageEditorPart multiPageEditor) { + Assert.isNotNull(multiPageEditor); + this.multiPageEditor = multiPageEditor; + } + + /* + * (non-Javadoc) Method declared on ISelectionProvider. + */ + public void addSelectionChangedListener(ISelectionChangedListener listener) { + listeners.add(listener); + } + + /** + * Adds a listener for post selection changes in this multi page selection + * provider. + * + * @param listener + * a selection changed listener + * @since 3.2 + */ + public void addPostSelectionChangedListener(ISelectionChangedListener listener) { + postListeners.add(listener); + } + + /** + * Notifies all registered selection changed listeners that the editor's + * selection has changed. Only listeners registered at the time this method + * is called are notified. + * + * @param event + * the selection changed event + */ + public void fireSelectionChanged(final SelectionChangedEvent event) { + Object[] listeners = this.listeners.getListeners(); + fireEventChange(event, listeners); + } + + /** + * Notifies all post selection changed listeners that the editor's selection + * has changed. + * + * @param event + * the event to propogate. + * @since 3.2 + */ + public void firePostSelectionChanged(final SelectionChangedEvent event) { + Object[] listeners = postListeners.getListeners(); + fireEventChange(event, listeners); + } + + private void fireEventChange(final SelectionChangedEvent event, Object[] listeners) { + for(int i = 0; i < listeners.length; ++i) { + final ISelectionChangedListener l = (ISelectionChangedListener)listeners[i]; + SafeRunner.run(new SafeRunnable() { + + public void run() { + l.selectionChanged(event); + } + }); + } + } + + // /** + // * Returns the multi-page editor. + // * + // * @return the multi-page editor. + // */ + // private IMultiPageEditorPart getMultiPageEditor() { + // return multiPageEditor; + // } + + /* + * (non-Javadoc) Method declared on ISelectionProvider. + */ + public ISelection getSelection() { + IEditorPart activeEditor = multiPageEditor.getActiveEditor(); + if(activeEditor != null) { + ISelectionProvider selectionProvider = activeEditor.getSite().getSelectionProvider(); + if(selectionProvider != null) { + return selectionProvider.getSelection(); + } + } + return StructuredSelection.EMPTY; + } + + /* + * (non-JavaDoc) Method declaed on ISelectionProvider. + */ + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + listeners.remove(listener); + } + + /** + * Removes a listener for post selection changes in this multi page + * selection provider. + * + * @param listener + * a selection changed listener + * @since 3.2 + */ + public void removePostSelectionChangedListener(ISelectionChangedListener listener) { + postListeners.remove(listener); + } + + /* + * (non-Javadoc) Method declared on ISelectionProvider. + */ + public void setSelection(ISelection selection) { + IEditorPart activeEditor = multiPageEditor.getActiveEditor(); + if(activeEditor != null) { + ISelectionProvider selectionProvider = activeEditor.getSite().getSelectionProvider(); + if(selectionProvider != null) { + selectionProvider.setSelection(selection); + } + } + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/ITabTooltipPreferences.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/ITabTooltipPreferences.java new file mode 100644 index 00000000000..38e7705a7be --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/ITabTooltipPreferences.java @@ -0,0 +1,52 @@ +package org.eclipse.papyrus.infra.core.sasheditor.internal.preferences; + + + +public interface ITabTooltipPreferences { + + /** + * Constant used in Eclipse preferences + */ + public String isTooltipEnable = "isTooltipEnable"; + public String isTooltipForCurrentTabShown = "isTooltipForCurrentTabShown"; + public String scaledFactor = "scaledFactor"; + public String tooltipAutoCloseDelay = "tooltipAutoCloseDelay"; + + + /** + * Is the tooltip Enable ? + * If true, tooltip are displayed. + * If false, they are not displayed. + * + * @return + */ + public abstract boolean isTooltipEnable(); + + /** + * Is an tooltip shown when the flied tabs is the tab for the cuurently shown diagram ? + * If true, the tooltip is shown. + * If false, the tooltip is not shown. + * + * @return + */ + public abstract boolean isTooltipForCurrentTabShown(); + + /** + * + * @return + */ + public abstract float getScaledFactor(); + + /** + * + * @return + */ + public int getIntScaledFactor(); + + /** + * Return the delay used to close automatically the tooltip. + * @return The delay in millisecond or -1 if there is no delay. + */ + public abstract int getTooltipAutoCloseDelay(); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/ShowPreferencesHandler.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/ShowPreferencesHandler.java new file mode 100644 index 00000000000..f24cccc6c6c --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/ShowPreferencesHandler.java @@ -0,0 +1,60 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.internal.preferences; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; + + +/** + * An handler getting the selected element and reporting them in console. + * + * @author Cedric dumoulin + * + */ +public class ShowPreferencesHandler extends AbstractHandler implements IHandler { + + + /** + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + * @param event + * @return + * @throws ExecutionException + * + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + + + ITabTooltipPreferences settings = new TabTooltipPreferences(); + + showPreferences(settings); + + + return null; + } + + private void showPreferences(ITabTooltipPreferences settings) { + + System.out.println( ITabTooltipPreferences.isTooltipEnable + "=" + settings.isTooltipEnable()); + System.out.println( ITabTooltipPreferences.isTooltipForCurrentTabShown + "=" + settings.isTooltipForCurrentTabShown()); + System.out.println( ITabTooltipPreferences.scaledFactor + "=" + settings.getScaledFactor()); + System.out.println( ITabTooltipPreferences.scaledFactor + "(int)=" + settings.getIntScaledFactor()); + System.out.println( ITabTooltipPreferences.tooltipAutoCloseDelay + "=" + settings.getTooltipAutoCloseDelay()); + + } + + /** + * Get the name used in the {@link RecordingCommand}. This name will be visible in + * undo/redo. + * + * @return The command name to show. + */ + public String getCommandName() { + return "Read Preferences"; + } + + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/TabTooltipPreferenceInitializer.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/TabTooltipPreferenceInitializer.java new file mode 100644 index 00000000000..f4756122585 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/TabTooltipPreferenceInitializer.java @@ -0,0 +1,38 @@ +package org.eclipse.papyrus.infra.core.sasheditor.internal.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.core.runtime.preferences.DefaultScope; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.papyrus.infra.core.sasheditor.Activator; +import org.eclipse.ui.preferences.ScopedPreferenceStore; + +/** + * Class used to initialize default preference values. + */ +public class TabTooltipPreferenceInitializer extends AbstractPreferenceInitializer { + + /** + * + * + */ + public void initializeDefaultPreferences() { + IPreferenceStore store = createPreferenceStore(); + store.setDefault(ITabTooltipPreferences.isTooltipEnable, true); + store.setDefault(ITabTooltipPreferences.isTooltipForCurrentTabShown, false); + store.setDefault(ITabTooltipPreferences.scaledFactor, 50); + store.setDefault(ITabTooltipPreferences.tooltipAutoCloseDelay, 5000); + + + } + + /** + * Subclasses may implements this method in order to provide the requested preferenceStore. + * @return + */ + protected IPreferenceStore createPreferenceStore() { + IPreferenceStore store = new ScopedPreferenceStore(DefaultScope.INSTANCE, Activator.getDefault().getBundle().getSymbolicName()); + + return store; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/TabTooltipPreferencePage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/TabTooltipPreferencePage.java new file mode 100644 index 00000000000..fb4c6447916 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/TabTooltipPreferencePage.java @@ -0,0 +1,78 @@ +package org.eclipse.papyrus.infra.core.sasheditor.internal.preferences; + +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.IntegerFieldEditor; +import org.eclipse.jface.preference.ScaleFieldEditor; +import org.eclipse.papyrus.infra.core.sasheditor.Activator; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.preferences.ScopedPreferenceStore; + +/** + * This class represents a preference page that + * is contributed to the Preferences dialog. By + * subclassing FieldEditorPreferencePage, we + * can use the field support built into JFace that allows + * us to create a page that is small and knows how to + * save, restore and apply itself. + *

+ * This page is used to modify preferences only. They + * are stored in the preference store that belongs to + * the main plug-in class. That way, preferences can + * be accessed directly via the preference store. + */ + +public class TabTooltipPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + public TabTooltipPreferencePage() { + super(GRID); + +// IPreferenceStore store = new ScopedPreferenceStore(new InstanceScope(), Activator.getDefault().getBundle().getSymbolicName()); + IPreferenceStore store = createPreferenceStore(); + setPreferenceStore(store); + setDescription("SashWindows Tabs Tooltip Preferences"); + + } + + /** + * Subclasses may implements this method in order to provide the requested preferenceStore. + * @return + */ + protected IPreferenceStore createPreferenceStore() { + IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.getDefault().getBundle().getSymbolicName()); + + return store; + } + + + /** + * Creates the field editors. Field editors are abstractions of + * the common GUI blocks needed to manipulate various types + * of preferences. Each field editor knows how to save and + * restore itself. + */ + public void createFieldEditors() { + addField( + new BooleanFieldEditor( ITabTooltipPreferences.isTooltipEnable, "Is Tooltip &Enable", getFieldEditorParent())); + + addField( + new BooleanFieldEditor( ITabTooltipPreferences.isTooltipForCurrentTabShown, "Is Tooltip For &Current Tab Shown", getFieldEditorParent())); + + addField( + new IntegerFieldEditor(ITabTooltipPreferences.tooltipAutoCloseDelay, "Auto Close &Delay (in ms)", getFieldEditorParent(), 10)); + + addField( + new ScaleFieldEditor(ITabTooltipPreferences.scaledFactor, "Tooltip &Scale", getFieldEditorParent(), 0, 100, 1, 10)); + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench workbench) { + } + +} \ No newline at end of file diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/TabTooltipPreferences.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/TabTooltipPreferences.java new file mode 100644 index 00000000000..cbf2a93726b --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/preferences/TabTooltipPreferences.java @@ -0,0 +1,103 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.sasheditor.internal.preferences; + +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.papyrus.infra.core.sasheditor.Activator; +import org.eclipse.ui.preferences.ScopedPreferenceStore; + + +/** + * An implementation retrieving values from Eclipse preferences + * @author cedric dumoulin + * + */ +public class TabTooltipPreferences implements ITabTooltipPreferences { + + /** + * Store used to access preferences. + */ + protected IPreferenceStore store; + + public TabTooltipPreferences() { + IPreferenceStore store = createPreferenceStore(); + setPreferenceStore(store); + } + + /** + * Subclasses may implements this method in order to provide the requested preferenceStore. + * @return + */ + protected IPreferenceStore createPreferenceStore() { + IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.getDefault().getBundle().getSymbolicName()); + + return store; + } + + + /** + * @return the store + */ + public IPreferenceStore getPreferenceStore() { + return store; + } + + + /** + * @param store the store to set + */ + public void setPreferenceStore(IPreferenceStore store) { + this.store = store; + } + + /** + * @see org.eclipse.papyrus.examples.preferences.wsprefs.ITabTooltipPreferences#isTooltipEnable() + * + * @return + */ + public boolean isTooltipEnable() { + + return store.getBoolean(ITabTooltipPreferences.isTooltipEnable); + } + + /** + * @see org.eclipse.papyrus.examples.preferences.wsprefs.ITabTooltipPreferences#isTooltipForCurrentTabShown() + * + * @return + */ + public boolean isTooltipForCurrentTabShown() { + return store.getBoolean(ITabTooltipPreferences.isTooltipForCurrentTabShown); + } + + /** + * @see org.eclipse.papyrus.examples.preferences.wsprefs.ITabTooltipPreferences#getScaledFactor() + * + * @return + */ + public float getScaledFactor() { + return (store.getInt(ITabTooltipPreferences.scaledFactor)/100.0f); + + } + + /** + * @see org.eclipse.papyrus.examples.preferences.wsprefs.ITabTooltipPreferences#getScaledFactor() + * + * @return + */ + public int getIntScaledFactor() { + return store.getInt(ITabTooltipPreferences.scaledFactor); + + } + + /** + * @see org.eclipse.papyrus.examples.preferences.wsprefs.ITabTooltipPreferences#getTooltipAutoCloseDelay() + * + * @return + */ + public int getTooltipAutoCloseDelay() { + return store.getInt(ITabTooltipPreferences.tooltipAutoCloseDelay); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/multipage/editor/MultiPageEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/multipage/editor/MultiPageEditor.java new file mode 100644 index 00000000000..ad06108309f --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/multipage/editor/MultiPageEditor.java @@ -0,0 +1,381 @@ +/***************************************************************************** + * Copyright (c) 2009 CEA LIST & LIFL + * + * + * 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: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.sasheditor.multipage.editor; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IComponentModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ITabFolderModel; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.part.MultiPageEditorPart; + +/** + * A MultiPageEditor implementation accepting IMultiSashContentProvider as + * content provider. This implementation extends the regular eclipse + * MultiPageEditorPart. The refresh() method allows to refresh the tabs. + * + * The implementation do not listen on model change. This can be done by + * subclasses. To add a new tab, one should add it as a model in the + * ContentProvider. The addPage() methods should not be used for this purpose. + * + * This implementation is intended for debug and testing purpose : it can be + * used in place of the AbstractMultiPageSashEditor. It takes the same arguments + * and ContentProvider, but it only allows one folder and don't deal with + * multisashes. Also, the implementation use the regular Eclipse EditorSite + * management. This allows to check for problems from this site management. + * + * @author dumoulin + */ +public abstract class MultiPageEditor extends MultiPageEditorPart { + + /** Log object */ + protected Logger log = Logger.getLogger(getClass().getName()); + + /** The pageProvider */ + private ISashWindowsContentProvider pageProvider; + + /** + * The tabfolder model providing the pages that must be shown. + */ + private ITabFolderModel tabFolderModel; + + /** Ordered set of currently shown diagrams */ + protected List currentTabs = new ArrayList(); + + /** + * Constructor. + */ + public MultiPageEditor() { + super(); + } + + /** + * This method is called at the end of createPartControl(). Just intercept + * the call in order to call activate(). Create the part controls. {@inheritDoc} + */ + @Override + protected void initializePageSwitching() { + + super.initializePageSwitching(); + activate(); + } + + /** + * Method to activate the editor. Called immediately after + * createPartControl() is complete. To be implemented by subclasses. Default + * implementation do nothing. + */ + protected void activate() { + + } + + /** + * Method to deactivate the editor. Called when dispose() is called. To be + * implemented by subclasses. Default implementation do nothing. + */ + protected void deactivate() { + + } + + /** + * Dispose the Editor. Also dispose the sashsystem. + * + * @see org.eclipse.ui.part.WorkbenchPart#dispose() + * + */ + @Override + public void dispose() { + deactivate(); + super.dispose(); + // sashContainer.dispose(); + } + + @Override + public Object getAdapter(Class adapter) { + + // Get the content provider if requested. + if(ISashWindowsContentProvider.class == adapter) + return getContentProvider(); + + return super.getAdapter(adapter); + } + + /** + * get the contentProvider. Create it if necessary. + * + * @return + */ + protected ISashWindowsContentProvider getContentProvider() { + if(pageProvider == null) + pageProvider = createPageProvider(); + + return pageProvider; + } + + /** + * @param pageProvider + * the pageProvider to set + */ + protected void setContentProvider(ISashWindowsContentProvider pageProvider) { + this.pageProvider = pageProvider; + } + + /** + * Add a page containing the Component described by the provided model. + * + * @param tabItem + */ + protected int addPage(IComponentModel tabItem) { + Composite composite = tabItem.createPartControl(getContainer()); + + int index = addPage(composite); + setPageText(index, tabItem.getTabTitle()); + Image image = tabItem.getTabIcon(); + if(image != null) + setPageImage(index, image); + return index; + } + + /** + * Add the editor corresponding to the model to the folder. + * + * @param editorModel + */ + protected int addPage(IEditorModel editorModel) { + try { + IEditorPart editor = editorModel.createIEditorPart(); + int index = addPage(editor, getEditorInput()); + setPageText(index, editorModel.getTabTitle()); + Image image = editorModel.getTabIcon(); + if(image != null) + setPageImage(index, image); + return index; + } catch (PartInitException e) { + ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus()); + return -1; + } + + } + + /** + * Creates the pages of the multi-page editor. + */ + protected void createPages() { + // get the page descriptions + pageProvider = getContentProvider(); + // Get the current tabFolder + // + tabFolderModel = lookupFolder(); + + refreshTabs(); + + // // iterate over pages to be show + // for( Object rawPageModel : tabFolderModel.getChildren() ) + // { + // // Get the model interface + // ITabItemModel tabItem = tabFolderModel.createChildSashModel( + // rawPageModel); + // if(tabItem instanceof IEditorModel ) + // { + // addPage((IEditorModel)tabItem ); + // } + // else if(tabItem instanceof IComponentModel ) + // { + // addPage((IComponentModel)tabItem ); + // } + // else + // { + // System.err.println("Can't create page for model '" + tabItem + + // "'. Skipp it."); + // } + // } + } + + /** + * Lookup for a folder in the SashModel. Return the first folder found. + * + * @return + */ + private ITabFolderModel lookupFolder() { + if(pageProvider == null) + return null; + + Object rawModel = pageProvider.getRootModel(); + IAbstractPanelModel panelModel = pageProvider.createChildSashModel(rawModel); + + return lookupFolder(panelModel); + } + + /** + * Recursively search in sash models for a FolderModel. Return the first + * encountered folder. + * + * @param panelModel + * @return + */ + private ITabFolderModel lookupFolder(IAbstractPanelModel panelModel) { + + if(panelModel instanceof ITabFolderModel) + return (ITabFolderModel)panelModel; + else { + ISashPanelModel sashModel = (ISashPanelModel)panelModel; + // Iterate on children + for(Object child : sashModel.getChildren()) { + IAbstractPanelModel childModel = pageProvider.createChildSashModel(child); + ITabFolderModel res = lookupFolder(childModel); + if(res != null) + return res; + } + } + // Not found + return null; + } + + /** + * Create the provider. Subclass must implements this method. It should + * return the provider used by the editor. + * + */ + abstract protected ISashWindowsContentProvider createPageProvider(); + + /** + * Refresh the tabs order. This method should be called after the model list + * is modified. + */ + protected void refreshTabs() { + // get list of diagrams to be displayed + List newModels = tabFolderModel.getChildren(); + + // Check if each model has an open pageEditor. If not, create the + // editor. + Iterator newIter = newModels.iterator(); + while(newIter.hasNext()) { + Object model = newIter.next(); + if(!tabExistsFor(model)) { // create a new editor for the model + IPageModel pageModel = tabFolderModel.createChildSashModel(model); + if(pageModel != null) { + addEditor(pageModel); + } + } + } + + // If open editor count is the same has models count, + // all models have an editor. So, end the refresh process. + if(newModels.size() == getPageCount()) + return; + + // There is some extra editors ! remove them. + // remove extra editors : for each open editor, check if its model is in + // the list of required models. + List toBeRemoved = new ArrayList(); + Iterator currentIter = currentTabs.iterator(); + while(currentIter.hasNext()) { + IPageModel model = currentIter.next(); + if(!newModels.contains(model.getRawModel())) { // remove editor + toBeRemoved.add(model); + } + } + + // Remove editor from the editors displayed by the multi editor + Iterator removeIter = toBeRemoved.iterator(); + while(removeIter.hasNext()) { + IPageModel model = removeIter.next(); + removeEditor(model); + } + } + + /** + * Check if an editor exists for the specified model. + * + * @param model + * the diagram (model) that should be displayed + * @return true if the editor exists for this model + */ + private boolean tabExistsFor(Object model) { + for(IPageModel tabItem : currentTabs) { + if(tabItem.getRawModel() == model) + return true; + } + return false; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.MultiPageEditorPart#removePage(int) + */ + @Override + public void removePage(int pageIndex) { + super.removePage(pageIndex); + // synchronize the list of currently shown models. + currentTabs.remove(pageIndex); + } + + /** + * Removes the editor associated to the specified model. + * + * @param model + * the diagram (model) displayed in the editor + */ + private void removeEditor(IPageModel model) { + int index = currentTabs.indexOf(model); + removePage(index); + } + + /** + * Add a new editor at the end of existing editors. First, create the + * editor, then add it to the tabs. + * + * @param contentProvider + * the diagram (model) to be displayed in the editor + */ + private void addEditor(IPageModel tabItem) { + // Check if an editor already exists + if(tabExistsFor(tabItem)) { + if(log.isLoggable(Level.FINE)) + log.fine("Editor already exists for '" + tabItem + "'"); + return; + } + + int editorIndex = -1; + if(tabItem instanceof IEditorModel) { + editorIndex = addPage((IEditorModel)tabItem); + } else if(tabItem instanceof IComponentModel) { + editorIndex = addPage((IComponentModel)tabItem); + } else { + System.err.println("Can't create page for model '" + tabItem + "'. Skipp it."); + return; + } + + // Add the model in the list of current tabs. + currentTabs.add(tabItem); + // set active page + setActivePage(editorIndex); + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/Activator.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/Activator.java deleted file mode 100644 index 5ef671afa0a..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/Activator.java +++ /dev/null @@ -1,69 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor; - -import org.eclipse.papyrus.log.LogHelper; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - /** Plugin ID */ - public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.sasheditor"; - - /** shared instance of the plugin */ - private static Activator plugin; - - /** Logging helper */ - public static LogHelper log = new LogHelper(); - - /** - * The constructor - */ - public Activator() { - } - - /** - * {@inheritDoc} - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - // register the login helper - log.setPlugin(plugin); - } - - /** - * {@inheritDoc} - */ - @Override - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared eINSTANCE - * - * @return the shared eINSTANCE - */ - public static Activator getDefault() { - return plugin; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IAbstractPanelModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IAbstractPanelModel.java deleted file mode 100644 index b356dd43ed6..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IAbstractPanelModel.java +++ /dev/null @@ -1,15 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.contentprovider; - -/** - * A Panel represent a SashPanel or a TabFolder. This interface is the common - * ancestor of the Panel models used in sash system. - * - * @author dumoulin - * - */ -public abstract interface IAbstractPanelModel { - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IComponentModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IComponentModel.java deleted file mode 100644 index 6078b7d2228..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IComponentModel.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.contentprovider; - -import org.eclipse.swt.widgets.Composite; - -/** - * This model represent a ui Component to be shown in a sash window folder. - * - * @author dumoulin - * - */ -public interface IComponentModel extends IPageModel { - - /** - * Create the Control corresponding to this model. - * - * @param parent - * The parent of the created container. - * @return - */ - public Composite createPartControl(Composite parent); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IContentChangedListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IContentChangedListener.java deleted file mode 100644 index 3339af725be..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IContentChangedListener.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.contentprovider; - -/** - * Interface to be implemented by classes needing to be notified when the - * SashContent model has changed. This interface is not used by the - * sashesWindows itself. It exists to allows ContentProvider implementation to - * provide a common notification mechanism. - * - * @author dumoulin - */ -public interface IContentChangedListener { - - /** - * Event indicating the change. TODO The types are not set correctly from - * user like DI model. But anyway there aren't used by clients. - * - * @author dumoulin - */ - public class ContentEvent { - - public static final int ADDED = 0; - - public static final int REMOVED = 1; - - public static final int CHANGED = 2; - - public static final int MOVED = 3; - - /** type of event */ - private int type; - - /** model to which the event apply */ - private Object model; - - /** object added or removed or modified */ - private Object object; - - /** - * @param type - * @param model - * @param object - */ - public ContentEvent(int type, Object model, Object object) { - this.type = type; - this.model = model; - this.object = object; - } - - /** - * @return the type - */ - public int getType() { - return type; - } - - /** - * @return the model - */ - public Object getModel() { - return model; - } - - /** - * @return the object - */ - public Object getObject() { - return object; - } - - } - - /** - * Method called when the content has changed. - */ - public void contentChanged(ContentEvent event); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IContentChangedProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IContentChangedProvider.java deleted file mode 100644 index 718420b124a..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IContentChangedProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.eclipse.papyrus.sasheditor.contentprovider; - -/** - * Interface implemented by classes firing events when the ContentProvider - * content change. This interface can be used by client of ContentProvider. It - * is not use directly by the SashSystem. - * - * @author dumoulin - */ -public interface IContentChangedProvider { - - /** - * Add a listener listening on content changed. This listener will be - * notified each time the content change. - * - * @param listener - */ - public abstract void addListener(IContentChangedListener listener); - - /** - * Add a listener listening on content changed. This listener will be - * notified each time the content change. - * - * @param listener - */ - public abstract void removeListener(IContentChangedListener listener); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IEditorModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IEditorModel.java deleted file mode 100644 index 804174b4367..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IEditorModel.java +++ /dev/null @@ -1,44 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.contentprovider; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.EditorActionBarContributor; - -/** - * This model indicate that an Editor should be drawn in the sash window folder. - * - * @author dumoulin - * - */ -public interface IEditorModel extends IPageModel { - - /** - * Create the IEditor that should be shown. Editor life cycle methods are - * not called. - * - * @return A new instance of the IEditor. - */ - public IEditorPart createIEditorPart() throws PartInitException; - - /** - * Get the EditorActionBarContributor that should be associated with the - * editor . - * - * @return - */ - public EditorActionBarContributor getActionBarContributor(); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IPageMngr.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IPageMngr.java deleted file mode 100644 index 8b3bd6a1f53..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IPageMngr.java +++ /dev/null @@ -1,141 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * Anass Radouani (Atos) - Add History management - * - *****************************************************************************/ - -package org.eclipse.papyrus.sasheditor.contentprovider; - -import java.util.List; - -import org.eclipse.papyrus.sasheditor.editor.IPageChangedListener; -import org.eclipse.papyrus.sasheditor.editor.SashContainerEventsListener; -import org.eclipse.papyrus.sasheditor.editor.SashWindowsContainer; - -/** - * Interface providing method to manage pages in the Sash Windows system. This - * interface can be provided by ContentProvider whishing to provide a standard - * way to manage pages. This interface is not mandatory for the Sasheditor. This - * interface provide basic access to the Sash Windows system. It is intended to - * be used from the application in order to interact with the ContentProvider. - * Then, the {@link SashWindowsContainer} will refresh its views. - * - * - * @author dumoulin - */ -public interface IPageMngr extends IPageChangedListener, SashContainerEventsListener { - - /** - * Add a Page identifier to the list of pages, do not open it. - * - * @param page - * The object identifying the page to add. This object will be - * passed to the {@link IPageModelFactory#createIPageModel(EObject)}. This - * identifier is stored in the sash model. It should be a - * reference on a EMF object identifying the page. - */ - public void addPage(Object pageIdentifier); - - /** - * Remove the page from the SashWindows system and from the list of page. - * The page will not be available anymore. - * - * @param pageIdentifier - * The object identifying the page - */ - public void removePage(Object pageIdentifier); - - /** - * Close the page corresponding to the identifier. The identifier is removed - * from the Sash Windows, but not from the list of pages. - * - * @param pageIdentifier - * The object identifying the page - */ - public void closePage(Object pageIdentifier); - - /** - * Close all opened pages. - * - */ - public void closeAllOpenedPages(); - - /** - * Close all opened pages except the one provided as parameter. - * - * @param pageIdentifier - */ - public void closeOtherPages(Object pageIdentifier); - - /** - * Open a Page corresponding to the identifier. If the page is not in the - * list of pages, add it. The identifier is first added to the current - * folder model. Then the Sash Windows should react and ask the {@link IPageModelFactory} to create the IPageModel. This later is then - * used to create the SWT page. If - * - * @param page - * The object identifying the page to add. This object will be - * passed to the {@link IPageModelFactory#createIPageModel(EObject)}. This - * identifier is stored in the sash model. It should be a - * reference on a EMF object identifying the page. - */ - public void openPage(Object pageIdentifier); - - /** - * Return all available page identifiers (open and closed pages). - * - * @return List of registered page identifiers. - */ - public List allPages(); - - /** - * Return true if a page is open for the specified pageIdentifier. - * - * @param diagram - * @return - */ - public boolean isOpen(Object pageIdentifier); - - /** - * Open the previously opened page - */ - public void openPrevious(); - - /** - * Open the next page after a previous - */ - public void openNext(); - - /** - * Verify if the PageMngr car backward in history - * - * @return - */ - public boolean hasPreviousHistory(); - - /** - * Verify if the PageMngr car forward in history - * - * @return - */ - public boolean hasNextHistory(); - - /** - * add a page to PageMngr History - * - * @param pageIdentifier - * identifying the page to add - * @return - */ - public int isInHsitory(Object pageIdentifier); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IPageModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IPageModel.java deleted file mode 100644 index b692ab3f457..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/IPageModel.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.contentprovider; - -import org.eclipse.swt.graphics.Image; - -/** - * This interface is the root of the hierarchy of models representing Pages. - * This represent the final element shown in the sashes window. It can be an - * Editor or a simple control. This interface is used by the sashes window to - * interact with the model describing the element to be shown in the TabItem. - * - * @author dumoulin - * - */ -public abstract interface IPageModel { - - /** - * Get the title to be shown in the tab - * - * @return - */ - public String getTabTitle(); - - /** - * Get the icon to be shown in the tab - * - * @return - */ - public Image getTabIcon(); - - /** - * Get the raw model corresponding to this node. This is the object provided - * to {@link ITabFolderModel.getChildren()} - * - * @return - */ - public Object getRawModel(); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/ISashPanelModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/ISashPanelModel.java deleted file mode 100644 index d2bb3a4d716..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/ISashPanelModel.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.eclipse.papyrus.sasheditor.contentprovider; - -import java.util.List; - -/** - * A sash node contains two children separated by a sash. The sash can be moved, - * resizing the children. This interface is used to specify that a sash with two - * children should be drawn. - * - * @author dumoulin - * - */ -public interface ISashPanelModel extends IAbstractPanelModel { - - /** - * Get the list of children that should be displayed in the folder. - * - * @return - */ - public List getChildren(); - - /** - * Create the Interface used to access the real model. This method is called - * by the sashes window to get the interface. The method is called only once - * for a given object. - * - * @param child - * A child returned by getChildren(). - * @return - */ - public IAbstractPanelModel createChildSashModel(Object child); - - /** - * Get the sash direction. Can be SWT.VERTICAL or SWT.HORIZONTAL. - */ - public int getSashDirection(); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/ISashWindowsContentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/ISashWindowsContentProvider.java deleted file mode 100644 index 85a4b334684..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/ISashWindowsContentProvider.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.eclipse.papyrus.sasheditor.contentprovider; - -/** - * This interface is used by the sash windows system to discover its content. It - * is considered as the root of the sash windows models. The sashsystem is able - * to retrieve all its content from this interface, and associated interfaces {@link ITabFolderModel}, {@link ISashPanelModel}, {@link IPageModel}. - * The - * interface is also used by the sashsystem to communicate, by sending event, - * with the effective implementation or upper level. - * - * @author dumoulin - * - */ -public interface ISashWindowsContentProvider { - - /** - * Get the root object shown in the sashes window. The type of the returned - * object is left to the implementation. The sashes window will ask for an - * interface used to interact with the object. In normal implementation, - * this method should return the model used by the implementation. - * - * @return The object representing the root of the sashes window. - */ - public Object getRootModel(); - - /** - * create the interface used by the sashes window to access the root model. - * This method is called by the sashes window to get the interface. The - * method is called only once for a given object. - * - * @param root - * @return The SashModel corresponding to the specified root object. - */ - public IAbstractPanelModel createChildSashModel(Object root); - - /** - * Add a page to the current TabFolder. The Page is added at the end of the - * tab list. - * - * @param page - * An object identifying the page to add. The object could be - * anything. It will be passed to the {@link ITabFolderModel#createChildSashModel(Object)} method. - */ - public void addPage(Object page); - - /** - * Add a page at the specified index of TabFolder. - * - * @param page - * An object identifying the page to add. The object could be - * anything. It will be passed to the {@link ITabFolderModel#createChildSashModel(Object)} method. - * @param index - * Index to where the tabItem should be added. - */ - public void addPage(Object page, int index); - - /** - * Move a tab inside the specified folder. - * - * @param model - * @param oldIndex - * @param newIndex - */ - public void movePage(ITabFolderModel folderModel, int oldIndex, int newIndex); - - /** - * Move a tab from folder to folder. - * - * @param model - * @param sourceIndex - * @param model2 - * @param targetIndex - */ - public void movePage(ITabFolderModel srcFolderModel, int sourceIndex, ITabFolderModel targetFolderModel, int targetIndex); - - /** - * Remove the page at the specified index of the current tabFolder - * - * @param index - */ - public void removePage(int index); - - /** - * Remove the page from the sashes window. Look for the folder containing - * the page. - * - * @param page - * The Object identifying the page. This is the object used in {@link #addPage(Object)}. - */ - public void removePage(Object page); - - /** - * Remove the specified page from the parentFolder. - * - * @param tabItem - */ - public void removePage(ITabFolderModel parentFolder, int tabIndex); - - /** - * Ask the model to move the specified tab to the specified side of the - * specified targetFolder. This method is called by the the - * SashTileContainer when the user have drag a tab in a correct place. The - * SashTileContainer has not change is presentation yet. This will be done - * when the corresponding event will occur. - * - * @param tabFolder - * The folder containing the tab to move - * @param tabIndex - * The index of the tab to move - * @param targetFolder - * The folder to which the side refer to - * @param side - * Side where node should be inserted : SWT.LEFT, SWT.RIGHT, - * SWT.TOP, SWT.DOWN. - */ - public void createFolder(ITabFolderModel tabFolder, int tabIndex, ITabFolderModel targetFolder, int side); - - /** - * Ask the model to keep trace of the Current Folder. The notion of Current - * Folder is used by {@link #addPage(Object)}. Calling this method should - * not fire a Change Event. - * - * This method is used by the SashSystem when the user select a new folder - * by clicking on one of the tabs. - * - * @param rawModel - * The Raw model identifying the folder. This is the same object - * as the one returned by {@link ISashPanelModel#getChildren()} when the child denote a folder. - */ - public void setCurrentFolder(Object rawModel); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/ITabFolderModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/ITabFolderModel.java deleted file mode 100644 index ead64a94024..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/ITabFolderModel.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.eclipse.papyrus.sasheditor.contentprovider; - -import java.util.List; - -/** - * A folder containing tabItem. This interface is used to specify that a - * TabFolder should be drawn. - * - * @author dumoulin - * - * @param - * Type of the children of the folder. This is the type returned by - * getChildren(). - */ -public interface ITabFolderModel extends IAbstractPanelModel { - - /** - * Get the list of children that should be displayed in the folder. - * - * @return - */ - public List getChildren(); - - /** - * Create the Interface used to access the real model. This method is called - * by the sashes window to get the interface. The method is called only once - * for a given object. - * - * @param child - * A child returned by getChildren(). - * @return - */ - public IPageModel createChildSashModel(Object child); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/AbstractModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/AbstractModel.java deleted file mode 100644 index 8cf1745019e..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/AbstractModel.java +++ /dev/null @@ -1,42 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.contentprovider.simple; - -/** - * @author dumoulin - */ -public abstract class AbstractModel { - - /** - * Return the parent of the model. Can be null in the case of rootModel. - * - * @return the parent - */ - abstract public AbstractModel getParent(); - - /** - * @param parent - * the parent to set - */ - abstract public void setParent(AbstractModel parent); - - /** - * Replace the oldChild by the newChild - * - * @param oldChild - * @param newChild - */ - abstract public void replaceChild(AbstractPanelModel oldChild, AbstractPanelModel newChild); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/AbstractPanelModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/AbstractPanelModel.java deleted file mode 100644 index 10409b68d83..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/AbstractPanelModel.java +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.contentprovider.simple; - -import org.eclipse.papyrus.sasheditor.contentprovider.IAbstractPanelModel; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; - -/** - * @author dumoulin - */ -public abstract class AbstractPanelModel extends AbstractModel implements IAbstractPanelModel { - - /** - * Parent of the model. Can be null in the case of rootModel. - */ - protected AbstractModel parent; - - /** - * Constructor. - * - * @param parent2 - */ - public AbstractPanelModel(AbstractModel parent) { - this.parent = parent; - } - - /** - * Return the parent of the model. Can be null in the case of rootModel. - * - * @return the parent - */ - public AbstractModel getParent() { - return parent; - } - - /** - * @param parent - * the parent to set - */ - public void setParent(AbstractModel parent) { - this.parent = parent; - } - - /** - * Lookup the folder containing the specified tabItem. - * - * @param tabItem - * @return - */ - abstract protected TabFolderModel lookupTabFolder(IPageModel tabItem); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/RootModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/RootModel.java deleted file mode 100644 index 37b173a81da..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/RootModel.java +++ /dev/null @@ -1,79 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.contentprovider.simple; - -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; - -/** - * @author dumoulin - */ -public class RootModel extends AbstractModel { - - /** - * Child of this root model. - */ - private AbstractPanelModel child; - - /** - * Constructor. - * - * @param child - */ - public RootModel(AbstractPanelModel child) { - this.child = child; - child.setParent(this); - } - - /** - * Return the parent of the model. Can be null in the case of rootModel. - * - * @return the parent - */ - public AbstractModel getParent() { - return null; - } - - /** - * @param parent - * the parent to set - */ - public void setParent(AbstractModel parent) { - } - - /** - * Replace the actual child by the new child. - * - */ - public void replaceChild(AbstractPanelModel oldChild, AbstractPanelModel newChild) { - - assert (child == oldChild); - child = newChild; - - } - - /** - * Lookup the folder containing the specified tabItem. - * - * @param tabItem - * @return - */ - protected TabFolderModel lookupTabFolder(IPageModel tabItem) { - return child.lookupTabFolder(tabItem); - } - - protected AbstractPanelModel getChild() { - return child; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/SashPanelModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/SashPanelModel.java deleted file mode 100644 index fd378209b8d..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/SashPanelModel.java +++ /dev/null @@ -1,153 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.contentprovider.simple; - -import java.util.Arrays; -import java.util.List; - -import org.eclipse.papyrus.sasheditor.contentprovider.IAbstractPanelModel; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashPanelModel; - -/** - * Simple implementation of the {@link ISashPanelModel}. - * - * @author dumoulin - */ -public class SashPanelModel extends AbstractPanelModel implements ISashPanelModel { - - /** Ordered set of childs (a left and right child, or upper and lower) */ - protected AbstractPanelModel[] children = new AbstractPanelModel[2]; - - // The children array as a list - protected List childrenList = Arrays.asList(children); - - protected int sashDirection; - - /** - * @param children - * @param sashDirection - */ - public SashPanelModel(AbstractModel parent, AbstractPanelModel leftChild, AbstractPanelModel rightChild, int sashDirection) { - super(parent); - this.children[0] = leftChild; - this.children[1] = rightChild; - - this.sashDirection = sashDirection; - } - - /** - * Set the left child. - * - * @param child - */ - public void setLeftChild(AbstractPanelModel child) { - this.children[0] = child; - } - - /** - * Get the left child - * - * @return - */ - private AbstractPanelModel getLeftChild() { - return children[0]; - } - - /** - * Set the left child. - * - * @param child - */ - public void setRightChild(AbstractPanelModel child) { - this.children[1] = child; - } - - /** - * Get the right child - * - * @return - */ - private AbstractPanelModel getRightChild() { - return children[1]; - } - - /** - * Create the SashPanelModel from the raw model. In this implementation, the - * rawModel is the SashPanelModel. This default implementation return - * directly the child which is already of the appropriate type. - */ - public IAbstractPanelModel createChildSashModel(Object rawModel) { - return (IAbstractPanelModel)rawModel; - } - - /** - * {@inheritDoc} - */ - public List getChildren() { - return childrenList; - } - - /** - * Return the direction of the sash: - * - */ - public int getSashDirection() { - return sashDirection; - } - - /** - * Replace specified child with the new child. {@inheritDoc} - */ - public void replaceChild(AbstractPanelModel oldChild, AbstractPanelModel newChild) { - - if(getLeftChild() == oldChild) - setLeftChild(newChild); - else if(getRightChild() == oldChild) - setRightChild(newChild); - - } - - /** - * - * {@inheritDoc} - */ - @Override - protected TabFolderModel lookupTabFolder(IPageModel tabItem) { - TabFolderModel parent = getLeftChild().lookupTabFolder(tabItem); - if(parent != null) - return parent; - - return getRightChild().lookupTabFolder(tabItem); - } - - /** - * Delete the sashModel. The childToDelete is removed from the tree, bypass - * the sashnode : the other child parent is set to sashnode parent. - * - * @param tabFolder - */ - protected void delete(AbstractPanelModel childToDelete) { - - // Get the other child - AbstractPanelModel otherChild = (childToDelete == getLeftChild() ? getRightChild() : getLeftChild()); - - AbstractModel parent = getParent(); - // Change parent - otherChild.setParent(parent); - parent.replaceChild(this, otherChild); - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/SimpleSashWindowsContentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/SimpleSashWindowsContentProvider.java deleted file mode 100644 index 97eb83f42f6..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/SimpleSashWindowsContentProvider.java +++ /dev/null @@ -1,500 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.contentprovider.simple; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.papyrus.sasheditor.contentprovider.IAbstractPanelModel; -import org.eclipse.papyrus.sasheditor.contentprovider.IContentChangedListener; -import org.eclipse.papyrus.sasheditor.contentprovider.IContentChangedListener.ContentEvent; -import org.eclipse.papyrus.sasheditor.contentprovider.IContentChangedProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel; -import org.eclipse.papyrus.sasheditor.editor.SashWindowsContainer; -import org.eclipse.swt.SWT; - -/** - * A simple implementation of providers allowing sashes and folders. The tabs - * can be added and removed. - * - * @author dumoulin - * - */ -public class SimpleSashWindowsContentProvider implements ISashWindowsContentProvider, IContentChangedProvider { - - /** The currently selected tab folder */ - private TabFolderModel currentTabFolder; - - /** The root model. */ - private RootModel rootModel; - - /** */ - private ContentChangeListenerManager contentChangedListenerManager = new ContentChangeListenerManager(); - - /** - * Constructor. - */ - public SimpleSashWindowsContentProvider() { - - // Create a tree with one single folder - currentTabFolder = new TabFolderModel(this); - rootModel = new RootModel(currentTabFolder); - } - - /** - * Add a listener listening on content changed. This listener will be - * notified each time the content change. - * - * @param listener - */ - public void addListener(IContentChangedListener listener) { - contentChangedListenerManager.addContentChangedListener(listener); - } - - /** - * Add a listener listening on content changed. This listener will be - * notified each time the content change. - * - * @param listener - */ - public void removeListener(IContentChangedListener listener) { - contentChangedListenerManager.removeContentChangedListener(listener); - } - - /** - * Add a listener listening on content changed. This listener will be - * notified each time the content change. - * - * @param listener - */ - protected void firePropertyChanged(ContentEvent event) { - contentChangedListenerManager.fireContentChanged(event); - } - - /** - * Add the page which should be an IPageModel instance. {@inheritDoc} - */ - public void addPage(Object newModel) { - addPage((IPageModel)newModel); - } - - /** - * Add the page which should be an IPageModel instance. {@inheritDoc} - */ - public void addPage(Object newModel, int index) { - addPage((IPageModel)newModel, index); - } - - /** - * - * {@inheritDoc} - */ - public void addPage(IPageModel newModel) { - currentTabFolder.doAddItem(newModel); - firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, newModel)); - } - - /** - * - * {@inheritDoc} - */ - public void addPage(int index, IPageModel newModel) { - currentTabFolder.doAddItem(index, newModel); - firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, newModel)); - } - - /** - * Move a Page inside the folder. {@inheritDoc} - */ - public void movePage(ITabFolderModel folderModel, int oldIndex, int newIndex) { - org.eclipse.papyrus.sasheditor.Activator.log.debug("movePage()"); - ((TabFolderModel)folderModel).moveTab(oldIndex, newIndex); - - } - - /** - * Move a tab from folder to folder. The change event is sent only once - * after the complete operation is performed. {@inheritDoc} - */ - public void movePage(ITabFolderModel srcFolderModel, int sourceIndex, ITabFolderModel targetFolderModel, int targetIndex) { - // This implementation use (TabFolderModel), so we can cast safely - org.eclipse.papyrus.sasheditor.Activator.log.debug("movePage()"); - if(sourceIndex == -1) { - moveAllPages(srcFolderModel, targetFolderModel); - return; - } - IPageModel movedTab = doMoveTab((TabFolderModel)srcFolderModel, sourceIndex, (TabFolderModel)targetFolderModel, targetIndex); - removeEmptyFolder((TabFolderModel)srcFolderModel); - doSetCurrentFolder((TabFolderModel)targetFolderModel); - contentChangedListenerManager.fireContentChanged(new ContentEvent(ContentEvent.MOVED, this, movedTab)); - } - - /** - * Move all tabs from source to target - * - * @param srcFolderModel - * @param targetFolderModel - */ - public void moveAllPages(ITabFolderModel srcFolderModel, ITabFolderModel targetFolderModel) { - TabFolderModel srcFolder = (TabFolderModel)srcFolderModel; - TabFolderModel targetFolder = (TabFolderModel)targetFolderModel; - List toMove = srcFolder.doRemoveAll(); - targetFolder.doAddAllTab(toMove); - removeEmptyFolder((TabFolderModel)srcFolderModel); - doSetCurrentFolder((TabFolderModel)targetFolderModel); - contentChangedListenerManager.fireContentChanged(new ContentEvent(ContentEvent.MOVED, this, srcFolderModel)); - } - - /** - * Set the Current Folder to the newCurrentFolder. - * - * @param targetFolderModel - */ - private void doSetCurrentFolder(TabFolderModel newCurrentFolder) { - currentTabFolder = (TabFolderModel)newCurrentFolder; - } - - /** - * Create a new folder and insert it at the specified side. Move the - * specified tab into the created Folder. - * - * The change event is sent only once after the complete operation is - * performed. {@inheritDoc} - * - * @param referenceFolder - * The folder used as reference to insert the newly created - * Folder. - * @param side - * The side to which the created folder is inserted. Can be - * SWT.TOP, DOWN, LEFT, RIGHT. - */ - public void createFolder(ITabFolderModel sourceFolder, int tabIndex, ITabFolderModel referenceFolder, int side) { - org.eclipse.papyrus.sasheditor.Activator.log.debug("createFolder()"); - - ITabFolderModel newFolder = doCreateFolder((TabFolderModel)sourceFolder, tabIndex, (TabFolderModel)referenceFolder, side); - contentChangedListenerManager.fireContentChanged(new ContentEvent(ContentEvent.CHANGED, this, sourceFolder)); - // return newFolder; - } - - /** - * Create a new folder and insert it at the specified side of the reference - * folder. The change event is sent only once after the complete operation - * is performed. - * - * This method is not part of the {@link SashWindowsContainer} API. It is - * here to help writing junit tests. - * - * @param referenceFolder - * The folder used as reference to insert the newly created - * Folder. - * @param side - * The side to which the created folder is inserted. Can be - * SWT.TOP, DOWN, LEFT, RIGHT. - */ - public ITabFolderModel createFolder(ITabFolderModel referenceFolder, int side) { - org.eclipse.papyrus.sasheditor.Activator.log.debug("createFolder()"); - - ITabFolderModel newFolder = doCreateFolder((TabFolderModel)referenceFolder, side); - contentChangedListenerManager.fireContentChanged(new ContentEvent(ContentEvent.CHANGED, this, referenceFolder)); - return newFolder; - } - - /** - * Move a tab from folder to folder. The change event is sent only once - * after the complete operation is performed. - * - * @return The moved tab. - */ - private IPageModel doMoveTab(TabFolderModel srcFolderModel, int sourceIndex, TabFolderModel targetFolderModel, int targetIndex) { - - IPageModel tab = srcFolderModel.doRemoveTab(sourceIndex); - targetFolderModel.doAddItem(targetIndex, tab); - return tab; - } - - /** - * Move a tab from folder to folder. The tab is added at the end of the - * target folder. The change event is sent only once after the complete - * operation is performed. {@inheritDoc} - */ - private void doMoveTab(TabFolderModel srcFolderModel, int sourceIndex, TabFolderModel targetFolderModel) { - - IPageModel tab = srcFolderModel.doRemoveTab(sourceIndex); - targetFolderModel.doAddItem(tab); - } - - /** - * Create a new folder and insert it at the specified side. - * - */ - private TabFolderModel doCreateFolder(TabFolderModel tabFolder, int tabIndex, TabFolderModel targetFolder, int side) { - - // Create new folder. Parent will be set when inserted. - TabFolderModel newFolder = new TabFolderModel(this); - // Inset folder - doInsertFolder(newFolder, targetFolder, side); - // Move tab from folder to folder - doMoveTab(tabFolder, tabIndex, newFolder); - // Remove unused folder if necessary - removeEmptyFolder(tabFolder); - doSetCurrentFolder(targetFolder); - - return newFolder; - } - - /** - * Create a new folder and insert it at the specified side. - * - */ - private TabFolderModel doCreateFolder(TabFolderModel referenceFolder, int side) { - - // Create new folder. Parent will be set when inserted. - TabFolderModel newFolder = new TabFolderModel(this); - // Insert folder - doInsertFolder(newFolder, referenceFolder, side); - doSetCurrentFolder(referenceFolder); - - return newFolder; - } - - /** - * Remove the folder if it is empty. - * - * @param tabFolder - */ - private void removeEmptyFolder(TabFolderModel tabFolder) { - // Check if empty - if(tabFolder.getChildren().size() > 0) - return; - - AbstractModel parent = tabFolder.getParent(); - // Forbid removing of the last folder - if(parent == rootModel) - return; - - // Parent is a sash. Ask it to remove the child and itself - ((SashPanelModel)parent).delete(tabFolder); - } - - /** - * Insert the folderToInsert on the specified side of the refFolder. Create - * and insert the requested SashModel. - * - * @param folderToInsert - * @param refFolder - * @param side - */ - private void doInsertFolder(TabFolderModel folderToInsert, TabFolderModel refFolder, int side) { - // Get the parent under which the sash will be inserted - AbstractModel refParent = refFolder.getParent(); - SashPanelModel newSash; - - int direction; - // Compute sash direction - if(side == SWT.LEFT || side == SWT.RIGHT) - direction = SWT.HORIZONTAL; - else - direction = SWT.VERTICAL; - // Create sash - if(side == SWT.LEFT || side == SWT.UP) { - newSash = new SashPanelModel(refParent, folderToInsert, refFolder, direction); - } else { - newSash = new SashPanelModel(refParent, refFolder, folderToInsert, direction); - } - - // Change sash childs parent - refFolder.setParent(newSash); - folderToInsert.setParent(newSash); - - // Change sash parent - refParent.replaceChild(refFolder, newSash); - } - - /** - * Get the root used as root to be shown in the editor. {@inheritDoc} - */ - public IAbstractPanelModel getRootModel() { - return rootModel.getChild(); - } - - /** - * Create the interface used to access the rootModel {@inheritDoc} - */ - public IAbstractPanelModel createChildSashModel(Object root) { - // The root object should be of type IAbstractPanelModel. - // This is normally the object returned by getRootPanel - return (IAbstractPanelModel)root; - } - - /** - * - * {@inheritDoc} - */ - public void removePage(int index) { - currentTabFolder.removeTab(index); - } - - /** - * Remove the specified page which should be an instance of IPageModel. {@inheritDoc} - */ - public void removePage(Object page) { - - removePage((IPageModel)page); - } - - /** - * Remove the specified tab from its parent. {@inheritDoc} - */ - public void removePage(IPageModel tabItem) { - - TabFolderModel folder = lookupPageFolder(tabItem); - if(folder != null) - folder.removeTab(tabItem); - } - - /** - * Remove the tab at the specified index. - * - */ - public void removePage(ITabFolderModel parentFolder, int tabIndex) { - TabFolderModel folder = (TabFolderModel)parentFolder; - IPageModel removed = folder.doRemoveTab(tabIndex); - removeEmptyFolder(folder); - doSetCurrentFolder(lookupPageFolder()); - contentChangedListenerManager.fireContentChanged(new ContentEvent(ContentEvent.REMOVED, this, removed)); - } - - /** - * Lookup the folder containing the specified tabItem. - * - * @param tabItem - * Item for which a folder is looked for. If the item is null, - * return the first folder encountered. - * @return The folder containing the item, or the first encountered folder - * if item is null. - */ - private TabFolderModel lookupPageFolder(IPageModel tabItem) { - return rootModel.lookupTabFolder(tabItem); - } - - /** - * Lookup for the first folder in the model. - * - * @return The first encountered folder. - */ - private TabFolderModel lookupPageFolder() { - return rootModel.lookupTabFolder(null); - } - - /** - * Get the parent of the specified tabItem, or null - * - * @param tabItem - * @return The parent tabFolder or null if not found. - */ - public ITabFolderModel getParentFolder(IPageModel tabItem) { - return lookupPageFolder(tabItem); - } - - /** - * Return the currently selected TabFolder. - * - * @return - */ - public ITabFolderModel getCurrentTabFolder() { - return currentTabFolder; - } - - /** - * Set the the current Folder. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#setCurrentFolder(java.lang.Object) - * - * @param rawModel - * Object identifying the current folder. In this implementation, - * the object is the FolderModel. - */ - public void setCurrentFolder(Object rawModel) { - if(!(rawModel instanceof TabFolderModel)) { - return; - } - doSetCurrentFolder((TabFolderModel)rawModel); - } - - /** - * A class managing a list of listeners. - * - * @author dumoulin - */ - protected class ContentChangeListenerManager { - - private List listeners; - - /** - * Add a listener listening on content changed. This listener will be - * notified each time the content change. - * - * @param listener - */ - public void addContentChangedListener(IContentChangedListener listener) { - if(listeners == null) - createListeners(); - - // Check if already exists. - if(listeners.contains(listener)) - return; - - listeners.add(listener); - } - - /** - * Add a listener listening on content changed. This listener will be - * notified each time the content change. - * - * @param listener - */ - public void removeContentChangedListener(IContentChangedListener listener) { - if(listeners == null) - return; - - listeners.remove(listener); - } - - /** - * Create the list of listeners. - */ - private void createListeners() { - if(listeners == null) - listeners = new ArrayList(); - - } - - /** - * Fire the changed event. - * - * @param event - */ - public void fireContentChanged(ContentEvent event) { - if(listeners == null) - return; - - for(IContentChangedListener listener : listeners) { - listener.contentChanged(event); - } - } - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/TabFolderModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/TabFolderModel.java deleted file mode 100644 index 2d69cc3cc2d..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/simple/TabFolderModel.java +++ /dev/null @@ -1,233 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.contentprovider.simple; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.papyrus.sasheditor.contentprovider.IContentChangedListener.ContentEvent; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel; - -/** - * Basic implementation allowing to add item to be shown. - * - * @author dumoulin - * - */ -public class TabFolderModel extends AbstractPanelModel implements ITabFolderModel { - - /** - * List of items to be shown - */ - private List children = new ArrayList(); - - /** - * The root of the sash models - */ - private SimpleSashWindowsContentProvider contentProvider; - - /** - * Constructor. - */ - public TabFolderModel(SimpleSashWindowsContentProvider contentProvider) { - // Parent should be set later. - super(null); - this.contentProvider = contentProvider; - } - - /** - * - */ - public List getChildren() { - return children; - } - - /** - * This default implementation return directly the child which is already of - * the appropriate type. - */ - public IPageModel createChildSashModel(Object child) { - // In this default implementation, the child is already of the - // appropriate type. - return (IPageModel)child; - } - - /** - * Add a new model. - * - * @param newModel - */ - private void addItem(IPageModel newModel) { - doAddItem(newModel); - contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, newModel)); - } - - /** - * Add a model at the specified position. - * - * @param index - * @param newModel - */ - private void addItem(int index, IPageModel newModel) { - doAddItem(index, newModel); - contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, newModel)); - } - - /** - * Remove the specified tab. - * - * @param index - * @return - */ - public IPageModel removeTab(int index) { - IPageModel removed = doRemoveTab(index); - contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.REMOVED, this, removed)); - return removed; - - } - - /** - * Remove the specified tab. - * - * @param tabItem - */ - public void removeTab(IPageModel tabItem) { - doRemoveTab(tabItem); - contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, tabItem)); - } - - /** - * Move a tab inside the folder. Moves the tab from the old position to the - * new position. - * - * @param oldIndex - * the position of the tab before the move. - * @param newIndex - * the position of the tab after the move. - */ - public void moveTab(int oldIndex, int newIndex) { - int listSize = children.size(); - if(newIndex >= listSize) { - newIndex = listSize - 1; - } - if(newIndex < 0) { - newIndex = 0; - } - - if(oldIndex == newIndex) - return; - - if(listSize == 0) - return; - - // Move - IPageModel toMove = children.remove(oldIndex); - children.add(newIndex, toMove); - contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.MOVED, this, toMove)); - } - - /** - * Add a new model. Do not fire change Event - * - * @param newModel - */ - protected void doAddItem(IPageModel newModel) { - children.add(newModel); - } - - /** - * Add a model at the specified position. Do not fire change Event - * - * @param index - * @param newModel - */ - protected void doAddItem(int index, IPageModel newModel) { - if(index > children.size() || index < 0) - children.add(newModel); - else - children.add(index, newModel); - } - - /** - * Remove the specified tab. Do not fire change Event - * - * @param index - * @return - */ - protected IPageModel doRemoveTab(int index) { - IPageModel removed = children.remove(index); - return removed; - - } - - /** - * Remove all tabs from the folder. - * - * @return A list of removed tabs. - */ - protected List doRemoveAll() { - List removed = new ArrayList(children); - children.clear(); - return removed; - } - - /** - * Add all tabs to the folder. - * - * @param newTabs - */ - protected void doAddAllTab(List newTabs) { - children.addAll(newTabs); - } - - /** - * Remove the specified tab. Do not fire change Event - * - * @param tabItem - */ - protected void doRemoveTab(IPageModel tabItem) { - children.remove(tabItem); - contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, tabItem)); - } - - /** - * Do nothing as this method should never be called on this class. {@inheritDoc} - */ - @Override - public void replaceChild(AbstractPanelModel oldChild, AbstractPanelModel newChild) { - throw new UnsupportedOperationException("This method should not be called on this class."); - } - - /** - * Get a folder by one of its tab. - * - * @param tabItem - * Item for which a folder is looked for. If the item is null, - * return the first folder encountered. - * @return The folder if it contains the item, or if item is null. - */ - @Override - protected TabFolderModel lookupTabFolder(IPageModel tabItem) { - - if(tabItem == null) - return this; - - if(children.contains(tabItem)) - return this; - // not found - return null; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/singlefolder/SingleFolderContentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/singlefolder/SingleFolderContentProvider.java deleted file mode 100644 index a2a6ca51a3a..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/singlefolder/SingleFolderContentProvider.java +++ /dev/null @@ -1,262 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.contentprovider.singlefolder; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.papyrus.sasheditor.contentprovider.IAbstractPanelModel; -import org.eclipse.papyrus.sasheditor.contentprovider.IContentChangedListener; -import org.eclipse.papyrus.sasheditor.contentprovider.IContentChangedListener.ContentEvent; -import org.eclipse.papyrus.sasheditor.contentprovider.IContentChangedProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel; - -/** - * A simple implementation of providers allowing only one single folder - * containing tabs. The tabs can be added and removed. - * - * @author dumoulin - */ -public class SingleFolderContentProvider implements ISashWindowsContentProvider, IContentChangedProvider { - - /** The currently selected tab folder */ - private SingleFolderModel currentTabFolder; - - /** */ - private ContentChangeListenerManager contentChangedListenerManager = new ContentChangeListenerManager(); - - /** - * Constructor. - */ - public SingleFolderContentProvider() { - currentTabFolder = new SingleFolderModel(this); - } - - /** - * Add a listener listening on content changed. This listener will be - * notified each time the content change. - * - * @param listener - */ - public void addListener(IContentChangedListener listener) { - contentChangedListenerManager.addContentChangedListener(listener); - } - - /** - * Add a listener listening on content changed. This listener will be - * notified each time the content change. - * - * @param listener - */ - public void removeListener(IContentChangedListener listener) { - contentChangedListenerManager.removeContentChangedListener(listener); - } - - /** - * Add a listener listening on content changed. This listener will be - * notified each time the content change. - * - * @param listener - */ - protected void firePropertyChanged(ContentEvent event) { - contentChangedListenerManager.fireContentChanged(event); - } - - /** - * Add the page which should be an IPageModel instance. {@inheritDoc} - */ - public void addPage(Object newModel) { - addPage((IPageModel)newModel); - } - - /** - * Add the page which should be an IPageModel instance. {@inheritDoc} - */ - public void addPage(Object newModel, int index) { - addPage((IPageModel)newModel, index); - } - - /** - * - * {@inheritDoc} - */ - public void addPage(IPageModel newModel) { - currentTabFolder.addItem(newModel); - - } - - /** - * - * {@inheritDoc} - */ - public void addPage(int index, IPageModel newModel) { - currentTabFolder.addItem(index, newModel); - } - - /** - * Do nothing because this implementation doesn't allows folders. {@inheritDoc} - */ - public void createFolder(ITabFolderModel tabFolder, int tabIndex, ITabFolderModel targetFolder, int side) { - // TODO Auto-generated method stub - } - - /** - * Get the root used as root to be shown in the editor. {@inheritDoc} - */ - public SingleFolderModel getRootModel() { - return currentTabFolder; - } - - /** - * Create the interface used to access the rootModel. {@inheritDoc} - */ - public IAbstractPanelModel createChildSashModel(Object root) { - // The root object should be of type IAbstractPanelModel. - // This is normally the object returned by getRootPanel - return (IAbstractPanelModel)root; - } - - /** - * Remove the specified page which should be an instance of IPageModel. {@inheritDoc} - */ - public void removePage(Object page) { - - removePage((IPageModel)page); - } - - /** - * - * {@inheritDoc} - */ - public void removePage(int index) { - currentTabFolder.removeTab(index); - } - - /** - * - * {@inheritDoc} - */ - public void removePage(IPageModel tabItem) { - currentTabFolder.removeTab(tabItem); - } - - /** - * Remove the specified tab. As we have only one folder, this should be from - * the currentFolder {@inheritDoc} - */ - public void removePage(ITabFolderModel parentFolder, int tabIndex) { - removePage(tabIndex); - } - - /** - * Return the currently selected TabFolder. - * - * @return - */ - public ITabFolderModel getCurrentTabFolder() { - return currentTabFolder; - } - - /** - * Do nothing as we can't have other folders. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider#setCurrentFolder(java.lang.Object) - * - * @param rawModel - */ - public void setCurrentFolder(Object rawModel) { - } - - /** - * A class managing a list of listeners. - * - * @author dumoulin - */ - protected class ContentChangeListenerManager { - - private List listeners; - - /** - * Add a listener listening on content changed. This listener will be - * notified each time the content change. - * - * @param listener - */ - public void addContentChangedListener(IContentChangedListener listener) { - if(listeners == null) - createListeners(); - - // Check if already exists. - if(listeners.contains(listener)) - return; - - listeners.add(listener); - } - - /** - * Add a listener listening on content changed. This listener will be - * notified each time the content change. - * - * @param listener - */ - public void removeContentChangedListener(IContentChangedListener listener) { - if(listeners == null) - return; - - listeners.remove(listener); - } - - /** - * Create the list of listeners. - */ - private void createListeners() { - if(listeners == null) - listeners = new ArrayList(); - - } - - /** - * Fire the changed event. - * - * @param event - */ - public void fireContentChanged(ContentEvent event) { - if(listeners == null) - return; - - for(IContentChangedListener listener : listeners) { - listener.contentChanged(event); - } - } - } - - /** - * Move a tab inside the folder. {@inheritDoc} - */ - public void movePage(ITabFolderModel folderModel, int oldIndex, int newIndex) { - currentTabFolder.moveTab(oldIndex, newIndex); - - } - - /** - * Move a tab from folder to folder. As this implementation has only one - * folder, this can't happen. Do nothing. {@inheritDoc} - */ - public void movePage(ITabFolderModel srcFolderModel, int sourceIndex, ITabFolderModel targetFolderModel, int targetIndex) { - return; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/singlefolder/SingleFolderModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/singlefolder/SingleFolderModel.java deleted file mode 100644 index caf77cddc3b..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/contentprovider/singlefolder/SingleFolderModel.java +++ /dev/null @@ -1,139 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.contentprovider.singlefolder; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.papyrus.sasheditor.contentprovider.IContentChangedListener.ContentEvent; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel; - -/** - * Basic implementation allowing to add item to be shown. - * - * @author dumoulin - * - */ -public class SingleFolderModel implements ITabFolderModel { - - /** - * List of items to be shown - */ - private List itemModels = new ArrayList(); - - /** - * The root of the sash models - */ - private SingleFolderContentProvider contentProvider; - - /** - * Constructor. - */ - public SingleFolderModel(SingleFolderContentProvider contentProvider) { - this.contentProvider = contentProvider; - } - - /** - * - */ - public List getChildren() { - return itemModels; - } - - /** - * This default implementation return directly the child which is already of - * the appropriate type. - */ - public IPageModel createChildSashModel(Object child) { - // In this default implementation, the child is already of the - // appropriate type. - return (IPageModel)child; - } - - /** - * Add a new model. - * - * @param newModel - */ - public void addItem(IPageModel newModel) { - itemModels.add(newModel); - contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, newModel)); - } - - /** - * Add a model at the specified position. - * - * @param index - * @param newModel - */ - public void addItem(int index, IPageModel newModel) { - itemModels.add(index, newModel); - contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, newModel)); - } - - /** - * Remove the specified tab. - * - * @param index - * @return - */ - public IPageModel removeTab(int index) { - IPageModel removed = itemModels.remove(index); - contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, removed)); - return removed; - - } - - /** - * Remove the specified tab. - * - * @param tabItem - */ - public void removeTab(IPageModel tabItem) { - itemModels.remove(tabItem); - contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.ADDED, this, tabItem)); - } - - /** - * Move a tab inside the folder. Moves the tab from the old position to the - * new position. - * - * @param oldIndex - * the position of the tab before the move. - * @param newIndex - * the position of the tab after the move. - */ - public void moveTab(int oldIndex, int newIndex) { - - int listSize = itemModels.size(); - if(newIndex >= listSize) { - newIndex = listSize - 1; - } - if(newIndex < 0) { - newIndex = 0; - } - - if(oldIndex == newIndex) - return; - - if(listSize == 0) - return; - - // Move - IPageModel toMove = itemModels.remove(oldIndex); - itemModels.add(newIndex, toMove); - contentProvider.firePropertyChanged(new ContentEvent(ContentEvent.MOVED, this, toMove)); - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/AbstractMultiPageSashEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/AbstractMultiPageSashEditor.java deleted file mode 100644 index 57152130a33..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/AbstractMultiPageSashEditor.java +++ /dev/null @@ -1,323 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.editor; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.internal.eclipsecopy.MultiPageSelectionProvider; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.internal.util.Util; -import org.eclipse.ui.part.EditorPart; - -/** - * Base editor that can be subclassed to provide a multi page editor with sash - * windows. - * - * @author dumoulin - */ -public abstract class AbstractMultiPageSashEditor extends EditorPart implements IMultiPageEditorPart, IMultiEditorManager { - - /** The pageProvider */ - private ISashWindowsContentProvider pageProvider; - - /** The sash windows system :-) */ - private SashWindowsContainer sashContainer; - - /** - * Synchronizer in charge of synchronizing tab names with IEditorPart title. - */ - private SashTabDecorationSynchronizer tabsSynchronizer; - - /** - * get the contentProvider. Create it if necessary. - * - * @return - */ - protected ISashWindowsContentProvider getContentProvider() { - if(pageProvider == null) { - pageProvider = createPageProvider(); - } - - return pageProvider; - } - - /** - * Set the contentProvider if not set. If it is already set, this method do - * not change it. - * - * @param contentProvider - */ - protected void setContentProvider(ISashWindowsContentProvider contentProvider) { - if(pageProvider == null) { - pageProvider = contentProvider; - } - } - - /** - * Create the provider. Subclass must implements this method. It should - * return the provider used by the editor. - * - */ - abstract protected ISashWindowsContentProvider createPageProvider(); - - /** - * Handles a property change notification from a nested editor. The default - * implementation simply forwards the change to listeners on this multi-page - * editor by calling firePropertyChange with the same property - * id. For example, if the dirty state of a nested editor changes (property - * id IEditorPart.PROP_DIRTY), this method handles it by firing - * a property change event for IEditorPart.PROP_DIRTY to - * property listeners on this multi-page editor. - *

- * Subclasses may extend or reimplement this method. - *

- * - * @copiedfrom - * org.eclipse.ui.part.MultiPageEditorPart.handlePropertyChange(int - * ) - * - * @param propertyId - * the id of the property that changed - */ - protected void handlePropertyChange(int propertyId) { - firePropertyChange(propertyId); - } - - /** - * The MultiPageEditorPart implementation of this IEditorPart method sets its site to the given site, its - * input to the given input, and the site's selection provider to a MultiPageSelectionProvider. Subclasses may extend this - * method. - * - * @copiedfrom org.eclipse.ui.part.MultiPageEditorPart - * @param site - * The site for which this part is being created; must not be null. - * @param input - * The input on which this editor should be created; must not be null. - * @throws PartInitException - * If the initialization of the part fails -- currently never. - */ - @Override - public void init(IEditorSite site, IEditorInput input) throws PartInitException { - setSite(site); - setInput(input); - site.setSelectionProvider(new MultiPageSelectionProvider(this)); - } - - /** - * Create the part controls. {@inheritDoc} - */ - @Override - public void createPartControl(Composite parent) { - - // Create and intialize sash windows - sashContainer = new SashWindowsContainer(this); - sashContainer.setContentProvider(getContentProvider()); - sashContainer.createPartControl(parent); - activate(); - } - - /** - * Method to activate the editor. Called immediately after - * createPartControl() is complete. To be implemented by subclasses. Default - * implementation do nothing. - */ - protected void activate() { - - tabsSynchronizer = new SashTabDecorationSynchronizer(sashContainer); - } - - /** - * Method to deactivate the editor. Called when dispose() is called. To be - * implemented by subclasses. Default implementation do nothing. - */ - protected void deactivate() { - - tabsSynchronizer.dispose(); - } - - /** - * Dispose the Editor. Also dispose the sashsystem. - * - * @see org.eclipse.ui.part.WorkbenchPart#dispose() - * - */ - @Override - public void dispose() { - deactivate(); - super.dispose(); - } - - /** - * Refresh the sash windows system - */ - protected void refreshTabs() { - if(sashContainer != null) { - sashContainer.refreshTabs(); - } - - } - - /** - * If there is an adapter registered against the subclass of - * MultiPageEditorPart return that. Otherwise, delegate to the internal - * editor. - * - * @copiedfrom org.eclipse.ui.part.MultiPageEditorPart - * - * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class) - */ - @Override - public Object getAdapter(Class adapter) { - - // Get the content provider if requested. - if(ISashWindowsContentProvider.class == adapter) { - return getContentProvider(); - } - - // Get the content provider if requested. - if(ISashWindowsContainer.class == adapter) { - return sashContainer; - } - - // Look in hierarchy - Object result = super.getAdapter(adapter); - // restrict delegating to the UI thread for bug 144851 - if(result == null && Display.getCurrent() != null) { - IEditorPart innerEditor = getActiveEditor(); - // see bug 138823 - prevent some subclasses from causing - // an infinite loop - if(innerEditor != null && innerEditor != this) { - result = Util.getAdapter(innerEditor, adapter); - } - } - return result; - } - - /** - * Needed by MultiPageActionBarContributor and MultiPageSelectionProvider. - */ - public IEditorPart getActiveEditor() { - return sashContainer.getActiveEditor(); - } - - /** - * Get the {@link ISashWindowsContainer}. Note the the ISashWindowsContainer - * can also be acuired with getAdapter(ISashWindowsContainer.class). - */ - public ISashWindowsContainer getISashWindowsContainer() { - return sashContainer; - } - - /** - * - * {@inheritDoc} - */ - @Override - public void setFocus() { - sashContainer.setFocus(); - - } - - /** - * Overrides isDirty. - * - * {@inheritDoc} - * - * TODO Move this method aways. This method is too tightly coupled to the - * Papyrus GMF UML IEditor. It doesn't work on other kind of IEditor. It - * introduce problems in IEditor of other kinds - * - * @see org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer#isDirty() - * @deprecated A SaveAndDirtyService is used instead. - */ - @Override - public boolean isDirty() { - // return sashContainer.isDirty(); - EditorVisitor visitor = new EditorVisitor(); - sashContainer.visit(visitor); - - for(IEditorPart editorPart : visitor.getPages()) { - if(editorPart.isDirty()) { - return true; - } - } - - return false; - } - - /** - * Notify all the editors that the multi editor has been saved.
- * Fires the PROP_DIRTY property change. - * - * TODO Move this method aways. This method is too tightly coupled to the - * Papyrus GMF UML IEditor. It doesn't work on other kind of IEditor. It - * introduce problems in IEditor of other kinds - * - * @deprecated A SaveAndDirtyService is used instead. - */ - protected void markSaveLocation() { - // return sashContainer.isDirty(); - EditorVisitor visitor = new EditorVisitor(); - sashContainer.visit(visitor); - - for(IEditorPart editorPart : visitor.getPages()) { - editorPart.doSave(new NullProgressMonitor()); - } - firePropertyChange(PROP_DIRTY); - } - - /** - * A visitor allowing to collect the available IEditor. TODO : Remove - * - * @author dumoulin - * - */ - protected class EditorVisitor implements IPageVisitor { - - private List pages = new ArrayList(); - - /** - * Get collected pages. - * - * @return - */ - public List getPages() { - return pages; - } - - /** - * - */ - public void accept(IComponentPage page) { - // Do nothing - } - - /** - * - */ - public void accept(IEditorPage page) { - - IEditorPart editor = page.getIEditorPart(); - pages.add(editor); - } - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IComponentPage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IComponentPage.java deleted file mode 100644 index d8d8ee812d8..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IComponentPage.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.editor; - -/** - * Allows to access to properties of a Sash ComponentPage. This interface allows - * to read the data. User should not attent to modifiy or write the data in - * anyway. This interface is provided as parameter of the {@link IPageChangedListener#pageChanged(IPage)} event and in the - * SashContainer Visitor. - * - * @author cedric dumoulin - * - */ -public interface IComponentPage extends IPage { - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IEditorPage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IEditorPage.java deleted file mode 100644 index 2b37cab9260..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IEditorPage.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.editor; - -import org.eclipse.ui.IEditorPart; - -/** - * Allows to access to properties of a Sash IEditor Page. This interface allows - * to read the data. User should not attent to modifiy or write the data in - * anyway. This interface is provided as parameter of the {@link IPageChangedListener#pageChanged(IPage)} event and in the - * SashContainer Visitor. - * - * @author cedric dumoulin - * - */ -public interface IEditorPage extends IPage { - - /** - * Returns the active nested editor if there is one. - * - * @return the active nested editor, or null if none - */ - public IEditorPart getIEditorPart(); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IMultiEditorManager.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IMultiEditorManager.java deleted file mode 100644 index 4417541b6e4..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IMultiEditorManager.java +++ /dev/null @@ -1,74 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.editor; - -import org.eclipse.papyrus.sasheditor.internal.EditorPart; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IWorkbenchPartSite; - -/** - * This interface allows EditorPart to access objects provided by the real - * editor. Implementation of this interface is provided to the {@link SashWindowsContainer} and used by {@link EditorPart}. The EditorPart - * will call {@link #getEditorInput()} and pass the result to input of the - * created nested IEditorPart. The site provided by {@link #getEditorSite()} is - * used to initialize a specific site for the nested IEditorPart. It is also - * used by the {@link SashWindowsContainer}. - * - * @author dumoulin - */ -public interface IMultiEditorManager { - - /** - * Get the EditorActionBarContributor for the editor associated to the - * specified model. - * - * @param editorModel - * @return - * @throws MultiDiagramException - */ - // public EditorActionBarContributor getActionBarContributor(Object - // editorModel); - - /** - * Fires a property changed event. - * - * @param propertyId - * the id of the property that changed - */ - // public void firePropertyChange(int propertyId); - - /** - * Get the editor input associated to the main IMultiPageEditorPart. - * - * @return - */ - public IEditorInput getEditorInput(); - - /** - * Get the main site of the MultiPageEditorPart. - * - * @return - */ - public IWorkbenchPartSite getSite(); - - /** - * Get the IEditorSite associated to this MultiPageEditorPart. This return - * the same object as getSite(). - * - * @return - */ - public IEditorSite getEditorSite(); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IMultiPageEditorPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IMultiPageEditorPart.java deleted file mode 100644 index 3111bf2ee07..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IMultiPageEditorPart.java +++ /dev/null @@ -1,48 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.editor; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IWorkbenchPartSite; - -/** - * Marker to mark a EditorPart as a MultiPartEditor. Provides methods needed by - * classes like MultiPageActionBarContributor and MultiPageSelectionProvider. - */ -public interface IMultiPageEditorPart { - - /** - * Get the currently active editor of the MultiPageEditorPart. - * - * @return - */ - public IEditorPart getActiveEditor(); - - /** - * Get the main site of the MultiPageEditorPart. - * - * @return - */ - public IWorkbenchPartSite getSite(); - - /** - * Get the IEditorSite associated to this MultiPageEditorPart. This return - * the same object as getSite(). - * - * @return - */ - public IEditorSite getEditorSite(); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPage.java deleted file mode 100644 index 243c2038507..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPage.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.editor; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Control; - -/** - * Allows to access to properties of a Sash Page. This interface allows to read - * the data. User should not attent to modifiy or write the data in anyway. This - * interface is provided as parameter of the {@link IPageChangedListener#pageChanged(IPage)} event. - * - * @author cedric dumoulin - * - */ -public interface IPage { - - /** - * Get the title to be shown in the tab - * - * @return - */ - public String getPageTitle(); - - /** - * Get the icon to be shown in the tab - * - * @return - */ - public Image getPageIcon(); - - /** - * Get the raw model corresponding to this node. This is the object provided - * to {@link ITabFolderModel.getChildren()} - * - * @return - */ - public Object getRawModel(); - - /** - * Get the control associated to this page. - * - * @return - */ - public Control getControl(); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPageChangedListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPageChangedListener.java deleted file mode 100644 index 036f9efe3d4..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPageChangedListener.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.editor; - -/** - * @author cedric dumoulin - * - */ -public interface IPageChangedListener { - - /** - * Method called when the page is changed - * - * @param newPage - * The new page, or null if there is no container. - */ - public void pageChanged(IPage newPage); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPageImageUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPageImageUtils.java deleted file mode 100644 index 8caf041ec09..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPageImageUtils.java +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Cedric Dumoulin. - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.sasheditor.editor; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Control; - - -/** - * Utility class to get an Image from an IPage. - * - * @author cedric dumoulin - * - */ -public class IPageImageUtils { - - - /** - * Get an Image of the page. - * The Image is build from the Control. - * - * @param The IPage for which an Image is requested. - * @return The Image of the page, or null if no Image can be built. - */ - static public Image getPageImage(IPage page) { - Rectangle size; - Control control = page.getControl(); - - size = control.getBounds(); - if(size.width == 0 && size.height == 0) { - Point pt = control.computeSize(SWT.DEFAULT, SWT.DEFAULT); - size = new Rectangle(0, 0, pt.x, pt.y); - } - - Image image = new Image(control.getDisplay(), size); - GC gc = new GC(image); - - boolean success = control.print(gc); - gc.dispose(); - if(!success) { - image.dispose(); - return null; - } - - return image; - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPageVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPageVisitor.java deleted file mode 100644 index 1aab9135b8d..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/IPageVisitor.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.editor; - -/** - * A Visitor used to visit all the {@link IPage} of a {@link SashWindowsContainer}. - * - * @author cedric dumoulin - * - */ -public interface IPageVisitor { - - /** - * Visit the provided page of type {@link IComponentPage}. - * - * @param page - */ - void accept(IComponentPage page); - - /** - * Visit the provided page of type {@link IEditorPage}. - * - * @param page - */ - void accept(IEditorPage page); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/ISashWindowsContainer.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/ISashWindowsContainer.java deleted file mode 100644 index 07e8cc87812..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/ISashWindowsContainer.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.eclipse.papyrus.sasheditor.editor; - -import java.util.List; - -import org.eclipse.jface.action.MenuManager; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.ui.IEditorPart; - -public interface ISashWindowsContainer { - - /** - * Get the currently active editor, or null if none is active. - * - * @return - */ - public abstract IEditorPart getActiveEditor(); - - /** - * Get the currently active SashWindows Page. This is s - * - * @return An {@link IPage} allowing to access current page data. - */ - public abstract IPage getActiveSashWindowsPage(); - - /** - * Get the list of visible IPages. The visible IPages are the one that have - * there diagram area visible. - * - * @return - */ - public List getVisiblePages(); - - /** - * Get the list of visible IEditorPart obtain from the pages of type - * IEditorPage. The visible IPages are the one that have there diagram area - * visible. - * - * @return - */ - public List getVisibleIEditorParts(); - - /** - * The AbstractMultiPageSashEditor implementation of this IWorkbenchPart method sets focus on the active nested - * editor, if there is one. - *

- * Subclasses may extend or reimplement. - *

- */ - public abstract void setFocus(); - - /** - * Refresh the SashWindows. Synchronize the internal structure with the {@link ISashWindowsContentProvider}. - */ - public abstract void refreshTabs(); - - /** - * Add a PageChangedListener to the list of listeners. - * - * @param pageEventsManager - */ - public abstract void addPageChangedListener(IPageChangedListener pageChangedListener); - - /** - * Remove the PageChangedListener from the list of listeners. - * - * @param pageEventsManager - */ - public abstract void removePageChangedListener(IPageChangedListener pageChangedListener); - - /** - * Add a listener on Page LifeCycle events. This implementation delegates to - * the internal PageTracker. - * - * @see org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer#addPageChangedListener(org.eclipse.papyrus.sasheditor.editor.IPageChangedListener) - * @param listener - * - */ - public void addLifeCycleListener(SashContainerEventsListener listener); - - /** - * Remove a listener on Page LifeCycle events. - * - * @see org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer#removePageChangedListener(org.eclipse.papyrus.sasheditor.editor.IPageChangedListener) - * @param listener - * - */ - public void removeLifeCycleListener(SashContainerEventsListener listener); - - /** - * Set a {@link MenuManager} used to manage a contextual menu that is shown - * on the tabs area of the folders. - * - * @param menuManager - * The {@link MenuManager} used to create the menu on the tab - * area. - */ - public abstract void setFolderTabMenuManager(MenuManager menuManager); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/ISashWindowsContainerChangedListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/ISashWindowsContainerChangedListener.java deleted file mode 100644 index fc51c1cff83..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/ISashWindowsContainerChangedListener.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.editor; - -/** - * @author dumoulin - * - */ -public interface ISashWindowsContainerChangedListener { - - /** - * Method called when the container changed - * - * @param newContainer - * The new container, or null if there is no container. - */ - public void sashWindowsContainerChanged(ISashWindowsContainer newContainer); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashContainerEventsListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashContainerEventsListener.java deleted file mode 100644 index ab61acb4b19..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashContainerEventsListener.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.editor; - -/** - * Interface to be implemented by listeners on {@link SashWindowsContainer} life - * cycle events. - * - * @author cedric dumoulin - * - */ -public interface SashContainerEventsListener extends IPageChangedListener { - - /** - * - * @param page - * The page firing the event. - */ - public void pageOpened(IPage page); - - /** - * - * @param page - * The page firing the event. - */ - public void pageClosed(IPage page); - - /** - * The specify page is activated. It become the current active page. - * - * @param page - * The page firing the event. - */ - public void pageActivated(IPage page); - - /** - * The specify page is deactivated. - * - * @param page - * The page firing the event. - */ - public void pageDeactivated(IPage page); - - /** - * - * @param page - * The page firing the event. - */ - public void pageAboutToBeOpened(IPage page); - - /** - * - * @param page - * The page firing the event. - */ - public void pageAboutToBeClosed(IPage page); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashTabDecorationSynchronizer.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashTabDecorationSynchronizer.java deleted file mode 100644 index ec33c3a008a..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashTabDecorationSynchronizer.java +++ /dev/null @@ -1,211 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.editor; - -import java.util.logging.Logger; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IPropertyListener; -import org.eclipse.ui.IWorkbenchPart; - -/** - * This class take care to refresh a Sash Tab (name and icon) when its model - * change. The class listen to IEditor property change, and refresh the - * corresponding tab accordingly. The class also listen on {@link SashWindowsContainer} page's life cycle in order to attach/remove the - * listener on pages. - * - * The class can be extended. - * - * @author cedric dumoulin - * - */ -public class SashTabDecorationSynchronizer { - - /** - * Logger for debug purpose. - */ - Logger log = Logger.getLogger(this.getClass().getName()); - - /** - * The container to synchronize. - */ - private SashWindowsContainer container; - - /** - * Listener on Container'pages life cycle. - */ - SashContainerEventsListener pageLifeCycleListener = new SashContainerEventsListener() { - - public void pageChanged(IPage newPage) { - } - - public void pageOpened(IPage page) { - attachPage(page); - - } - - public void pageDeactivated(IPage page) { - } - - public void pageClosed(IPage page) { - detachPage(page); - - } - - public void pageActivated(IPage page) { - } - - public void pageAboutToBeOpened(IPage page) { - } - - public void pageAboutToBeClosed(IPage page) { - } - }; - - /** - * Listener on changes of an {@link IEditorPart} - */ - private IPropertyListener editorPartPropertyListener = new IPropertyListener() { - - public void propertyChanged(Object source, int propId) { - if(propId == IWorkbenchPart.PROP_TITLE && source instanceof IEditorPart) { - refreshContainerTabForPage((IEditorPart)source); - } - - } - }; - - /** - * - * Constructor. - * - * @param container - * The container to synchronize. - * - */ - public SashTabDecorationSynchronizer(SashWindowsContainer container) { - this.container = container; - attachContainerPages(); - attachListeners(); - } - - /** - * Detach any listeners. - */ - public void dispose() { - detachListeners(); - detachContainerPages(); - } - - /** - * Attach listeners requested by the class. - */ - protected void attachListeners() { - container.addLifeCycleListener(pageLifeCycleListener); - } - - /** - * Detach listeners requested by the class. - */ - protected void detachListeners() { - container.removeLifeCycleListener(pageLifeCycleListener); - } - - /** - * Start listening on change for the specified page. - * - * @param page - */ - protected void attachPage(IPage page) { - if(page instanceof IEditorPage) { - log.fine("attachPage( " + page + " )"); - IEditorPage editorPage = (IEditorPage)page; - editorPage.getIEditorPart().addPropertyListener(editorPartPropertyListener); - } - - } - - /** - * Stop listening onchange for the specified page. - * - * @param page - */ - protected void detachPage(IPage page) { - if(page instanceof IEditorPage) { - log.fine("attachPage( " + page + " )"); - IEditorPage editorPage = (IEditorPage)page; - editorPage.getIEditorPart().removePropertyListener(editorPartPropertyListener); - } - } - - protected void refreshContainerTabForPage(IEditorPart source) { - // lookup page - IPage page = container.lookupIPageByIEditorPart(source); - refreshContainerTabForPage(page); - - } - - /** - * Refresh the tab for the specified page - * - * @param page - */ - protected void refreshContainerTabForPage(IPage page) { - container.refreshPageTab(page); - } - - /** - * Iterate on pages owned by the container, and call detachPage for each. - */ - private void detachContainerPages() { - // Visit all pages of the container. - container.visit(new DetachVisitor()); - - } - - /** - * Iterate on pages owned by the container, and call detachPage for each. - */ - private void attachContainerPages() { - // Visit all pages of the container. - container.visit(new AttachVisitor()); - - } - - /** - * Visitor to visit all pages of the container and attach the page. - * - * @author dumoulin - * - */ - private class AttachVisitor implements IPageVisitor { - - public void accept(IComponentPage page) { - } - - public void accept(IEditorPage page) { - attachPage(page); - - } - - } - - /** - * Visitor to visit all pages of the container and attach the page. - * - * @author dumoulin - * - */ - private class DetachVisitor implements IPageVisitor { - - public void accept(IComponentPage page) { - } - - public void accept(IEditorPage page) { - detachPage(page); - - } - - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashWindowsContainer.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashWindowsContainer.java deleted file mode 100644 index 740d01436ee..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashWindowsContainer.java +++ /dev/null @@ -1,1024 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.editor; - -import static org.eclipse.papyrus.sasheditor.Activator.log; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.util.Geometry; -import org.eclipse.papyrus.sasheditor.contentprovider.IComponentModel; -import org.eclipse.papyrus.sasheditor.contentprovider.IEditorModel; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.internal.AbstractPanelPart; -import org.eclipse.papyrus.sasheditor.internal.AbstractPart; -import org.eclipse.papyrus.sasheditor.internal.ActiveEditorServicesSwitcher; -import org.eclipse.papyrus.sasheditor.internal.ActivePageTracker; -import org.eclipse.papyrus.sasheditor.internal.ComponentPart; -import org.eclipse.papyrus.sasheditor.internal.EditorPart; -import org.eclipse.papyrus.sasheditor.internal.IPartVisitor; -import org.eclipse.papyrus.sasheditor.internal.LookupIPageByIEditorPartVisitor; -import org.eclipse.papyrus.sasheditor.internal.LookupModelPageVisitor; -import org.eclipse.papyrus.sasheditor.internal.PTabFolder; -import org.eclipse.papyrus.sasheditor.internal.PagePart; -import org.eclipse.papyrus.sasheditor.internal.PageVisitorWrapper; -import org.eclipse.papyrus.sasheditor.internal.PartLists; -import org.eclipse.papyrus.sasheditor.internal.PartVisitor; -import org.eclipse.papyrus.sasheditor.internal.RootPart; -import org.eclipse.papyrus.sasheditor.internal.SashContainerEventsProvider; -import org.eclipse.papyrus.sasheditor.internal.ShowPartStatusVisitor; -import org.eclipse.papyrus.sasheditor.internal.TabFolderPart; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.internal.DragCursors; -import org.eclipse.ui.internal.dnd.DragUtil; -import org.eclipse.ui.internal.dnd.IDragOverListener; -import org.eclipse.ui.internal.dnd.IDropTarget; - -/** - * Main entry class of the SashWindows system. This class allows to have a - * multitab window with sashes. The class require a ContentProvider describing - * the content to be shown. - * - * @author dumoulin - */ -@SuppressWarnings("restriction") -public class SashWindowsContainer implements ISashWindowsContainer { - - /** - * The content provider describing the sashes, folders and tabs. - */ - private ISashWindowsContentProvider contentProvider; - - /** - * The manager used to get Main editor properties like Site, ActionBars, ... - */ - private IMultiEditorManager multiEditorManager; - - /** - * Tracker tracking the current active page. The tracker also disconnect - * last active page and connect the new one. - */ - private ActivePageTracker activePageTracker; - - /** - * Event provider firing Pages life cycle events to registered listeners. - * Inner parts call the fireXxxEvents when appropriate. - */ - private SashContainerEventsProvider lifeCycleEventProvider; - - /** - * The part used as root. We use an extra class as root in order to separate - * the code dedicated to ITilePart. - */ - private RootPart rootPart; - - /** - * The SWT container associated to this part. This is generally the - * container of the parent. - */ - private Composite container; - - /** - * The drop target. - */ - protected DropTarget dropTarget; - - /** A flag that indicates that the model is being synchronized. */ - private AtomicBoolean isRefreshing = new AtomicBoolean(false); - - /** - * The cached value of the menu manager, if any. - */ - private MenuManager folderTabMenuManager; - - /** - * Constructor. Build a Container without IEditor management. Trying to add - * a EditorPart will result in an Exception. The ContentProvider should not - * contain IEditorModel. - */ - public SashWindowsContainer() { - this(null); - } - - /** - * Constructor. Build a container with EditorPart management. The container - * will allow to add EditorPart (and thus IEditorModel to the - * ContentProvider). - * - * @param multiEditorManager - * The manager allowing to use {@link IEditorModel} in the model. - * If null, the sash will not render IEditorModel. - * - */ - public SashWindowsContainer(IMultiEditorManager multiEditorManager) { - this.multiEditorManager = multiEditorManager; - activePageTracker = new ActivePageTracker(); - - if(multiEditorManager != null) { - // Add listener on activePageChange. - // This listener will take in charge editor services switching. - activePageTracker.addActiveEditorChangedListener(new ActiveEditorServicesSwitcher(multiEditorManager.getEditorSite())); - } - - // Life cycle event provider - lifeCycleEventProvider = new SashContainerEventsProvider(); - } - - /** - * @return the contentProvider - */ - public ISashWindowsContentProvider getContentProvider() { - // Content provider should have been set. - assert (contentProvider != null); - // Double check for developement - if(contentProvider == null) - throw new IllegalStateException("ContentProvider should be set before calling any method requiring it."); - - return contentProvider; - } - - /** - * Set the content provider describing the sashes, folders and tabs. - * - * @param contentProvider - * the contentProvider to set - */ - public void setContentProvider(ISashWindowsContentProvider contentProvider) { - this.contentProvider = contentProvider; - } - - /** - * Creates control associated to this Container. This method should be - * called when the parent is build. - * - * @param parent - * The parent in which the editor should be created; must not be null. - */ - public void createPartControl(Composite parent) { - this.container = parent; - - rootPart = createRootPart(); - // Create the tree of tile part. - rootPart.createPartControl(container); - // Create children - refreshTabs(); - // Set selection - selectPage(lookupFirstValidPage()); - - // postCreatePartControl(); - // TODO reactivate next - initDrag(container); - // activate(); - } - - /** - * Create the root part for the model. - */ - private RootPart createRootPart() { - RootPart part = new RootPart(this); - return part; - } - - /** - * Notifies this page container that the specified page has been activated. - * This method is called after the current tabs has been changed, either by - * refreshing the tabs, or by a user UI action. This method just set - * correctly the active page value in the Container, and fire pageChanged - * events if needed. It does not change the selected page in the Part. - * - * Propagate the event to activePageTracker. - * - * @param childPart - */ - public void pageChanged(PagePart childPart) { - activePageTracker.setActiveEditor(childPart); - lifeCycleEventProvider.firePageActivatedEvent(childPart); - } - - /** - * Notifies this page container that a pageChanged event has been fired by - * one swt Control. This method is usually called after the user selects a - * different tab. - * - * The method record the new active folder in the ContentProvider, and calls {@link #pageChanged(PagePart)}. - * - * @param childPart - */ - public void pageChangedEvent(PagePart childPart) { - - // Check if it is really a change before changing the model (which can - // throw change event) - // The folder model change is done before the tracker fires the - // listeners, like this - // listeners can check the model. - if(getActivePage() == childPart) - return; - - contentProvider.setCurrentFolder(childPart.getParent().getRawModel()); - pageChanged(childPart); - } - - /** - * Set the active page. The current active page will be the specified page. - * Do not record the new active folder in the ContentProvider - * - * The method record the new CurrentFolder, and calls {@link #pageChanged(PagePart)}. - * - * @param childPart - */ - protected void setActivePage(PagePart childPart) { - pageChanged(childPart); - } - - /** - * A change has happen in one of the inner parts. Relay the event. This - * method is called by inner parts whenever the event happen in one of the - * part. It collects and relay the firePropertyChange(int propertyId) calls - * from the inner IEditor. - * - * @param propertyId - */ - public void firePropertyChange(int propertyId) { - // For now, we do nothing with this event. - } - - /** - * Create the part for the specified newModel. - * - * @param parent - * The parent of the created part. - * @param partModel - * The model for which a part should be created. - * @return - */ - public PagePart createPagePart(TabFolderPart parent, IPageModel partModel, Object rawModel) { - - if(partModel instanceof IEditorModel) { - // Check if we can use IEditorModel - if(multiEditorManager == null) - throw new IllegalArgumentException("Container can't accept IEditorModel as no IMultiEditorManager is set. Please set a IMultiEditorManager."); - - return new EditorPart(parent, (IEditorModel)partModel, rawModel, multiEditorManager); - } else if(partModel instanceof IComponentModel) { - return new ComponentPart(parent, (IComponentModel)partModel, rawModel); - } else { - // Return a default part - } - - // TODO return a default part showing an error instead. - throw new IllegalArgumentException("No Part found for the model '" + rawModel + "'"); - } - - /** - * Get the active page. - * - * @return - */ - private PagePart getActivePage() { - return activePageTracker.getActiveEditor(); - } - - /** - * @see org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer#getActiveEditor() - * @return - * - */ - public IEditorPart getActiveEditor() { - PagePart pagePart = getActivePage(); - if(pagePart instanceof EditorPart) - return ((EditorPart)pagePart).getIEditorPart(); - else - return null; - } - - /** - * Get the active page public API. - * - * @return - */ - public IPage getActiveSashWindowsPage() { - return getActivePage(); - } - - /** - * Get the list of visible IPages. The visible IPages are the one that have - * there diagram area visible. - * - * @return - */ - public List getVisiblePages() { - CollectVisiblePageVisitor visitor = new CollectVisiblePageVisitor(); - - rootPart.visit(visitor); - - return visitor.getVisiblePages(); - } - - /** - * Get the list of visible IPages. The visible IPages are the one that have - * there diagram area visible. - * - * @return - */ - // public List getVisibleIEditorPages() { - // CollectVisiblePageVisitor visitor = new CollectVisiblePageVisitor( - // IEditorPage.class); - // - // rootPart.visit(visitor); - // - // return visitor.getVisiblePages(); - // } - - /** - * Get the list of visible IPages. The visible IPages are the one that have - * there diagram area visible. - * - * @return - */ - public List getVisibleIEditorParts() { - CollectVisibleIEditorPart visitor = new CollectVisibleIEditorPart(); - rootPart.visit(visitor); - - return visitor.getVisiblePages(); - } - - /** - * @see org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer#setFocus() - * - */ - public void setFocus() { - setFocus(getActivePage()); - } - - /** - * Sets focus to the control for the given page. If the page has an editor, - * this calls its setFocus() method. Otherwise, this calls setFocus on the control for the page. - * - * @param pageIndex - * the index of the page - */ - private void setFocus(PagePart part) { - if(part != null) - part.setFocus(); - } - - /** - * Refresh the tabs. Is we are already currently refreshing, simply return. - * - * @see org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer#refreshTabs() - * - */ - public void refreshTabs() { - - // Check if we arent already refreshing - if(isRefreshing.compareAndSet(false, true)) { - try { - refreshTabsInternal(); - } finally { - isRefreshing.set(false); - } - } else { - log.warn("refresh inside refresh !"); - } - - } - - /** - * Refresh the tab of the page, (i.e the name and icon in the page's tab). - * - * @param page - * The page for which the name and icon should be refreshed. - */ - public void refreshPageTab(IPage page) { - if(page instanceof PagePart) { - ((PagePart)page).refreshTab(); - } else { - // TODO : lookup for the corresponding PagePart, and call refresh. - - } - } - - /** - * Real implementation of refreshTab. - * - * @see org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer#refreshTabs() - * - */ - private void refreshTabsInternal() { - // System.out.println("start synchronize2() ------------------------"); - // showTilesStatus(); - - // Get the currently selected folder - PagePart oldActivePage = getActivePage(); - - // Do refresh - container.setRedraw(false); - // Create map of parts - // PartMap partMap = new PartMap(); - PartLists garbageMaps = new PartLists(); - rootPart.fillPartMap(garbageMaps); - - // Synchronize parts - rootPart.synchronize2(garbageMaps); - - // Remove orphaned parts (no more used) - garbageMaps.garbage(); - - // set active page if needed - setActivePage(checkAndGetActivePage(oldActivePage, garbageMaps)); - - // Reenable SWT and force layout - container.setRedraw(true); - container.layout(true, true); - // System.out.println("end synchronize2() ------------------------"); - // showTilesStatus(); - } - - /** - * Select the specified page in the Parts. The specified page will becomes - * the active one. Appropriate events are fired. This is the programatic - * counterpart of selecting a page in the UI. If the provided page is null, - * do nothing. - * - * @param page - * The page to select or null. - */ - protected void selectPage(PagePart page) { - if(page == null) - return; - TabFolderPart folder = page.getParent(); - folder.setActiveEditor(page); - } - - /** - * Select the specified page in the Parts. The specified page will becomes - * the active one. Appropriate events are fired. This is the programatic - * counterpart of selecting a page in the UI. If the provided page is null, - * do nothing. - * - * @param page - * The page to select or null. The IPage should be an instance - * previously returned by the SashContainer. - */ - public void selectPage(IPage page) { - if(page == null) - return; - - // check if we are a correct instance. - if(!(page instanceof PagePart)) - return; - - selectPage((PagePart)page); - } - - /** - * Lookup the {@link IPage} used to render the specified rawModel. - * - * @param rawModel - * The model for which the IPage is requested. If the model is - * not rendered, return null; - * - * @return The corresponding IPage or null if not found. - */ - public IPage lookupModelPage(Object rawModel) { - // Use a visitor to lookup the first IPage - LookupModelPageVisitor visitor = new LookupModelPageVisitor(rawModel); - rootPart.visit(visitor); - return visitor.result(); - } - - /** - * Lookup the {@link IPage} used to render the specified IEditorPart. - * - * @param editor - * The IEditorPart for which the IPage is requested. If the - * IEditorPart is not rendered, return null; - * - * @return The corresponding IPage or null if not found. - */ - public IPage lookupIPageByIEditorPart(IEditorPart editor) { - // Use a visitor to lookup the first IPage - LookupIPageByIEditorPartVisitor visitor = new LookupIPageByIEditorPartVisitor(editor); - rootPart.visit(visitor); - return visitor.result(); - } - - /** - * Check if the oldActivePage still alive, and set it if needed. If the - * oldActivePage is null, set an active page if one exist. If the - * oldActivePage still alive, let it as the active one. If it is disposed, - * get arbitrarily an active page if one exist. - * - * @param oldActivePage - * @param partLists - * @param garbageMaps - * @return A valid active page or null if none exists. - */ - private PagePart checkAndGetActivePage(PagePart oldActivePage, PartLists partLists) { - - // Check if there is a created page - PagePart activePage = partLists.getFirstCreatedPage(); - if(activePage != null) - return activePage; - - // Check oldActivePage validity (in case it has been deleted) - if(oldActivePage != null && !(oldActivePage.isOrphaned() || oldActivePage.isUnchecked())) - return oldActivePage; - - // Get an active page if any - return lookupFirstValidPage(); - } - - /** - * Lookup for a valid active Page. Return null if none is found. TODO Use a - * visitor to implements this method. - * - * @return - */ - private PagePart lookupFirstValidPage() { - // First get a list of active editors - PartLists garbageMaps = new PartLists(); - rootPart.fillPartMap(garbageMaps); - return garbageMaps.getFirstValidPage(); - } - - /** - * Set a {@link MenuManager} used to manage a contextual menu that is shown - * on the tabs area of the folders. - * - * @param menuManager - * The {@link MenuManager} used to create the menu on the tab - * area. - */ - public void setFolderTabMenuManager(MenuManager menuManager) { - this.folderTabMenuManager = menuManager; - // Set the MenuManager in each existing folder. - // Use a visitor. - SetFolderTabMenuVisitor visitor = new SetFolderTabMenuVisitor(menuManager); - rootPart.visit(visitor); - } - - /** - * @return the menuManager - */ - public MenuManager getFolderTabMenuManager() { - return folderTabMenuManager; - } - - /** - * Show the status of the different Tiles composing the sash system. Used - * for debug purpose. - */ - public void showTilesStatus() { - ShowPartStatusVisitor visitor = new ShowPartStatusVisitor(); - rootPart.visit(visitor); - } - - /** - * Visit all the Pages (IEditorPage and IComponentPage), allowing to access - * to the public interface. - */ - public void visit(IPageVisitor pageVisitor) { - PageVisitorWrapper visitor = new PageVisitorWrapper(pageVisitor); - rootPart.visit(visitor); - } - - /** - * Visit the Part associated to the container. This method visibility is - * protected in order to be able to access it from junit tests. It is not - * intended to be used by public API or from outside. - */ - protected void visit(IPartVisitor visitor) { - rootPart.visit(visitor); - } - - /* ***************************************************** */ - /* Drag and Drop methods */ - /* ***************************************************** */ - - /** - * - */ - private void initDrag(Composite container) { - DragUtil.addDragTarget(container, dragOverListener); - - } - - IDragOverListener dragOverListener = new IDragOverListener() { - - /** - * - * @see org.eclipse.ui.internal.dnd.IDragOverListener#drag(org.eclipse.swt.widgets.Control, java.lang.Object, org.eclipse.swt.graphics.Point, - * org.eclipse.swt.graphics.Rectangle) - */ - public IDropTarget drag(Control currentControl, Object draggedObject, Point position, Rectangle dragRectangle) { - // TODO remove the cast by changing the method. Only folder can be - // source and target - final TabFolderPart sourcePart = (TabFolderPart)rootPart.findPart(draggedObject); // (ITilePart) draggedObject; - // Compute src tab index - // TODO move that and previous in the sender of drag event. Use a - // class containing both as draggedObject. - final int srcTabIndex = PTabFolder.getDraggedObjectTabIndex(draggedObject); - - // System.out.println("drag to position=" + position); - Rectangle containerDisplayBounds = DragUtil.getDisplayBounds(container); - AbstractPanelPart targetPart = null; - - // Check if the cursor is inside the container - if(containerDisplayBounds.contains(position)) { - - if(rootPart != null) { - targetPart = (AbstractPanelPart)rootPart.findPart(position); - // System.out.println("targetPart=" + targetPart - // + ", position=" + position - // + "container.toControl(position)=" + - // container.toControl(position)); - } - - if(targetPart != null) { - final Control targetControl = targetPart.getControl(); - - final Rectangle targetBounds = DragUtil.getDisplayBounds(targetControl); - - int side = Geometry.getClosestSide(targetBounds, position); - int distance = Geometry.getDistanceFromEdge(targetBounds, position, side); - - // Reserve the 5 pixels around the edge of the part for the - // drop-on-edge cursor - // Check if the target can handle the drop. - if(distance >= 5) { - // Otherwise, ask the part if it has any special meaning - // for this drop location - // TODO remove cast; change return type of findPart() - IDropTarget target = targetPart.getDropTarget(draggedObject, (TabFolderPart)sourcePart, position); - if(target != null) { - return target; - } - } else { - // We are on the boarder, try to drop on the parent - // Warning : the parent could be the rootPart - // System.out.println("DropTarget near the border"); - } - // - if(distance > 30) { - side = SWT.CENTER; - } - // - // // If the part doesn't want to override this drop - // location then drop on the edge - // - // // A "pointless drop" would be one that will put the - // dragged object back where it started. - // // Note that it should be perfectly valid to drag an - // object back to where it came from -- however, - // // the drop should be ignored. - // - @SuppressWarnings("unused") - boolean pointlessDrop = false; - - if(sourcePart == targetPart) { - pointlessDrop = true; - } - - return createDropTarget(sourcePart, srcTabIndex, side, side, targetPart); - } - } else { - // Cursor is outside the container - // System.out.println("Outside container bounds"); - // This will be used to create a new Window. - // We only allow dropping into a stack, not creating one - // if (differentWindows) - // return null; - - int side = Geometry.getClosestSide(containerDisplayBounds, position); - - boolean pointlessDrop = false; - int cursor = Geometry.getOppositeSide(side); - - if(pointlessDrop) { - side = SWT.NONE; - } - - return createDropTarget(sourcePart, srcTabIndex, side, cursor, null); - } - return null; - } - - }; - - /** - * Create the drop target - */ - private DropTarget createDropTarget(final TabFolderPart sourcePart, int srcTabIndex, int side, int cursor, AbstractPart targetPart) { - if(dropTarget == null) { - dropTarget = new DropTarget(sourcePart, srcTabIndex, side, cursor, targetPart); - } else { - dropTarget.setTarget(sourcePart, srcTabIndex, side, cursor, targetPart); - } - return dropTarget; - } - - /** - * Class implementing methods required by drop targets. - */ - protected class DropTarget implements IDropTarget { - - int count = 0; - - int cursor = SWT.TOP; - - private int side; - - private AbstractPanelPart targetPart; - - private int srcTabIndex; - - private TabFolderPart sourcePart; - - /** - * Constructor. - */ - public DropTarget(TabFolderPart sourcePart, int srcTabIndex, int cursor, int side, AbstractPart targetPart) { - this.cursor = cursor; - this.side = side; - this.sourcePart = sourcePart; - this.srcTabIndex = srcTabIndex; - this.targetPart = (AbstractPanelPart)targetPart; - } - - public void setTarget(TabFolderPart sourcePart, int srcTabIndex, int cursor, int side, AbstractPart targetPart) { - this.cursor = cursor; - this.side = side; - this.sourcePart = sourcePart; - this.srcTabIndex = srcTabIndex; - this.targetPart = (AbstractPanelPart)targetPart; - } - - /** - * A folder is dropped. - * - * @see org.eclipse.ui.internal.dnd.IDropTarget#drop() - */ - public void drop() { - // @TODO remove next cast - if(side == SWT.CENTER) { // Add to target folder - contentProvider.movePage(sourcePart.getPartModel(), srcTabIndex, ((TabFolderPart)targetPart).getPartModel(), -1); - } else { // Create a new folder - contentProvider.createFolder(sourcePart.getPartModel(), srcTabIndex, ((TabFolderPart)targetPart).getPartModel(), side); - } - } - - /** - * Return the cursor used during drag. - * - * @see org.eclipse.ui.internal.dnd.IDropTarget#getCursor() - */ - public Cursor getCursor() { - // System.out.println(SashWindowsContainer.this.getClass().getSimpleName() - // + ".getCursor()-" + count++); - return DragCursors.getCursor(DragCursors.positionToDragCursor(cursor)); - - } - - public Rectangle getSnapRectangle() { - // System.out.println(SashWindowsContainer.this.getClass().getSimpleName() - // + ".getSnapRectangle(" + "sourcePart=" + sourcePart + - // ", targetPart=" + targetPart + ", side=" + side); - Rectangle targetDisplayBounds; - - if(targetPart != null) { - targetDisplayBounds = DragUtil.getDisplayBounds(targetPart.getControl()); - } else { - // targetBounds = DragUtil.getDisplayBounds(getParent()); - targetDisplayBounds = DragUtil.getDisplayBounds(container); - } - - if(side == SWT.CENTER || side == SWT.NONE) { - return targetDisplayBounds; - } - - int distance = Geometry.getDimension(targetDisplayBounds, !Geometry.isHorizontal(side)); - - return Geometry.getExtrudedEdge(targetDisplayBounds, (int)(distance * getDockingRatio(sourcePart, targetPart)), side); - } - - protected float getDockingRatio(AbstractPart dragged, AbstractPart target) { - return 0.5f; - } - - } - - /** - * @return the lifeCycleEventProvider - */ - public SashContainerEventsProvider getLifeCycleEventProvider() { - return lifeCycleEventProvider; - } - - /** - * Add a listener on pageChanged event. This implementation delegates to the - * internal PageTracker. - * - * @see org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer#addPageChangedListener(org.eclipse.papyrus.sasheditor.editor.IPageChangedListener) - * @param pageChangedListener - * - */ - public void addPageChangedListener(IPageChangedListener pageChangedListener) { - activePageTracker.addPageChangedListener(pageChangedListener); - } - - /** - * Remove a listener on pageChanged event. - * - * @see org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer#removePageChangedListener(org.eclipse.papyrus.sasheditor.editor.IPageChangedListener) - * @param pageChangedListener - * - */ - public void removePageChangedListener(IPageChangedListener pageChangedListener) { - activePageTracker.removePageChangedListener(pageChangedListener); - } - - /** - * Add a listener on Page LifeCycle events. This implementation delegates to - * the internal PageTracker. - * - * @see org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer#addPageChangedListener(org.eclipse.papyrus.sasheditor.editor.IPageChangedListener) - * @param listener - * - */ - public void addLifeCycleListener(SashContainerEventsListener listener) { - lifeCycleEventProvider.addListener(listener); - } - - /** - * Remove a listener on Page LifeCycle events. - * - * @see org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer#removePageChangedListener(org.eclipse.papyrus.sasheditor.editor.IPageChangedListener) - * @param listener - * - */ - public void removeLifeCycleListener(SashContainerEventsListener listener) { - lifeCycleEventProvider.removeListener(listener); - } - - /* ***************************************************** */ - /* Internal Visitors */ - /* ***************************************************** */ - - /** - * Inner class. A visitor setting the {@link MenuManager} on each folder. - */ - private class SetFolderTabMenuVisitor extends PartVisitor { - - private MenuManager menuManager; - - /** - * Constructor. - * - * @param menuManager - */ - public SetFolderTabMenuVisitor(MenuManager menuManager) { - this.menuManager = menuManager; - } - - /** - * Set the menu if the visited node is a folder. - */ - @Override - public boolean accept(TabFolderPart part) { - part.setFolderTabMenuManager(menuManager); - return true; - } - - } - - /** - * Inner class. A visitor used to collect all visible page in the - * sashcontainer. A visible page is a page whose the diagram area is - * visible. - */ - private class CollectVisiblePageVisitor extends PartVisitor { - - private List visiblePages = new ArrayList(); - - private Class expectedClass; - - /** - * Constructor. - * - * @param menuManager - */ - public CollectVisiblePageVisitor() { - - } - - /** - * Constructor. - * - * @param menuManager - */ - @SuppressWarnings("unused") - public CollectVisiblePageVisitor(Class expectedClass) { - this.expectedClass = expectedClass; - } - - /** - * Get the result list. - * - * @param - * @return - */ - @SuppressWarnings("unchecked") - public List getVisiblePages() { - return (List)visiblePages; - } - - /** - * Set the menu if the visited node is a folder. - */ - @Override - public boolean accept(TabFolderPart part) { - - IPage page = part.getVisiblePagePart(); - if(part != null) { - if(expectedClass != null && expectedClass.isInstance(page)) { - visiblePages.add(page); - } else { - visiblePages.add(page); - } - - } - - return true; - } - - } - - /** - * Inner class. A visitor used to collect all visible page in the - * sashcontainer. A visible page is a page whose the diagram area is - * visible. - */ - private class CollectVisibleIEditorPart extends PartVisitor { - - private List visiblePages = new ArrayList(); - - /** - * Constructor. - * - * @param menuManager - */ - public CollectVisibleIEditorPart() { - - } - - /** - * Get the result list. - * - * @param - * @return - */ - public List getVisiblePages() { - return visiblePages; - } - - /** - * Set the menu if the visited node is a folder. - */ - @Override - public boolean accept(TabFolderPart part) { - - IPage page = part.getVisiblePagePart(); - if(page != null && page instanceof IEditorPage) { - IEditorPage editorPage = (IEditorPage)page; - visiblePages.add(editorPage.getIEditorPart()); - - } - // continue searching - return true; - } - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashWindowsEventsProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashWindowsEventsProvider.java deleted file mode 100644 index e2c392d6601..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/SashWindowsEventsProvider.java +++ /dev/null @@ -1,432 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.editor; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; - -/** - * This class allows to listen on events from the {@link SashWindowsContainer}: - *
    - *
  • pageChanged - a page has changed in the current container
  • - *
  • - containerChanged - the active editor has changed, and so the currently active container.
  • - *
- * - * This class require the current Eclipse page in order to listen on active - * editor changed. This class connect itself to the Workbench editor changed - * event. Then, it ask the current editor for a ISashWindowsContainer (using - * getAdaptor() ). If the editor return a ISashWindowsContainer, this class - * listen to the pageChanged events. This class takes care to connect itself to - * the new ISashWindowsContainer when the editor changes. - * - * @TODO rename as SashWindowsEventsNotifier - * @author cedric dumoulin - * - */ -public class SashWindowsEventsProvider { - - /** - * List of listeners that will be notified when the current Sash Page has - * changed. - */ - private PageChangedListeners pageEventsManager = new PageChangedListeners(); - - /** - * List of listeners that will be notified when the SashWindowsContainer has - * changed. - */ - private SashWindowsContainerChangedListeners containerEventsManager = new SashWindowsContainerChangedListeners(); - - /** - * Workbench page to which this mngr listen for {@link IEditorPart} changes. - */ - private IWorkbenchPage workbenchPage; - - /** - * The last active editor read by a call to workbenchPage.getActiveEditor(); - */ - private IEditorPart lastActiveEditor = null; - - /** - * Currently active SashContainer, or null if none is active. - */ - private ISashWindowsContainer currentContainer = null; - - /** Currently active page, or null if no container is active */ - private IPage activePage = null; - - private IPartListener workbenchPartListener = new IPartListener() { - - public void partOpened(IWorkbenchPart part) { - // System.out.println("partOpened("+ part +")"); - - } - - public void partDeactivated(IWorkbenchPart part) { - // System.out.println("partDeactivated("+ part +")"); - } - - public void partClosed(IWorkbenchPart part) { - // System.out.println("("+ part +")"); - } - - public void partBroughtToTop(IWorkbenchPart part) { - // System.out.println("partClosed("+ part +")"); - } - - public void partActivated(IWorkbenchPart part) { - // System.out.println("partActivated(" + part + ") - activeEditor: " - // + workbenchPage.getActiveEditor()); - checkActiveEditorChange(); - } - }; - - /** - * Permanent listener on sash pageChanged event. - */ - private IPageChangedListener sashPageChangedListener = new IPageChangedListener() { - - public void pageChanged(IPage newPage) { - firePageChanged(newPage); - } - }; - - /** - * - * Constructor. Page can be acquired with : - * IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - */ - public SashWindowsEventsProvider(IWorkbenchPage page) { - - // Initialize activePave and current Sash Container. - init(page); - // Register changed event listeners - registerEditorChangedListener(); - checkActiveEditorChange(); - } - - /** - * Initialize the first values. - * - * @param page - */ - private void init(IWorkbenchPage page) { - if(page == null) - throw new IllegalArgumentException("page should not be null."); - - workbenchPage = page; - - // Get the currently active container, if any. - ISashWindowsContainer newContainer = null; - IEditorPart editorPart = page.getActiveEditor(); - if(editorPart != null) { - newContainer = (ISashWindowsContainer)editorPart.getAdapter(ISashWindowsContainer.class); - } - - // // Set SashContainer and ActivePage - // currentContainer = newContainer; - // if( currentContainer != null) - // { - // activePage = newContainer.getActiveSashWindowsPage(); - // System.err.println("activePage=" + activePage.getPageTitle() - // + ", tab index=" + currentContainer.); - // } - } - - /** - * Return the currently active ISashWindowsContainer or null if none is - * actif. - * - * @return - */ - public ISashWindowsContainer activeSashWindowsContainer() { - return currentContainer; - } - - /** - * Return the currently active {@link IEditorPart} owning the currently - * active ISashWindowsContaineror. Return null if no container is actif. - * - * @return - */ - public IEditorPart activeSashWindowsContainerOwner() { - if(currentContainer == null) - return null; - return workbenchPage.getActiveEditor(); - } - - /** - * Return the currently active page associated to the currently active - * Container. Return null if no container is actif. - * - * @return - */ - public IPage activeSashWindowsPage() { - return activePage; - } - - /** - * Check if the active editor has changed. If true, send appropriate event. - */ - private void checkActiveEditorChange() { - // If the currently active editor has changed, send an event. - IEditorPart editor = workbenchPage.getActiveEditor(); - if(editor != lastActiveEditor) { - lastActiveEditor = editor; - activeEditorChanged(editor); - } - lastActiveEditor = editor; - } - - /** - * Dispose this manager. Cleanup listeners. - */ - public void dispose() { - workbenchPage.removePartListener(workbenchPartListener); - } - - /** - * Register a listener listeneing on editor change. Page can be acuired with - * : IWorkbenchPage page = - * PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - */ - private void registerEditorChangedListener() { - - workbenchPage.addPartListener(workbenchPartListener); - } - - /** - * This method is called when the active editor has change. The method - * checks the new editor and send appropriate events. The editor can be - * null. - * - * @param newEditor - * The new editor of null if none is set. - */ - private void activeEditorChanged(IEditorPart newEditor) { - - // Editor has changed. It can be null. - // Compute new container. - ISashWindowsContainer newContainer = null; - if(newEditor != null) { - newContainer = (ISashWindowsContainer)newEditor.getAdapter(ISashWindowsContainer.class); - } - - // Throw event if necessary - if(newContainer != currentContainer) - activeContainerChanged(newContainer); - } - - /** - * This method is called when the active container has changed. The - * pageChangedListener is removed from the oldContainer, and attached to the - * newContainer. - * - * @param newContainer - */ - private void activeContainerChanged(ISashWindowsContainer newContainer) { - // Detach listener from the old container - if(currentContainer != null) - currentContainer.removePageChangedListener(sashPageChangedListener); - - // record new container - currentContainer = newContainer; - - // attach listener to new container - if(currentContainer != null) { - currentContainer.addPageChangedListener(sashPageChangedListener); - firePageChanged(newContainer.getActiveSashWindowsPage()); - } - - // Fire events. - fireContainerChanged(newContainer); - IPage newPage = (newContainer != null ? newContainer.getActiveSashWindowsPage() : null); - firePageChanged(newPage); - } - - /** - * Send an event indicating a containerChanged. Propagate the event to all - * the listeners. - * - * @param activeEditor - */ - private void fireContainerChanged(ISashWindowsContainer newContainer) { - // Propagate to all the listeners - containerEventsManager.fireEvent(newContainer); - } - - /** - * Send an event indicating a pageChanged. Propagate the event to all the - * listeners. - * - * @param activeEditor - */ - private void firePageChanged(IPage newPage) { - - activePage = newPage; - // Propagate to all the listeners - pageEventsManager.fireEvent(newPage); - } - - /** - * Add a listener on pageChanged event. - * - * @param listener - */ - public void addPageChangedListener(IPageChangedListener listener) { - pageEventsManager.addListener(listener); - } - - /** - * Remove listener on pageChanged event. - * - * @param listener - */ - public void removePageChangedListener(IPageChangedListener listener) { - pageEventsManager.removeListener(listener); - } - - /** - * Add a listener on pageChanged event. - * - * @param listener - */ - public void addSashWindowsContainerChangedListener(ISashWindowsContainerChangedListener listener) { - containerEventsManager.addListener(listener); - } - - /** - * Remove listener on pageChanged event. - * - * @param listener - */ - public void removeSashWindowsContainerChangedListener(ISashWindowsContainerChangedListener listener) { - containerEventsManager.removeListener(listener); - } - - /** - * - * @author dumoulin - * - */ - private abstract class ListenersList { - - List listeners; - - /** - * Add specified listener. - * - * @param listener - */ - public void addListener(Listener listener) { - // Lazy creation - if(listeners == null) - listeners = new ArrayList(); - - // do not add if already present. - if(listeners.contains(listener)) - return; - - listeners.add(listener); - } - - /** - * Remove specified listener. - * - * @param listener - */ - public void removeListener(Listener listener) { - // Lazy creation - if(listeners == null) - return; - - listeners.remove(listener); - } - - /** - * Fire the event on each listener - * - * @param event - */ - public void fireEvent(Event event) { - // Lazy creation - if(listeners == null) - return; - - for(Listener listener : listeners) { - propertyChanged(listener, event); - } - } - - /** - * Call the listener appropriate property. - * - * @param listener - * @param event - */ - public abstract void propertyChanged(Listener listener, Event event); - } - - /** - * A list of {@link IPageChangedListener}. - * - * @author dumoulin - * - */ - public class PageChangedListeners extends ListenersList { - - /** - * Call the appropriate method on the listener. - * - * @see org.eclipse.papyrus.sasheditor.editor.SashWindowsEventsProvider.ListenersList#propertyChanged(java.lang.Object, java.lang.Object) - * @param listener - * @param newPage - * - */ - @Override - public void propertyChanged(IPageChangedListener listener, IPage newPage) { - - try { - listener.pageChanged(newPage); - } catch (Exception e) { - // catch error in case a listener send an exception. - // Still show the exception for debug purpose - e.printStackTrace(); - } - - } - - } - - /** - * A list of {@link ISashWindowsContainerChangedListener} listening on - * container changed event. - * - * @author dumoulin - * - */ - public class SashWindowsContainerChangedListeners extends ListenersList { - - /** - * Call the appropriate method on the listener. - * - * @see org.eclipse.papyrus.sasheditor.editor.SashWindowsEventsProvider.ListenersList#propertyChanged(java.lang.Object, java.lang.Object) - * @param listener - * @param newPage - * - */ - @Override - public void propertyChanged(ISashWindowsContainerChangedListener listener, ISashWindowsContainer newContainer) { - listener.sashWindowsContainerChanged(newContainer); - - } - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java deleted file mode 100644 index 2637e6bafe3..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/actionbarcontributor/ComposedActionBarContributor.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.editor.actionbarcontributor; - -import java.util.logging.Level; - -import org.eclipse.ui.IEditorActionBarContributor; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.part.EditorActionBarContributor; - -/** - * - * An ActionBarContributor composed of ActionBarContributor from multi editor. - * This ActionBarContributor switch to the contributor dedicated to the active - * editor in a MultiPageEditor environement. - * - * @author dumoulin - * - */ -public class ComposedActionBarContributor extends MultiPageEditorActionBarContributor { - - // /** - // * List of contributors. - // */ - // protected ContributorMap, - // EditorActionBarContributor> contributors = new ContributorMap, EditorActionBarContributor>(); - // - // - // /** - // * Contributor used as default. - // */ - // protected EditorActionBarContributor defaultContributor; - // - // /** - // * The currently active contributor. - // */ - // protected EditorActionBarContributor activeContributor; - - /** The currently active nested editor */ - protected IEditorPart activeNestedEditor; - - /** - * Constructor. - */ - public ComposedActionBarContributor() { - } - - /** - * Sets the active page of the the multi-page editor to be the given editor. - * Switch the currently active editor. - *

- * This method is called whenever the page changes. Subclasses must implement this method to redirect actions to the given editor (if not already - * directed to it). - *

- * - * @param activeEditor - * the new active editor, or null if there is no - * active page, or if the active page does not have a - * corresponding editor - */ - @Override - public void setActivePage(IEditorPart activeEditor) { - // Check if we are already initialized - // Return if we are not - if(getPage() == null) - return; - - // skip if the activeEditor doesn't change. - if(activeEditor == activeNestedEditor) - return; - - if(log.isLoggable(Level.FINE)) { - log.fine("setActivePage(" + activeEditor + " " + ")"); - } - - activeNestedEditor = activeEditor; - - // System.out.println(this.getClass().getSimpleName() - // + ".setActivePage(" + activeEditor - // + ") :" + getActiveContributor()); - - // Propagate call if possible - // Call setActiveEditor() on nested contributor. - IEditorActionBarContributor contributor = getActiveContributor(); - if(contributor != this && contributor instanceof EditorActionBarContributor) - ((EditorActionBarContributor)contributor).setActiveEditor(activeEditor); - - // if(contributor != this && contributor instanceof - // IMultiPageEditorActionBarContributor) - // ((IMultiPageEditorActionBarContributor)contributor).setActivePage(activeEditor); - - } - - /** - * Sets the active editor for the contributor. - *

- * The EditorActionBarContributor implementation of this method does nothing. Subclasses may reimplement. This generally entails - * disconnecting from the old editor, connecting to the new editor, and updating the actions to reflect the new editor. - *

- * - * @param part - * the new target editor - */ - public void setActiveEditor(IEditorPart part) { - if(log.isLoggable(Level.FINE)) { - log.fine("setActiveEditor(" + part + " " + ")"); - } - - // Switch the editor and activeContributor. - super.setActiveEditor(part); - // Now, propagate to the new activeContributor - // IEditorActionBarContributor activeContributor = - // getActiveContributor(); - // - // if(activeContributor!=this) - // activeContributor.setActiveEditor(part); - } - - /** - * Get the active nested contributor, if any. - * - * @return the active nested contributor, or null if any. - */ - protected IEditorActionBarContributor getActiveContributor() { - - // If there is no nestedEditor, this contributor is used. - if(activeNestedEditor == null) - return this; - - // - return activeNestedEditor.getEditorSite().getActionBarContributor(); - } - - // ************************************************ // - // Propagate method calls // - // ************************************************ // - - /** - * Returns this contributor's action bars. - * - * @return the action bars - */ - // public IActionBars getActionBars() { - // IEditorActionBarContributor activeContributor = getActiveContributor(); - // if( activeContributor!=this && activeContributor instanceof - // EditorActionBarContributor) - // return - // ((EditorActionBarContributor)getActiveContributor()).getActionBars(); - // else - // return super.getActionBars(); - // } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/actionbarcontributor/IMultiPageEditorActionBarContributor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/actionbarcontributor/IMultiPageEditorActionBarContributor.java deleted file mode 100644 index cd4a4f5b045..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/actionbarcontributor/IMultiPageEditorActionBarContributor.java +++ /dev/null @@ -1,46 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.editor.actionbarcontributor; - -import org.eclipse.ui.IEditorPart; - -/** - * Interface implemented by ActionBarContributor dedicated to MultiEditor. - * ActionBarContributor that want to be advised of a page change should - * implement this interface. Another way should be to use a Observer/Observee - * mechanism, allowing to remove the dependancy from the editor to the - * ActionBarContributor ? - * - * @author dumoulin - * - */ -public interface IMultiPageEditorActionBarContributor { - - /** - * Sets the active page of the the multi-page editor to be the given editor. - * Redirect actions to the given editor if actions are not already being - * sent to it. - *

- * This method is called whenever the page changes. Subclasses must implement this method to redirect actions to the given editor (if not already - * directed to it). - *

- * - * @param activeEditor - * the new active editor, or null if there is no - * active page, or if the active page does not have a - * corresponding editor - */ - public abstract void setActivePage(IEditorPart activeEditor); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/actionbarcontributor/MultiPageEditorActionBarContributor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/actionbarcontributor/MultiPageEditorActionBarContributor.java deleted file mode 100644 index 21a1f34c092..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/actionbarcontributor/MultiPageEditorActionBarContributor.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.papyrus.sasheditor.editor.actionbarcontributor; - -import java.util.logging.Logger; - -import org.eclipse.papyrus.sasheditor.editor.IMultiPageEditorPart; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.part.EditorActionBarContributor; - -/** - * Abstract base class for managing the installation/deinstallation of global - * actions for multi-page editors. - *

- * Subclasses must implement setActivePage, and may reimplement any of the following methods: - *

    - *
  • contributeToMenu - reimplement to contribute to menu
  • - *
  • contributeToToolBar - reimplement to contribute to tool bar
  • - *
  • contributeToStatusLine - reimplement to contribute to status line
  • - *
- *

- * This class is copied from {@link org.eclipse.ui.part.MultiPageEditorActionBarContributor} - */ -public abstract class MultiPageEditorActionBarContributor extends EditorActionBarContributor implements IMultiPageEditorActionBarContributor { - - /** Log object */ - Logger log = Logger.getLogger(getClass().getName()); - - /** - * Creates a multi-page editor action contributor. - */ - protected MultiPageEditorActionBarContributor() { - super(); - } - - /** - * Method declared on EditorActionBarContributor. Registers the contributor - * with the multi-page editor for future editor action redirection when the - * active page is changed, and sets the active page. - */ - public void setActiveEditor(IEditorPart part) { - - IEditorPart activeNestedEditor = null; - if(part instanceof IMultiPageEditorPart) { - activeNestedEditor = ((IMultiPageEditorPart)part).getActiveEditor(); - setActivePage(activeNestedEditor); - } - - } - - /** - * Called by the MultiEditor whenever the active page change. - * - * @param activeEditor - */ - public abstract void setActivePage(IEditorPart activeEditor); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/gef/MultiDiagramEditorGefDelegate.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/gef/MultiDiagramEditorGefDelegate.java deleted file mode 100644 index ec2a1d58c30..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/editor/gef/MultiDiagramEditorGefDelegate.java +++ /dev/null @@ -1,108 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.editor.gef; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; - -/** - * Provide methods and services needed for Gef Editors. This class is intended - * to be used as a delegate inside classes providing MultiDiagramEditor. - * - * @author dumoulin - * - */ -public class MultiDiagramEditorGefDelegate { - - /** The registry holding actions associated to the main editor */ - protected ActionRegistry actionRegistry; - - /** Synchronizer object */ - // private MultiPageSelectionSynchronizer synchronizer; - - /** List of listeners on SelectionChanged event */ - private List selectionListeners = new ArrayList(1); - - /** - * This method should be called by the containing class. - */ - public void dispose() { - selectionListeners.clear(); - if(actionRegistry != null) { - actionRegistry.dispose(); - } - } - - /** - * Adds a listener for selection changes in this selection provider. Has no - * effect if an identical listener is already registered. - * - * @param listener - * a selection changed listener - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - selectionListeners.add(listener); - } - - /** - * Lazily creates and returns the action registry. - * - * @return the action registry - */ - public ActionRegistry getActionRegistry() { - if(actionRegistry == null) - actionRegistry = new ActionRegistry(); - return actionRegistry; - } - - // /** - // * Returns the selection synchronizer object. The synchronizer can be used - // to sync the selection of 2 or more EditPartViewers. - // * - // * @return the syncrhonizer - // */ - // public MultiPageSelectionSynchronizer getSelectionSynchronizer() { - // if (synchronizer == null) { - // synchronizer = new MultiPageSelectionSynchronizer(); - // // Hook this editor. - // // synchronizer.addViewer(this); - // } - // return synchronizer; - // } - - /** - * Removes the given selection change listener from this selection provider. - * Has no affect if an identical listener is not registered. - * - * @param listener - * the selection changed listener to be removed - */ - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - selectionListeners.remove(listener); - } - - /** - * Sets the current selection for this selection provider. - * - * @param selection - * the new selection - */ - public void setSelection(ISelection selection) { - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/AbstractPanelPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/AbstractPanelPart.java deleted file mode 100644 index 8900e34dc64..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/AbstractPanelPart.java +++ /dev/null @@ -1,170 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.sasheditor.internal; - -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.internal.dnd.IDropTarget; - -/** - * Common ancestor of Panel Parts. Panels are sashes and folders. - * - * @author cedric dumoulin - */ -public abstract class AbstractPanelPart extends AbstractPart { - - /** - * Parent of this part. - */ - protected IPanelParent parent; - - /** - * Constructor. - * - * @param parent - * Parent of the Pane. - */ - public AbstractPanelPart(IPanelParent parent) { - super(parent.getSashWindowContainer()); - } - - /** - * Create the SWT controls. This method is called by the SWT parent. - * - * @param container - */ - abstract public void createPartControl(Composite container); - - /** - * Dispose all nested SWT controls. - */ - abstract public void dispose(); - - /** - * Visit the part. - * - * @param visitor - */ - abstract public boolean visit(IPartVisitor visitor); - - /** - * Synchronize the part and its children with the models in contentProvider. - * - * @param existingParts - * List of already existing part before the synchronization. - */ - abstract public void synchronize2(PartLists existingParts); - - /** - * Return true is the part is for the specified raw model. Return false - * otherwise. - * - * @param rawModel - * @return - */ - abstract public boolean isPartFor(Object rawModel); - - /** - * Orphan this node. The parent is set to null, but control is left - * unchanged. The node can be reattached with reparent(). Change garbage - * state to {@link GarbageState.ORPHANED}. This method as no effect if the - * Tile has already been reparented. - */ - public void orphan() { - // orphan only if we are in UNCHANGED state - if(garbageState == GarbageState.UNVISITED) { - garbageState = GarbageState.ORPHANED; - parent = null; - } - } - - /** - * Mark this Page as UNCHANGED. The PAge should be in the COLLECTED state. - * - * @see - * @return the parent - */ - public void unchanged() { - // orphan only if we are in COLLECTED state - if(garbageState == GarbageState.UNVISITED || garbageState == GarbageState.ORPHANED) { - garbageState = GarbageState.UNCHANGED; - } else { - // Bad state, this is an internal error - // TODO : log a warning ? - throw new IllegalStateException("Try to change state from " + garbageState.toString() + " to UNCHANGED. This is forbidden."); - } - } - - /** - * Change the parent of the Part. The parent is changed, and the control is - * attached to the parent control. Change garbage state to {@link GarbageState.REPARENTED}. - * - * @param newParent - * The new parent to which the part should be attached. - */ - abstract public void reparent(IPanelParent newParent, Composite swtParent); - - /** - * Collect all the parts. The method is called recursively in the tree of - * parts. - * - * @param parts - * The list into which parts are added. - */ - abstract public void fillPartMap(PartLists parts); - - /** - * Traverses the tree to find the part that intersects the given point - * - * @param toFind - * Point in display coordinate - * @return the part that intersects the given point - * @throws NotFoundException - */ - abstract public AbstractPart findPart(Point toFind) throws NotFoundException; - - /** - * Find the part associated to the provided control. - * - * @param control - * @return - */ - abstract public AbstractPart findPart(Object control); - - /** - * Locates the part that intersects the given point and that have the - * expected type - * - * @param toFind - * Position in Display coordinate. - * @return - */ - abstract public AbstractPart findPartAt(Point toFind, Class expectedTileType); - - /* ***************************************************** */ - /* Drag and Drop methods */ - /* ***************************************************** */ - - /** - * Return the swt Control associated to this part. - */ - abstract public Composite getControl(); - - /** - * Get the drop target. Used by the drag tab mechanism. - */ - abstract public IDropTarget getDropTarget(Object draggedObject, TabFolderPart sourcePart, Point position); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/AbstractPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/AbstractPart.java deleted file mode 100644 index d2c77276629..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/AbstractPart.java +++ /dev/null @@ -1,101 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.editor.SashWindowsContainer; - -/** - * Base class of the Part hierarchy. This class provides common methods for - * sashwindows Parts. - * - * - * @author dumoulin - */ -public abstract class AbstractPart { - - /** - * Enumeration used when the parts are synchronized. - *
    - *
  • UNVISITED - The part not yet visited. This is the initial state when synchronizing. The part can stay in this state after synchronization - * if one of its parent is ORPHANED.
  • - *
  • ORPHANED - The part is orphaned from its direct parent.
  • - *
  • REPARENTED - The part parent has changed
  • - *
  • CREATED - The part is newly created
  • - *
  • UNCHANGED - The part is visited, and its parent is unchanged.
  • - *
- */ - public enum GarbageState { - UNVISITED, ORPHANED, REPARENTED, CREATED, UNCHANGED - } - - /** - * The main container. - */ - protected SashWindowsContainer sashWindowsContainer; - - /** Garbage state used during refresh */ - protected GarbageState garbageState = GarbageState.CREATED; - - /** - * @param sashWindowsContainer - */ - public AbstractPart(SashWindowsContainer sashWindowsContainer) { - this.sashWindowsContainer = sashWindowsContainer; - } - - /** - * Get the {@link SashWindowsContainer}. - * - * @return - */ - public SashWindowsContainer getSashWindowContainer() { - return sashWindowsContainer; - } - - /** - * Get the content provider of the sashwindows. - * - * @return - */ - public ISashWindowsContentProvider getContentProvider() { - return sashWindowsContainer.getContentProvider(); - } - - /** - * - * @return - */ - public boolean isOrphaned() { - return garbageState == GarbageState.ORPHANED; - } - - /** - * Return true if the page state == {@link GarbageState#UNVISITED}. - * - * @return - */ - public boolean isUnchecked() { - - return garbageState == GarbageState.UNVISITED; - } - - /** - * @return - */ - public GarbageState getGarbageState() { - return garbageState; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ActiveEditorServicesSwitcher.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ActiveEditorServicesSwitcher.java deleted file mode 100644 index bc2bc2af923..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ActiveEditorServicesSwitcher.java +++ /dev/null @@ -1,270 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.papyrus.sasheditor.editor.SashWindowsContainer; -import org.eclipse.papyrus.sasheditor.editor.actionbarcontributor.IMultiPageEditorActionBarContributor; -import org.eclipse.papyrus.sasheditor.internal.ActivePageTracker.IActiveEditorChangedListener; -import org.eclipse.papyrus.sasheditor.internal.eclipsecopy.MultiPageSelectionProvider; -import org.eclipse.ui.IEditorActionBarContributor; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IKeyBindingService; -import org.eclipse.ui.INestableKeyBindingService; -import org.eclipse.ui.IPartService; -import org.eclipse.ui.internal.WorkbenchPlugin; -import org.eclipse.ui.internal.services.INestable; -import org.eclipse.ui.part.MultiPageEditorActionBarContributor; -import org.eclipse.ui.services.IServiceLocator; - -/** - * This class is used to switch the services of a nested editor when the active - * nested editor change. This class is a {@link IActiveEditorChangedListener} registered to the {@link ActivePageTracker} by the - * {@link SashWindowsContainer}. - * - * When a new Editor is set active, by calling {@link #setActiveEditor(PagePart)}, following actions are performed: - *
    - *
  • deactivate services: nested site and keybinding
  • - *
  • An event is sent to the ActionBarContributor if it accept it (by implementing {@link IMultiPageEditorActionBarContributor})
  • - *
  • Send {@link SelectionChangedEvent} to the main editor. The event contains the current selection of the new active editor.
  • - *
  • Connect the keybinding service to the new Editor.
  • - *
- * - * - * @author cedric dumoulin - * - */ -public class ActiveEditorServicesSwitcher implements IActiveEditorChangedListener { - - /** Log object */ - Logger log = Logger.getLogger(getClass().getName()); - - /** The currently active editor */ - protected PagePart activeEditor; - - /** - * The {@link IEditorSite} of the outerMost editor (the main editor) ... - */ - private IEditorSite outerEditorSite; - - /** - * The active service locator. This value may be null if there - * is no selected page, or if the selected page is a control with no site. - */ - private INestable activeServiceLocator; - - /** - * Constructor. - * - * @param outerEditorSite - * {@link IEditorSite} of the main editor. - */ - public ActiveEditorServicesSwitcher(IEditorSite outerEditorSite) { - this.outerEditorSite = outerEditorSite; - } - - /** - * Get the currently active IEditorPart, if any. Return null if there is no - * active IeditorPart. Method check if the active leaf encapsulate an - * IEditorPart. Return it if true. - * - * @return The currentlyactive IEditorPart or null. - */ - private IEditorPart getActiveIEditorPart() { - return getIEditorPart(activeEditor); - } - - /** - * Get IEditorPart of the specified PagePart, if any. Return null if there - * is no IeditorPart. Method check if the leaf encapsulate an IEditorPart. - * Return it if true. - * - * @return The IEditorPart or null. - */ - private IEditorPart getIEditorPart(PagePart pagePart) { - if(pagePart == null) - return null; - - if(pagePart instanceof EditorPart) { - return ((EditorPart)pagePart).getIEditorPart(); - } - // not found - return null; - } - - /** - * Called when the active editor is changed. Perform requested operations. - * - * @param oldEditor - * @param newEditor - */ - public void activeEditorChanged(PagePart oldEditor, PagePart newEditor) { - if(activeEditor == newEditor) { - return; - } - - // System.out.println(getClass().getSimpleName() + - // ".activeEditorChange('" + (newEditor != null ? - // newEditor.getPageTitle() : "null") + "')"); - - activeEditor = newEditor; - - // Set focus - IPartService partService = (IPartService)getOuterEditorSite().getService(IPartService.class); - if(newEditor != null && partService.getActivePart() == getOuterEditorSite().getPart()) { - newEditor.setFocus(); - } - - // Switch services - deactivateServices(false); - fireChangeEventToActionBarContributor(); - propagateSelectionChanged(); - activateServices(); - - // - if(newEditor != null) - newEditor.setFocus(); - } - - /** - * Change the current selection of the outermost editor (the main editor). - * Send a {@link SelectionChangedEvent} event to the outerProvider. The - * event contains the current selection of the new activeEditor. - * - * @param editor - * The new activeEditor. - */ - private void propagateSelectionChanged() { - - // Get the IEditor - IEditorPart editorPart = getActiveIEditorPart(); - - // Propagate the selection change event. - // Get the selection of the new activeEditor and send an - // SelectionChangedEvent to the outerProvider (provider of the main - // editor) with the selection. - if(editorPart != null) { - ISelectionProvider selectionProvider = editorPart.getSite().getSelectionProvider(); - if(selectionProvider != null) { - ISelectionProvider outerProvider = getOuterEditorSite().getSelectionProvider(); - if(outerProvider instanceof MultiPageSelectionProvider) { - SelectionChangedEvent event = new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()); - - MultiPageSelectionProvider provider = (MultiPageSelectionProvider)outerProvider; - provider.fireSelectionChanged(event); - provider.firePostSelectionChanged(event); - } else { - if(log.isLoggable(Level.WARNING)) { - log.warning(this.getClass().getSimpleName() + " did not propogate selection for " //$NON-NLS-1$ - + editorPart.getTitle()); - } - } - } - } - } - - /** - * Activates services of the active editor: site, keybinding deactivate old - * active site. - */ - @SuppressWarnings({ "restriction", "deprecation" }) - private void activateServices() { - // Deactivate old active site - if(activeServiceLocator != null) { - activeServiceLocator.deactivate(); - activeServiceLocator = null; - } - - // Get the service - final IKeyBindingService service = getOuterEditorSite().getKeyBindingService(); - - final IEditorPart editor = getActiveIEditorPart(); - - if(editor != null) { - // active the service for this inner editor - if(service instanceof INestableKeyBindingService) { - final INestableKeyBindingService nestableService = (INestableKeyBindingService)service; - nestableService.activateKeyBindingService(editor.getEditorSite()); - - } else { - WorkbenchPlugin.log("MultiPageEditorPart.activateSite() Parent key binding service was not an instance of INestableKeyBindingService. It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$ - } - // Activate the services for the new service locator. - final IServiceLocator serviceLocator = editor.getEditorSite(); - if(serviceLocator instanceof INestable) { - activeServiceLocator = (INestable)serviceLocator; - activeServiceLocator.activate(); - } - - } - } - - /** - * Deactivate services: old nested site if any and keybinding service if - * there is no active editor. Deactivate the key binding service. Deactivate - * it only if there is no editor selected. - */ - @SuppressWarnings({ "restriction", "deprecation" }) - private void deactivateServices(boolean immediate) { - // Deactivate the nested services from the last active service locator. - if(activeServiceLocator != null) { - activeServiceLocator.deactivate(); - activeServiceLocator = null; - } - - final IEditorPart editor = getActiveIEditorPart(); - final IKeyBindingService service = getOuterEditorSite().getKeyBindingService(); - if(editor != null || immediate) { - // There is no selected page, so deactivate the active service. - if(service instanceof INestableKeyBindingService) { - final INestableKeyBindingService nestableService = (INestableKeyBindingService)service; - nestableService.activateKeyBindingService(null); - } else { - WorkbenchPlugin.log("MultiPageEditorPart.deactivateSite() Parent key binding service was not an instance of INestableKeyBindingService. It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - - /** - * Send message to the ActionBarContributor, like this it can switch the - * active editor. - */ - private void fireChangeEventToActionBarContributor() { - IEditorActionBarContributor contributor = getOuterEditorSite().getActionBarContributor(); - if(contributor != null && contributor instanceof IMultiPageEditorActionBarContributor) { - ((IMultiPageEditorActionBarContributor)contributor).setActivePage(getActiveIEditorPart()); - } - - // Ensure compatibility with Eclipse MultiPageEditorActionBarContributor - else if(contributor != null && contributor instanceof MultiPageEditorActionBarContributor) { - ((MultiPageEditorActionBarContributor)contributor).setActivePage(getActiveIEditorPart()); - } - - } - - /** - * Return the MultipageEditorSite - * - * @return - */ - private IEditorSite getOuterEditorSite() { - return outerEditorSite; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ActivePageTracker.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ActivePageTracker.java deleted file mode 100644 index b8b11a93ae8..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ActivePageTracker.java +++ /dev/null @@ -1,182 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Logger; - -import org.eclipse.papyrus.sasheditor.editor.IPageChangedListener; -import org.eclipse.papyrus.sasheditor.internal.ActivePageTracker.IActiveEditorChangedListener; - -/** - * Instance of this class track the active Page. When the active Page change, - * the tracker receive an event on {@link #setActiveEditor(PagePart)}, and - * perform following tasks: - *
    - *
  • - call {@link #fireEditorChangeEvent(PagePart, PagePart)}
  • - *
  • - fire events to all registered listeners.
  • - *
- * - * This class allows tow kind of listeners: - * - *
    - *
  • {@link IActiveEditorChangedListener} for internal use (ex: {@link ActiveEditorServicesSwitcher})
  • - *
  • {@link IPageChangedListener} for public API use.
  • - *
- * This class allows to set externally the active editor. - * - * @author dumoulin - * - */ -public class ActivePageTracker { - - /** Log object */ - Logger log = Logger.getLogger(getClass().getName()); - - /** List of listeners */ - private List activeEditorChangedListeners = new ArrayList(); - - /** List of public listeners */ - private List publicPageChangedListeners; - - /** The currently active editor */ - protected PagePart activeEditor; - - /** - * Interface that must be implemented by listeners on activeEditorChange - * event. - * - * @author dumoulin - * - */ - public interface IActiveEditorChangedListener { - - /** - * This method is called whenever the active editor is changed. - * - * @param oldEditor - * @param newEditor - */ - public void activeEditorChanged(PagePart oldEditor, PagePart newEditor); - } - - /** - * Constructor. The activeEditor will be set by the first TabFolder that - * will call TabFolderPart.setPage(). - * - * @param multiPartEditor - */ - public ActivePageTracker() { - } - - /** - * Get the activeEditor. - * - * @return The active editor or null if there is none. - */ - public PagePart getActiveEditor() { - return activeEditor; - } - - /** - * Set the active editor with the specified editor. This will notify all - * registered listeners - * - * @param editor - */ - public void setActiveEditor(PagePart editor) { - // Skip if there is no change - if(activeEditor == editor) - return; - - PagePart oldEditor = activeEditor; - activeEditor = editor; - fireEditorChangeEvent(oldEditor, editor); - } - - /** - * Add a listener on the activeEditorChange event. - * - * @param listener - */ - public void addActiveEditorChangedListener(IActiveEditorChangedListener listener) { - // no duplicate - if(activeEditorChangedListeners.contains(listener)) - return; - activeEditorChangedListeners.add(listener); - } - - /** - * Add a listener on the activeEditorChange event. - * - * @param listener - */ - public void removeActiveEditorChangedListener(IActiveEditorChangedListener listener) { - activeEditorChangedListeners.remove(listener); - } - - /** - * Add a listener on the activeEditorChange event. - * - * @param listener - */ - public void addPageChangedListener(IPageChangedListener listener) { - // no duplicate - if(publicPageChangedListeners == null) - publicPageChangedListeners = new ArrayList(); - - if(publicPageChangedListeners.contains(listener)) - return; - publicPageChangedListeners.add(listener); - } - - /** - * Add a listener on the activeEditorChange event. - * - * @param listener - */ - public void removePageChangedListener(IPageChangedListener listener) { - if(publicPageChangedListeners == null) - return; - - publicPageChangedListeners.remove(listener); - } - - /** - * Notify all listener with event. - * - * @param oldEditor - * @param newEditor - */ - private void fireEditorChangeEvent(PagePart oldEditor, PagePart newEditor) { - // Fire only if really change - // if(oldEditor == newEditor) - // return; - - // Fire events to internal listeners - for(IActiveEditorChangedListener listener : activeEditorChangedListeners) { - listener.activeEditorChanged(oldEditor, newEditor); - } - - // Fire event to public listeners - if(publicPageChangedListeners != null) { - for(IPageChangedListener listener : publicPageChangedListeners) { - listener.pageChanged(newEditor); - } - } - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ComponentPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ComponentPart.java deleted file mode 100644 index 95ecc23a805..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ComponentPart.java +++ /dev/null @@ -1,274 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.papyrus.sasheditor.Activator; -import org.eclipse.papyrus.sasheditor.contentprovider.IComponentModel; -import org.eclipse.papyrus.sasheditor.editor.IComponentPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.internal.dnd.IDropTarget; - -/** - * This is a controler/part for an SWT Control. It is associated to a {@link IComponentModel}. This Part encapsulate a SWT Control. - * - * @author dumoulin - * - */ -@SuppressWarnings("restriction") -public class ComponentPart extends PagePart implements IComponentPage { - - /** - * The model representing the control. - */ - private IComponentModel partModel; - - /** - * The SWT Control. - */ - private Composite editorControl; - - /** - * Constructor. - * - * @param partModel - * The model of the editor. - */ - public ComponentPart(TabFolderPart parent, IComponentModel partModel, Object rawModel) { - super(parent, rawModel); - this.partModel = partModel; - } - - /** - * Create the control of this Part, and children's controls. - * - * @param parent - */ - public void createPartControl(Composite parent) { - - try { - // Initialize it and create its controls. - editorControl = createEditorPartControl(parent); - // attachListeners(editorControl, true); - - } catch (PartInitException e) { - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage())); - } - } - - /** - * Create the controls required by the editor. Init the editor. - * - * @param viewer - * @param editorInput - * @param model - * @return - * @throws PartInitException - */ - private Composite createEditorPartControl(Composite parentControl) throws PartInitException { - Composite editorParent = new Composite(parentControl, SWT.NONE); - editorParent.setLayout(new FillLayout()); - partModel.createPartControl(editorParent); - - return editorParent; - } - - /** - * @param isRecursive - */ - public void dispose() { - - // detachListeners(editorControl, true); - // dispose the SWT root control - editorControl.dispose(); - } - - /** - * As we are a final Tile, we should be the requested part. Return this - * TilePart. - * - * @param toFind - * @return - */ - public PagePart findPart(Point toFind) { - return this; - } - - /** - * Locates the part that intersects the given point and that have the - * expected type - * - * @param toFind - * @return - */ - public PagePart findPartAt(Point toFind, Class expectedTileType) { - - if(expectedTileType == this.getClass()) - return this; - - // Not found !! - // The tile contains the position, but the type is not found. - throw new UnsupportedOperationException("Tile match the expected position '" + toFind + "' but there is no Tile of requested type '" + expectedTileType.getClass().getName() + "'"); - } - - /** - * @param control - * @return - */ - public PagePart findPart(Object control) { - if(getControl() == control) - return this; - - // Not found - return null; - } - - /** - * Get associated SWT Control. - * - * @return - */ - public Composite getControl() { - return editorControl; - } - - /** - * This is a container method. Not necessary in Leaf Tile. TODO: change the - * interface. - * - * @param draggedObject - * @param sourcePart - * @param position - * @return - */ - public IDropTarget getDropTarget(Object draggedObject, TabFolderPart sourcePart, Point position) { - return null; - } - - /** - * Change the parent of the Tile. The parent is changed, and the control is - * attached to the parent control. Change garbage state to {@link GarbageState.REPARENTED}. Do not detach the Tile from its old - * parent. - * - * @param newParent - * The tilePart that should be used as part parent. - * @param compositeParent - * The composite that should be used as parent. - */ - public void reparent(TabFolderPart newParent) { - - // Change the tile parent - this.parent = newParent; - // Change the SWT parent. - editorControl.setParent(newParent.getControl()); - - // Change state - if(garbageState == GarbageState.UNVISITED || garbageState == GarbageState.ORPHANED) { - garbageState = GarbageState.REPARENTED; - } else { - // Bad state, this is an internal error - // TODO : log a warning ? - throw new IllegalStateException("Try to change state from " + garbageState.toString() + " to REPARENTED. This is forbidden."); - } - } - - /** - * Asks this part to take focus within the workbench. Set the focus on the - * active nested part if the part is a container. - */ - public void setFocus() { - editorControl.setFocus(); - } - - /** - * Synchronize the Part, and its children. PartMap contains a snapshot of - * the available part before the synchronization. After synchronization, - * unreachable parts should be marked "orphaned" (= no parent). Do nothing - * in this implementation, as we are a final leaf, and there is nothing to - * synchronize with the underlying model. - * - * @param partMap - */ - public void synchronize2(PartLists partMap) { - - } - - /** - * Garbage this part. The part is already marked as ORPHANED. It is not used - * anymore. It is already detached from its parent. - * - */ - public void garbage() { - dispose(); - // fire appropriate life cycle event - getSashWindowContainer().getLifeCycleEventProvider().firePageClosedEvent(this); - } - - /** - * Accept the provided visitor. Call the corresponding accept method in the - * visitor. - * - * @param visitor - * @return - */ - public boolean visit(IPartVisitor visitor) { - return visitor.accept(this); - } - - /** - * Visit the children of this Tile. There is no child, so do nothing. - * - * @param visitor - */ - public boolean visitChildren(IPartVisitor visitor) { - return true; - } - - /** - * Show item status. - */ - protected void showStatus() { - // System.out.println( "EditorTile: " - // + " disposed=" + editorControl.isDisposed() - // + ", visible=" + editorControl.isVisible() - // + ", garbState=" + garbageState - // + ", '" + editorPart.getTitle() - // + "', " + this); - - System.out.printf("ComponentPart: disposed=%-5b, visible=%-5b, garbState=%-10s, %s, %s\n", editorControl.isDisposed(), (editorControl.isDisposed() ? false : editorControl.isVisible()), garbageState, getPageTitle(), this); - - } - - /** - * Get the title for this part. {@inheritDoc} - */ - @Override - public String getPageTitle() { - return partModel.getTabTitle(); - } - - /** - * Return an icon for this part. {@inheritDoc} - */ - @Override - public Image getPageIcon() { - return partModel.getTabIcon(); - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/Copyright.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/Copyright.java deleted file mode 100644 index dad56534512..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/Copyright.java +++ /dev/null @@ -1,22 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.sasheditor.internal; - -/** - * @author dumoulin - */ -public class Copyright { - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/EditorPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/EditorPart.java deleted file mode 100644 index 918ad9c921b..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/EditorPart.java +++ /dev/null @@ -1,624 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -import java.io.PrintWriter; -import java.io.StringWriter; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.sasheditor.Activator; -import org.eclipse.papyrus.sasheditor.contentprovider.IEditorModel; -import org.eclipse.papyrus.sasheditor.editor.IEditorPage; -import org.eclipse.papyrus.sasheditor.editor.IMultiEditorManager; -import org.eclipse.papyrus.sasheditor.editor.SashWindowsContainer; -import org.eclipse.papyrus.sasheditor.internal.eclipsecopy.MultiPageEditorSite; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IPropertyListener; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.internal.ErrorEditorPart; -import org.eclipse.ui.internal.dnd.IDropTarget; -import org.eclipse.ui.internal.misc.StatusUtil; -import org.eclipse.ui.part.EditorActionBarContributor; -import org.eclipse.ui.part.IWorkbenchPartOrientation; - -/** - * This is a controler/part for an Editor. It is associated to a {@link IEditorModel}. This Part encapsulate an Eclipse Editor implementing - * {@link IEditorPart}. - * - * @author dumoulin - * @author Thomas SZADEL - * Improve the error text (avoid NPE) - */ -@SuppressWarnings("restriction") -public class EditorPart extends PagePart implements IEditorPage { - - /** - * The model representing the editor. - */ - private IEditorModel editorModel; - - /** - * The created Eclipse editor. - */ - private IEditorPart editorPart; - - /** - * The SWT Control containning the editor's controls. - */ - private Composite editorControl; - - /** - * The MultiPageContainer system. This is the manager of all tiles. - */ - private SashWindowsContainer tilesContainer; - - /** - * The manager used to access main editor properties like site, actionbars, - * ... - */ - private IMultiEditorManager multiEditorManager; - - /** - * Parent owning this PagePart. Can be null if the Part is orphaned. Even if - * it is orphaned, the Item still set. - */ - // protected TabFolderPart parent; - - /** - * Listen on mouse enter event. Try to get an event indicating that the - * mouse enter over the editor. This can be used to switch the active - * editor. TODO This doesn't work yet. - */ - private Listener mouseEnterListener = new Listener() { - - /** - * (non-Javadoc) - * - * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) - */ - public void handleEvent(Event event) { - // Point globalPos = new Point(event.x, event.y); - // System.out.println(this.getClass().getSimpleName() + - // ".handleEvent(" + eventName(event.type) + ", " + globalPos + - // ")"); - } - }; - - private String eventName(int eventType) { - switch(eventType) { - case SWT.MouseEnter: - return "MouseEnter"; - case SWT.MouseDown: - return "MouseDown"; - case SWT.MouseExit: - return "MouseExit"; - case SWT.MouseHover: - return "MouseHover"; - case SWT.FocusIn: - return "FocusIn"; - case SWT.FocusOut: - return "FocusOut"; - case SWT.MouseMove: - return "MouseMove"; - case SWT.MouseUp: - return "MouseUp"; - case SWT.Activate: - return "Activate"; - default: - return Integer.toString(eventType); - } - } - - /** - * Constructor. - * - * @param editorModel - * The model of the editor. - */ - public EditorPart(TabFolderPart parent, IEditorModel editorModel, Object rawModel, IMultiEditorManager multiEditorManager) { - super(parent, rawModel); - this.editorModel = editorModel; - this.multiEditorManager = multiEditorManager; - } - - /** - * Create the control of this part. For a this implementations, also create - * the children's controls. This method forward to {@link - * createPartControl(Composite)}. - * - * @param parent - * TODO remove ? - */ - // public void createControl(Composite parent) { - // createPartControl(parent); - // } - - /** - * Create the control of this Part, and children's controls. - * - * @param parent - */ - @Override - public void createPartControl(Composite parent) { - - try { - // Create the editor. - editorPart = createIEditorPart(); - // Initialize it and create its controls. - editorControl = createEditorPartControl(parent, editorPart); - attachListeners(editorControl, true); - } catch (PartInitException e) { - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage(), e)); - // TODO Create a fake Error Page and initialize this part with. - // editorPart = new ErrorEditorPart(); - // editorControl = createEditorPartControl(parent, editorPart); - // editorControl = createErrorPartControl(parent, e); - createErrorEditorPart(parent, e); - } catch (Exception e) { - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage(), e)); - // TODO Create a fake Error Page and initialize this part with. - // editorControl = createErrorPartControl(parent, e); - createErrorEditorPart(parent, e); - } - } - - /** - * Create a Control showing the error. - * - * @param parent - * Parent Control to which the Created Control should be attached - * @param e - * Exception containing the error. - */ - private Composite createErrorPartControl(Composite parent, Exception e) { - - Composite comp = new Composite(parent, SWT.NONE); - comp.setLayout(new FillLayout()); - // Show the stack trace - StringWriter strOut = new StringWriter(); - PrintWriter out = new PrintWriter(strOut); - e.printStackTrace(out); - out.flush(); - out.close(); - - Text diag = new Text(comp, SWT.MULTI); - diag.setSize(64, 32); - - diag.setText(strOut.toString()); - return comp; - } - - /** - * Create an EditorPart showing the Exception. This is used when the - * creation of the regular IEditorPart failed. - * - * @param e - */ - private void createErrorEditorPart(Composite parent, Exception e) { - - try { - PartInitException partInitException = new PartInitException(StatusUtil.getLocalizedMessage(e), StatusUtil.getCause(e)); - editorPart = new ErrorEditorPart(partInitException.getStatus()); - // Initialize it and create its controls. - editorControl = createEditorPartControl(parent, editorPart); - - } catch (Exception ex) { - // Even the ErrorEditorPart creation fail. - // Use a more simple renderer. - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage(), e)); - // TODO Create a fake Error Page and initialize this part with. - editorControl = createErrorPartControl(parent, e); - } - - } - - /** - * Create the editor associated to this TabPart. - * - * @return - * @throws PartInitException - */ - private IEditorPart createIEditorPart() throws PartInitException { - - return editorModel.createIEditorPart(); - } - - /** - * Create the controls required by the editor. Init the editor. - * - * @param viewer - * @param editorInput - * @param model - * @return - * @throws PartInitException - */ - private Composite createEditorPartControl(Composite parentControl, IEditorPart editor) throws PartInitException { - IEditorSite site = createSite(editor); - // call init first so that if an exception is thrown, we have created no - // new widgets - editor.init(site, getIMultiEditorManager().getEditorInput()); - Composite editorParent = new Composite(parentControl, getOrientation(editor)); - editorParent.setLayout(new FillLayout()); - editor.createPartControl(editorParent); - editor.addPropertyListener(new IPropertyListener() { - - public void propertyChanged(Object source, int propertyId) { - EditorPart.this.handlePropertyChange(propertyId); - } - }); - - // TODO test to be removed - // attachListeners(editorParent, false); - return editorParent; - } - - /** - * Attach SWT listeners. - */ - private void attachListeners(Control theControl, boolean recursive) { - - // All following methods listen to the same event. - // So use only one of them - // theControl.addListener(SWT.MouseEnter, mouseEnterListener); - // - // theControl.addListener(SWT.FocusIn, mouseEnterListener); - // theControl.addListener(SWT.MouseMove, mouseEnterListener); - // theControl.addListener(SWT.MouseHover, mouseEnterListener); - // theControl.addListener(SWT.MouseUp, mouseEnterListener); - // theControl.addListener(SWT.MouseDown, mouseEnterListener); - theControl.addListener(SWT.Activate, mouseEnterListener); - - // if (recursive && theControl instanceof Composite) { - // Composite composite = (Composite) theControl; - // Control[] children = composite.getChildren(); - // - // for (int i = 0; i < children.length; i++) { - // Control control = children[i]; - // - // attachListeners(control, true); - // } - // } - } - - /** - * Detach SWT listeners - */ - private void detachListeners(Control theControl, boolean recursive) { - // theControl.removeListener(SWT.MouseEnter, mouseEnterListener); - // theControl.removeListener(SWT.FocusIn, mouseEnterListener); - // theControl.removeListener(SWT.MouseMove, mouseEnterListener); - // theControl.removeListener(SWT.MouseHover, mouseEnterListener); - // theControl.removeListener(SWT.MouseUp, mouseEnterListener); - // theControl.removeListener(SWT.MouseDown, mouseEnterListener); - theControl.removeListener(SWT.Activate, mouseEnterListener); - - // if (recursive && theControl instanceof Composite) { - // Composite composite = (Composite) theControl; - // Control[] children = composite.getChildren(); - // - // for (int i = 0; i < children.length; i++) { - // Control control = children[i]; - // - // detachListeners(control, false); - // } - // } - } - - /** - * Handles a property change notification from a nested editor. The default - * implementation simply forwards the change to listeners on this multi-page - * editor by calling firePropertyChange with the same property - * id. For example, if the dirty state of a nested editor changes (property - * id IEditorPart.PROP_DIRTY), this method handles it by firing - * a property change event for IEditorPart.PROP_DIRTY to - * property listeners on this multi-page editor. - *

- * Subclasses may extend or reimplement this method. - *

- * - * @param propertyId - * the id of the property that changed - */ - private void handlePropertyChange(int propertyId) { - getSashWindowContainer().firePropertyChange(propertyId); - } - - /** - * Creates the site for the given nested editor. The MultiPageEditorPart implementation of this method creates an - * instance of MultiPageEditorSite. Subclasses may reimplement - * to create more specialized sites. - * - * @param editor - * the nested editor - * @return the editor site - */ - protected IEditorSite createSite(IEditorPart editor) { - EditorActionBarContributor contributor = createEditorActionBarContributor(); - return new MultiPageEditorSite(multiEditorManager.getEditorSite(), editor, contributor); - } - - /** - * Create the EditorActionBarContributor requested by the editor. Creation - * is done by delegating to the IMultiEditorNestedPartManager. - * - * @return - */ - private EditorActionBarContributor createEditorActionBarContributor() { - EditorActionBarContributor contributor = editorModel.getActionBarContributor(); - return contributor; - } - - /** - * Get the orientation of the editor. - * - * @param editor - * @return int the orientation flag - * @see SWT#RIGHT_TO_LEFT - * @see SWT#LEFT_TO_RIGHT - * @see SWT#NONE - */ - private int getOrientation(IEditorPart editor) { - if(editor instanceof IWorkbenchPartOrientation) { - return ((IWorkbenchPartOrientation)editor).getOrientation(); - } - return Window.getDefaultOrientation(); - } - - /** - * Get the nested part manager. - * - * @return - */ - private IMultiEditorManager getIMultiEditorManager() { - return multiEditorManager; - } - - /** - * @param isRecursive - */ - public void dispose() { - - detachListeners(editorControl, true); - // dispose the SWT root control - editorControl.dispose(); - // Dispose the editor. - editorPart.dispose(); - } - - /** - * As we are a final Tile, we should be the requested part. Return this - * TilePart. - * - * @param toFind - * @return - */ - public PagePart findPart(Point toFind) { - return this; - } - - /** - * Locates the part that intersects the given point and that have the - * expected type - * - * @param toFind - * @return - */ - @Override - public PagePart findPartAt(Point toFind, Class expectedTileType) { - - if(expectedTileType == this.getClass()) { - return this; - } - - // Not found !! - // The tile contains the position, but the type is not found. - throw new UnsupportedOperationException("Tile match the expected position '" + toFind + "' but there is no Tile of requested type '" + expectedTileType.getClass().getName() + "'"); - } - - /** - * @param control - * @return - */ - public PagePart findPart(Object control) { - if(getControl() == control) { - return this; - } - - // Not found - return null; - } - - /** - * Returns the active nested editor if there is one. - *

- * Subclasses should not override this method - *

- * - * @return the active nested editor, or null if none - */ - public IEditorPart getIEditorPart() { - return editorPart; - } - - /** - * Get associated SWT Control. - * - * @return - */ - @Override - public Composite getControl() { - return editorControl; - } - - /** - * This is a container method. Not necessary in Leaf Tile. TODO: change the - * interface. - * - * @param draggedObject - * @param sourcePart - * @param position - * @return - */ - public IDropTarget getDropTarget(Object draggedObject, TabFolderPart sourcePart, Point position) { - return null; - } - - /** - * @return - */ - @Override - public GarbageState getGarbageState() { - return garbageState; - } - - /** - * Is the associated editor dirty ? Delegate to {@link - * IEditorPart.isDirty()} - * - * @return true if the associated editor is dirty. - * - * @unused - */ - public boolean isDirty() { - return editorPart.isDirty(); - } - - /** - * Change the parent of the Tile. The parent is changed, and the control is - * attached to the parent control. Change garbage state to {@link GarbageState.REPARENTED}. Do not detach the Tile from its old - * parent. - * - * @param newParent - * The tilePart that should be used as part parent. - * @param compositeParent - * The composite that should be used as parent. - */ - @Override - public void reparent(TabFolderPart newParent) { - - // Change the tile parent - this.parent = newParent; - // Change the SWT parent. - editorControl.setParent(newParent.getControl()); - - // Change state - if(garbageState == GarbageState.UNVISITED || garbageState == GarbageState.ORPHANED) { - garbageState = GarbageState.REPARENTED; - } else { - // Bad state, this is an internal error - // TODO : log a warning ? - throw new IllegalStateException("Try to change state from " + garbageState.toString() + " to REPARENTED. This is forbidden."); - } - - } - - /** - * Asks this part to take focus within the workbench. Set the focus on the - * active nested part if the part is a container. - */ - @Override - public void setFocus() { - editorPart.setFocus(); - } - - /** - * Synchronize the Part, and its children. PartMap contains a snapshot of - * the available part before the synchronization. After synchronization, - * unreachable parts should be marked "orphaned" (= no parent). Do nothing - * in this implementation, as we are a final leaf, and there is nothing to - * synchronize with the underlying model. - * - * @param partMap - */ - public void synchronize2(PartLists partMap) { - - } - - /** - * Garbage this part. This part will be not used anymore. The part is - * already marked as ORPHANED. It is not used anymore. It is already - * detached from its parent. - * - */ - @Override - public void garbage() { - dispose(); - // fire appropriate life cycle event - getSashWindowContainer().getLifeCycleEventProvider().firePageClosedEvent(this); - } - - /** - * Accept the provided visitor. Call the corresponding accept method in the - * visitor. - * - * @param visitor - * @return - */ - @Override - public boolean visit(IPartVisitor visitor) { - return visitor.accept(this); - } - - /** - * Visit the children of this Tile. There is no child, so do nothing. - * - * @param visitor - */ - public boolean visitChildren(IPartVisitor visitor) { - return true; - } - - /** - * Show item status. - */ - protected void showStatus() { - // System.out.println( "EditorTile: " - // + " disposed=" + editorControl.isDisposed() - // + ", visible=" + editorControl.isVisible() - // + ", garbState=" + garbageState - // + ", '" + editorPart.getTitle() - // + "', " + this); - String title = (editorPart != null ? editorPart.getTitle() : "no editorPart"); - System.out.printf("EditorTile: disposed=%-5b, visible=%-5b, garbState=%-10s, %s, %s\n", editorControl.isDisposed(), (editorControl.isDisposed() ? false : editorControl.isVisible()), garbageState, title, this); - - } - - /** - * Get the title for this part. {@inheritDoc} - */ - @Override - public String getPageTitle() { - return editorModel.getTabTitle(); - } - - /** - * Return an icon for this part. {@inheritDoc} - */ - @Override - public Image getPageIcon() { - return editorModel.getTabIcon(); - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/IPanelParent.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/IPanelParent.java deleted file mode 100644 index d3c02a1f8d6..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/IPanelParent.java +++ /dev/null @@ -1,43 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -import org.eclipse.papyrus.sasheditor.editor.SashWindowsContainer; -import org.eclipse.swt.widgets.Composite; - -/** - * Interface implemented by Part that can be parent of a Panel (Sashes or - * Folders). The interface allows to restrict the classes that can be parent of - * a Panel. For now, only {@link RootPart} and {@link SashPanelPart} can be - * parent of a Panel. - * - * @author dumoulin - */ -public interface IPanelParent { - - /** - * Get the {@link SashWindowsContainer}. - * - * @return - */ - public SashWindowsContainer getSashWindowContainer(); - - /** - * Get the parent SWT control. - * - * @return - */ - public Composite getControl(); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/IPartVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/IPartVisitor.java deleted file mode 100644 index 538851f11ea..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/IPartVisitor.java +++ /dev/null @@ -1,80 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -/** - * Visitor used to visit the hierarchy of Parts. Visit can be stopped by - * returning false from the visit() method. - * - * @author dumoulin - * - */ -public interface IPartVisitor { - - /** - * Accept the node of specified type. - * - * @param folder - * @return true if the visit should continue, false if the visit should be - * stopped. - */ - - public boolean accept(RootPart tile); - - /** - * Accept the node of specified type. - * - * @param folder - * @return true if the visit should continue, false if the visit should be - * stopped. - */ - public boolean accept(SashPanelPart tile); - - /** - * Accept the node of specified type. - * - * @param folder - * @return true if the visit should continue, false if the visit should be - * stopped. - */ - public boolean accept(TabFolderPart folder); - - /** - * Accept the node of specified type. - * - * @param folder - * @return true if the visit should continue, false if the visit should be - * stopped. - */ - public boolean accept(TabItemPart tile); - - /** - * Accept the node of specified type. - * - * @param folder - * @return true if the visit should continue, false if the visit should be - * stopped. - */ - public boolean accept(EditorPart tile); - - /** - * Accept the node of specified type. - * - * @param componentPart - * @return true if the visit should continue, false if the visit should be - * stopped. - */ - public boolean accept(ComponentPart componentPart); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ImageToolTipManager.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ImageToolTipManager.java deleted file mode 100644 index 3e9a0fdd147..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ImageToolTipManager.java +++ /dev/null @@ -1,346 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -import java.util.logging.Logger; - -import org.eclipse.papyrus.sasheditor.editor.IPageImageUtils; -import org.eclipse.papyrus.sasheditor.internal.preferences.ITabTooltipPreferences; -import org.eclipse.papyrus.sasheditor.internal.preferences.TabTooltipPreferences; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Device; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.graphics.Transform; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; - - -/** - * A class managing tooltips as Part. - * - * @author dumoulin - */ -public class ImageToolTipManager { - - /** Log object */ - Logger log = Logger.getLogger(getClass().getName()); - - protected ITabTooltipPreferences settings = new TabTooltipPreferences(); - - /** */ - private Control toolTipedControl; - - /** - * Size of the image to show. - */ - private Rectangle toolTipExpectedSize = new Rectangle(0, 0, 100, 80); - - private int offsetX = 20; - - private int offsetY = 20; - - /** - * Position of the tooltip relative to the tooltiped swt.Control. - */ - private int toolTipAlignement = SWT.TOP; - - /** - * - */ - private Shell tip = null; - - /** - * Cached value of the image. Use to do dispose when closing. - */ - private Image image = null; - - /** - * Constructor. - */ - public ImageToolTipManager() { - // TODO Auto-generated constructor stub - } - - private void resetTimer() { - if( settings.getTooltipAutoCloseDelay() == -1) - return; - - // do reset timer - } - /** - * Close the tooltip and dispose it. - */ - public void closeToolTip() { - if(tip != null) { - tip.dispose(); - tip = null; - } - if(image != null) { - image.dispose(); - image = null; - } - toolTipedControl = null; - - } - - /** - * Disable the tooltip. - * If the tooltip is shown, hide it. - * In the disable state, calls to showTooltip() with the same Control will not - * show the tooltip again untill another control is proposed. - * A call to closeToolTip() is required to show the same Control again. - */ - public void disableToolTip() { - // Close the tooltip. - if(tip != null) { - tip.dispose(); - tip = null; - } - if(image != null) { - image.dispose(); - image = null; - } - // Keep the control for future checking. - } - - /** - * dispose the tooltip and its resources. - * - */ - public void dispose() { - if(tip != null) { - tip.dispose(); - tip = null; - } - if(image != null) { - image.dispose(); - image = null; - } - toolTipedControl = null; - } - - /** - * Ask to show the tooltip. - * First check if preferences allows to show tooltip. - * - * @param pagePart The PagePart for which a ToolTip should be opened. - * @param flyedControl The control that trigger the tooltip opening - * @param mousePos - */ - public void showToolTip(PagePart pagePart, Rectangle flyedControlBounds, Point mousePos) { - - // If tooltip is already showing for this control, skip. - if(toolTipedControl == pagePart.getControl()) { - resetTimer(); - return; - } - - if( ! settings.isTooltipEnable() ) - return; - - // Check if we are showing the tooltip for current tab. - if( ! settings.isTooltipForCurrentTabShown() && pagePart.getParent().getVisiblePagePart() == pagePart ) { - // close current tooltip if any - closeToolTip(); - return; - } - - doShowToolTip(pagePart, flyedControlBounds, mousePos); - } - - /** - * Do show th tooltip, unless we can't get an image for the part. - * @param pagePart - * @param flyedControlBounds - * @param mousePos - */ - private void doShowToolTip(PagePart pagePart, Rectangle flyedControlBounds, Point mousePos) { - Image image = getPageImage(pagePart); - if(image == null) - return; - - toolTipedControl = pagePart.getControl(); - // Change image scale - float scaleFactor = settings.getScaledFactor(); //.5f; - Image scaledImage = scaledImage(pagePart.getControl().getDisplay(), image, scaleFactor); - image.dispose(); - - // Remember the image to be able to dispose it. - this.image = scaledImage; - - Point pos = computeToolTipPosition(flyedControlBounds, mousePos, scaledImage.getBounds()); - openToolTip(pagePart.getControl(), scaledImage, pos); - } - - /** - * Compute the tooltip position. - * - * @param relatedControlBounds - * Bounds of the item to which the tooltip apply - * @param mousePos - * Position of the mouse inside the relatedControlBounds. - * @param toolTipSize - * Size of the ToolTip. - * - * @return Position of the tooltip - */ - private Point computeToolTipPosition(Rectangle relatedControlBounds, Point mousePos, Rectangle toolTipSize) { - - int x, y; - if(toolTipAlignement == SWT.TOP) { - // Position.x = mousePoint.x - // Position.y = itemBounds - (toolTipSize.y + offsetY) - x = mousePos.x; - y = relatedControlBounds.y - (toolTipSize.height + offsetY); - } else if(toolTipAlignement == SWT.BOTTOM) { - x = mousePos.x; - y = relatedControlBounds.y + (relatedControlBounds.height + offsetY); - } else { - throw new UnsupportedOperationException("Not yet implemented for this alignement."); - } - return new Point(x, y); - } - - /** - * Open a tooltip like window containing the image. - * - * @param device - * The control from which atPoint is specified. - * @param scaledImage - * @param atPoint - */ - private void openToolTip(Control device, Image scaledImage, Point atPoint) { - if(tip != null && !tip.isDisposed()) - tip.dispose(); - tip = new Shell(device.getShell(), SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); - FillLayout layout = new FillLayout(); - layout.marginWidth = 2; - tip.setLayout(layout); - Label label = new Label(tip, SWT.NONE); - label.setImage(scaledImage); - Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT); - Point pt = device.toDisplay(atPoint.x + 20, atPoint.y); - tip.setBounds(pt.x, pt.y, size.x, size.y); - tip.setVisible(true); - } - - /** - * Create an image corresponding to the control. - * - * @param control - * The control for which an image is to be built. - * @return - */ - private Image createControlImage(Control control) { - // Create an image of the part. - - Rectangle size; - - size = control.getBounds(); - if(size.width == 0 && size.height == 0) { - Point pt = control.computeSize(SWT.DEFAULT, SWT.DEFAULT); - size = new Rectangle(0, 0, pt.x, pt.y); - } - - Image image = new Image(control.getDisplay(), size); - GC gc = new GC(image); - - boolean success = control.print(gc); - gc.dispose(); - if(!success) { - image.dispose(); - // log.warning("Can't create Snapshot for the control of '" + part + "'."); - return null; - } - - return image; - } - - /** - * Create an image corresponding to the control. - * - * @param control - * The control for which an image is to be built. - * @return - */ - private Image scaledImage2(Device device, Image image, float factor) { - Rectangle imageBounds = image.getBounds(); - Rectangle size = computeToolTipSize(image, factor); - Image scaledImage = new Image(device, size); - GC gc = new GC(scaledImage); - - gc.drawImage(image, 0, 0, imageBounds.width, imageBounds.height, 0, 0, size.width, size.height); - - return scaledImage; - } - - /** - * Compute the expected size of the tooltip. - * For now, simply return the expected size. - * - * @param image - * @param factor - * @return - */ - private Rectangle computeToolTipSize(Image image, float factor) { - - // Rectangle imageBounds = image.getBounds(); - // Rectangle size; - - return toolTipExpectedSize; - } - - /** - * Create a new image which is the input image scaled. - * - * @param image - * @param factor - * @return - */ - private Image scaledImage(Device device, Image image, float factor) { - - Rectangle bounds = image.getBounds(); - // Float factor = 0.5f; - - Rectangle newBounds = new Rectangle(0, 0, Math.round(bounds.width * factor), Math.round(bounds.height * factor)); - Image scaledImage = new Image(device, newBounds); - GC gc = new GC(scaledImage); - - gc.setAdvanced(true); - gc.setAntialias(SWT.ON); - Transform tr = new Transform(device); - tr.scale(factor, factor); - gc.setTransform(tr); - gc.drawImage(image, 0, 0); - gc.dispose(); - tr.dispose(); - return scaledImage; - } - - /** - * get the Image for the page. - * @param pagePart - * @return - */ - private Image getPageImage( PagePart pagePart ) { - - return IPageImageUtils.getPageImage(pagePart); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/LookupFolderPartByRawModelVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/LookupFolderPartByRawModelVisitor.java deleted file mode 100644 index 4f2a6960c69..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/LookupFolderPartByRawModelVisitor.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.internal; - -/** - * A visitor used to lookup a {@link TabFolderPart} by its raw model. - * - * @author cedric dumoulin - * - */ -public class LookupFolderPartByRawModelVisitor extends PartVisitor { - - private Object rawModel; - - private TabFolderPart result; - - public LookupFolderPartByRawModelVisitor(Object rawModel) { - this.rawModel = rawModel; - } - - /** - * Get the result of the lookup. - * - * @return - */ - public TabFolderPart result() { - return result; - } - - /** - * Check if the part is for the specified rawModel. - * - * @param part - * @return - */ - private boolean isModelFor(TabFolderPart part) { - - if(part.getRawModel() == rawModel) { - result = part; - return true; - } - // stop looking - return false; - } - - /** - * Check if it is this Component - */ - @Override - protected boolean acceptTabFolderPart(TabFolderPart part) { - if(isModelFor(part)) - return false; - - // Continue looking - return true; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/LookupIPageByIEditorPartVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/LookupIPageByIEditorPartVisitor.java deleted file mode 100644 index a5f2e1171bf..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/LookupIPageByIEditorPartVisitor.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.internal; - -import org.eclipse.papyrus.sasheditor.editor.IPage; -import org.eclipse.ui.IEditorPart; - -/** - * A visitor used to lookup a PagePart by its IEditorPart. - * - * @author cedric dumoulin - * - */ -public class LookupIPageByIEditorPartVisitor extends PartVisitor { - - private IEditorPart editorPart; - - private IPage result; - - public LookupIPageByIEditorPartVisitor(IEditorPart editorPart) { - this.editorPart = editorPart; - } - - /** - * Get the result of the lookup. - * - * @return - */ - public IPage result() { - return result; - } - - /** - * Check if the part is for the specified rawModel. - * - * @param part - * @return - */ - private boolean isModelFor(EditorPart part) { - - if(part.getIEditorPart() == editorPart) { - result = part; - return true; - } - // stop looking - return false; - } - - /** - * Check if it is this IEditor - */ - @Override - protected boolean acceptEditorTile(EditorPart part) { - if(isModelFor(part)) - return false; - - // Continue looking - return true; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/LookupModelPageVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/LookupModelPageVisitor.java deleted file mode 100644 index f78a8456981..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/LookupModelPageVisitor.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.internal; - -import org.eclipse.papyrus.sasheditor.editor.IPage; - -/** - * A visitor used to lookup a PagePart from its raw model. - * - * @author cedric dumoulin - * - */ -public class LookupModelPageVisitor extends PartVisitor { - - private Object rawModel; - - private IPage result; - - public LookupModelPageVisitor(Object rawModel) { - this.rawModel = rawModel; - } - - /** - * Get the result of the lookup. - * - * @return - */ - public IPage result() { - return result; - } - - /** - * Check if the part is for the specified rawModel. - * - * @param part - * @return - */ - private boolean isModelFor(PagePart part) { - - if(part.getRawModel() == rawModel) { - result = part; - return true; - } - // stop looking - return false; - } - - /** - * Check if it is this Component - */ - @Override - protected boolean acceptEditorTile(ComponentPart part) { - if(isModelFor(part)) - return false; - - // Continue looking - return true; - } - - /** - * Check if it is this IEditor - */ - @Override - protected boolean acceptEditorTile(EditorPart part) { - if(isModelFor(part)) - return false; - - // Continue looking - return true; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/NotFoundException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/NotFoundException.java deleted file mode 100644 index e24e901069d..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/NotFoundException.java +++ /dev/null @@ -1,60 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -/** - * Exception thrown when a search or lookup fails. - * - * @author dumoulin - */ -public class NotFoundException extends SashWindowsException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * - */ - public NotFoundException() { - // TODO Auto-generated constructor stub - } - - /** - * @param message - */ - public NotFoundException(String message) { - super(message); - // TODO Auto-generated constructor stub - } - - /** - * @param cause - */ - public NotFoundException(Throwable cause) { - super(cause); - // TODO Auto-generated constructor stub - } - - /** - * @param message - * @param cause - */ - public NotFoundException(String message, Throwable cause) { - super(message, cause); - // TODO Auto-generated constructor stub - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PTabFolder.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PTabFolder.java deleted file mode 100644 index 1c28a352ad6..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PTabFolder.java +++ /dev/null @@ -1,495 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.jface.util.Geometry; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.custom.CTabFolder2Adapter; -import org.eclipse.swt.custom.CTabFolderEvent; -import org.eclipse.swt.custom.CTabItem; -import org.eclipse.swt.events.MenuDetectEvent; -import org.eclipse.swt.events.MenuDetectListener; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.ui.internal.dnd.DragUtil; -import org.eclipse.ui.presentations.PresentationUtil; - -/** - * Papyrus wrapper for CTabFolder. Provides miscelaneous methods for dragging. - * Provides different fireEvents for: menu detected, pageChange, itemClosed. - * TODO : add listeners mechanism to listen on events ? - */ -@SuppressWarnings("restriction") -public class PTabFolder { - - /** - * The underlying tabfolder. - */ - protected CTabFolder tabFolder; - - /** - * This object allows to register listeners on event from this class. - */ - private EventsManager listenersManager = new EventsManager(); - - private Listener dragListener = new Listener() { - - public void handleEvent(Event e) { - Point globalPos = ((Control)e.widget).toDisplay(e.x, e.y); - handleDragStarted(globalPos, e); - } - }; - - /** - * Listener on control activated event. This event is used to set the tab as - * the active page. - */ - private Listener activateListener = new Listener() { - - public void handleEvent(Event e) { - Point globalPos = ((Control)e.widget).toDisplay(e.x, e.y); - handleFolderReselected(globalPos, null); - } - }; - - /** - * Listen on menu detect. The event is forwarded. TODO [20100417] deprecated - * ? - */ - private MenuDetectListener menuDetectListener = new MenuDetectListener() { - - public void menuDetected(MenuDetectEvent e) { - // Point globalPos = ((Control) e.widget).toDisplay(e.x, e.y); - Point globalPos = new Point(e.x, e.y); - handleMenuDetect(globalPos, e); - } - - }; - - /** - * Get the underlying control. - */ - public Composite getControl() { - return tabFolder; - } - - /** - * Create the corresponding SWT Control - */ - public void createPartControl(Composite parent) { - tabFolder = createContainer(parent); - - // Attach listeners - attachListeners(tabFolder, false); - } - - /** - * Creates an empty container. Creates a CTabFolder with no style bits set, - * and hooks a selection listener which calls pageChange() whenever the selected tab changes. - * - * @param parent - * The composite in which the container tab folder should be - * created; must not be null. - * @return a new container - */ - private CTabFolder createContainer(Composite parent) { - // use SWT.FLAT style so that an extra 1 pixel border is not reserved - // inside the folder - parent.setLayout(new FillLayout()); - final CTabFolder newContainer = new CTabFolder(parent, SWT.BOTTOM | SWT.FLAT | SWT.CLOSE); - - // TODO Move listener init in appropriate method. - newContainer.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - int newPageIndex = newContainer.indexOf((CTabItem)e.item); - firePageChange(newPageIndex); - } - }); - - // Test for the close icon. Need style=SWT.CLOSE - // addCTabFolderListener is required :-( - newContainer.setUnselectedCloseVisible(false); - newContainer.addCTabFolder2Listener(new CTabFolder2Adapter() { - - @Override - public void close(CTabFolderEvent event) { - int pageIndex = newContainer.indexOf((CTabItem)event.item); - event.doit = false; - fireItemClosed(event, pageIndex); - } - }); - return newContainer; - } - - /** - * Dispose internal resources. - */ - public void dispose() { - if(tabFolder.isDisposed()) - return; - - detachListeners(tabFolder); - tabFolder.dispose(); - } - - /** - * Copied from org.eclipse.ui.internal.presentations.util.AbstractTabFolder. - * attachListeners(Control, boolean) - */ - protected void attachListeners(CTabFolder theControl, boolean recursive) { - - // Listen to menu event - theControl.addMenuDetectListener(menuDetectListener); - // Listen to drag event - PresentationUtil.addDragListener(theControl, dragListener); - - theControl.addListener(SWT.Activate, activateListener); - - } - - /** - * Copied from org.eclipse.ui.internal.presentations.util.AbstractTabFolder. - * detachListeners(Control, boolean) - */ - private void detachListeners(Control theControl) { - theControl.removeMenuDetectListener(menuDetectListener); - // - PresentationUtil.removeDragListener(theControl, dragListener); - // theControl.removeDragDetectListener(dragDetectListener); - // theControl.removeListener(SWT.MouseUp, mouseUpListener); - theControl.removeListener(SWT.Activate, activateListener); - } - - /** - * The context menu event has been fired, handle it. Actually, it is - * forwarded to the {@link EventsManager}. - * - * @param displayPos - * @param e - */ - protected void handleContextMenu(Point displayPos, Event e) { - - CTabItem tab = getItem(displayPos); - listenersManager.fireContextMenuEvent(tab, e); - } - - /** - * Called when drag start. From here, DragUtil.performDrag() is called, - * which start the dragging process. DragUtil.performDrag() will contains - * the tabFolder or the dragged tab. - */ - protected void handleDragStarted(Point displayPos, Event e) { - - CTabItem tab = getItem(displayPos); - - boolean allowSnapping = true; - Rectangle sourceBounds = Geometry.toDisplay(tabFolder.getParent(), tabFolder.getBounds()); - if(tab == null) { // drag folder - DragUtil.performDrag(tabFolder, sourceBounds, displayPos, allowSnapping); - } else { // drag item - DragUtil.performDrag(tab, sourceBounds, displayPos, allowSnapping); - } - } - - /** - * Handle menu detect. TODO Connect menu staff here. - * - * @param displayPos - * @param e - */ - private void handleMenuDetect(Point displayPos, MenuDetectEvent e) { - - // if(isOnBorder(displayPos)) { - // return; - // } - - CTabItem tab = getItem(displayPos); - listenersManager.fireMenuDetectEvent(tab, e); - } - - /** - * Handle folder reselected. A folder is reselected by clicking on the - * active tabs, on the page or on the empty tabs area. In each case a - * PageChangeEvent is fired. When mouse click happen on the empty area, or - * on the page, the last selected tabs is used. Used to switch the Active - * tab when user click on already opened tabs. - * - * @param displayPos - * @param e - */ - private void handleFolderReselected(Point displayPos, MouseEvent e) { - int itemIndex = getItemIndex(displayPos); - // If click is not from an item, it can come from a click on border. - // restore the last selected item - if(itemIndex == -1) - itemIndex = tabFolder.getSelectionIndex(); - if(itemIndex == -1) - return; - - listenersManager.firePageChange(itemIndex); - } - - /** - * Returns true iff the given point is on the border of the folder. By - * default, double-clicking, context menus, and drag/drop are disabled on - * the folder's border. - * - * @param toTest - * a point (display coordinates) - * @return true iff the point is on the presentation border - * @since 3.1 - */ - private boolean isOnBorder(Point toTest) { - Control content = getControl(); - if(content != null) { - Rectangle displayBounds = DragUtil.getDisplayBounds(content); - - if(tabFolder.getTabPosition() == SWT.TOP) { - return toTest.y >= displayBounds.y; - } - - if(toTest.y >= displayBounds.y && toTest.y < displayBounds.y + displayBounds.height) { - return true; - } - } - - return false; - } - - /** - * Get the item under the specified position. - */ - public CTabItem getItem(Point toFind) { - CTabItem[] items = tabFolder.getItems(); - - for(CTabItem item : items) { - if(getItemBounds(item).contains(toFind)) { - return item; - } - } - - return null; - } - - public int getItemIndex(Point pt) { - CTabItem item = tabFolder.getItem(pt); - if(item == null) - return -1; - return getItemIndex(item); - } - - /** - * Get the rectangle bounding the item, in the parent coordinates. Utility - * method. Can be moved somewhere else. - */ - public Rectangle getItemBounds(CTabItem item) { - return Geometry.toDisplay(item.getParent(), item.getBounds()); - } - - /** - * Fire a page closed event. This event is fired when the close item is - * pressed. The item is not closed yet. By default, the item is closed after - * the event. The item is not closed if event.doit is set to false. - * - */ - protected void fireItemClosed(CTabFolderEvent event, int pageIndex) { - listenersManager.fireItemClosed(event, pageIndex); - - } - - /** - * Fire a PageChangeEvent. - */ - protected void firePageChange(int newPageIndex) { - listenersManager.firePageChange(newPageIndex); - } - - /** - * @return the tabFolder - */ - public CTabFolder getTabFolder() { - return tabFolder; - } - - /** - * Get bounds of the tabs area in display coordinate. - */ - public Rectangle getTabArea() { - Rectangle bounds = DragUtil.getDisplayBounds(tabFolder); - // - if(tabFolder.getTabPosition() == SWT.TOP) { - bounds.height = tabFolder.getTabHeight(); - } else { // bottom - bounds.y = bounds.y + bounds.height - tabFolder.getTabHeight(); - bounds.height = tabFolder.getTabHeight(); - } - - return bounds; - } - - /** - * Get the index of the draggedObject - * - * @param draggedObject - * draggedObject should be of type CTabFolder or CTabItem (as - * provided by handleDragStarted()) - */ - static public int getDraggedObjectTabIndex(Object draggedObject) { - if(draggedObject instanceof CTabItem) { - CTabItem item = (CTabItem)draggedObject; - int index = getItemIndex(item); - return index; - } else if(draggedObject instanceof CTabFolder) { - return -1; - } - - return -2; - } - - /** - * Get the item index or -1 if not found. - */ - static private int getItemIndex(CTabItem item) { - CTabItem[] items = item.getParent().getItems(); - - for(int i = 0; i < items.length; i++) { - CTabItem cur = items[i]; - - if(cur == item) { - return i; - } - } - - return -1; - } - - /** - * Get the event manager. The event manager can be used to listen to events. - * - * @return - */ - public EventsManager getEventManager() { - return listenersManager; - } - - /** - * Interface to ne implemented by listeners on PTabFodler events. - * - * @author dumoulin - * - */ - public interface IPTabFolderListener { - - /** - * - * @param tab - * @param event - */ - public void menuDetectEvent(CTabItem tab, MenuDetectEvent event); - - public void contextMenuDetectEvent(CTabItem tab, Event event); - - public void itemClosedEvent(CTabFolderEvent event, int pageIndex); - - public void pageChangeEvent(int newPageIndex); - } - - /** - * Internal implementations. Implements a list of listeners. - * - * @author dumoulin - * - */ - public class EventsManager { - - /** - * List of event listeners. - */ - Set listeners = new HashSet(); - - /** - * Add a listener - * - * @param listener - */ - public void addListener(IPTabFolderListener listener) { - listeners.add(listener); - } - - /** - * Remove a listener - * - * @param listener - */ - public void removeListener(IPTabFolderListener listener) { - listeners.remove(listener); - } - - /** - * @param tab - * @param e - */ - public void fireContextMenuEvent(CTabItem tab, Event event) { - for(IPTabFolderListener cur : listeners) { - cur.contextMenuDetectEvent(tab, event); - } - } - - /** - * @param event - * @param pageIndex - */ - private void fireItemClosed(CTabFolderEvent event, int pageIndex) { - for(IPTabFolderListener cur : listeners) { - cur.itemClosedEvent(event, pageIndex); - } - } - - /** - * @param newPageIndex - */ - private void firePageChange(int newPageIndex) { - for(IPTabFolderListener cur : listeners) { - cur.pageChangeEvent(newPageIndex); - } - } - - /** - * Fire the event to all listeners - * - * @param e - * @param tab - */ - private void fireMenuDetectEvent(CTabItem tab, MenuDetectEvent e) { - for(IPTabFolderListener cur : listeners) { - cur.menuDetectEvent(tab, e); - } - } - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PagePart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PagePart.java deleted file mode 100644 index 9de1c0941e6..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PagePart.java +++ /dev/null @@ -1,209 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -import org.eclipse.papyrus.sasheditor.editor.IPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * This class represent a leaf part that is a part containing an editor or a - * component. - * - * @author dumoulin - */ -public abstract class PagePart extends AbstractPart implements IPage { - - /** - * Raw model associated to this part. We store it because the PartModel do - * not provide it - */ - protected Object rawModel; - - /** Parent part of this Part */ - protected TabFolderPart parent; - - /** - * Constructor. - * - * @param sashWindowsContainer - */ - public PagePart(TabFolderPart parent, Object rawModel) { - super(parent.getSashWindowContainer()); - this.parent = parent; - this.rawModel = rawModel; - } - - /** - * @return the parent - */ - public TabFolderPart getParent() { - return parent; - } - - /** - * Orphan this node. The parent is set to null, but control is left - * unchanged. The node can be reattached with reparent(). Change garbage - * state to {@link GarbageState.ORPHANED}. This method as no effect if the - * Page has already been reparented. - * - * @see - * @return the parent - */ - public void orphan() { - // orphan only if we are in COLLECTED state - if(garbageState == GarbageState.UNVISITED) { - garbageState = GarbageState.ORPHANED; - parent = null; - } - } - - /** - * Mark this Page as UNCHANGED. The PAge should be in the COLLECTED state. - * - * @see - * @return the parent - */ - public void unchanged() { - // orphan only if we are in COLLECTED state - if(garbageState == GarbageState.UNVISITED || garbageState == GarbageState.ORPHANED) { - garbageState = GarbageState.UNCHANGED; - } else { - // Bad state, this is an internal error - // TODO : log a warning ? - throw new IllegalStateException("Try to change state from " + garbageState.toString() + " to UNCHANGED. This is forbidden."); - } - } - - /** - * Visit this part. - * - * @param visitor - * @return true if the visit should continue, false otherwise. - */ - abstract boolean visit(IPartVisitor visitor); - - /** - * Locates the part that intersects the given point and that have the - * expected type. For a leaf, return the leaf if it is of the expected type. - * - * @param position - * @param expectedTileType - * @return - */ - public AbstractPart findPartAt(Point position, Class expectedTileType) { - - if(expectedTileType == this.getClass()) - return this; - - return null; - } - - /** - * Create the control of this Part, and children's controls. - * - * @param parent - */ - abstract public void createPartControl(Composite parent); - - /** - * Get the control associated to this Part. - * - * @return - */ - abstract public Control getControl(); - - /** - * reparent this Part with the specified new parent. The part is marked as - * reparented. - * - * @param parent - */ - abstract public void reparent(TabFolderPart parent); - - /** - * Add the tree of parts starting from this part. As we are a leaf, add - * itself only. - * - * @param partMap - */ - public void fillPartMap(PartLists partMap) { - partMap.addLeaf(this); - garbageState = GarbageState.UNVISITED; - } - - /** - * Get the raw model associated to this Part. - * - * @return - */ - public Object getRawModel() { - return rawModel; - } - - /** - * Return a title for this part. This title can be used by parent to be - * shown in tabs ... To be implemented by subclasses. - * - * @return The title or null. - */ - public String getPageTitle() { - return null; - } - - /** - * Return a icon for this part. This title can be used by parent to be shown - * in tabs ... To be implemented by subclasses. - * - * @return The icon or null. - */ - public Image getPageIcon() { - return null; - } - - /** - * Refresh the tab of this page (I.e the name and icon in the tab). - */ - public void refreshTab() { - getParent().refreshPageTab(this); - } - - /** - * Set focus on the SWT control associated to this PagePart. Used by the - * ActivePageTracker. - */ - abstract public void setFocus(); - - /** - * Garbage the part. - */ - abstract public void garbage(); - - /** - * Return true if the part is associated to the specified rawModel. Return - * false otherwise. - * - * @param realModel - * @return - */ - public boolean isPartFor(Object realModel) { - return this.rawModel == realModel; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PageVisitorWrapper.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PageVisitorWrapper.java deleted file mode 100644 index 0a900678b5d..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PageVisitorWrapper.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.internal; - -import org.eclipse.papyrus.sasheditor.editor.IEditorPage; -import org.eclipse.papyrus.sasheditor.editor.IPageVisitor; - -/** - * A wrapper used to let the provided public visitor use the internal visitor to - * visit {@link ComponentPart} and {@link EditorPart}. - * - * @author Cedric dumoulin - * - */ -public class PageVisitorWrapper extends PartVisitor { - - /** - * The public visitor. - */ - private IPageVisitor pageVisitor; - - /** - * @param pageVisitor - */ - public PageVisitorWrapper(IPageVisitor pageVisitor) { - super(); - this.pageVisitor = pageVisitor; - } - - /** - * We visit a Component part - */ - @Override - public boolean acceptEditorTile(ComponentPart part) { - pageVisitor.accept(part); - return true; - } - - /** - * We visit an {@link EditorPart}. - */ - @Override - public boolean acceptEditorTile(EditorPart part) { - pageVisitor.accept((IEditorPage)part); - return true; - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PartLists.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PartLists.java deleted file mode 100644 index 0c33340a245..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PartLists.java +++ /dev/null @@ -1,155 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class contains lists of parts, regardless of the part parents. There are - * two lists: one for the pane Parts and one for the Page Parts (leafs). This - * class is used when refreshing the SashContainer: a new instance is created - * and filled with existing parts. Then the list is carried in each pane refresh - * method. - * - * @author cedric dumoulin - */ -public class PartLists { - - private List pageParts = new ArrayList(); - - private List panelParts = new ArrayList(); - - /** List of created pages during synchronization */ - private List createdPages /* = new ArrayList() */; - - /** - * Search for a Part associated to the specified newModel. Return the part - * or null if none is found. - * - * @param rawModel - * @return - */ - public PagePart findPagePartFor(Object rawModel) { - - for(PagePart part : pageParts) { - if(part.isPartFor(rawModel)) - return part; - } - return null; - } - - /** - * Find the pane part for the specified rawModel. Return the found part or - * null - * - * @param rawModel - * The raw model for which a part is lookup. - * @return - */ - public AbstractPanelPart findPartFor(Object rawModel) { - - for(AbstractPanelPart part : panelParts) { - if(part.isPartFor(rawModel)) - return part; - } - - return null; - } - - /** - * Add a leaf part to the lists. - * - * @param pagePart - */ - public void addLeaf(PagePart pagePart) { - pageParts.add(pagePart); - } - - /** - * Add the partPane to the lists. - * - * @param panelPart - */ - public void addPart(AbstractPanelPart panelPart) { - panelParts.add(panelPart); - - } - - /** - * Garbage orphaned elements. - */ - public void garbage() { - // Remove orphaned part (no more used) - for(AbstractPanelPart part : panelParts) { - if(part.isOrphaned()) - part.dispose(); - } - - // Remove orphaned part (no more used) - for(PagePart part : pageParts) { - if(part.isOrphaned()) - part.garbage(); - } - } - - /** - * Get the first non orphaned page, or null if none exists. - * - * @return a valid active page, or null if none exists. - */ - public PagePart getFirstValidPage() { - - for(PagePart part : pageParts) { - if(!part.isOrphaned()) - return part; - } - - // No page - return null; - } - - /** - * Get the first created page if any. - * - * @return a valid active page, or null if none exists. - */ - public PagePart getFirstCreatedPage() { - - if(createdPages == null) - return null; - - if(createdPages.size() > 0) - return createdPages.get(0); - - // No page - return null; - } - - /** - * Add a PagePart to the list of created Page. This is called from the - * TabFolder when a new page is created. - * - * @param modelPart - */ - public void addCreatedPage(PagePart newPage) { - - if(createdPages == null) - createdPages = new ArrayList(); - - createdPages.add(newPage); - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PartVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PartVisitor.java deleted file mode 100644 index 968520e4264..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/PartVisitor.java +++ /dev/null @@ -1,167 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -/** - * Visitor implementation allowing to visit the hierarchy of Parts. - * - * @author dumoulin - * - */ -public class PartVisitor implements IPartVisitor { - - /** - * Visit the specified type, and then visit the children ... - * - * @param folder - */ - public boolean accept(TabFolderPart part) { - - if(acceptTabFolderPart(part)) { - // Visit the children - return part.visitChildren(this); - } - - // stop visiting - return false; - } - - /** - * Visit the specified type, and then visit the childs.. - * - * @param folder - */ - public boolean accept(RootPart part) { - - if(acceptRootPart(part)) { - // Visit the children - return part.visitChildren(this); - } - // stop visiting - return false; - } - - /** - * Visit the specified type, and then visit the children.. - * - * @param folder - */ - public boolean accept(SashPanelPart part) { - if(acceptSashPanelPart(part)) { - // Visit the children - return part.visitChildren(this); - } - // stop visiting - return false; - } - - /** - * Visit the specified type, and then visit the children.. - * - * @param folder - */ - public boolean accept(TabItemPart part) { - if(acceptTabItemPart(part)) { - // Visit the children - return part.visitChildren(this); - } - // stop visiting - return false; - } - - /** - * Visit the specified type, and then visit the children.. - * - * @param part - */ - public boolean accept(EditorPart part) { - if(acceptEditorTile(part)) { - // Visit the children - return part.visitChildren(this); - } - // stop visiting - return false; - } - - /** - * Visit the specified type, and then visit the children .. - * - * @param part - */ - public boolean accept(ComponentPart part) { - if(acceptEditorTile(part)) { - // Visit the children - return part.visitChildren(this); - } - // stop visiting - return false; - } - - // ---------------------------------------------- - - /** - * Visit the specified type. - * - * @param part - */ - protected boolean acceptRootPart(RootPart part) { - return true; - } - - /** - * Visit the specified type. - * - * @param part - */ - protected boolean acceptSashPanelPart(SashPanelPart part) { - return true; - } - - /** - * Visit the specified type. - * - * @param part - */ - protected boolean acceptTabFolderPart(TabFolderPart part) { - return true; - } - - /** - * Visit the specified type. - * - * @param part - */ - protected boolean acceptTabItemPart(TabItemPart part) { - return true; - } - - /** - * Visit the specified type. - * - * @param part - */ - protected boolean acceptEditorTile(EditorPart part) { - return true; - } - - /** - * Visit the specified type. - * - * @param part - */ - protected boolean acceptEditorTile(ComponentPart part) { - return true; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ReplaceableSashForm.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ReplaceableSashForm.java deleted file mode 100644 index 2318f0920c4..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ReplaceableSashForm.java +++ /dev/null @@ -1,71 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * Allows to replace one of the window - */ -public class ReplaceableSashForm extends SashForm { - - private Composite leftComposite; - - private Composite rightComposite; - - public ReplaceableSashForm(Composite parent, int style) { - super(parent, style); - - leftComposite = new Composite(this, 0); - leftComposite.setLayout(new FillLayout()); - rightComposite = new Composite(this, 0); - rightComposite.setLayout(new FillLayout()); - } - - public Composite getLeftParent() { - return leftComposite; - } - - public Composite getRightParent() { - return rightComposite; - } - - /** - * Reparent the provided control to have the leftPart parent. - */ - public void setLeftControl(Control control) { - if(leftComposite == null) { - leftComposite = new Composite(this, 0); - } - - // reparent the control - control.setParent(leftComposite); - } - - /** - * Reparent the provided control to have the leftPart parent. - */ - public void setRightControl(Control control) { - if(rightComposite == null) { - rightComposite = new Composite(this, 0); - } - - // reparent the control - control.setParent(rightComposite); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/RootPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/RootPart.java deleted file mode 100644 index b984cbf5c71..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/RootPart.java +++ /dev/null @@ -1,324 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -import org.eclipse.papyrus.sasheditor.contentprovider.IAbstractPanelModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashPanelModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel; -import org.eclipse.papyrus.sasheditor.editor.SashWindowsContainer; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; - -/** - * Part used as root. This is the one with no parent and no model. This class is - * intended for local use only. - * - * @author dumoulin - * - * @param T - * Common ancestor for the model provided for the sash windows by the - * application. This is the type used externally by the application. - * Sash implementation don't use this type, it just carry it to ask - * for the appropriate wrapper. Concrete implementation can specify a - * type. - */ -@SuppressWarnings("restriction") -public class RootPart extends AbstractPart implements IPanelParent { - - /** The SWT container used as parent of all */ - private Composite container; - - /** - * The first SWT controled part; - */ - private AbstractPanelPart child; - - /** - * Raw model associated to this part. We store it because the PartModel do - * not provide it - */ - private Object rawModel; - - /** - * Constructor. - */ - public RootPart(SashWindowsContainer sashWindowsContainer) { - super(sashWindowsContainer); - } - - /** - * Create the SWT controls. This Root as no control. Create the child part - * and call the same method on the child. - */ - public void createPartControl(Composite parent) { - this.container = parent; - Object rawModel = getContentProvider().getRootModel(); - - // Create child part - // child = createChildPart(rawModel); - } - - /** - * Dispose this part. - */ - public void dispose() { - if(child != null) - child.dispose(); - } - - /** - * Get control associated to this part. - */ - public Composite getControl() { - return container; - } - - /** - * Create the part for the specified child model. The controls are also - * builds. - * - * TODO: delegate to sashContainer. - * - * @param rootPart - * @param partModel - * @return - */ - private AbstractPanelPart createChildPart(Object rawModel) { - - // Create the child PartModel. Delegate creation to the root PartModel. - IAbstractPanelModel model = getPartModel().createChildSashModel(rawModel); - - AbstractPanelPart createdPart; - if(model instanceof ITabFolderModel) { - createdPart = new TabFolderPart(this, (ITabFolderModel)model, rawModel); - } else if(model instanceof ISashPanelModel) { - createdPart = new SashPanelPart(this, (ISashPanelModel)model, rawModel); - } else { - // error - throw new IllegalArgumentException("Can't create child part for model of type '" + model.getClass().getName() + "'"); - // TODO: Return an error Part showing the exception instead of - // throwing it ? - } - - // Create controls - createdPart.createPartControl(getControl()); - return createdPart; - - } - - /** - * Get the PartModel associated to this Part. - * - * @return - */ - private ISashWindowsContentProvider getPartModel() { - // The associated model for a root is the ContentProvider. - return getSashWindowContainer().getContentProvider(); - } - - /** - * Synchronize the part and its children. - * - * @param partMap - */ - public void synchronize2(PartLists partMap) { - - // Synchronize locally the child - synchronizeChild(partMap); - // Synchronize recursively subchilds. - if(child != null) - child.synchronize2(partMap); - - } - - /** - * Synchronize locally the child - * - * @param partMap - */ - private void synchronizeChild(PartLists partMap) { - - // Get the new raw model - Object rawModel = getContentProvider().getRootModel(); - - // Check if old child exist - // If exist, check if the current part is associated to the checked - // model - // - if(child != null) { - // If the tile is already for the model, there is nothing to do. - if(child.isPartFor(rawModel)) { - child.unchanged(); - return; - } - // The current tile is not for the model: mark it as orphan - child.orphan(); - } - - // The child tile need to be updated. Do it. - // First check if already exist in the map - AbstractPanelPart newPart = partMap.findPartFor(rawModel); - if(newPart != null) { - // Reparent the tile - newPart.reparent(this, getControl()); - } else { - // create the tile and its control - newPart = createChildPart(rawModel); - } - - // Now, put the tile on the right side - setChild(newPart); - } - - /** - * Set the child. If a child already exist at the specified index, it is - * lost. - * - * @param newTile - */ - private void setChild(AbstractPanelPart newTile) { - child = newTile; - } - - /** - * Get the Composite used as parent for childs. - * - * @return - */ - private Composite getChildParent() { - // This is the rootContainer - return container; - } - - /** - * Fill partMap with the children. - * - * @param partMap - */ - public void fillPartMap(PartLists partMap) { - if(child != null) - child.fillPartMap(partMap); - - } - - /** - * Find The AbstractPart under the specified position. - */ - public AbstractPart findPart(Point toFind) { - if(child != null) - try { - return child.findPart(toFind); - } catch (NotFoundException e) { - System.err.println(e.getMessage()); - return null; - } - else - return null; - } - - // /** - // * Locates the part that intersects the given point and that have the - // expected type - // * - // * @param toFind - // * @return - // */ - // public AbstractPart findPartAt(Point toFind, Class tileType) { - // return child.findPartAt(toFind, tileType); - // } - - /** - * - */ - public AbstractPart findPart(Object control) { - if(child != null) - return child.findPart(control); - else - return null; - } - - // /** - // * @see - // org.eclipse.papyrus.sasheditor.sash.ITilePart#getDropTarget(java.lang.Object, - // org.eclipse.papyrus.sasheditor.sash.TabFolderPart, - // org.eclipse.swt.graphics.Point) - // */ - // public IDropTarget getDropTarget(Object draggedObject, TabFolderPart - // sourcePart, Point position) { - // return child.getDropTarget(draggedObject, sourcePart, position); - // } - - /** - * Do nothing. This node can't be orphaned - * - */ - public void orphan() { - // Do nothing. This node can't be orphaned - } - - /** - * Always return false. This Part can't be orphaned. - * - * @see org.eclipse.papyrus.sasheditor.internal.AbstractPart#isOrphaned() - * - * @return - */ - public boolean isOrphaned() { - return false; - } - - /** - * Get the Garbage state. - * - * @see org.eclipse.papyrus.sasheditor.internal.AbstractPart#getGarbageState() - * - * @return - */ - public GarbageState getGarbageState() { - return GarbageState.UNVISITED; - } - - /** - * Accept the provided visitor. Call the corresponding accept method in the - * visitor. - * - * @param visitor - * @return - */ - public boolean visit(IPartVisitor visitor) { - return visitor.accept(this); - } - - /** - * Visit the children of this Tile. - * - * @param visitor - */ - public boolean visitChildren(IPartVisitor visitor) { - if(child != null) - return child.visit(visitor); - - // Return the default value - return true; - } - - /** - * Show tile status. - */ - protected void showStatus() { - org.eclipse.papyrus.sasheditor.Activator.log.debug("rootPart (1)" + ", disposed=" + container.isDisposed() + ", visible=" + container.isVisible() + ", " + this); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/SashContainerEventsProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/SashContainerEventsProvider.java deleted file mode 100644 index e93c1c92085..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/SashContainerEventsProvider.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.papyrus.sasheditor.editor.SashContainerEventsListener; -import org.eclipse.papyrus.sasheditor.editor.SashWindowsContainer; - -/** - * A class managing events of the {@link SashWindowsContainer}. This class - * dispatch events fired by the {@link SashWindowsContainer} to any listeners - * implementing {@link SashContainerEventsProvider}. - * - * @author cedric dumoulin - * - */ -public class SashContainerEventsProvider { - - /** List of listeners */ - private List listeners = new ArrayList(); - - /** - * Add a listener on the activeEditorChange event. - * - * @param listener - */ - public void addListener(SashContainerEventsListener listener) { - // no duplicate - if(listeners.contains(listener)) - return; - listeners.add(listener); - } - - /** - * Add a listener on the activeEditorChange event. - * - * @param listener - */ - public void removeListener(SashContainerEventsListener listener) { - listeners.remove(listener); - } - - /** - * Notify all listener with event. - * - * @param newEditor - */ - public void firePageOpenedEvent(PagePart page) { - // Fire events to internal listeners - for(SashContainerEventsListener listener : listeners) { - listener.pageOpened(page); - } - } - - /** - * Notify all listener with event. - * - * @param newEditor - */ - public void firePageClosedEvent(PagePart page) { - // Fire events to internal listeners - for(SashContainerEventsListener listener : listeners) { - listener.pageClosed(page); - } - } - - /** - * Notify all listener with event. - * - * @param newEditor - */ - public void firePageAboutToBeOpenedEvent(PagePart page) { - // Fire events to internal listeners - for(SashContainerEventsListener listener : listeners) { - listener.pageAboutToBeOpened(page); - } - } - - /** - * Notify all listener with event. - * - * @param newEditor - */ - public void firePageAboutToBeClosedEvent(PagePart page) { - // Fire events to internal listeners - for(SashContainerEventsListener listener : listeners) { - listener.pageAboutToBeClosed(page); - } - } - - /** - * Notify all listener with event. - * - * @param newEditor - */ - public void firePageActivatedEvent(PagePart page) { - // Fire events to internal listeners - for(SashContainerEventsListener listener : listeners) { - listener.pageActivated(page); - } - } - - /** - * Notify all listener with event. - * - * @param newEditor - */ - public void firePageDeactivatedEvent(PagePart page) { - // Fire events to internal listeners - for(SashContainerEventsListener listener : listeners) { - listener.pageDeactivated(page); - } - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/SashPanelPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/SashPanelPart.java deleted file mode 100644 index de1cce38a7b..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/SashPanelPart.java +++ /dev/null @@ -1,480 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -import java.util.logging.Logger; - -import org.eclipse.papyrus.sasheditor.contentprovider.IAbstractPanelModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashPanelModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.internal.dnd.DragUtil; -import org.eclipse.ui.internal.dnd.IDropTarget; - -/** - * Controller for a sash panel. A sash panel contain 2 children. It shows them - * in two windows separated by a sash. Implementation use one model, a {@link ISashPanelModel}. This model encapsulate the real model which is of an - * unknown type. - * - * - * @author dumoulin - * - * @param T - * Type of the external model representing the sash. - */ -@SuppressWarnings({ "restriction" }) -public class SashPanelPart extends AbstractPanelPart implements IPanelParent { - - /** Log object */ - Logger log = Logger.getLogger(getClass().getName()); - - /** Interface to the model */ - protected ISashPanelModel model; - - /** - * Raw model associated to this part. We store it because the PartModel do - * not provide it - */ - private Object rawModel; - - /** - * Ordered set of currently shown diagrams (a left and right child, or upper - * and lower) TODO rename as children - */ - protected AbstractPanelPart[] currentChildParts = new AbstractPanelPart[2]; - - /** - * The container widget. - */ - private ReplaceableSashForm container; - - /** - * Direction of the sash: SWT.HORIZONTAL or SWT.VERTICAL. Default = - * SWT.HORIZONTAL - */ - private int sashDirection = SWT.HORIZONTAL; - - /** - * Constructor. - */ - public SashPanelPart(IPanelParent parent, ISashPanelModel model, Object rawModel) { - super(parent); - this.model = model; - this.rawModel = rawModel; - this.sashDirection = model.getSashDirection(); - } - - /** - * Get the associated model. - */ - public ISashPanelModel getPartModel() { - return model; - } - - /** - * Fill the provided part map with this parts and recursively call children - * to fillin. - * - * @param partMap - */ - public void fillPartMap(PartLists partMap) { - partMap.addPart(this); - for(AbstractPanelPart child : currentChildParts) { - child.fillPartMap(partMap); - } - garbageState = GarbageState.UNVISITED; - } - - /** - * Create local control, and the tree of children (TileParts AND controls). - * Create this TilePart control, and then Tile childs of this TilePart. - * - * @param parent - * @return Control - */ - public void createPartControl(Composite parent) { - - createControl(parent); - // activate(); - // createChildrenControl(); - } - - /** - * Create local control. Does not create children. - * - */ - protected void createControl(Composite parent) { - // container = new SashForm(parent, sashDirection); - container = new ReplaceableSashForm(parent, sashDirection); - } - - /** - * Create the part for the specified child model. The controls are NOT - * build. - * - * TODO: delegate to sashContainer, remove duplication from here and - * RootPart. - * - * @param rootPart - * @param partModel - * @return - */ - private AbstractPanelPart createChildPart(Object rawModel) { - - // Create the child PartModel. Delegate creation to this part PartModel. - IAbstractPanelModel model = getPartModel().createChildSashModel(rawModel); - - AbstractPanelPart createdPart; - if(model instanceof ITabFolderModel) { - createdPart = new TabFolderPart(this, (ITabFolderModel)model, rawModel); - } else if(model instanceof ISashPanelModel) { - createdPart = new SashPanelPart(this, (ISashPanelModel)model, rawModel); - } else { - // error - throw new IllegalArgumentException("Can't create child part for model of type '" + model.getClass().getName() + "'"); - // TODO: Return an error Part showing the exception instead of - // throwing it ? - } - - return createdPart; - } - - /** - * Create the part for the specified child model. The controls are build. - * - * TODO: delegate to sashContainer, remove duplication from here and - * RootPart. - * - * @param rootPart - * @param partModel - * @return - */ - private AbstractPanelPart createChildPart(Object rawModel, int childIndex) { - // Create parts - AbstractPanelPart createdPart = createChildPart(rawModel); - // Create controls - createdPart.createPartControl(getChildParent(childIndex)); - return createdPart; - } - - /** - * Get the sash container. - * - * @see org.eclipse.papyrus.sasheditor.internal.AbstractPanelPart#getControl() - * - * @return - */ - public Composite getControl() { - return container; - } - - /** - * Change the parent of this method. Reparent the Tile and the control. - * Normally, the control already exists. - * - */ - @Override - public void reparent(IPanelParent newParent, Composite swtParent) { - parent = newParent; - // Create control if needed - // This can happen if the TilePart is just created after a refresh - // if(getControl() == null) - // { - // container = createContainer(parent.getControl()); - // } - // Reparent the control - assert (getControl() != null); - // getControl().setParent(newParent.getControl()) ; - getControl().setParent(swtParent); - garbageState = GarbageState.REPARENTED; - } - - /** - * Orphan this node, and children. The parent is set to null, but control is - * left unchanged. The node can be reattached with reparent(). - * - * @see - * @return the parent - */ - public void orphan() { - - // orphan only if we are in UNCHANGED state - if(garbageState == GarbageState.UNVISITED) { - garbageState = GarbageState.ORPHANED; - parent = null; - } - } - - /** - * Dispose the TilePart and its controls. - */ - @Override - public void dispose() { - if(container != null && !container.isDisposed()) { - container.dispose(); - } - container = null; - } - - /** - * Traverses the tree to find the part that intersects the given point - * - * @param toFind - * Point in display coordinate - * @return the part that intersects the given point - * @throws NotFoundException - */ - @Override - public AbstractPart findPart(Point toFind) throws NotFoundException { - - Rectangle bounds = DragUtil.getDisplayBounds(container); // container.getBounds(); - - // Try the left/up pane - bounds = DragUtil.getDisplayBounds(container.getLeftParent()); - if(bounds.contains(toFind)) { - return currentChildParts[0].findPart(toFind); - } - bounds = DragUtil.getDisplayBounds(container.getRightParent()); - if(bounds.contains(toFind)) { - // Return right part - return currentChildParts[1].findPart(toFind); - } - - throw new NotFoundException("Can't find a part at '" + toFind + "'"); - - } - - /** - * Locates the part that intersects the given point and that have the - * expected type - * - * @param toFind - * Position in Display coordinate. - * @return - */ - public AbstractPart findPartAt(Point toFind, Class expectedTileType) { - - if(expectedTileType == this.getClass()) - return this; - - Rectangle bounds = DragUtil.getDisplayBounds(container); // container.getBounds(); - - if(isVertical()) { - if(toFind.y < bounds.y + (bounds.height / 2)) { - return currentChildParts[0].findPartAt(toFind, expectedTileType); - } - return currentChildParts[1].findPartAt(toFind, expectedTileType); - } else { - if(toFind.x < bounds.x + (bounds.width / 2)) { - return currentChildParts[0].findPartAt(toFind, expectedTileType); - } - return currentChildParts[1].findPartAt(toFind, expectedTileType); - } - } - - /** - * Return true if this sash is vertical, false otherwise. - */ - private boolean isVertical() { - return (container.getOrientation() == SWT.VERTICAL); - } - - /** - * Find the part associated to the provided control. - * - * @see org.eclipse.papyrus.sasheditor.sash.ITilePart#findPart(org.eclipse.swt.widgets.Control) - */ - @Override - public AbstractPart findPart(Object control) { - if(this.getControl() == control) { - return this; - } - - AbstractPart node = currentChildParts[0].findPart(control); - if(node != null) { - return node; - } - node = currentChildParts[1].findPart(control); - if(node != null) { - return node; - } - return null; - - } - - /** - * SashPanelPart can't be a DropTarget. Do nothing. - */ - public IDropTarget getDropTarget(Object draggedObject, TabFolderPart sourcePart, Point position) { - return null; - } - - /** - * Return true if the Part is for the specified real model. Return false - * otherwise. - * - * @param realModel - * The raw model to check - * @return - */ - public boolean isPartFor(Object realModel) { - return getRawModel() == realModel; - } - - /** - * Get the raw model associated to this part. - * - * @return - */ - protected Object getRawModel() { - return rawModel; - } - - /** - * Synchronize the sash. - * - * @see org.eclipse.papyrus.sasheditor.internal.AbstractPanelPart#synchronize2(org.eclipse.papyrus.sasheditor.internal.PartLists) - * - * @param partMap - */ - public void synchronize2(PartLists partMap) { - - // Compare currentChildParts and node model - assert (model.getChildren().size() == 2); - - // Synchronize each child - for(int i = 0; i < 2 /* model.getChildModels().size() */; i++) { - synchronizeChild(i, partMap); - } - - // Now recursively call synchronize on childs. - for(int i = 0; i < currentChildParts.length; i++) { - currentChildParts[i].synchronize2(partMap); - // // Set the child controls at the right place - // if(i==0) - // container.moveAbove(currentChildParts[i].getControl()); - // else - // container.moveBelow(currentChildParts[i].getControl()); - // - } - - } - - /** - * Synchronize the specified child. - * - * @param childIndex - * index of the child to be synchronized - * @param existingParts - */ - private void synchronizeChild(int childIndex, PartLists existingParts) { - - Object newModel = model.getChildren().get(childIndex); - - // Check if old child exist - // If exist, check if the current part is associated to the checked - // model - // - AbstractPanelPart currentChildPart = currentChildParts[childIndex]; - if(currentChildPart != null) { - // If the tile is already for the model, there is nothing to do. - if(currentChildPart.isPartFor(newModel)) { - currentChildPart.unchanged(); - return; - } - // The current tile is not for the model: mark it as orphan - currentChildPart.orphan(); - } - - // The child part need to be updated. Do it. - // First check if already exist in the map - AbstractPanelPart newTile = existingParts.findPartFor(newModel); - if(newTile != null) { - // Reparent the tile - newTile.reparent(this, getChildParent(childIndex)); - } else { - // create the tile and its control - newTile = createChildPart(newModel, childIndex); - } - - // Now, put the tile on the right side - setChildToSide(newTile, childIndex); - - } - - /** - * Get the Composite parent that will be provided to the child. - * - * @param childIndex - * @return - */ - private Composite getChildParent(int childIndex) { - // return container; - if(childIndex == 0) - return container.getLeftParent(); - else - return container.getRightParent(); - - } - - /** - * Set the provided child at the specified index. If a child already exist - * at the specified index, it is lost. The controls are set accordingly - * - * @param newTile - * @param childIndex - */ - private void setChildToSide(AbstractPanelPart newTile, int childIndex) { - currentChildParts[childIndex] = newTile; - - } - - /** - * Accept the provided visitor. Call the corresponding accept method in the - * visitor. - * - * @param visitor - * @return - */ - public boolean visit(IPartVisitor visitor) { - return visitor.accept(this); - } - - /** - * Visit the children of this Tile. - * - * @param visitor - */ - public boolean visitChildren(IPartVisitor visitor) { - for(AbstractPanelPart child : currentChildParts) { - if(!child.visit(visitor)) - return false; - } - - // All children have accepter the visit, continue visiting. - return true; - - } - - /** - * Show tile status. Used for debug purpose - */ - protected void showStatus() { - org.eclipse.papyrus.sasheditor.Activator.log.debug("sash[" + currentChildParts.length + "]:" + ", disposed=" + container.isDisposed() + ", visible=" + container.isVisible() + ", garbState=" + garbageState + ", " + this); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/SashWindowsException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/SashWindowsException.java deleted file mode 100644 index 947b04bcbc9..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/SashWindowsException.java +++ /dev/null @@ -1,56 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -/** - * Main Exception from the SashWindowsSystem. - * - * @author dumoulin - */ -public class SashWindowsException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * - */ - public SashWindowsException() { - } - - /** - * @param message - */ - public SashWindowsException(String message) { - super(message); - } - - /** - * @param cause - */ - public SashWindowsException(Throwable cause) { - super(cause); - } - - /** - * @param message - * @param cause - */ - public SashWindowsException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ShowPartStatusVisitor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ShowPartStatusVisitor.java deleted file mode 100644 index bac2c993d3e..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/ShowPartStatusVisitor.java +++ /dev/null @@ -1,115 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -/** - * Visitor used to show the status of the different Tiles composing the sash - * system. - * - * @author dumoulin - * - */ -@SuppressWarnings("unchecked") -public class ShowPartStatusVisitor extends PartVisitor { - - int level = 1; - - /** - * @param tile - */ - - @Override - public boolean accept(RootPart tile) { - indent(); - tile.showStatus(); - // System.out.println( "root:" + tile ); - level++; - super.accept(tile); - level--; - return true; - } - - /** - * - */ - private void indent() { - if(level < 1) { - // error - return; - } - - for(int i = 0; i < level - 1; i++) { - System.out.print("| "); - } - // last segment - System.out.print("+ "); - } - - /** - * @param tile - */ - @Override - public boolean accept(SashPanelPart tile) { - indent(); - tile.showStatus(); - // System.out.println( "sash:" + tile ); - level++; - super.accept(tile); - level--; - return true; - } - - /** - * @param tile - */ - @Override - public boolean accept(TabFolderPart tile) { - indent(); - tile.showStatus(); - // System.out.println( "folder:" + tile ); - level++; - super.accept(tile); - level--; - return true; - } - - /** - * @param tile - */ - @Override - public boolean accept(EditorPart tile) { - indent(); - tile.showStatus(); - // System.out.println( "editor:" + tile ); - level++; - super.accept(tile); - level--; - return true; - } - - /** - * @param tile - */ - @Override - public boolean accept(ComponentPart tile) { - indent(); - tile.showStatus(); - // System.out.println( "editor:" + tile ); - level++; - super.accept(tile); - level--; - return true; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/TabFolderPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/TabFolderPart.java deleted file mode 100644 index 208ff40f692..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/TabFolderPart.java +++ /dev/null @@ -1,1230 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Logger; - -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.util.Geometry; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel; -import org.eclipse.papyrus.sasheditor.editor.SashWindowsContainer; -import org.eclipse.papyrus.sasheditor.internal.eclipsecopy.AbstractTabFolderPart; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.custom.CTabFolderEvent; -import org.eclipse.swt.custom.CTabItem; -import org.eclipse.swt.events.MenuDetectEvent; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseTrackListener; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.ui.internal.DragCursors; -import org.eclipse.ui.internal.dnd.DragUtil; -import org.eclipse.ui.internal.dnd.IDragOverListener; -import org.eclipse.ui.internal.dnd.IDropTarget; - -/** - * Controller associated to a tabfolder. - * - * - * - * Extends MultiPageEditor to inherit methods implementations. - * - * @param T - * Common ancestor for the model provided for the sash windows by the - * application. This is the type used externally by the application. - * Sash implementation don't use this type, it just carry it to ask - * for the appropriate wrapper. Concrete implementation can specify a - * type. - * - * TODO : be more precise for the generic type ? TODO : Listen to the - * page change event, and call setActivePage(). - */ -@SuppressWarnings("restriction") -public class TabFolderPart extends AbstractTabFolderPart { - - /** Log object */ - Logger log = Logger.getLogger(getClass().getName()); - - /** Interface to the model */ - protected ITabFolderModel partModel; - - /** - * Raw model associated to this part. We store it because the PartModel do - * not provide it - */ - private Object rawModel; - - /** - * The wrapper around the CTabFolder. This represent the SWT control - * associated to this part. - */ - protected PTabFolder pTabFolder; - - /** - * Ordered set of currently shown diagrams (list of their models) TODO - * remove - */ - protected TabPartList currentTabItems = new TabPartList(); - - /** The drop target associated to this folderPart */ - private DropTarget dropTarget; - - /** - * Track the mouse hover and fire appropriate event. - */ - private MouseHoverTracker mouseHoverTracker; - - /** - * Listener on DragOver event. - */ - IDragOverListener dragOverListener = new IDragOverListener() { - - /** - * - * @see org.eclipse.ui.internal.dnd.IDragOverListener#drag(org.eclipse.swt.widgets.Control, java.lang.Object, org.eclipse.swt.graphics.Point, - * org.eclipse.swt.graphics.Rectangle) - */ - public IDropTarget drag(Control currentControl, Object draggedObject, Point position, Rectangle dragRectangle) { - // System.out.println(TabFolderPart.this.getClass().getSimpleName() - // + ".drag()"); - // System.out.println(this + ".drag()"); - return null; - } - }; - - /** - * Listener on CTabFolder events. - */ - private PTabFolder.IPTabFolderListener cTabFolderEventListener = new PTabFolder.IPTabFolderListener() { - - public void contextMenuDetectEvent(CTabItem tab, Event event) { - // System.out.println("contextMenuDetect()"); - } - - /** - * The close cross has been pressed. Remove the corresponding tab. {@inheritDoc} - */ - public void itemClosedEvent(CTabFolderEvent event, int pageIndex) { - // System.out.println("itemClosedEvent()"); - // TODO: call appropriate method (to be determine) - // model.removeTab(pageIndex); - // getSashWindowContainer().getContentProvider().removeTab(model, - // pageIndex); - getContentProvider().removePage(partModel, pageIndex); - } - - public void menuDetectEvent(CTabItem tab, MenuDetectEvent event) { - // System.out.println("menuDetectEvent()"); - } - - /** - * Listen to pageChange event, and propagate to TabFolderPart. - * - * @param newPageIndex - */ - public void pageChangeEvent(int newPageIndex) { - pageChangedEvent(newPageIndex); - } - - }; - - /** - * Constructor. - * - * @param nestedPartManager - * @param partModel - * @param rawModel - * - */ - public TabFolderPart(IPanelParent parent, ITabFolderModel partModel, Object rawModel) { - super(parent); - this.partModel = partModel; - this.rawModel = rawModel; - } - - /** - * Get the associated model. - */ - public ITabFolderModel getPartModel() { - return partModel; - } - - /** - * Activate the part. Register as listener to required services. - */ - private void activate() { - // Listen to page changes - pTabFolder.getEventManager().addListener(cTabFolderEventListener); - // Create the tracker that will show tooltips on tabs. - mouseHoverTracker = new MouseHoverTracker(pTabFolder.getControl(), new ImageToolTipManager()); - } - - /** - * Deactivate this part. Unregistered from required service. Do not dispose - * the part. - */ - private void deactivate() { - // Listen to page changes - pTabFolder.getEventManager().removeListener(cTabFolderEventListener); - mouseHoverTracker.deactivate(); - } - - /** - * Fill the provided part map with this parts and recursively call children - * to fillin. - * - * @param partMap - */ - public void fillPartMap(PartLists partMap) { - partMap.addPart(this); - garbageState = GarbageState.UNVISITED; - - for(TabItemPart child : currentTabItems) { - child.fillPartMap(partMap); - } - } - - /** - * Creates the control tree associated to this part. Create the control for - * this part, and eventually recursively call the method for the childs, if - * any. - * - */ - @Override - public void createPartControl(Composite parent) { - - createControl(parent); - // createPages(); - // model.addChangeListener(modelListener); - // model.activate(); - activate(); - } - - /** - * Add a new page at the end of pages. A new tab is created for the page, - * and the page control is created. - * - * @param pageModel - * @param index - */ - // private void addPage(Object pageModel) - // { - // int index = currentTabItems.size(); - // createTabItem(pageModel, index); - // } - - /** - * Create the control for this Part. Does not create children. This method - * is called by the parent after this folder is created. - * - */ - public void createControl(Composite parent) { - PTabFolder res = new PTabFolder(); - pTabFolder = res; - res.createPartControl(parent); - initDrag(res.getControl()); - // init menu - initMenuManager(); - } - - /** - * Init the menuManager after the control has been created. Get the {@link MenuManager} from the {@link SashWindowsContainer}. Set it to this - * folder if it is not null. - */ - private void initMenuManager() { - MenuManager menuManager = getSashWindowContainer().getFolderTabMenuManager(); - if(menuManager != null) { - setFolderTabMenuManager(menuManager); - } - - } - - /** - * Set a {@link MenuManager} used to manage a contextual menu that is shown - * on the tabs area of this folder. - * - * @param menuManager - * The {@link MenuManager} used to create the menu on the tab - * area. - */ - public void setFolderTabMenuManager(MenuManager menuManager) { - Composite folderControl = getControl(); - Menu menu = menuManager.createContextMenu(folderControl); - folderControl.setMenu(menu); - } - - /** - * The page has change. Propagate the event to the container. - * - * @param newPageIndex - */ - @Override - protected void pageChange(int newPageIndex) { - - // System.out.println(this.getClass().getSimpleName() + ".pageChange("+ - // newPageIndex +")"); - // Do nothing if out of range. - if(newPageIndex < 0 || newPageIndex > currentTabItems.size() - 1) - return; - - getSashWindowContainer().pageChanged(currentTabItems.get(newPageIndex).childPart); - } - - /** - * An event signaling that the selected page is changed has been caught. - * Propagate the event to the container. - * - * @param newPageIndex - */ - protected void pageChangedEvent(int newPageIndex) { - - // System.out.println(this.getClass().getSimpleName() + ".pageChange("+ - // newPageIndex +")"); - // Do nothing if out of range. - if(newPageIndex < 0 || newPageIndex > currentTabItems.size() - 1) - return; - - getSashWindowContainer().pageChangedEvent(currentTabItems.get(newPageIndex).childPart); - } - - /** - * Dispose the TilePart and its controls. - * - * @see org.eclipse.papyrus.sasheditor.eclipsecopy.MultiPageEditorTile#dispose() - */ - public void dispose() { - // detach menu as it is shared between folders. - getControl().setMenu(null); - - deactivate(); - -// getControl().dispose(); - pTabFolder.dispose(); - } - - /** - * - */ - private void initDrag(Composite container) { - DragUtil.addDragTarget(container, dragOverListener); - } - - /** - * Get the associated CTabFolder - */ - @Override - protected CTabFolder getTabFolder() { - return pTabFolder.getTabFolder(); - } - - /** - * Return the swt Control associated to this part. - */ - public Composite getControl() { - return getTabFolder(); - } - - /** - * The MultiPageEditor implementation of this IWorkbenchPart method sets focus on the active nested - * editor, if there is one. - *

- * Subclasses may extend or reimplement. - *

- */ - public void setFocus() { - setFocus(getActivePage()); - } - - /** - * Sets focus to the control for the given page. If the page has an editor, - * this calls its setFocus() method. Otherwise, this calls setFocus on the control for the page. - * - * @param pageIndex - * the index of the page - */ - private void setFocus(int pageIndex) { - if(pageIndex < 0 || pageIndex >= getPageCount()) { - // page index out of bounds, don't set focus. - return; - } - getPagePart(pageIndex).setFocus(); - } - - /** - * Set the active page of this multi-page editor to the page that contains - * the given editor part. This method has no effect of the given editor part - * is not contained in this multi-page editor. - * - * @param editorPart - * the editor part - * @since 3.3 - */ - public final void setActiveEditor(PagePart editorPart) { - int count = getPageCount(); - for(int i = 0; i < count; i++) { - PagePart editor = getPagePart(i); - if(editor == editorPart) { - setActivePage(i); - break; - } - } - } - - /** - * Return the part containing specified point. Normally return this part, - * because the caller has already determine that this contain the part. - * - */ - @Override - public AbstractPart findPart(Point toFind) { - return this; - } - - /** - * Locates the part that intersects the given point and that have the - * expected type - * - * @param toFind - * @return - */ - @Override - public AbstractPart findPartAt(Point toFind, Class expectedTileType) { - - if(expectedTileType == this.getClass()) - return this; - - // ask current active tab - TabItemPart activeTabPart = getActiveTab(); - if(activeTabPart == null) - return null; - - return getActiveTab().findPartAt(toFind, expectedTileType); - } - - /** - * Get the currently active tab. - * - * @return - */ - private TabItemPart getActiveTab() { - int index = getActivePage(); - if(index != -1) { - return currentTabItems.get(index); - } - return null; - } - - /** - * Get the specified childPart - * - * @param index - * Index of the requested childPart. - * @return - */ - protected PagePart getPagePart(int index) { - return currentTabItems.get(index).getChildPart(); - } - - /** - * Get the visible PagePart (from the Container point of view). The visible - * PagePart is the one that has its diagram area visible. From the folder - * point of view, this is the active PagePart. - * - * @return - */ - public PagePart getVisiblePagePart() { - int index = getActivePage(); - if(index != -1) { - return getPagePart(index); - } - return null; - } - - /** - * Find the part associated to the provided control. - * - */ - @Override - public AbstractPanelPart findPart(Object control) { - if(getControl() == control) - return this; - - // Check if it is one of the Item - if(control instanceof CTabItem && ((CTabItem)control).getParent() == getControl()) - return this; - - // Ask childs TODO - return null; - } - - /** - * - * @see org.eclipse.papyrus.sasheditor.internal.AbstractPanelPart#getDropTarget(java.lang.Object, - * org.eclipse.papyrus.sasheditor.internal.TabFolderPart, org.eclipse.swt.graphics.Point) - * - * @param draggedObject - * @param sourcePart - * @param position - * @return - */ - public IDropTarget getDropTarget(Object draggedObject, TabFolderPart sourcePart, Point position) { - // see org.eclipse.ui.internal.presentations.util.ReplaceDragHandler - // Determine which tab we're currently dragging over - CTabItem tabUnderPointer = pTabFolder.getItem(position); - - // Compute source tab index. If folder, index==-1 - int sourceIndex = PTabFolder.getDraggedObjectTabIndex(draggedObject); - // This drop target only deals with tabs... if we're not dragging over - // a tab, exit. - if(tabUnderPointer == null) { - Rectangle titleArea = pTabFolder.getTabArea(); - - // If we're dragging over the title area, treat this as a drop in - // the last - // tab position. - if(titleArea.contains(position) && pTabFolder.getTabFolder().getItemCount() > 0) { - int dragOverIndex = pTabFolder.getTabFolder().getItemCount(); - CTabItem lastTab = pTabFolder.getTabFolder().getItem(dragOverIndex - 1); - - // Can't drag to end unless you can see the end - if(!lastTab.isShowing()) { - return null; - } - - // If we are unable to compute the bounds for this tab, then - // ignore the drop - Rectangle lastTabBounds = lastTab.getBounds(); - if(lastTabBounds.isEmpty()) { - return null; - } - - // if (dragStart >= 0) { - // dragOverIndex--; - // - // return createDropTarget( sourcePart, lastTabBounds, - // dragOverIndex); - // // return new StackDropResult(lastTabBounds, new - // Integer(dragOverIndex)); - // } - - // Make the drag-over rectangle look like a tab at the end of - // the tab region. - // We don't actually know how wide the tab will be when it's - // dropped, so just - // make it 3 times wider than it is tall. - // titleArea is in Display coordinate, lastTabBounds in parent - // coordinate - Rectangle dropRectangle = titleArea; - - dropRectangle.x = dropRectangle.x + lastTabBounds.x + lastTabBounds.width; - dropRectangle.width = 3 * dropRectangle.height; - return createDropTarget(sourcePart, sourceIndex, dropRectangle, dragOverIndex); - // return new StackDropResult(dropRectangle, new - // Integer(dragOverIndex)); - - } else { - // If the closest side is the side with the tabs, consider this - // a stack operation. - // Otherwise, let the drop fall through to whatever the default - // behavior is - Rectangle displayBounds = DragUtil.getDisplayBounds(pTabFolder.getControl()); - int closestSide = Geometry.getClosestSide(displayBounds, position); - if(closestSide == pTabFolder.getTabFolder().getTabPosition()) { - return createDropTarget(sourcePart, sourceIndex, displayBounds, -1); - } - - return null; - } - } - - if(!tabUnderPointer.isShowing()) { - return null; - } - - // Get thumbnail bounds in display coordinates - Rectangle tabBounds = pTabFolder.getItemBounds(tabUnderPointer); - - if(tabBounds.isEmpty()) { - return null; - } - - return createDropTarget(sourcePart, sourceIndex, tabBounds, pTabFolder.getTabFolder().indexOf(tabUnderPointer)); - } - - /** - * Copied from org.eclipse.ui.internal.PartStack - */ - public IDropTarget createDropTarget(TabFolderPart sourcePart, int sourceIndex, Rectangle snapRectangle, int tabIndex) { - - if(dropTarget == null) { - dropTarget = new DropTarget(sourcePart, sourceIndex, snapRectangle, tabIndex); - return dropTarget; - } - - dropTarget.setTarget(sourcePart, sourceIndex, snapRectangle, tabIndex); - return dropTarget; - } - - /** - * Class implementing methods required by drop targets. Drop target use when - * the drop occur on one of the thumbnail of the folder. - */ - protected class DropTarget implements IDropTarget { - - int cursor = SWT.CENTER; - - private TabFolderPart sourcePart; - - private Rectangle snapRectangle; - - private int targetIndex; - - private int sourceIndex; - - /** - * Constructor. targetPart is the current folder. - * - * @param sourcePart - * The sourcePart of the drag - * @param sourceIndex - * Index of the tab from where the drop occur - * @param snapRectangle - * the drop area. - * @param targetIndex - * Index of the tab where the drop occur - */ - public DropTarget(TabFolderPart sourcePart, int sourceIndex, Rectangle snapRectangle, int targetIndex) { - this.sourceIndex = sourceIndex; - this.targetIndex = targetIndex; - this.sourcePart = sourcePart; - this.snapRectangle = snapRectangle; - } - - public void setTarget(TabFolderPart sourcePart, int sourceIndex, Rectangle snapRectangle, int targetIndex) { - this.sourceIndex = sourceIndex; - this.targetIndex = targetIndex; - this.sourcePart = sourcePart; - this.snapRectangle = snapRectangle; - } - - /** - * - * @see org.eclipse.ui.internal.dnd.IDropTarget#drop() - */ - public void drop() { - - // move from a folder to another - if(sourcePart == TabFolderPart.this) { - // move inside the same folder - getContentProvider().movePage(sourcePart.getPartModel(), sourceIndex, targetIndex); - } else { // move between folder - getContentProvider().movePage(sourcePart.getPartModel(), sourceIndex, TabFolderPart.this.getPartModel(), targetIndex); - } - } - - /** - * Return the cursor used during drag. - * - * @see org.eclipse.ui.internal.dnd.IDropTarget#getCursor() - */ - public Cursor getCursor() { - // System.out.println(TabFolderPart.this.getClass().getSimpleName() - // + ".getCursor()-" + count++); - return DragCursors.getCursor(DragCursors.positionToDragCursor(cursor)); - - } - - public Rectangle getSnapRectangle() { - // System.out.println(TabFolderPart.this.getClass().getSimpleName() - // + ".getSnapRectangle()-" + count); - return snapRectangle; - } - - } - - /** - * Orphan this node. The parent is set to null, but control is left - * unchanged. The node can be reattached with reparent(). - * - * @see - * @return the parent - */ - public void orphan() { - // orphan only if we are in UNCHANGED state - if(garbageState == GarbageState.UNVISITED) { - garbageState = GarbageState.ORPHANED; - parent = null; - - } - } - - /** - * - * @see org.eclipse.papyrus.sasheditor.internal.AbstractPart#getGarbageState() - * - * @return - */ - public GarbageState getGarbageState() { - return garbageState; - } - - /** - * Change the parent of this method. - * - * @see org.eclipse.papyrus.sasheditor.sash.ITilePart#reparent(org.eclipse.papyrus.sasheditor.sash.ITilePart) - */ - public void reparent(IPanelParent newParent, Composite swtParent) { - parent = newParent; - // Create control if needed - // This can happen if the TilePart is just created after a refresh - // if(getControl() == null) - // { - // return; - // // createContainer(parent.getControl()); - // } - // Reparent the control - assert (getControl() != null); - // getControl().setParent(newParent.getControl()) ; - getControl().setParent(swtParent); - garbageState = GarbageState.REPARENTED; - } - - /** - * Return true if the Part is for the specified real model. Return false - * otherwise. - * - * @param realModel - * The raw model to check - * @return - */ - public boolean isPartFor(Object realModel) { - return getRawModel() == realModel; - } - - /** - * Get the raw model associated to this part. - * - * @return - */ - public Object getRawModel() { - return rawModel; - } - - /** - * Refresh the tab of this page (I.e the name and icon in the tab). - * - * @param page - * The page to be refreshed - */ - public void refreshPageTab(PagePart page) { - TabItemPart itemPart = currentTabItems.getByPagePart(page); - if(itemPart == null) - return; - - itemPart.refreshTabDecorations(); - } - - /** - * Synchronize the TabFolder with the models. The Tabs order is fixed and - * can't be moved. So, we move the associated ITilepart if needed. For each - * existing Tab, compare its model and the requested model. Synchronize if - * necessary. If their is more new model, add new Tab If their is less - * newModel, remove unused Tabs. - * - * @param partLists - */ - public void synchronize2(PartLists partLists) { - - // get list of model to be displayed. This is a list of Object. - List newModels = (List)partModel.getChildren(); - - // Disable redraw - CTabFolder folder = getTabFolder(); - folder.setRedraw(false); - // Remember active page - int activePageIndex = getActivePage(); - - // Iterate over the minimum common size - // Synchronize each tab with the requested model - int minSize = Math.min(newModels.size(), currentTabItems.size()); - int index; - for(index = 0; index < minSize; index++) { - Object curModel = newModels.get(index); - TabItemPart curTab = currentTabItems.get(index); - if(!curTab.isTabItemFor(curModel)) { - resetTabItem(curTab, partLists, curModel); - // end - activePageIndex = index; - } else { - // Change curTab state - curTab.getChildPart().unchanged(); - } - } - - // Check for extra tabs or extra models - if(index < newModels.size()) { - // There is extra models, add new tabs - for(int i = index; i < newModels.size(); i++) { - Object curModel = newModels.get(i); - // Create a new TabItem associated to the curModel. - createTabItem(partLists, curModel, i); - // end - } - // Set the last as active - activePageIndex = newModels.size() - 1; - } else if(index < currentTabItems.size()) { - // There is too much tabs, remove them - List toRemove = new ArrayList(); - // Collect tab to be removed - for(int i = index; i < currentTabItems.size(); i++) { - TabItemPart curTab = currentTabItems.get(i); - toRemove.add(curTab); - } - // do remove - for(TabItemPart curTab : toRemove) { - // removeTab(curTab) - removeTabItem(curTab); - // end - } - // Set the active page as the last part if needed - if(activePageIndex >= currentTabItems.size()) - activePageIndex = currentTabItems.size() - 1; - } - - folder.setRedraw(true); - // folder.setSelection(activePageIndex); - folder.redraw(); - - if(activePageIndex >= 0 && activePageIndex < folder.getItemCount()) { - // System.err.println("setActivePage(" + activePageIndex + ") : " + - // this); - // Set the activeTab has visible. - // Do it here because otherwise the active tab could be not visible. - // This come from an undefined bug setting the tab.isVisible(false) - // in some case. - folder.getItem(activePageIndex).getControl().setVisible(true); - setActivePage(activePageIndex); - } else { - // Check if there is item in the CTabFolder. - // If true, we have a trouble - if(getTabFolder().getItemCount() > 0) { - // System.err.println("Active page not set while synchronizing !"); - // We have items, but none is selected. - // Select the first one. - if(getTabFolder().getSelectionIndex() < 0) { - setActivePage(0); - } - } - } - // folder.update(); - // folder.showSelection(); - - } - - /** - * Remove the specified tabItem. Also call appropriate remove() method on - * the tabItem. - * - * @param curTab - */ - private void removeTabItem(TabItemPart tabItem) { - currentTabItems.remove(tabItem); - tabItem.remove(); - } - - /** - * Create a new TabItem associated to the part corresponding to the - * specified newModel. The TabItem is created at the specified index. The - * associated parts is searched in the existingParts or created if none is - * found. - * - * @param existingParts - * List of existing parts. - * @param newModel - * @param index - * @param i - */ - private void createTabItem(PartLists existingParts, Object newModel, int index) { - TabItemPart newTab = null; - - PagePart modelPart = existingParts.findPagePartFor(newModel); - if(modelPart != null) { - // A part already exist for the model. Use it. - modelPart.reparent(this); - newTab = new TabItemPart(this, modelPart, index); - } else { - // No part found, create one - modelPart = createChildPart(newModel); - if(modelPart != null) { - existingParts.addCreatedPage(modelPart); - // Attach it to the tabItem - newTab = new TabItemPart(this, modelPart, index); - } - } - - // Add to the list of items. - if(newTab != null) { - currentTabItems.add(index, newTab); - } - } - - // /** - // * Create a new TabItem and associated part corresponding to the specified - // newModel. - // * The TabItem is created at the specified index. - // * The associated parts is created. - // * - // * @param existingParts List of existing parts. - // * @param newModel - // * @param index - // * @param i - // */ - // private void createTabItem(Object newModel, int index) { - // TabItemPart newTab; - // - // PagePart modelPart = createChildPart( newModel ); - // // Attach it to the tabItem - // newTab = new TabItemPart(this, modelPart, index); - // - // // Add to the list of items. - // currentTabItems.add(index, newTab); - // } - - /** - * Instruct the specified tabItem to use the new model. Check if a part - * already exist for the model and use it if any. Otherwise create a new - * Part. - * - * @param curTab - * @param existingParts - * @param newModel - */ - private void resetTabItem(TabItemPart tabItem, PartLists existingParts, Object newModel) { - - PagePart modelPart = existingParts.findPagePartFor(newModel); - if(modelPart != null) { - // A part already exist for the model. Use it. - tabItem.resetChild(modelPart); - } else { - // No part found, create one - modelPart = createChildPart(newModel); - existingParts.addCreatedPage(modelPart); - // Attach it to the tabItem - tabItem.resetChild(modelPart); - } - } - - /** - * Factory method to create a new Part for the specified newModel. The - * method should always return a valid Part. In case of error while creating - * the requested part, the method should return a default part, maybe - * showing the encountered error. The control for the child is created. - * - * @param newModel - * @return The new part - */ - private PagePart createChildPart(Object newModel) { - - // Create the child PartModel. Delegate creation to this part PartModel. - IPageModel partModel = getPartModel().createChildSashModel(newModel); - - if(partModel != null) { - // Delegate part creation to the container. This allow the container to - // provide appropriate - // objects not available from the part. - PagePart newPart = getSashWindowContainer().createPagePart(this, partModel, newModel); - // Create control. - // Fire events before and after - getSashWindowContainer().getLifeCycleEventProvider().firePageAboutToBeOpenedEvent(newPart); - newPart.createPartControl(getControl()); - getSashWindowContainer().getLifeCycleEventProvider().firePageOpenedEvent(newPart); - - return newPart; - } - - return null; - } - - /** - * Show tab status - * - * @debug This is fo debug purpose. - * @param msg - */ - private void showTabs(String msg) { - System.out.println("------- " + msg); - // Show items - CTabFolder folder = getTabFolder(); - CTabItem items[] = folder.getItems(); - System.out.printf("sel.index %2d :\n", folder.getSelectionIndex()); - System.out.printf("items %2d :", folder.getItemCount()); - for(CTabItem item : items) { - System.out.printf("%10s |", item.getControl()); - } - System.out.println(); - - System.out.printf("it.dispose:"); - for(CTabItem item : items) { - System.out.printf("%10b |", item.getControl().isDisposed()); - } - System.out.println(); - - System.out.printf("it.ctrl.vis:"); - for(CTabItem item : items) { - System.out.printf("%10s |", item.getControl().isVisible()); - } - System.out.println(); - - // - System.out.printf("it.ctrl :"); - for(CTabItem item : items) { - System.out.printf("%10s |", item.getControl()); - } - System.out.println(); - - // - // System.out.printf("tabs.ctrl :" ); - // for( TabItemPart tab : currentModels) - // { - // System.out.printf( "%10s |", tab.childPart.getControl()); - // } - // System.out.println(); - - // - // System.out.printf("tab.editor:" ); - // for( TabItemPart tab : currentModels) - // { - // System.out.printf( "%10s |", tab.childPart.getIEditorPart()); - // } - // System.out.println(); - - // - System.out.printf("tabs %2d :", currentTabItems.size()); - for(TabItemPart tab : currentTabItems) { - System.out.printf("%10s |", tab); - } - System.out.println(); - - } - - /** - * Show tile status. - */ - protected void showStatus() { - // System.out.println( "tabfolder[" + currentModels.size() + "]:" - // + ", disposed=" + getCTabFolder().isDisposed() - // + ", visible=" + getCTabFolder().isVisible() - // + ", garbState=" + garbageState - // + ", " + this); - - CTabFolder ctrl = getTabFolder(); - System.out.printf("tabfolder[%2d]: disposed=%-5b, visible=%-5b, garbState=%-10s, %s\n", currentTabItems.size(), ctrl.isDisposed(), (ctrl.isDisposed() ? false : getTabFolder().isVisible()), garbageState, this); - } - - /** - * Accept the provided visitor. Call the corresponding accept method in the - * visitor. - * - * @param visitor - * @return - */ - public boolean visit(IPartVisitor visitor) { - return visitor.accept(this); - } - - /** - * Visit the children of this Tile. - * - * @param visitor - */ - public boolean visitChildren(IPartVisitor visitor) { - - for(TabItemPart child : currentTabItems) { - if(!child.visit(visitor)) - return false; - } - // All children have accepter the visit, continue visiting. - return true; - } - - /** - * Collection of tabpart. Add miscelenaous methods. - * - * @author dumoulin - * - */ - @SuppressWarnings("serial") - public class TabPartList extends ArrayList { - - /** - * Does the list contains a part with the specified model. - * - * @param model - * @return - */ - public boolean containsModel(Object model) { - return indexOfModel(model) >= 0; - } - - /** - * Returns the index of the first occurrence of the specified element in - * this list, or -1 if this list does not contain the element. More - * formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) , or -1 if - * there is no such index. - */ - public int indexOfModel(Object o) { - if(o == null) { - for(int i = 0; i < size(); i++) - if(get(i) == null) - return i; - } else { - for(int i = 0; i < size(); i++) - if(o.equals(get(i).getChildPart().getRawModel())) - return i; - } - return -1; - } - - /** - * Get the TabPart by its model. - * - * @param model - * @return - */ - public TabItemPart getByModel(Object model) { - return get(indexOfModel(model)); - } - - /** - * Get the TabPart by its PagePart. - * - * @param page - * @return - */ - public TabItemPart getByPagePart(PagePart page) { - return get(indexOfModel(page.getRawModel())); - } - - } - - /** - * Track the mouse for flying over the tabs and show tooltip. Show the - * tooltip when the mouse stop over a tab. Disable the tooltip if mouse is - * clicked. Reenable the tooltip when exiting the tab. - * - * @author dumoulin - * - */ - public class MouseHoverTracker { - - /** - * Control for which a mouse tracker is requested. - */ - private Control control; - - /** Tooltip manager showing tooltip */ - private ImageToolTipManager toolTipManager; - - /** Anonymous mouse tracker */ - MouseTrackListener mouseTrackListener = new MouseTrackListener() { - - private int count = 0; - - public void mouseEnter(MouseEvent e) { - // System.out.println("MouseEnter()" + count++); - - } - - public void mouseExit(MouseEvent e) { - // System.out.println("MouseExit()" + count++); - toolTipManager.closeToolTip(); - } - - public void mouseHover(MouseEvent e) { - CTabFolder folder = getTabFolder(); - // Point pt = folder.toDisplay(e.x, e.y); - Point pt = new Point(e.x, e.y); - CTabItem item = folder.getItem(pt); - int index = pTabFolder.getItemIndex(pt); - if(index == -1) { - toolTipManager.closeToolTip(); - return; - } - - PagePart part = currentTabItems.get(index).getChildPart(); - // System.out.println("MouseHover(" + e.widget - // + ", part=" + part.getPartTitle() - // + ", item=" + item - // + ") - " + count++); - // TODO move it away - //toolTipManager.showToolTip(item.getBounds(), part.getControl(), pt); - toolTipManager.showToolTip(part, item.getBounds(), pt); - } - - - }; - - /** - * Listener on mouse clicked. Used to disable the current tooltip. - */ - private Listener mouseClickedListener = new Listener() { - - private int count = 0; - - public void handleEvent(Event event) { - switch(event.type) { - case SWT.MouseUp: - // System.out.println("MouseUp()" + count++); - toolTipManager.disableToolTip(); - break; - } - } - }; - - /** - * Build a tracker for the specified control. Constructor. - * - * @param control - */ - public MouseHoverTracker(Control control, ImageToolTipManager toolTipManager) { - this.control = control; - this.toolTipManager = toolTipManager; - activate(); - } - - public void activate() { - control.addMouseTrackListener(mouseTrackListener); - control.addListener(SWT.MouseUp, mouseClickedListener); - } - - public void deactivate() { - control.removeMouseTrackListener(mouseTrackListener); - control.removeListener(SWT.MouseUp, mouseClickedListener); - toolTipManager.dispose(); - } - - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/TabItemPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/TabItemPart.java deleted file mode 100644 index cca4c7c1220..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/TabItemPart.java +++ /dev/null @@ -1,279 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal; - -import org.eclipse.papyrus.sasheditor.internal.AbstractPart.GarbageState; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.custom.CTabItem; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Control; - -/** - * A controller associated to a tabitem in a tabfolder. This controller contains - * a reference to a PagePart. This class is used exclusively by the - * TabFolderPart. It should be not used from elsewhere. - * - * @author dumoulin - * - */ -public class TabItemPart { - - /** - * The associated model TODO : change the type - */ - // protected Object model; - - /** - * The child associated to this tabitem. The child is rendered by the - * tabitem. - */ - protected PagePart childPart; - - /** - * Parent owning this TabItem. Can be null if the Part is orphaned. Even if - * it is orphaned, the SWT Item still set. - */ - protected TabFolderPart parent; - - /** - * The SWT item associated to this part. This item contains the control of - * the associated editor. - */ - protected CTabItem control; - - /** Garbage state used during refresh */ - protected GarbageState garbageState; - - /** - * Constructor. Create a TabItem for the provided modelPart. - * - * @param tabFolderPart - * @param modelPart - * @param index - */ - public TabItemPart(TabFolderPart parent, PagePart modelPart, int index) { - this.parent = parent; - this.childPart = modelPart; - - createItemControl(index); - } - - /** - * Create the part control and the control of the child. - * - * @param tabFolder - * @param index - */ - public void createItemControl(int index) { - // Create the item - CTabItem item = new CTabItem(getTabFolder(), SWT.NONE, index); - control = item; - if(childPart != null) { - item.setControl(childPart.getControl()); - refreshTabDecorations(); - } - } - - /** - * Set the tab decorations: label, icon. - */ - public void refreshTabDecorations() { - setTabText(childPart.getPageTitle()); - setTabImage(childPart.getPageIcon()); - } - - /** - * Reset this TabItem to use the new part. Reparent the new part and orphan - * the old part. - * - * @param modelPart - */ - protected void resetChild(PagePart newChild) { - childPart.orphan(); - newChild.reparent(parent); - childPart = newChild; - setItemControl(childPart.getControl()); - - refreshTabDecorations(); - } - - /** - * Get the container of the Parent. This container is used as root of the - * Controls associated to this editor. - * - * @return - */ - private CTabFolder getTabFolder() { - return (CTabFolder)parent.getControl(); - } - - /** - * Fill the provided part map with the child's parts. - * - * @param partMap - */ - public void fillPartMap(PartLists partMap) { - - childPart.fillPartMap(partMap); - garbageState = GarbageState.UNVISITED; - } - - /** - * Remove the TabPart. Dispose the associated SWT CTabItem. (TODO Remove - * from the parent list.) Orphan the associated ITilePart - * - * @see - * @return the parent - */ - protected void remove() { - - // setControl() change the visibility of the underlying SWT control - // (here the editor). - // This should not happen if the editor is already attached to another - // folder. - // check this case and remember the flag to put it back if needed - setItemControl(null); - parent = null; - control.dispose(); - // Orphan associates Tiles - childPart.orphan(); - } - - /** - * Set the item control. Setting the item control with the - * control.setControl() method has a side effect: the previous control is - * modified with previousControl.setVisible(false). This is annoying when - * the previous control has already been attached to another parent. This - * method take care to not change the visibility of the previous control if - * it is detached from the item's parent. - * - * @param newControl - */ - private void setItemControl(Control newControl) { - // setControl() change the visibility of the underlying SWT control - // (here the editor). - // This should not happen if the editor is already attached to another - // folder. - // check this case and remember the flag to put it back if needed - boolean editorIsVisible = false; - // Get previously attached editor's control - Control editorControl = control.getControl(); - if(editorControl != null && editorControl.getParent() != control.getParent()) { - // Editor has already been reattached - // Remember its visible flag - editorIsVisible = editorControl.getVisible(); - // Detach the item's control - control.setControl(newControl); - if(editorIsVisible) - editorControl.setVisible(editorIsVisible); - } else { - // Not reattached, do nothing else - control.setControl(newControl); - } - } - - /** - * Dispose the associated control. Only dispose this tabitem, not the - * childpart. - */ - public void dispose() { - Control itemControl = control.getControl(); - control.dispose(); - - // Dispose the inner control if any. - if(!itemControl.isDisposed()) - itemControl.dispose(); - - // - parent = null; - } - - /** - * Set the image of the associated tab. - * - * @param titleImage - */ - private void setTabImage(Image titleImage) { - control.setImage(titleImage); - } - - /** - * Set the text of the associated tab. - * - * @param title - */ - private void setTabText(String title) { - if(title == null) - title = ""; - control.setText(title); - control.setToolTipText(title); - } - - /** - * Return the associated EditorTile. - * - * @return - */ - public PagePart getChildPart() { - return childPart; - } - - /** - * Locates the part that intersects the given point and that have the - * expected type - * - * @param position - * @return - */ - public AbstractPart findPartAt(Point position, Class expectedTileType) { - - // if(expectedTileType == this.getClass()) - // return this; - - return childPart.findPartAt(position, expectedTileType); - } - - /** - * Accept the provided visitor. Call the corresponding accept method in the - * visitor. - * - * @param visitor - * @return - */ - public boolean visit(IPartVisitor visitor) { - return visitor.accept(this); - } - - /** - * Visit the children of this Tile. - * - * @param visitor - */ - public boolean visitChildren(IPartVisitor visitor) { - return childPart.visit(visitor); - } - - /** - * Return true if this TabItem is for the specified rawModel. - * - * @param curModel - * @return - */ - public boolean isTabItemFor(Object rawModel) { - return rawModel.equals(getChildPart().getRawModel()); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/eclipsecopy/AbstractTabFolderPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/eclipsecopy/AbstractTabFolderPart.java deleted file mode 100644 index bd1a2a0d57b..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/eclipsecopy/AbstractTabFolderPart.java +++ /dev/null @@ -1,501 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal.eclipsecopy; - -import org.eclipse.papyrus.sasheditor.internal.AbstractPanelPart; -import org.eclipse.papyrus.sasheditor.internal.IPanelParent; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.custom.CTabItem; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * Copy of org.eclipse.ui.part.MultiPageEditorPart. Change if to be suitable has - * a sash leaf. A multi-page editor is an editor with multiple pages, each of - * which may contain an editor or an arbitrary SWT control. - *

- * This class is intented to separate folder stuff into 2 classes. Subclasses must implement the following methods: - *

    - *
  • createPages - to create the required pages by calling one of the addPage methods
  • - *
  • IEditorPart.doSave - to save contents of editor
  • - *
  • IEditorPart.doSaveAs - to save contents of editor
  • - *
  • IEditorPart.isSaveAsAllowed - to enable Save As
  • - *
  • IEditorPart.gotoMarker - to scroll to a marker
  • - *
- *

- *

- * Multi-page editors have a single action bar contributor, which manages contributions for all the pages. The contributor must be a subclass of - * AbstractMultiPageEditorActionBarContributor. Note that since any nested editors are created directly in code by callers of - * addPage(IEditorPart,IEditorInput), nested editors do not have their own contributors. - *

- * - * @see org.eclipse.ui.part.MultiPageEditorActionBarContributor - */ -public abstract class AbstractTabFolderPart extends AbstractPanelPart { - - /** - * Subclasses that override {@link #createPageContainer(Composite)} can use - * this constant to get a site for the container that can be active while - * the current page is deactivated. - * - * @since 3.4 - * @see #activateSite() - * @see #deactivateSite(boolean, boolean) - * @see #getPageSite(int) - */ - protected static final int PAGE_CONTAINER_SITE = 65535; - - // /** - // * Private tracing output. - // */ - // private static final String TRACING_COMPONENT = "MPE"; //$NON-NLS-1$ - - // /** - // * The active service locator. This value may be null if - // there is no selected page, or if the selected page is a control with no - // site. - // */ - // private INestable activeServiceLocator; - // - // - // private IServiceLocator pageContainerSite; - - /** - * Creates an empty multi-page editor with no pages. - */ - protected AbstractTabFolderPart(IPanelParent parent) { - super(parent); - } - - /** - * The MultiPageEditor implementation of this IWorkbenchPart method creates the control for the multi-page - * editor by calling createContainer, then createPages. Subclasses should implement createPages rather than - * overriding this method. - * - * @param parent - * The parent in which the editor should be created; must not be null. - */ - @Override - abstract public void createPartControl(Composite parent); - - /** - * Returns the active nested editor if there is one. - *

- * Subclasses should not override this method - *

- * - * @return the active nested editor, or null if none - */ - // public IEditorPart getActiveEditor() { - // int index = getActivePage(); - // if (index != -1) { - // return getEditor(index); - // } - // return null; - // } - - /** - * Returns the index of the currently active page of this folder, or -1 if - * there is no active page. - *

- * Subclasses should not override this method - *

- * - * @return the index of the active page, or -1 if there is no active page - */ - protected int getActivePage() { - CTabFolder tabFolder = getTabFolder(); - if(tabFolder != null && !tabFolder.isDisposed()) { - return tabFolder.getSelectionIndex(); - } - return -1; - } - - /** - * Returns the control for the given page index, or null if no - * control has been set for the page. The page index must be valid. - *

- * Subclasses should not override this method - *

- * - * @param pageIndex - * the index of the page - * @return the control for the specified page, or null if none - * has been set - */ - protected Control getControl(int pageIndex) { - return getItem(pageIndex).getControl(); - } - - /** - * Returns the editor for the given page index. The page index must be - * valid. - * - * @param pageIndex - * the index of the page - * @return the editor for the specified page, or null if the - * specified page was not created with addPage(IEditorPart,IEditorInput) - */ - // abstract protected IEditorPart getEditor(int pageIndex); - - /** - * Returns the service locator for the given page index. This method can be - * used to create service locators for pages that are just controls. The - * page index must be valid. - *

- * This will return the editor site service locator for an editor, and create one for a page that is just a control. - *

- * - * @param pageIndex - * the index of the page - * @return the editor for the specified page, or null if the - * specified page was not created with addPage(IEditorPart,IEditorInput) - * @since 3.4 - */ - // protected final IServiceLocator getPageSite(int pageIndex) { - // if (pageIndex == PAGE_CONTAINER_SITE) { - // return getPageContainerSite(); - // } - // - // /** - // * Return the site associated to the editor. - // */ - // return getEditor(pageIndex).getSite(); - // } - - /** - * @return A site that can be used with a header. - * @since 3.4 - * @see #createPageContainer(Composite) - * @see #PAGE_CONTAINER_SITE - * @see #getPageSite(int) - */ - // private IServiceLocator getPageContainerSite() { - // if (pageContainerSite == null) { - // IServiceLocatorCreator slc = (IServiceLocatorCreator) - // getSite().getService(IServiceLocatorCreator.class); - // pageContainerSite = slc.createServiceLocator(getSite(), null, new - // IDisposable() { - // - // public void dispose() { - // final Control control = ((PartSite) getSite()).getPane().getControl(); - // if (control != null && !control.isDisposed()) { - // ((PartSite) getSite()).getPane().doHide(); - // } - // } - // }); - // } - // return pageContainerSite; - // } - - /** - * Returns the tab item for the given page index (page index is 0-based). - * The page index must be valid. - * - * @param pageIndex - * the index of the page - * @return the tab item for the given page index - */ - private CTabItem getItem(int pageIndex) { - return getTabFolder().getItem(pageIndex); - } - - /** - * Returns the number of pages in this multi-page editor. - * - * @return the number of pages - */ - protected int getPageCount() { - CTabFolder folder = getTabFolder(); - // May not have been created yet, or may have been disposed. - if(folder != null && !folder.isDisposed()) { - return folder.getItemCount(); - } - return 0; - } - - /** - * Returns the tab folder containing this multi-page editor's pages. - * - * @return the tab folder, or null if createPartControl has not been called yet - */ - protected abstract CTabFolder getTabFolder(); - - /** - * Notifies this multi-page editor that the page with the given id has been - * activated. This method is called when the user selects a different tab. - *

- * The MultiPageEditorPart implementation of this method sets focus to the new page, and notifies the action bar contributor (if - * there is one). This checks whether the action bar contributor is an instance of MultiPageEditorActionBarContributor, and, if so, - * calls setActivePage with the active nested editor. This also fires a selection change event if required. - *

- *

- * Subclasses may extend this method. - *

- * - * @param newPageIndex - * the index of the activated page - */ - protected void pageChange(int newPageIndex) { - // System.out.println(this.getClass().getSimpleName() + "pageChange()"); - // deactivateSite(false, false); - // - // IPartService partService = (IPartService) - // getSite().getService(IPartService.class); - // if (partService.getActivePart() == this) { - // setFocus(newPageIndex); - // } - // - // IEditorPart activeEditor = getEditor(newPageIndex); - // - // IEditorActionBarContributor contributor = - // getEditorSite().getActionBarContributor(); - // if (contributor != null && contributor instanceof - // MultiPageEditorActionBarContributor) { - // ((MultiPageEditorActionBarContributor) - // contributor).setActivePage(activeEditor); - // } - // - // if (activeEditor != null) { - // ISelectionProvider selectionProvider = - // activeEditor.getSite().getSelectionProvider(); - // if (selectionProvider != null) { - // ISelectionProvider outerProvider = getSite().getSelectionProvider(); - // if (outerProvider instanceof MultiPageSelectionProvider) { - // SelectionChangedEvent event = new - // SelectionChangedEvent(selectionProvider, - // selectionProvider.getSelection()); - // - // MultiPageSelectionProvider provider = (MultiPageSelectionProvider) - // outerProvider; - // provider.fireSelectionChanged(event); - // provider.firePostSelectionChanged(event); - // } else { - // if (Policy.DEBUG_MPE) { - // Tracing.printTrace(TRACING_COMPONENT, "MultiPageEditorPart " + getTitle() //$NON-NLS-1$ - // + " did not propogate selection for " //$NON-NLS-1$ - // + activeEditor.getTitle()); - // } - // } - // } - // } - // - // activateSite(); - } - - /** - * This method can be used by implementors of {@link AbstractTabFolderPart#createPageContainer(Composite)} to - * deactivate the active inner editor services while their header has focus. - * A deactivateSite() must have a matching call to activateSite() when - * appropriate. - *

- * An new inner editor will have its site activated on a {@link AbstractTabFolderPart#pageChange(int)}. - *

- *

- * Note: This API is evolving in 3.4 and this might not be its final form. - *

- * - * @param immediate - * immediately deactivate the legacy keybinding service - * @param containerSiteActive - * Leave the page container site active. - * @since 3.4 - * @see #activateSite() - * @see #createPageContainer(Composite) - * @see #getPageSite(int) - * @see #PAGE_CONTAINER_SITE - */ - // protected final void deactivateSite(boolean immediate, boolean - // containerSiteActive) { - // // Deactivate the nested services from the last active service locator. - // if (activeServiceLocator != null) { - // activeServiceLocator.deactivate(); - // activeServiceLocator = null; - // } - // - // final int pageIndex = getActivePage(); - // final IKeyBindingService service = getSite().getKeyBindingService(); - // if (pageIndex < 0 || pageIndex >= getPageCount() || immediate) { - // // There is no selected page, so deactivate the active service. - // if (service instanceof INestableKeyBindingService) { - // final INestableKeyBindingService nestableService = - // (INestableKeyBindingService) service; - // nestableService.activateKeyBindingService(null); - // } else { - // WorkbenchPlugin - // .log("MultiPageEditorPart.deactivateSite() Parent key binding service was not an instance of INestableKeyBindingService. It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$ - // } - // } - // - // if (containerSiteActive) { - // IServiceLocator containerSite = getPageContainerSite(); - // if (containerSite instanceof INestable) { - // activeServiceLocator = (INestable) containerSite; - // activeServiceLocator.activate(); - // } - // } - // } - - /** - * This method can be used by implementors of {@link #createPageContainer(Composite)} to activate the active inner - * editor services when their header loses focus. - *

- * An new inner editor will have its site activated on a {@link #pageChange(int)}. - *

- *

- * Note: This API is evolving in 3.4 and this might not be its final form. - *

- * - * @since 3.4 - * @see #deactivateSite(boolean,boolean) - * @see #createPageContainer(Composite) - * @see #getPageSite(int) - */ - // protected final void activateSite() { - // if (activeServiceLocator != null) { - // activeServiceLocator.deactivate(); - // activeServiceLocator = null; - // } - // - // final IKeyBindingService service = getSite().getKeyBindingService(); - // final int pageIndex = getActivePage(); - // final IEditorPart editor = getEditor(pageIndex); - // - // if (editor != null) { - // // active the service for this inner editor - // if (service instanceof INestableKeyBindingService) { - // final INestableKeyBindingService nestableService = - // (INestableKeyBindingService) service; - // nestableService.activateKeyBindingService(editor.getEditorSite()); - // - // } else { - // WorkbenchPlugin - // .log("MultiPageEditorPart.activateSite() Parent key binding service was not an instance of INestableKeyBindingService. It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$ - // } - // // Activate the services for the new service locator. - // final IServiceLocator serviceLocator = editor.getEditorSite(); - // if (serviceLocator instanceof INestable) { - // activeServiceLocator = (INestable) serviceLocator; - // activeServiceLocator.activate(); - // } - // - // } else { - // Item item = getItem(pageIndex); - // - // // There is no selected editor, so deactivate the active service. - // if (service instanceof INestableKeyBindingService) { - // final INestableKeyBindingService nestableService = - // (INestableKeyBindingService) service; - // nestableService.activateKeyBindingService(null); - // } else { - // WorkbenchPlugin - // .log("MultiPageEditorPart.activateSite() Parent key binding service was not an instance of INestableKeyBindingService. It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$ - // } - // - // if (item.getData() instanceof INestable) { - // activeServiceLocator = (INestable) item.getData(); - // activeServiceLocator.activate(); - // } - // } - // } - - // /** - // * Disposes the given part and its site. - // * - // * @param part - // * The part to dispose; must not be null. - // */ - // private void disposePart(final IWorkbenchPart part) { - // SafeRunner.run(new ISafeRunnable() { - // - // public void run() { - // IWorkbenchPartSite partSite = part.getSite(); - // part.dispose(); - // if (partSite instanceof MultiPageEditorSite) { - // ((MultiPageEditorSite) partSite).dispose(); - // } - // } - // - // public void handleException(Throwable e) { - // // Exception has already being logged by Core. Do nothing. - // } - // }); - // } - - /** - * Sets the currently active page for this folder. - * - * @param pageIndex - * the index of the page to be activated; the index must be valid - */ - public void setActivePage(int pageIndex) { - // Assert.isTrue(pageIndex >= 0 && pageIndex < getPageCount()); - if(!isValidPageIndex(pageIndex)) - return; - - getTabFolder().setSelection(pageIndex); - pageChange(pageIndex); - } - - /** - * Return true if the specified index is valid. The index should be between - * 0 and pageCount. If there is no page, return false. - * - * @param pageIndex - * @return - */ - private boolean isValidPageIndex(int pageIndex) { - - return pageIndex >= 0 && pageIndex < getPageCount(); - } - - /** - * Sets the control for the given page index. The page index must be valid. - * - * @param pageIndex - * the index of the page - * @param control - * the control for the specified page, or null to - * clear the control - */ - protected void setControl(int pageIndex, Control control) { - getItem(pageIndex).setControl(control); - } - - /* *************************************** */ - /* Added method. */ - /* *************************************** */ - - // /** - // * Title of this TilePart ? Needed by a trace message. - // */ - // protected String getTitle() { - // return getClass().toString(); - // } - // - // /** - // * - // */ - // protected IWorkbenchPartSite getSite() { - // return getEditorSite(); - // } - // - // /** - // * - // */ - // abstract protected void firePropertyChange(int propertyId); - // - // /** - // * - // */ - // abstract protected IEditorSite getEditorSite(); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java deleted file mode 100644 index 81b3712533f..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java +++ /dev/null @@ -1,554 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal.eclipsecopy; - -import java.util.ArrayList; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.jface.viewers.IPostSelectionProvider; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorActionBarContributor; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IKeyBindingService; -import org.eclipse.ui.INestableKeyBindingService; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.internal.PartSite; -import org.eclipse.ui.internal.PopupMenuExtender; -import org.eclipse.ui.internal.WorkbenchPlugin; -import org.eclipse.ui.internal.services.INestable; -import org.eclipse.ui.internal.services.IServiceLocatorCreator; -import org.eclipse.ui.internal.services.IWorkbenchLocationService; -import org.eclipse.ui.internal.services.ServiceLocator; -import org.eclipse.ui.internal.services.WorkbenchLocationService; -import org.eclipse.ui.part.EditorActionBarContributor; -import org.eclipse.ui.services.IDisposable; -import org.eclipse.ui.services.IServiceLocator; -import org.eclipse.ui.services.IServiceScopes; - -/** - * Site for a nested editor within a multi-page editor. Selection is handled by - * forwarding the event to the multi-page editor's selection listeners; most - * other methods are forwarded to the multi-page editor's site. - *

- * The base implementation of MultiPageEditor.createSite creates an instance of this class. This class may be instantiated or subclassed. - *

- * - * @see org.eclipse.ui.part.MultiPageEditorSite.class - */ -public class MultiPageEditorSite implements IEditorSite, INestable { - - org.eclipse.ui.part.MultiPageEditorSite e; - - /** - * The actionBarContributor associated to the site. Can be null. In this - * case, use the multiEditor ActionBarContributor. - */ - protected EditorActionBarContributor actionBarContributor; - - /** - * The nested editor. - */ - private IEditorPart editor; - - /** - * The list of popup menu extenders; null if none registered. - */ - private ArrayList menuExtenders; - - /** - * The main editor EditorSite. - */ - private IEditorSite mainEditorSite; - - /** - * The post selection changed listener. - */ - private ISelectionChangedListener postSelectionChangedListener = null; - - /** - * The selection change listener, initialized lazily; null if - * not yet created. - */ - private ISelectionChangedListener selectionChangedListener = null; - - /** - * The selection provider; null if none. - * - * @see MultiPageEditorSite#setSelectionProvider(ISelectionProvider) - */ - private ISelectionProvider selectionProvider = null; - - /** - * The cached copy of the key binding service specific to this multi-page - * editor site. This value is null if it is not yet - * initialized. - */ - private IKeyBindingService service = null; - - /** - * The local service locator for this multi-page editor site. This value is - * never null. - */ - private final ServiceLocator serviceLocator; - - /** - * Creates a site for the given editor nested within the given multi-page - * editor. - * - * @param mainEditorSite - * the multi-page editor - * @param editor - * the nested editor - * @param editDomain - * The shared editDomain. - */ - public MultiPageEditorSite(IEditorSite mainEditorSite, IEditorPart editor, EditorActionBarContributor actionBarContributor) { - Assert.isNotNull(mainEditorSite); - Assert.isNotNull(editor); - this.mainEditorSite = mainEditorSite; - this.editor = editor; - this.actionBarContributor = actionBarContributor; - - final IServiceLocator parentServiceLocator = mainEditorSite; - IServiceLocatorCreator slc = (IServiceLocatorCreator)parentServiceLocator.getService(IServiceLocatorCreator.class); - this.serviceLocator = (ServiceLocator)slc.createServiceLocator(mainEditorSite, null, new IDisposable() { - - public void dispose() { - final Control control = ((PartSite)getMainEditorSite()).getPane().getControl(); - if(control != null && !control.isDisposed()) { - ((PartSite)getMainEditorSite()).getPane().doHide(); - } - } - }); - - initializeDefaultServices(); - } - - /** - * Return the site of the main editor. - * - * @return - */ - private IWorkbenchPartSite getMainEditorSite() { - return mainEditorSite; - } - - /** - * Return the EditorSite of the main editor. This is the same object as - * getMainEditorSite. TODO: Remove this one. - * - * @return - */ - private IEditorSite getMainEditorEditorSite() { - return mainEditorSite; - } - - /** - * Initialize the slave services for this site. - */ - private void initializeDefaultServices() { - serviceLocator.registerService(IWorkbenchLocationService.class, new WorkbenchLocationService(IServiceScopes.MPESITE_SCOPE, getWorkbenchWindow().getWorkbench(), getWorkbenchWindow(), getMainEditorSite(), this, null, 3)); - } - - /** - * Notifies the multi page editor service that the component within which it - * exists has become active. - * - * @since 3.2 - */ - public final void activate() { - serviceLocator.activate(); - } - - /** - * Notifies the multi page editor service that the component within which it - * exists has been deactived. - * - * @since 3.2 - */ - public final void deactivate() { - serviceLocator.deactivate(); - } - - /** - * Dispose the contributions. - */ - public void dispose() { - if(menuExtenders != null) { - for(int i = 0; i < menuExtenders.size(); i++) { - ((PopupMenuExtender)menuExtenders.get(i)).dispose(); - } - menuExtenders = null; - } - - // Remove myself from the list of nested key binding services. - if(service != null) { - // TODO : check original implem - use main editor site ! - IKeyBindingService parentService = getEditor().getSite().getKeyBindingService(); - if(parentService instanceof INestableKeyBindingService) { - INestableKeyBindingService nestableParent = (INestableKeyBindingService)parentService; - nestableParent.removeKeyBindingService(this); - } - // TODO : dispose service ? - - service = null; - } - - if(serviceLocator != null) { - serviceLocator.dispose(); - } - } - - /** - * The MultiPageEditorSite implementation of this IEditorSite method returns the EditorActionBarContributor - * associated to the site if one is defined, or the - * EditorActionBarContributor of the multiEditor. - * - * @return null - */ - public IEditorActionBarContributor getActionBarContributor() { - - // If we use an action bar contributor, look for a registered - // ActionBarContributor. - // TODO : enable next asap - // ActionBarContributor contributor = - // multiPageEditor.getEditorSite().getActionBarContributor(); - // if(contributor instanceof ComposedActionBarContributor) - // { - // ComposedActionBarContributor composedContributor = - // (ComposedActionBarContributor)contributor; - // return composedContributor.getContributorFor(editor); - // } - - // Return the main ActionBarContributor, usually - // ComposedActionBarContributor - - if(actionBarContributor != null) - return actionBarContributor; - else - return getMainEditorEditorSite().getActionBarContributor(); - // return null; - } - - /** - * The MultiPageEditorSite implementation of this IEditorSite method forwards to the multi-page editor to - * return the action bars. - * - * @return The action bars from the parent multi-page editor. - */ - public IActionBars getActionBars() { - return getMainEditorEditorSite().getActionBars(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - return null; - } - - /** - * The MultiPageEditorSite implementation of this IWorkbenchPartSite method forwards to the multi-page editor - * to return the decorator manager. - * - * @return The decorator from the workbench window. - * @deprecated use IWorkbench.getDecoratorManager() - */ - public ILabelDecorator getDecoratorManager() { - return getWorkbenchWindow().getWorkbench().getDecoratorManager().getLabelDecorator(); - } - - /** - * Returns the nested editor. - * - * @return the nested editor - */ - public IEditorPart getEditor() { - return editor; - } - - /** - * The MultiPageEditorSite implementation of this IWorkbenchPartSite method returns an empty string since the - * nested editor is not created from the registry. - * - * @return An empty string. - */ - public String getId() { - return ""; //$NON-NLS-1$ - } - - /* - * (non-Javadoc) Method declared on IEditorSite. - */ - public IKeyBindingService getKeyBindingService() { - if(service == null) { - service = getMainEditorEditorSite().getKeyBindingService(); - if(service instanceof INestableKeyBindingService) { - INestableKeyBindingService nestableService = (INestableKeyBindingService)service; - service = nestableService.getKeyBindingService(this); - - } else { - /* - * This is an internal reference, and should not be copied by - * client code. If you are thinking of copying this, DON'T DO - * IT. - */ - WorkbenchPlugin.log("MultiPageEditorSite.getKeyBindingService() Parent key binding service was not an instance of INestableKeyBindingService. It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - return service; - } - - /** - * The MultiPageEditorSite implementation of this IWorkbenchPartSite method forwards to the multi-page editor - * to return the workbench page. - * - * @return The workbench page in which this editor site resides. - */ - public IWorkbenchPage getPage() { - return getMainEditorSite().getPage(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchPartSite#getPart() - */ - public IWorkbenchPart getPart() { - return editor; - } - - /** - * The MultiPageEditorSite implementation of this IWorkbenchPartSite method returns an empty string since the - * nested editor is not created from the registry. - * - * @return An empty string. - */ - public String getPluginId() { - return ""; //$NON-NLS-1$ - } - - /** - * Returns the post selection change listener which listens to the nested - * editor's selection changes. - * - * @return the post selection change listener. - */ - private ISelectionChangedListener getPostSelectionChangedListener() { - if(postSelectionChangedListener == null) { - postSelectionChangedListener = new ISelectionChangedListener() { - - public void selectionChanged(SelectionChangedEvent event) { - MultiPageEditorSite.this.handlePostSelectionChanged(event); - } - }; - } - return postSelectionChangedListener; - } - - /** - * The MultiPageEditorSite implementation of this IWorkbenchPartSite method returns an empty string since the - * nested editor is not created from the registry. - * - * @return An empty string. - */ - public String getRegisteredName() { - return ""; //$NON-NLS-1$ - } - - /** - * Returns the selection changed listener which listens to the nested - * editor's selection changes, and calls handleSelectionChanged . - * - * @return the selection changed listener - */ - private ISelectionChangedListener getSelectionChangedListener() { - if(selectionChangedListener == null) { - selectionChangedListener = new ISelectionChangedListener() { - - public void selectionChanged(SelectionChangedEvent event) { - MultiPageEditorSite.this.handleSelectionChanged(event); - } - }; - } - return selectionChangedListener; - } - - /** - * The MultiPageEditorSite implementation of this IWorkbenchPartSite method returns the selection provider set - * by setSelectionProvider. - * - * @return The current selection provider. - */ - public ISelectionProvider getSelectionProvider() { - return selectionProvider; - } - - public final Object getService(final Class key) { - return serviceLocator.getService(key); - } - - /** - * The MultiPageEditorSite implementation of this IWorkbenchPartSite method forwards to the multi-page editor - * to return the shell. - * - * @return The shell in which this editor site resides. - */ - public Shell getShell() { - return getMainEditorSite().getShell(); - } - - /** - * The MultiPageEditorSite implementation of this IWorkbenchPartSite method forwards to the multi-page editor - * to return the workbench window. - * - * @return The workbench window in which this editor site resides. - */ - public IWorkbenchWindow getWorkbenchWindow() { - return getMainEditorSite().getWorkbenchWindow(); - } - - /** - * Handles a post selection changed even from the nexted editor. - *

- * Subclasses may extend or reimplement this method - * - * @param event - * the event - * - * @since 3.2 - */ - protected void handlePostSelectionChanged(SelectionChangedEvent event) { - ISelectionProvider parentProvider = getMainEditorSite().getSelectionProvider(); - - // TODO : use org.eclipse.ui.part.MultiPageSelectionProvider ? - if(parentProvider instanceof MultiPageSelectionProvider) { - SelectionChangedEvent newEvent = new SelectionChangedEvent(parentProvider, event.getSelection()); - MultiPageSelectionProvider prov = (MultiPageSelectionProvider)parentProvider; - prov.firePostSelectionChanged(newEvent); - } - } - - /** - * Handles a selection changed event from the nested editor. The default - * implementation gets the selection provider from the multi-page editor's - * site, and calls fireSelectionChanged on it (only if it is an - * instance of MultiPageSelectionProvider), passing a new event - * object. - *

- * Subclasses may extend or reimplement this method. - *

- * - * @param event - * the event - */ - protected void handleSelectionChanged(SelectionChangedEvent event) { - ISelectionProvider parentProvider = getMainEditorSite().getSelectionProvider(); - if(parentProvider instanceof MultiPageSelectionProvider) { - SelectionChangedEvent newEvent = new SelectionChangedEvent(parentProvider, event.getSelection()); - MultiPageSelectionProvider prov = (MultiPageSelectionProvider)parentProvider; - prov.fireSelectionChanged(newEvent); - } - } - - public final boolean hasService(final Class key) { - return serviceLocator.hasService(key); - } - - /** - * The MultiPageEditorSite implementation of this IWorkbenchPartSite method forwards to the multi-page editor - * for registration. - * - * @param menuManager - * The menu manager - * @param selProvider - * The selection provider. - */ - public void registerContextMenu(MenuManager menuManager, ISelectionProvider selProvider) { - getMainEditorSite().registerContextMenu(menuManager, selProvider); - } - - public final void registerContextMenu(final MenuManager menuManager, final ISelectionProvider selectionProvider, final boolean includeEditorInput) { - registerContextMenu(getId(), menuManager, selectionProvider, includeEditorInput); - } - - /** - * The MultiPageEditorSite implementation of this IWorkbenchPartSite method forwards to the multi-page editor - * for registration. - * - * @param menuID - * The identifier for the menu. - * @param menuMgr - * The menu manager - * @param selProvider - * The selection provider. - */ - public void registerContextMenu(String menuID, MenuManager menuMgr, ISelectionProvider selProvider) { - if(menuExtenders == null) { - menuExtenders = new ArrayList(1); - } - PartSite.registerContextMenu(menuID, menuMgr, selProvider, true, editor, menuExtenders); - } - - public final void registerContextMenu(final String menuId, final MenuManager menuManager, final ISelectionProvider selectionProvider, final boolean includeEditorInput) { - if(menuExtenders == null) { - menuExtenders = new ArrayList(1); - } - PartSite.registerContextMenu(menuId, menuManager, selectionProvider, includeEditorInput, editor, menuExtenders); - } - - /** - * The MultiPageEditorSite implementation of this IWorkbenchPartSite method remembers the selection provider, - * and also hooks a listener on it, which calls handleSelectionChanged when a selection changed event - * occurs. - * - * @param provider - * The selection provider. - * @see MultiPageEditorSite#handleSelectionChanged(SelectionChangedEvent) - */ - public void setSelectionProvider(ISelectionProvider provider) { - ISelectionProvider oldSelectionProvider = selectionProvider; - selectionProvider = provider; - if(oldSelectionProvider != null) { - // see code WindowSelectionService (line287) - // in some case as GraphicalView do not implement - // IPostSelectionProvider - oldSelectionProvider.removeSelectionChangedListener(getSelectionChangedListener()); - if(oldSelectionProvider instanceof IPostSelectionProvider) { - ((IPostSelectionProvider)oldSelectionProvider).removePostSelectionChangedListener(getPostSelectionChangedListener()); - } else { - oldSelectionProvider.removeSelectionChangedListener(getPostSelectionChangedListener()); - } - } - if(selectionProvider != null) { - selectionProvider.addSelectionChangedListener(getSelectionChangedListener()); - if(selectionProvider instanceof IPostSelectionProvider) { - ((IPostSelectionProvider)selectionProvider).addPostSelectionChangedListener(getPostSelectionChangedListener()); - } else { - selectionProvider.addSelectionChangedListener(getPostSelectionChangedListener()); - - } - } - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/eclipsecopy/MultiPageSelectionProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/eclipsecopy/MultiPageSelectionProvider.java deleted file mode 100644 index 3b6c9bed10c..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/eclipsecopy/MultiPageSelectionProvider.java +++ /dev/null @@ -1,176 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.papyrus.sasheditor.internal.eclipsecopy; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.core.runtime.SafeRunner; -import org.eclipse.jface.util.SafeRunnable; -import org.eclipse.jface.viewers.IPostSelectionProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.papyrus.sasheditor.editor.IMultiPageEditorPart; -import org.eclipse.ui.IEditorPart; - -/** - * Manages the current selection in a multi-page editor by tracking the active - * nested editor within the multi-page editor. When the selection changes, - * notifications are sent to all registered listeners. - *

- * This class may be instantiated; it is not intended to be subclassed. The base implementation of MultiPageEditor.init creates an - * instance of this class. - *

- * - * @noextend This class is not intended to be subclassed by clients. - */ -public class MultiPageSelectionProvider implements IPostSelectionProvider { - - /** - * Registered selection changed listeners (element type: ISelectionChangedListener). - */ - private ListenerList listeners = new ListenerList(); - - /** - * Registered post selection changed listeners. - */ - private ListenerList postListeners = new ListenerList(); - - /** - * The multi-page editor. - */ - private IMultiPageEditorPart multiPageEditor; - - /** - * Creates a selection provider for the given multi-page editor. - * - * @param multiPageEditor - * the multi-page editor - */ - public MultiPageSelectionProvider(IMultiPageEditorPart multiPageEditor) { - Assert.isNotNull(multiPageEditor); - this.multiPageEditor = multiPageEditor; - } - - /* - * (non-Javadoc) Method declared on ISelectionProvider. - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - listeners.add(listener); - } - - /** - * Adds a listener for post selection changes in this multi page selection - * provider. - * - * @param listener - * a selection changed listener - * @since 3.2 - */ - public void addPostSelectionChangedListener(ISelectionChangedListener listener) { - postListeners.add(listener); - } - - /** - * Notifies all registered selection changed listeners that the editor's - * selection has changed. Only listeners registered at the time this method - * is called are notified. - * - * @param event - * the selection changed event - */ - public void fireSelectionChanged(final SelectionChangedEvent event) { - Object[] listeners = this.listeners.getListeners(); - fireEventChange(event, listeners); - } - - /** - * Notifies all post selection changed listeners that the editor's selection - * has changed. - * - * @param event - * the event to propogate. - * @since 3.2 - */ - public void firePostSelectionChanged(final SelectionChangedEvent event) { - Object[] listeners = postListeners.getListeners(); - fireEventChange(event, listeners); - } - - private void fireEventChange(final SelectionChangedEvent event, Object[] listeners) { - for(int i = 0; i < listeners.length; ++i) { - final ISelectionChangedListener l = (ISelectionChangedListener)listeners[i]; - SafeRunner.run(new SafeRunnable() { - - public void run() { - l.selectionChanged(event); - } - }); - } - } - - // /** - // * Returns the multi-page editor. - // * - // * @return the multi-page editor. - // */ - // private IMultiPageEditorPart getMultiPageEditor() { - // return multiPageEditor; - // } - - /* - * (non-Javadoc) Method declared on ISelectionProvider. - */ - public ISelection getSelection() { - IEditorPart activeEditor = multiPageEditor.getActiveEditor(); - if(activeEditor != null) { - ISelectionProvider selectionProvider = activeEditor.getSite().getSelectionProvider(); - if(selectionProvider != null) { - return selectionProvider.getSelection(); - } - } - return StructuredSelection.EMPTY; - } - - /* - * (non-JavaDoc) Method declaed on ISelectionProvider. - */ - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - listeners.remove(listener); - } - - /** - * Removes a listener for post selection changes in this multi page - * selection provider. - * - * @param listener - * a selection changed listener - * @since 3.2 - */ - public void removePostSelectionChangedListener(ISelectionChangedListener listener) { - postListeners.remove(listener); - } - - /* - * (non-Javadoc) Method declared on ISelectionProvider. - */ - public void setSelection(ISelection selection) { - IEditorPart activeEditor = multiPageEditor.getActiveEditor(); - if(activeEditor != null) { - ISelectionProvider selectionProvider = activeEditor.getSite().getSelectionProvider(); - if(selectionProvider != null) { - selectionProvider.setSelection(selection); - } - } - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/ITabTooltipPreferences.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/ITabTooltipPreferences.java deleted file mode 100644 index b05d96fc1f4..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/ITabTooltipPreferences.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.eclipse.papyrus.sasheditor.internal.preferences; - - - -public interface ITabTooltipPreferences { - - /** - * Constant used in Eclipse preferences - */ - public String isTooltipEnable = "isTooltipEnable"; - public String isTooltipForCurrentTabShown = "isTooltipForCurrentTabShown"; - public String scaledFactor = "scaledFactor"; - public String tooltipAutoCloseDelay = "tooltipAutoCloseDelay"; - - - /** - * Is the tooltip Enable ? - * If true, tooltip are displayed. - * If false, they are not displayed. - * - * @return - */ - public abstract boolean isTooltipEnable(); - - /** - * Is an tooltip shown when the flied tabs is the tab for the cuurently shown diagram ? - * If true, the tooltip is shown. - * If false, the tooltip is not shown. - * - * @return - */ - public abstract boolean isTooltipForCurrentTabShown(); - - /** - * - * @return - */ - public abstract float getScaledFactor(); - - /** - * - * @return - */ - public int getIntScaledFactor(); - - /** - * Return the delay used to close automatically the tooltip. - * @return The delay in millisecond or -1 if there is no delay. - */ - public abstract int getTooltipAutoCloseDelay(); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/ShowPreferencesHandler.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/ShowPreferencesHandler.java deleted file mode 100644 index be0954dca67..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/ShowPreferencesHandler.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.internal.preferences; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.IHandler; - - -/** - * An handler getting the selected element and reporting them in console. - * - * @author Cedric dumoulin - * - */ -public class ShowPreferencesHandler extends AbstractHandler implements IHandler { - - - /** - * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) - * @param event - * @return - * @throws ExecutionException - * - */ - public Object execute(ExecutionEvent event) throws ExecutionException { - - - ITabTooltipPreferences settings = new TabTooltipPreferences(); - - showPreferences(settings); - - - return null; - } - - private void showPreferences(ITabTooltipPreferences settings) { - - System.out.println( ITabTooltipPreferences.isTooltipEnable + "=" + settings.isTooltipEnable()); - System.out.println( ITabTooltipPreferences.isTooltipForCurrentTabShown + "=" + settings.isTooltipForCurrentTabShown()); - System.out.println( ITabTooltipPreferences.scaledFactor + "=" + settings.getScaledFactor()); - System.out.println( ITabTooltipPreferences.scaledFactor + "(int)=" + settings.getIntScaledFactor()); - System.out.println( ITabTooltipPreferences.tooltipAutoCloseDelay + "=" + settings.getTooltipAutoCloseDelay()); - - } - - /** - * Get the name used in the {@link RecordingCommand}. This name will be visible in - * undo/redo. - * - * @return The command name to show. - */ - public String getCommandName() { - return "Read Preferences"; - } - - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/TabTooltipPreferenceInitializer.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/TabTooltipPreferenceInitializer.java deleted file mode 100644 index 1c235922b82..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/TabTooltipPreferenceInitializer.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.eclipse.papyrus.sasheditor.internal.preferences; - -import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.core.runtime.preferences.DefaultScope; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.papyrus.sasheditor.Activator; -import org.eclipse.ui.preferences.ScopedPreferenceStore; - -/** - * Class used to initialize default preference values. - */ -public class TabTooltipPreferenceInitializer extends AbstractPreferenceInitializer { - - /** - * - * - */ - public void initializeDefaultPreferences() { - IPreferenceStore store = createPreferenceStore(); - store.setDefault(ITabTooltipPreferences.isTooltipEnable, true); - store.setDefault(ITabTooltipPreferences.isTooltipForCurrentTabShown, false); - store.setDefault(ITabTooltipPreferences.scaledFactor, 50); - store.setDefault(ITabTooltipPreferences.tooltipAutoCloseDelay, 5000); - - - } - - /** - * Subclasses may implements this method in order to provide the requested preferenceStore. - * @return - */ - protected IPreferenceStore createPreferenceStore() { - IPreferenceStore store = new ScopedPreferenceStore(DefaultScope.INSTANCE, Activator.getDefault().getBundle().getSymbolicName()); - - return store; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/TabTooltipPreferencePage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/TabTooltipPreferencePage.java deleted file mode 100644 index 575ddf5bfea..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/TabTooltipPreferencePage.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.eclipse.papyrus.sasheditor.internal.preferences; - -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.IntegerFieldEditor; -import org.eclipse.jface.preference.ScaleFieldEditor; -import org.eclipse.papyrus.sasheditor.Activator; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.preferences.ScopedPreferenceStore; - -/** - * This class represents a preference page that - * is contributed to the Preferences dialog. By - * subclassing FieldEditorPreferencePage, we - * can use the field support built into JFace that allows - * us to create a page that is small and knows how to - * save, restore and apply itself. - *

- * This page is used to modify preferences only. They - * are stored in the preference store that belongs to - * the main plug-in class. That way, preferences can - * be accessed directly via the preference store. - */ - -public class TabTooltipPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - - public TabTooltipPreferencePage() { - super(GRID); - -// IPreferenceStore store = new ScopedPreferenceStore(new InstanceScope(), Activator.getDefault().getBundle().getSymbolicName()); - IPreferenceStore store = createPreferenceStore(); - setPreferenceStore(store); - setDescription("SashWindows Tabs Tooltip Preferences"); - - } - - /** - * Subclasses may implements this method in order to provide the requested preferenceStore. - * @return - */ - protected IPreferenceStore createPreferenceStore() { - IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.getDefault().getBundle().getSymbolicName()); - - return store; - } - - - /** - * Creates the field editors. Field editors are abstractions of - * the common GUI blocks needed to manipulate various types - * of preferences. Each field editor knows how to save and - * restore itself. - */ - public void createFieldEditors() { - addField( - new BooleanFieldEditor( ITabTooltipPreferences.isTooltipEnable, "Is Tooltip &Enable", getFieldEditorParent())); - - addField( - new BooleanFieldEditor( ITabTooltipPreferences.isTooltipForCurrentTabShown, "Is Tooltip For &Current Tab Shown", getFieldEditorParent())); - - addField( - new IntegerFieldEditor(ITabTooltipPreferences.tooltipAutoCloseDelay, "Auto Close &Delay (in ms)", getFieldEditorParent(), 10)); - - addField( - new ScaleFieldEditor(ITabTooltipPreferences.scaledFactor, "Tooltip &Scale", getFieldEditorParent(), 0, 100, 1, 10)); - - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) - */ - public void init(IWorkbench workbench) { - } - -} \ No newline at end of file diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/TabTooltipPreferences.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/TabTooltipPreferences.java deleted file mode 100644 index 4d059e9b886..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/internal/preferences/TabTooltipPreferences.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.sasheditor.internal.preferences; - -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.papyrus.sasheditor.Activator; -import org.eclipse.ui.preferences.ScopedPreferenceStore; - - -/** - * An implementation retrieving values from Eclipse preferences - * @author cedric dumoulin - * - */ -public class TabTooltipPreferences implements ITabTooltipPreferences { - - /** - * Store used to access preferences. - */ - protected IPreferenceStore store; - - public TabTooltipPreferences() { - IPreferenceStore store = createPreferenceStore(); - setPreferenceStore(store); - } - - /** - * Subclasses may implements this method in order to provide the requested preferenceStore. - * @return - */ - protected IPreferenceStore createPreferenceStore() { - IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.getDefault().getBundle().getSymbolicName()); - - return store; - } - - - /** - * @return the store - */ - public IPreferenceStore getPreferenceStore() { - return store; - } - - - /** - * @param store the store to set - */ - public void setPreferenceStore(IPreferenceStore store) { - this.store = store; - } - - /** - * @see org.eclipse.papyrus.examples.preferences.wsprefs.ITabTooltipPreferences#isTooltipEnable() - * - * @return - */ - public boolean isTooltipEnable() { - - return store.getBoolean(ITabTooltipPreferences.isTooltipEnable); - } - - /** - * @see org.eclipse.papyrus.examples.preferences.wsprefs.ITabTooltipPreferences#isTooltipForCurrentTabShown() - * - * @return - */ - public boolean isTooltipForCurrentTabShown() { - return store.getBoolean(ITabTooltipPreferences.isTooltipForCurrentTabShown); - } - - /** - * @see org.eclipse.papyrus.examples.preferences.wsprefs.ITabTooltipPreferences#getScaledFactor() - * - * @return - */ - public float getScaledFactor() { - return (store.getInt(ITabTooltipPreferences.scaledFactor)/100.0f); - - } - - /** - * @see org.eclipse.papyrus.examples.preferences.wsprefs.ITabTooltipPreferences#getScaledFactor() - * - * @return - */ - public int getIntScaledFactor() { - return store.getInt(ITabTooltipPreferences.scaledFactor); - - } - - /** - * @see org.eclipse.papyrus.examples.preferences.wsprefs.ITabTooltipPreferences#getTooltipAutoCloseDelay() - * - * @return - */ - public int getTooltipAutoCloseDelay() { - return store.getInt(ITabTooltipPreferences.tooltipAutoCloseDelay); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/multipage/editor/MultiPageEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/multipage/editor/MultiPageEditor.java deleted file mode 100644 index f4eea220a4b..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/sasheditor/multipage/editor/MultiPageEditor.java +++ /dev/null @@ -1,381 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA LIST & LIFL - * - * - * 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: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.sasheditor.multipage.editor; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.papyrus.sasheditor.contentprovider.IAbstractPanelModel; -import org.eclipse.papyrus.sasheditor.contentprovider.IComponentModel; -import org.eclipse.papyrus.sasheditor.contentprovider.IEditorModel; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashPanelModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.ITabFolderModel; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.MultiPageEditorPart; - -/** - * A MultiPageEditor implementation accepting IMultiSashContentProvider as - * content provider. This implementation extends the regular eclipse - * MultiPageEditorPart. The refresh() method allows to refresh the tabs. - * - * The implementation do not listen on model change. This can be done by - * subclasses. To add a new tab, one should add it as a model in the - * ContentProvider. The addPage() methods should not be used for this purpose. - * - * This implementation is intended for debug and testing purpose : it can be - * used in place of the AbstractMultiPageSashEditor. It takes the same arguments - * and ContentProvider, but it only allows one folder and don't deal with - * multisashes. Also, the implementation use the regular Eclipse EditorSite - * management. This allows to check for problems from this site management. - * - * @author dumoulin - */ -public abstract class MultiPageEditor extends MultiPageEditorPart { - - /** Log object */ - protected Logger log = Logger.getLogger(getClass().getName()); - - /** The pageProvider */ - private ISashWindowsContentProvider pageProvider; - - /** - * The tabfolder model providing the pages that must be shown. - */ - private ITabFolderModel tabFolderModel; - - /** Ordered set of currently shown diagrams */ - protected List currentTabs = new ArrayList(); - - /** - * Constructor. - */ - public MultiPageEditor() { - super(); - } - - /** - * This method is called at the end of createPartControl(). Just intercept - * the call in order to call activate(). Create the part controls. {@inheritDoc} - */ - @Override - protected void initializePageSwitching() { - - super.initializePageSwitching(); - activate(); - } - - /** - * Method to activate the editor. Called immediately after - * createPartControl() is complete. To be implemented by subclasses. Default - * implementation do nothing. - */ - protected void activate() { - - } - - /** - * Method to deactivate the editor. Called when dispose() is called. To be - * implemented by subclasses. Default implementation do nothing. - */ - protected void deactivate() { - - } - - /** - * Dispose the Editor. Also dispose the sashsystem. - * - * @see org.eclipse.ui.part.WorkbenchPart#dispose() - * - */ - @Override - public void dispose() { - deactivate(); - super.dispose(); - // sashContainer.dispose(); - } - - @Override - public Object getAdapter(Class adapter) { - - // Get the content provider if requested. - if(ISashWindowsContentProvider.class == adapter) - return getContentProvider(); - - return super.getAdapter(adapter); - } - - /** - * get the contentProvider. Create it if necessary. - * - * @return - */ - protected ISashWindowsContentProvider getContentProvider() { - if(pageProvider == null) - pageProvider = createPageProvider(); - - return pageProvider; - } - - /** - * @param pageProvider - * the pageProvider to set - */ - protected void setContentProvider(ISashWindowsContentProvider pageProvider) { - this.pageProvider = pageProvider; - } - - /** - * Add a page containing the Component described by the provided model. - * - * @param tabItem - */ - protected int addPage(IComponentModel tabItem) { - Composite composite = tabItem.createPartControl(getContainer()); - - int index = addPage(composite); - setPageText(index, tabItem.getTabTitle()); - Image image = tabItem.getTabIcon(); - if(image != null) - setPageImage(index, image); - return index; - } - - /** - * Add the editor corresponding to the model to the folder. - * - * @param editorModel - */ - protected int addPage(IEditorModel editorModel) { - try { - IEditorPart editor = editorModel.createIEditorPart(); - int index = addPage(editor, getEditorInput()); - setPageText(index, editorModel.getTabTitle()); - Image image = editorModel.getTabIcon(); - if(image != null) - setPageImage(index, image); - return index; - } catch (PartInitException e) { - ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus()); - return -1; - } - - } - - /** - * Creates the pages of the multi-page editor. - */ - protected void createPages() { - // get the page descriptions - pageProvider = getContentProvider(); - // Get the current tabFolder - // - tabFolderModel = lookupFolder(); - - refreshTabs(); - - // // iterate over pages to be show - // for( Object rawPageModel : tabFolderModel.getChildren() ) - // { - // // Get the model interface - // ITabItemModel tabItem = tabFolderModel.createChildSashModel( - // rawPageModel); - // if(tabItem instanceof IEditorModel ) - // { - // addPage((IEditorModel)tabItem ); - // } - // else if(tabItem instanceof IComponentModel ) - // { - // addPage((IComponentModel)tabItem ); - // } - // else - // { - // System.err.println("Can't create page for model '" + tabItem + - // "'. Skipp it."); - // } - // } - } - - /** - * Lookup for a folder in the SashModel. Return the first folder found. - * - * @return - */ - private ITabFolderModel lookupFolder() { - if(pageProvider == null) - return null; - - Object rawModel = pageProvider.getRootModel(); - IAbstractPanelModel panelModel = pageProvider.createChildSashModel(rawModel); - - return lookupFolder(panelModel); - } - - /** - * Recursively search in sash models for a FolderModel. Return the first - * encountered folder. - * - * @param panelModel - * @return - */ - private ITabFolderModel lookupFolder(IAbstractPanelModel panelModel) { - - if(panelModel instanceof ITabFolderModel) - return (ITabFolderModel)panelModel; - else { - ISashPanelModel sashModel = (ISashPanelModel)panelModel; - // Iterate on children - for(Object child : sashModel.getChildren()) { - IAbstractPanelModel childModel = pageProvider.createChildSashModel(child); - ITabFolderModel res = lookupFolder(childModel); - if(res != null) - return res; - } - } - // Not found - return null; - } - - /** - * Create the provider. Subclass must implements this method. It should - * return the provider used by the editor. - * - */ - abstract protected ISashWindowsContentProvider createPageProvider(); - - /** - * Refresh the tabs order. This method should be called after the model list - * is modified. - */ - protected void refreshTabs() { - // get list of diagrams to be displayed - List newModels = tabFolderModel.getChildren(); - - // Check if each model has an open pageEditor. If not, create the - // editor. - Iterator newIter = newModels.iterator(); - while(newIter.hasNext()) { - Object model = newIter.next(); - if(!tabExistsFor(model)) { // create a new editor for the model - IPageModel pageModel = tabFolderModel.createChildSashModel(model); - if(pageModel != null) { - addEditor(pageModel); - } - } - } - - // If open editor count is the same has models count, - // all models have an editor. So, end the refresh process. - if(newModels.size() == getPageCount()) - return; - - // There is some extra editors ! remove them. - // remove extra editors : for each open editor, check if its model is in - // the list of required models. - List toBeRemoved = new ArrayList(); - Iterator currentIter = currentTabs.iterator(); - while(currentIter.hasNext()) { - IPageModel model = currentIter.next(); - if(!newModels.contains(model.getRawModel())) { // remove editor - toBeRemoved.add(model); - } - } - - // Remove editor from the editors displayed by the multi editor - Iterator removeIter = toBeRemoved.iterator(); - while(removeIter.hasNext()) { - IPageModel model = removeIter.next(); - removeEditor(model); - } - } - - /** - * Check if an editor exists for the specified model. - * - * @param model - * the diagram (model) that should be displayed - * @return true if the editor exists for this model - */ - private boolean tabExistsFor(Object model) { - for(IPageModel tabItem : currentTabs) { - if(tabItem.getRawModel() == model) - return true; - } - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.MultiPageEditorPart#removePage(int) - */ - @Override - public void removePage(int pageIndex) { - super.removePage(pageIndex); - // synchronize the list of currently shown models. - currentTabs.remove(pageIndex); - } - - /** - * Removes the editor associated to the specified model. - * - * @param model - * the diagram (model) displayed in the editor - */ - private void removeEditor(IPageModel model) { - int index = currentTabs.indexOf(model); - removePage(index); - } - - /** - * Add a new editor at the end of existing editors. First, create the - * editor, then add it to the tabs. - * - * @param contentProvider - * the diagram (model) to be displayed in the editor - */ - private void addEditor(IPageModel tabItem) { - // Check if an editor already exists - if(tabExistsFor(tabItem)) { - if(log.isLoggable(Level.FINE)) - log.fine("Editor already exists for '" + tabItem + "'"); - return; - } - - int editorIndex = -1; - if(tabItem instanceof IEditorModel) { - editorIndex = addPage((IEditorModel)tabItem); - } else if(tabItem instanceof IComponentModel) { - editorIndex = addPage((IComponentModel)tabItem); - } else { - System.err.println("Can't create page for model '" + tabItem + "'. Skipp it."); - return; - } - - // Add the model in the list of current tabs. - currentTabs.add(tabItem); - // set active page - setActivePage(editorIndex); - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/.options b/plugins/infra/core/org.eclipse.papyrus.infra.core/.options index e98ce7bb88b..7b6d533158e 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/.options +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/.options @@ -1,6 +1,6 @@ # master switch -org.eclipse.papyrus.core/debug=true +org.eclipse.papyrus.infra.core/debug=true # switch for tracing papyrus core -org.eclipse.papyrus.core/debug/core=true +org.eclipse.papyrus.infra.core/debug/core=true # switch for tracing papyrus extension point loading -org.eclipse.papyrus.core/debug/extensionpoint=true \ No newline at end of file +org.eclipse.papyrus.infra.core/debug/extensionpoint=true \ No newline at end of file diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF index f119db8a1f4..0523b8ad727 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF @@ -1,36 +1,36 @@ Manifest-Version: 1.0 -Require-Bundle: org.eclipse.papyrus.infra.sasheditor;bundle-version="0.9.0";visibility:=reexport, - org.eclipse.papyrus.infra.sasheditor.di;bundle-version="0.9.0";visibility:=reexport, +Require-Bundle: org.eclipse.papyrus.infra.core.sasheditor;bundle-version="0.9.0";visibility:=reexport, + org.eclipse.papyrus.infra.core.sasheditor.di;bundle-version="0.9.0";visibility:=reexport, org.eclipse.ui.ide;bundle-version="3.4.0";visibility:=reexport, org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.1.0";visibility:=reexport, org.eclipse.emf.edit.ui;bundle-version="2.6.0";visibility:=reexport, org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="0.9.0";visibility:=reexport -Export-Package: org.eclipse.papyrus.core, - org.eclipse.papyrus.core.contentoutline, - org.eclipse.papyrus.core.editor, - org.eclipse.papyrus.core.editorsfactory, - org.eclipse.papyrus.core.extension, - org.eclipse.papyrus.core.extension.commands, - org.eclipse.papyrus.core.extension.diagrameditor, - org.eclipse.papyrus.core.lifecycleevents, - org.eclipse.papyrus.core.listenerservice, - org.eclipse.papyrus.core.modelsetquery, - org.eclipse.papyrus.core.modelsetquery.impl;x-friends:="org.eclipse.papyrus.uml.resourceloading.profile", - org.eclipse.papyrus.core.multidiagram.actionbarcontributor, - org.eclipse.papyrus.core.services, - org.eclipse.papyrus.core.ui, - org.eclipse.papyrus.core.utils, - org.eclipse.papyrus.resource, - org.eclipse.papyrus.resource.notation, - org.eclipse.papyrus.resource.sasheditor, - org.eclipse.papyrus.resource.uml +Export-Package: org.eclipse.papyrus.infra.core, + org.eclipse.papyrus.infra.core.contentoutline, + org.eclipse.papyrus.infra.core.editor, + org.eclipse.papyrus.infra.core.editorsfactory, + org.eclipse.papyrus.infra.core.extension, + org.eclipse.papyrus.infra.core.extension.commands, + org.eclipse.papyrus.infra.core.extension.diagrameditor, + org.eclipse.papyrus.infra.core.lifecycleevents, + org.eclipse.papyrus.infra.core.listenerservice, + org.eclipse.papyrus.infra.core.modelsetquery, + org.eclipse.papyrus.infra.core.modelsetquery.impl;x-friends:="org.eclipse.papyrus.uml.resourceloading.profile", + org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor, + org.eclipse.papyrus.infra.core.resource, + org.eclipse.papyrus.infra.core.resource.notation, + org.eclipse.papyrus.infra.core.resource.sasheditor, + org.eclipse.papyrus.infra.core.resource.uml, + org.eclipse.papyrus.infra.core.services, + org.eclipse.papyrus.infra.core.ui, + org.eclipse.papyrus.infra.core.utils 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.core.Activator +Bundle-Activator: org.eclipse.papyrus.infra.core.Activator Bundle-SymbolicName: org.eclipse.papyrus.infra.core;singleton:=true Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml b/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml index 756b31fe0c5..719e8a1b3c0 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml @@ -12,9 +12,9 @@ + id="org.eclipse.papyrus.uml.diagram.ui.toolbar"> + value="org.eclipse.papyrus.infra.core.papyrusEditor"> @@ -31,12 +31,12 @@ + locationURI="toolbar:org.eclipse.papyrus.uml.diagram.ui.toolbar"> + locationURI="popup:org.eclipse.papyrus.infra.core.editor.ui.tabmenu?endof=tabcommands"> @@ -44,13 +44,13 @@ + value="org.eclipse.papyrus.infra.core.papyrusEditor"> @@ -58,13 +58,13 @@ + value="org.eclipse.papyrus.infra.core.papyrusEditor"> @@ -72,7 +72,7 @@ + value="org.eclipse.papyrus.infra.core.papyrusEditor"> @@ -80,22 +80,22 @@ + locationURI="menu:org.eclipse.papyrus.infra.core.commands.dropdowncommand"> + value="org.eclipse.papyrus.infra.core.papyrusEditor"> @@ -103,13 +103,13 @@ + value="org.eclipse.papyrus.infra.core.papyrusEditor"> @@ -117,7 +117,7 @@ + value="org.eclipse.papyrus.infra.core.papyrusEditor"> @@ -127,74 +127,74 @@ + class="org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.commands.CloseDiagramCommand" + commandId="org.eclipse.papyrus.infra.core.commands.closediagram"> + class="org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.commands.CloseAllDiagramsCommand" + commandId="org.eclipse.papyrus.infra.core.commands.closealldiagram"> + class="org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.commands.CloseOtherDiagramsCommand" + commandId="org.eclipse.papyrus.infra.core.commands.closeothersdiagrams"> + point="org.eclipse.papyrus.infra.core.model"> + point="org.eclipse.papyrus.infra.core.service"> + serviceKeyRef="org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelMngr"> + serviceKeyRef="org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelMngr"> + serviceKeyRef=" org.eclipse.papyrus.infra.core.lifecycleevents.ISaveAndDirtyService"> diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/contentOutline.exsd b/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/contentOutline.exsd index 18d72546961..2d9c56c7a7f 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/contentOutline.exsd +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/contentOutline.exsd @@ -1,9 +1,9 @@ - + - + Specify the content outline to be used by the Papyrus backbone. @@ -60,10 +60,10 @@ The class implementing the contentOutline. -Class must extends org.eclipse.papyrus.core.contentoutline.IPapyrusContentOutlinePage. +Class must extends org.eclipse.papyrus.infra.core.contentoutline.IPapyrusContentOutlinePage. - + diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/model.exsd b/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/model.exsd index 76acdba8c94..4d1277ff396 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/model.exsd +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/model.exsd @@ -1,9 +1,9 @@ - + - + A model represent a unit containing model elements. @@ -76,7 +76,7 @@ This is the class that wil be registered in the ModelSet. The class will be registered using the key set in the Model. - + @@ -107,7 +107,7 @@ For example, it is possible to add listeners to the model. The code is executed right after the model is loaded. - + @@ -136,7 +136,7 @@ A snippet allows to do post operations after ModelSet is loaded. The code is executed right after the modelSet is loaded. - + diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/modelListener.exsd b/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/modelListener.exsd index 5cc3436db8e..bcfa22b3e41 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/modelListener.exsd +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/modelListener.exsd @@ -1,9 +1,9 @@ - + - + This extension is used to plug a listener that will know all event in uml model di2 or notation. @@ -69,7 +69,7 @@ Class that is realizes this listener - + diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/papyrusDiagram.exsd b/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/papyrusDiagram.exsd index 943ab4f7da2..f6263ab3e65 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/papyrusDiagram.exsd +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/papyrusDiagram.exsd @@ -1,13 +1,13 @@ - + - + <p> -The <code>org.eclipse.papyrus.core.papyrusDiagram</code> extension point is used to register a new diagram editor within Papyrus. Once diagram editor is registered it can be used in the Papyrus multi-page diagram editor. The editor can have its own icon, label, a button for the creation action in the toolbar, and the possibility to be created using new Papyrus Model wizard. +The <code>org.eclipse.papyrus.infra.core.papyrusDiagram</code> extension point is used to register a new diagram editor within Papyrus. Once diagram editor is registered it can be used in the Papyrus multi-page diagram editor. The editor can have its own icon, label, a button for the creation action in the toolbar, and the possibility to be created using new Papyrus Model wizard. </p> <p>Papyrus uses the term "<b>Diagram Category</b>" to categorize domain models and the term "<b>Diagram Kind</b>" to specialize a diagram editor for a domain model. Each Diagram Kind belongs to exactly one Diagram Category, Diagram Category can contains many Diagram Kinds. Papyrus supports <b>UML</b>, <b>Profile</b> and <b>SysML</b> diagram categories. @@ -71,10 +71,10 @@ The <code>org.eclipse.papyrus.core.papyrusDiagram</code> extension p - a name of the fully qualified class that implements <samp> org.eclipse.papyrus.sasheditor.extension.IEditorFactory</samp>. It is used to create an instance of the editor. + a name of the fully qualified class that implements <samp> org.eclipse.papyrus.infra.core.sasheditor.extension.IEditorFactory</samp>. It is used to create an instance of the editor. - + @@ -152,10 +152,10 @@ The <code>org.eclipse.papyrus.core.papyrusDiagram</code> extension p - a name of the fully qualified class that implements <samp>org.eclipse.papyrus.core.extension.commands.ICreationCommand</samp>. + a name of the fully qualified class that implements <samp>org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand</samp>. - + @@ -175,7 +175,7 @@ The <code>org.eclipse.papyrus.core.papyrusDiagram</code> extension p the action in the diagram creation menu is disabled if this condition is evaluated to false. - + @@ -185,7 +185,7 @@ The <code>org.eclipse.papyrus.core.papyrusDiagram</code> extension p the id of a diagramCategory the creation command belongs to. - + @@ -209,10 +209,10 @@ The <code>org.eclipse.papyrus.core.papyrusDiagram</code> extension p - a name of the fully qualified class that implements <samp>org.eclipse.papyrus.core.extension.commands.IModelCreationCommand</samp>. + a name of the fully qualified class that implements <samp>org.eclipse.papyrus.infra.core.extension.commands.IModelCreationCommand</samp>. - + @@ -265,7 +265,7 @@ The <code>org.eclipse.papyrus.core.papyrusDiagram</code> extension p <pre> -<extension point="org.eclipse.papyrus.core.papyrusDiagram"> +<extension point="org.eclipse.papyrus.infra.core.papyrusDiagram"> <diagramCategory id="sysml" class="org.eclipse.papyrus.sysml.diagram.common.commands.CreateSysMLModelCommand" @@ -275,7 +275,7 @@ The <code>org.eclipse.papyrus.core.papyrusDiagram</code> extension p </diagramCategory> <editorDiagram - actionBarContributorId="org.eclipse.papyrus.diagram.common.part.UMLDiagramActionBarContributor" + actionBarContributorId="org.eclipse.papyrus.uml.diagram.common.part.UMLDiagramActionBarContributor" factoryClass="org.eclipse.papyrus.sysml.diagram.requirement.RequirementDiagramEditorFactory" icon="icons/obj16/Diagram_Requirement.gif"> </editorDiagram> @@ -300,19 +300,19 @@ As Requirement diagram belongs to SysML category it will be created with a SysML - <p>The value of the <code>class</code> attribute of <code>diagramCategory</code> must represent a class that implements the <code>org.eclipse.papyrus.core.extension.commands.IModelCreationCommand</code> interface. There are a few default implementations of <code>IModelCreationCommand</code> that may be useful to users of this extension point: + <p>The value of the <code>class</code> attribute of <code>diagramCategory</code> must represent a class that implements the <code>org.eclipse.papyrus.infra.core.extension.commands.IModelCreationCommand</code> interface. There are a few default implementations of <code>IModelCreationCommand</code> that may be useful to users of this extension point: <ul> -<li><code>org.eclipse.papyrus.core.extension.commands.ModelCreationCommandBase</code> - an abstract implementation of a basic <code>IModelCreationCommand</code>.</li> -<li><code>org.eclipse.papyrus.diagram.common.commands.CreateUMLModelCommand</code></li> - implementation of IModelCreationCommand that creates a UML model. -<li><code>org.eclipse.papyrus.diagram.profile.CreateProfileModelCommand</code> - a subclass of CreateUMLModelCommand which creates Profile as a root element</li> +<li><code>org.eclipse.papyrus.infra.core.extension.commands.ModelCreationCommandBase</code> - an abstract implementation of a basic <code>IModelCreationCommand</code>.</li> +<li><code>org.eclipse.papyrus.uml.diagram.common.commands.CreateUMLModelCommand</code></li> - implementation of IModelCreationCommand that creates a UML model. +<li><code>org.eclipse.papyrus.uml.diagram.profile.CreateProfileModelCommand</code> - a subclass of CreateUMLModelCommand which creates Profile as a root element</li> <li><code>org.eclipse.papyrus.sysml.diagram.common.commands.CreateSysMLModelCommand</code> - a subclass of CreateUMLModelCommand which applies SysML profile to the root element</li> </ul> </p> <p>The value of the <code>creationCommandClass</code> attribute of <code>creationCommand</code> - must represent a class that implements the <code>org.eclipse.papyrus.core.extension.commands.ICreationCommand</code> interface. + must represent a class that implements the <code>org.eclipse.papyrus.infra.core.extension.commands.ICreationCommand</code> interface. <ul> -<li><code>org.eclipse.papyrus.core.adaptor.gmf.AbstractPapyrusGmfCreateDiagramCommandHandler</code> - an abstract implementation of a basic <code>ICreationCommand</code> for GMF diagrams. All CreationCommands for Papyrus diagrams extend this class.</li> +<li><code>org.eclipse.papyrus.infra.core.adaptor.gmf.AbstractPapyrusGmfCreateDiagramCommandHandler</code> - an abstract implementation of a basic <code>ICreationCommand</code> for GMF diagrams. All CreationCommands for Papyrus diagrams extend this class.</li> </ul> </p> diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/service.exsd b/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/service.exsd index 42f57a97f2e..bede2f658b0 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/service.exsd +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/service.exsd @@ -1,9 +1,9 @@ - + - + Define a Service used by Papyrus Editors. @@ -74,7 +74,7 @@ If not set (default), the classname is used as key. Name of the class implementing the service. - + @@ -137,7 +137,7 @@ If not set (default), the classname is used as key. Name of the class implementing the service. - + diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/transactionalEditingDomainProvider.exsd b/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/transactionalEditingDomainProvider.exsd index 9d5935ae8fa..41c5715300f 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/transactionalEditingDomainProvider.exsd +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/transactionalEditingDomainProvider.exsd @@ -1,9 +1,9 @@ - + - + [Enter description of this extension point.] @@ -55,7 +55,7 @@ - + diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/Activator.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/Activator.java deleted file mode 100644 index d09a7a69e83..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/Activator.java +++ /dev/null @@ -1,78 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core; - -import org.eclipse.papyrus.log.LogHelper; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.core"; - - // The shared instance - private static Activator plugin; - - /** Logging helper */ - public static LogHelper log = new LogHelper(); - - /** - * 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; - // register the login helper - log.setPlugin(plugin); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext - * ) - */ - @Override - public void stop(BundleContext context) throws Exception { - plugin = null; - log = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/IElementWithSemantic.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/IElementWithSemantic.java deleted file mode 100644 index ee725bc4b86..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/IElementWithSemantic.java +++ /dev/null @@ -1,34 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation - */ -package org.eclipse.papyrus.core; - -/** - * - * all implementation is used to give the semantic element form a wrapper - * - * the implementation can call method getAdapter for example for notation - * element return semantic element, for edit part return the semantic element - * and not the view... - */ -public interface IElementWithSemantic { - - /** - * return the semantic element linked to this wrapper - * - * @param wrapper - * an object that wrapped or are linked to a semantic element - * cannot be null - * @return null or the semantic element - */ - public Object getSemanticElement(Object wrapper); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/contentoutline/ContentOutlineRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/contentoutline/ContentOutlineRegistry.java deleted file mode 100644 index 009c923aff8..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/contentoutline/ContentOutlineRegistry.java +++ /dev/null @@ -1,256 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.contentoutline; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; -import org.eclipse.papyrus.core.editor.BackboneException; -import org.eclipse.papyrus.core.editor.IMultiDiagramEditor; -import org.eclipse.papyrus.core.extension.BadClassNameException; -import org.eclipse.papyrus.core.extension.NotFoundException; -import org.eclipse.papyrus.core.extension.diagrameditor.EditorDescriptorExtensionFactory; -import org.osgi.framework.Bundle; - -public class ContentOutlineRegistry { - - /** ID of the editor extension (schema filename) */ - public static final String EDITOR_EXTENSION_ID = "papyrusContentOutline"; - - private static String classAttributeName = "class"; - - private static String actionBarContributorIdPropertyName = "actionBarContributorId"; - - /** Namespace where to look for the extension points. */ - protected String extensionPointNamespace; - - /** - * The selected content outline. - */ - protected IPapyrusContentOutlinePage contentOutline; - - /** - * Associated editor. - */ - private IMultiDiagramEditor multiEditor; - - /** - * Constructor. defaultContext, input and site are explicitly required in - * order be sure that they are initialized. The multiEditor should be - * initialized. In particular, getEditorSite(), getEditorInput() and - * getDefaultContext() should return initialized values. - * - * @param multiEditor - * @param defaultContext - * @param input - * @param site - * @param extensionPointNamespace - */ - public ContentOutlineRegistry(IMultiDiagramEditor multiEditor, String extensionPointNamespace) { - this.multiEditor = multiEditor; - this.extensionPointNamespace = extensionPointNamespace; - } - - /** - * Returns the single instance of the content outline. Creates one if - * necessary. - * - * @return the contentOutline the single instance of the content outline - * @throws BackboneException - * exception thrown when the outline can not be created. - */ - public IPapyrusContentOutlinePage getContentOutline() throws BackboneException { - if(contentOutline == null) { - createContentOutline(); - } - return contentOutline; - } - - /** - * Return the {@link ContentOutlineDescriptor} with the highest priority. - * - * @return - * @throws BackboneException - * @throws NotFoundException - * If no ContentOutline can be found in extensions - */ - private ContentOutlineDescriptor getContentOutlineDescriptor() throws BackboneException { - IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointNamespace, EDITOR_EXTENSION_ID); - ContentOutlineDescriptor found = null; - - // look for the one with the highest priority - for(IConfigurationElement ele : configElements) { - ContentOutlineDescriptor desc = new ContentOutlineDescriptor(ele); - if(desc.isHigher(found)) - found = desc; - } - - // Instanciate the object - if(found == null) - throw new NotFoundException("No ContentOutline registered."); - - return found; - - } - - /** - * Creates the content outline from the selected extension. - * - * @throws BackboneException - * exception thrown when the outline can not be created. - */ - private void createContentOutline() throws BackboneException { - - ContentOutlineDescriptor found = getContentOutlineDescriptor(); - // Instanciate the object - if(found != null) { - contentOutline = found.createContentOutlinePage(); - } - } - - /** - * Inner Descriptor for content outline. This class load data from Eclipse - * extension mechanism TODO Change the parent class. It is here just to have - * quick code. - */ - protected class ContentOutlineDescriptor extends EditorDescriptorExtensionFactory { - - private int priority; - - private String className; - - private String actionBarContributorID; - - private IConfigurationElement element; - - /** - * Instance is created when requested. - */ - protected IPapyrusContentOutlinePage instance = null; - - /** - * Create a descriptor backuped by the config element. - */ - protected ContentOutlineDescriptor(IConfigurationElement element) throws BackboneException { - String tagName = "contentoutline"; - checkTagName(element, tagName); - this.className = element.getAttribute(classAttributeName); - this.actionBarContributorID = element.getAttribute(actionBarContributorIdPropertyName); - try { - this.priority = Integer.parseInt(element.getAttribute("priority")); - } catch (NumberFormatException e) { - this.priority = 0; - } - - this.element = element; - // check parameters - if(className == null) - throw new BadClassNameException("Class name must be set", "contentoutline", classAttributeName); - - } - - /** - * Compare priority. The highest priority win. - */ - public boolean isHigher(ContentOutlineDescriptor found) { - if(found == null) { - return true; - } - return this.getPriority() > found.getPriority(); - } - - /** - * Return the higher value of the descriptor. This value is used to - * order the contentOutline. The highest priority win. - */ - private int getPriority() { - return priority; - } - - /** - * @return the actionBarContributorID - */ - public String getActionBarContributorID() { - return actionBarContributorID; - } - - /** - * Returns the content outline page instance (lazy initialization) - * - * @return the context outline page - * @throws BackboneException - * exception thrown when a problem occurs. - */ - protected IPapyrusContentOutlinePage getContentOutline() throws BackboneException { - if(instance == null) { - instance = createContentOutlinePage(); - } - return instance; - } - - /** - * Create the class corresponding to the class attribute. - */ - private Class loadClass() throws BadClassNameException { - if(className == null || className.length() == 0) { - throw new BadClassNameException("Classname should be set.", "contentoutline", classAttributeName); - } - Class factoryClass; - try { - factoryClass = (Class)Class.forName(className); - } catch (ClassNotFoundException e) { - // try another way - try { - String declaringID = element.getContributor().getName(); - Bundle bundle = Platform.getBundle(declaringID); - factoryClass = (Class)bundle.loadClass(className); - } catch (ClassNotFoundException e1) { - throw new BadClassNameException("", "contentoutline", classAttributeName, e1); - } - } - return factoryClass; - } - - /** - * create the outlinepage by calling constructor without parameter and - * then call init method - * - * @return the outline. - * @throws BackboneException - */ - protected IPapyrusContentOutlinePage createContentOutlinePage() throws BackboneException { - try { - IPapyrusContentOutlinePage outline = loadClass().newInstance(); - outline.init(multiEditor); - return outline; - - } catch (SecurityException e) { - // Lets propagate. This is an implementation problem that should - // be solved by programmer. - throw new RuntimeException(e); - } - - catch (InstantiationException e) { - // Lets propagate. This is an implementation problem that should - // be solved by programmer. - // throw new RuntimeException(e); - } catch (IllegalAccessException e) { - // Lets propagate. This is an implementation problem that should - // be solved by programmer. - throw new RuntimeException(e); - } - return null; - } - - } // end class -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/contentoutline/IPapyrusContentOutlinePage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/contentoutline/IPapyrusContentOutlinePage.java deleted file mode 100644 index 44a74b7bb33..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/contentoutline/IPapyrusContentOutlinePage.java +++ /dev/null @@ -1,34 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.contentoutline; - -import org.eclipse.papyrus.core.editor.BackboneException; -import org.eclipse.papyrus.core.editor.IMultiDiagramEditor; - -/** - * Extends the original interface to add the init method. - */ -public interface IPapyrusContentOutlinePage extends org.eclipse.ui.views.contentoutline.IContentOutlinePage { - - /** - * Init the content outline. - * - * @param multiEditor - * the multiEditor is used to access to the context - * @throws BackboneException - * during research of the associated context. - */ - void init(IMultiDiagramEditor multiEditor) throws BackboneException; - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/BackboneException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/BackboneException.java deleted file mode 100644 index 4dcffc19e5f..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/BackboneException.java +++ /dev/null @@ -1,71 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.editor; - -/** - * Root of Backbone Exception - * - * @author dumoulin - * - */ -public class BackboneException extends Exception { - - /** - * serial version UID - * - * @generated - */ - private static final long serialVersionUID = 4859634627616979417L; - - /** - * Creates a new BackboneException. - */ - public BackboneException() { - super(); - } - - /** - * Creates a new BackboneException with the specified message. - * - * @param message - * the message of the exception - */ - public BackboneException(String message) { - super(message); - } - - /** - * Creates a new BackboneException with the specified cause. - * - * @param cause - * the cause of the exception - */ - public BackboneException(Throwable cause) { - super(cause); - } - - /** - * Creates a new BackboneException with a specified message and the - * specified cause. - * - * @param message - * the message of the exception - * @param cause - * the cause of the exception - */ - public BackboneException(String arg0, Throwable arg1) { - super(arg0, arg1); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/ContentProviderServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/ContentProviderServiceFactory.java deleted file mode 100644 index 350258c73ef..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/ContentProviderServiceFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.editor; - -import org.eclipse.papyrus.core.services.IServiceFactory; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.di.DiSashModelMngr; - -/** - * A service factory to create the {@link ISashWindowsContentProvider} service. - * This service depends on {@link DiSashModelMngrServiceFactory}. - * - * @author cedric dumoulin - * - */ -public class ContentProviderServiceFactory implements IServiceFactory { - - /** - * The sashModelMangr. - */ - private DiSashModelMngr sashModelMngr; - - /** - * @see org.eclipse.papyrus.core.services.IService#init(org.eclipse.papyrus.core.services.ServicesRegistry) - * - * @param servicesRegistry - * @throws ServiceException - */ - public void init(ServicesRegistry servicesRegistry) throws ServiceException { - // Get required services - sashModelMngr = servicesRegistry.getService(DiSashModelMngr.class); - - } - - /** - * @see org.eclipse.papyrus.core.services.IService#startService() - * - * @throws ServiceException - */ - public void startService() throws ServiceException { - } - - /** - * @see org.eclipse.papyrus.core.services.IService#disposeService() - * - * @throws ServiceException - */ - public void disposeService() throws ServiceException { - } - - /** - * @see org.eclipse.papyrus.core.services.IServiceFactory#createServiceInstance() - * - * @return - * @throws ServiceException - */ - public Object createServiceInstance() throws ServiceException { - return sashModelMngr.getISashWindowsContentProvider(); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/CoreMultiDiagramEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/CoreMultiDiagramEditor.java deleted file mode 100644 index 1d7064266f1..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/CoreMultiDiagramEditor.java +++ /dev/null @@ -1,809 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.core.editor; - -import static org.eclipse.papyrus.core.Activator.log; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.commands.operations.IUndoContext; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; -import org.eclipse.emf.edit.provider.ComposedAdapterFactory; -import org.eclipse.emf.edit.provider.IItemLabelProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; -import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain; -import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor; -import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer; -import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart; -import org.eclipse.gmf.runtime.emf.commands.core.command.EditingDomainUndoContext; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.papyrus.core.Activator; -import org.eclipse.papyrus.core.contentoutline.ContentOutlineRegistry; -import org.eclipse.papyrus.core.lifecycleevents.DoSaveEvent; -import org.eclipse.papyrus.core.lifecycleevents.IEditorInputChangedListener; -import org.eclipse.papyrus.core.lifecycleevents.ISaveAndDirtyService; -import org.eclipse.papyrus.core.multidiagram.actionbarcontributor.ActionBarContributorRegistry; -import org.eclipse.papyrus.core.multidiagram.actionbarcontributor.CoreComposedActionBarContributor; -import org.eclipse.papyrus.core.services.ExtensionServicesRegistry; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServiceMultiException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.core.utils.BusinessModelResolver; -import org.eclipse.papyrus.resource.ModelMultiException; -import org.eclipse.papyrus.resource.ModelSet; -import org.eclipse.papyrus.sasheditor.contentprovider.IContentChangedListener; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.di.DiSashModelMngr; -import org.eclipse.papyrus.sasheditor.contentprovider.di.IPageModelFactory; -import org.eclipse.papyrus.sasheditor.contentprovider.di.TransactionalDiSashModelMngr; -import org.eclipse.papyrus.sasheditor.editor.AbstractMultiPageSashEditor; -import org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer; -import org.eclipse.papyrus.sasheditor.editor.gef.MultiDiagramEditorGefDelegate; -import org.eclipse.ui.IEditorActionBarContributor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IViewReference; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IGotoMarker; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; -import org.eclipse.ui.views.properties.IPropertySheetPage; -import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; - -/** - * Multi diagram editor allowing to plug various kind of editors. Editors are registered with the help of the Eclipse extension mechanism. This - * implementation allows to register editors and context - * separately. An editor should specify which context it need to run. This multi diagram editor allows to show editor side by side in one or more sash - * windows. - * - * The real implementation for the generic type T of SashMultiPageEditorPart is actually di2.Diagram - * - * @author cedric dumoulin - * @author Jerome Benois - * @author Thomas Szadel Refactoring. - * - * TODO : remove GMF dependency ! - */ -public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implements IMultiDiagramEditor, ITabbedPropertySheetPageContributor, IDiagramWorkbenchPart, IGotoMarker { - - /** Gef adapter */ - private MultiDiagramEditorGefDelegate gefAdaptorDelegate; - - /** ContentOutline registry */ - private ContentOutlineRegistry contentOutlineRegistry; - - /** Services registry. Used to get registered services */ - private ServicesRegistry servicesRegistry; - - /** - * ActionBarContributor Registry. Allows to get an ActionBar by its Id. The registry is initialized from the Eclipse extension mechanism. - */ - private ActionBarContributorRegistry actionBarContributorRegistry; - - /** SashModelMngr to add pages */ - protected DiSashModelMngr sashModelMngr; - - /** - * Service used to maintain the dirty state and to perform save and saveAs. - */ - protected ISaveAndDirtyService saveAndDirtyService; - - /** - * Listener on {@link ISaveAndDirtyService#addInputChangedListener(IEditorInputChangedListener)} - */ - protected IEditorInputChangedListener editorInputChangedListener = new IEditorInputChangedListener() { - - /** - * This method is called when the editor input is changed from the ISaveAndDirtyService. - * - * @see org.eclipse.papyrus.core.lifecycleevents.IEditorInputChangedListener#editorInputChanged(org.eclipse.ui.part.FileEditorInput) - * - * @param fileEditorInput - */ - public void editorInputChanged(FileEditorInput fileEditorInput) { - // Change the editor input. - setInputWithNotify(fileEditorInput); - setPartName(fileEditorInput.getName()); - } - - /** - * The isDirty flag has changed, reflect its new value - * - * @see org.eclipse.papyrus.core.lifecycleevents.IEditorInputChangedListener#isDirtyChanged() - * - */ - public void isDirtyChanged() { - - // Run it in async way. - getSite().getShell().getDisplay().asyncExec(new Runnable() { - - public void run() { - firePropertyChange(IEditorPart.PROP_DIRTY); - } - }); - } - }; - - private TransactionalEditingDomain transactionalEditingDomain; - - /** - * Object managing models lifeCycle. - */ - protected ModelSet resourceSet; - - /** - * Cached event that can be reused. - */ - protected DoSaveEvent lifeCycleEvent; - - /** - * - */ - private TabbedPropertySheetPage tabbedPropertySheetPage = null; - - /** - * My editing domain provider. - */ - private IEditingDomainProvider domainProvider = new IEditingDomainProvider() { - - public EditingDomain getEditingDomain() { - return transactionalEditingDomain; - } - }; - - /** - * A listener on model change events. - */ - private IContentChangedListener contentChangedListener = new IContentChangedListener() { - - /** - * Called when the content is changed. RefreshTabs. - */ - public void contentChanged(ContentEvent event) { - refreshTabs(); - } - }; - - /** - * Undo context used to have the same undo context in all Papyrus related views and editors. - * TODO : move away, use a version independent of GMF, add a listener that will add - * the context to all commands modifying attached Resources (==> linked to ModelSet ?) - */ - private EditingDomainUndoContext undoContext; - - /** - * Get the contentOutlineRegistry. Create it if needed. - * - * @return the contentOutlineRegistry - */ - protected ContentOutlineRegistry getContentOutlineRegistry() { - if(contentOutlineRegistry == null) { - createContentOutlineRegistry(); - } - - return contentOutlineRegistry; - } - - /** - * Create the contentOutlineRegistry. - */ - private void createContentOutlineRegistry() { - contentOutlineRegistry = new ContentOutlineRegistry(this, Activator.PLUGIN_ID); - } - - /** - * Returns the service registry associated to the editor. - * - * @return the servicesRegistry The registry. - */ - public ServicesRegistry getServicesRegistry() { - if(servicesRegistry == null) { - servicesRegistry = createServicesRegistry(); - } - return servicesRegistry; - } - - /** - * Create the ServicesRegistry. - * - * @return - */ - private ServicesRegistry createServicesRegistry() { - // Create Services Registry - try { - ServicesRegistry servicesRegistry = new ExtensionServicesRegistry(Activator.PLUGIN_ID); - // servicesRegistry.startRegistry(); - return servicesRegistry; - } catch (ServiceException e) { - // Show log and error - log.error(e.getMessage(), e); - } - return null; - } - - /** - * Do nothing as we create the provider before any calls to this method. - * Should not be called by subclasses. - * - * @see org.eclipse.papyrus.sasheditor.editor.AbstractMultiPageSashEditor#createPageProvider() - */ - @Override - protected ISashWindowsContentProvider createPageProvider() { - throw new UnsupportedOperationException("Not implemented. Should not be called as the ContentProvider is already initialized."); - } - - /** - * Create the pageContentProvider. - * - * @param pageFactory - * @param diResource - * Resource used to load/save the SashModel. - */ - protected ISashWindowsContentProvider createPageProvider(IPageModelFactory pageFactory, Resource diResource, TransactionalEditingDomain editingDomain) { - - sashModelMngr = new TransactionalDiSashModelMngr(pageFactory, diResource, editingDomain); - - ISashWindowsContentProvider pageProvider = sashModelMngr.getISashWindowsContentProvider(); - - return pageProvider; - } - - /** - * Get The {@link IPageMngr} used to add, open, remove or close a diagram in the - * SashWindow. - * This method is available as soon as the {@link CoreMultiDiagramEditor#init(IEditorSite, IEditorInput)} method is called. - * - * @return - */ - protected IPageMngr getIPageMngr() throws IllegalStateException { - try { - return sashModelMngr.getIPageMngr(); - } catch (Exception e) { - throw new IllegalStateException("Method should be called after CoreMultiDiagramEditor#init(IEditorSite, IEditorInput) is called"); - } - } - - /** - * Get the ActionBarContributorRegistry. Creates it if necessary. - * - * @return - */ - protected ActionBarContributorRegistry getActionBarContributorRegistry() { - if(actionBarContributorRegistry != null) { - return actionBarContributorRegistry; - } - - // Try to got it from CoreComposedActionBarContributor - // The ActionBarContributorRegistry is initialized by the Contributor. - // Get it from the contributor. - IEditorActionBarContributor contributor = getEditorSite().getActionBarContributor(); - if(contributor instanceof CoreComposedActionBarContributor) { - log.debug(getClass().getSimpleName() + " - ActionBarContributorRegistry loaded from CoreComposedActionBarContributor."); - return ((CoreComposedActionBarContributor)contributor).getActionBarContributorRegistry(); - } else { - // Create a registry. - log.debug(getClass().getSimpleName() + " - create an ActionBarContributorRegistry."); - return createActionBarContributorRegistry(); - } - - } - - /** - * Create the ActionBarContributorRegistry. - * - * @return - */ - private ActionBarContributorRegistry createActionBarContributorRegistry() { - return new ActionBarContributorRegistry(Activator.PLUGIN_ID); - } - - /** - * - * - * @param adapter - * - * @return - */ - @SuppressWarnings("rawtypes") - @Override - public Object getAdapter(Class adapter) { - - if(ServicesRegistry.class == adapter) { - return getServicesRegistry(); - } - - if(IPageMngr.class == adapter) { - return getIPageMngr(); - } - - if(IPropertySheetPage.class == adapter) { - // Do not test if tabbedPropertySheetPage is null before calling new - // this is managed by Eclipse which only call current method when necessary - return getPropertySheetPage(); - } - - // Add a viewer - if(IContentOutlinePage.class == adapter) { - try { - IContentOutlinePage contentOutline = getContentOutlineRegistry().getContentOutline(); - if(contentOutline != null) { - return contentOutline; - } - } catch (BackboneException e) { - // TODO change next exception to more appropriate one - throw new RuntimeException(e); - } - } - - if(EditingDomain.class == adapter) { - return transactionalEditingDomain; - } - - /** - * Return context used for undo/redo. - * All papyrus views should use this context. - */ - if(IUndoContext.class == adapter) { - if(undoContext != null) { - return undoContext; - } - - undoContext = new EditingDomainUndoContext(transactionalEditingDomain); - return undoContext; - } - - // EMF requirements - if(IEditingDomainProvider.class == adapter) { - - // return (IEditingDomainProvider) defaultContext.getTransactionalEditingDomain().getResourceSet(); - return domainProvider; - } - - // GEF diagram requirements - if(adapter == ActionRegistry.class) { - return gefAdaptorDelegate.getActionRegistry(); - } - - // // GEF diagram requirements - // if (adapter == SelectionSynchronizer.class) { - // return gefAdaptorDelegate.getSelectionSynchronizer(); - // } - - // TODO : following code is GMF dependent. It should be moved to adapter - // Do we really need it? Who use it ? - // -> It seems to be needed, see bug 354050 - if(adapter == IDiagramGraphicalViewer.class) { - IEditorPart activeEditor = getActiveEditor(); - if(activeEditor instanceof DiagramEditor) { - return ((DiagramEditor)activeEditor).getDiagramGraphicalViewer(); - } - return null; - } - - return super.getAdapter(adapter); - } - - /** - * Init the editor. - */ - @Override - public void init(IEditorSite site, IEditorInput input) throws PartInitException { - - // Init super - super.init(site, input); - - // Used to get the appropriate domain object from a graphical object (EditPart, ...) - BusinessModelResolver.getInstance(); - - // Load resources - // resourceSet = new DiResourceSet(); - // IFile file = ((IFileEditorInput)input).getFile(); - // resourceSet.loadResources(file); - - // Create the 2 edit domains - // transactionalEditingDomain = resourceSet.getTransactionalEditingDomain(); - - // Create Gef adaptor - gefAdaptorDelegate = new MultiDiagramEditorGefDelegate(); - - - // Create ServicesRegistry and register services - servicesRegistry = createServicesRegistry(); - - // Add itself as a service - servicesRegistry.add(IMultiDiagramEditor.class, 1, this); - - // Create lifeCycle event provider and the event that is used when the editor fire a save event. - // lifeCycleEventsProvider = new LifeCycleEventsProvider(); - // lifeCycleEvent = new DoSaveEvent(servicesRegistry, this); - // servicesRegistry.add(ILifeCycleEventsProvider.class, 1, lifeCycleEventsProvider); - - // register services - servicesRegistry.add(ActionBarContributorRegistry.class, 1, getActionBarContributorRegistry()); - // servicesRegistry.add(TransactionalEditingDomain.class, 1, transactionalEditingDomain); - // servicesRegistry.add(DiResourceSet.class, 1, resourceSet); - - // Create and initalize editor icons service - // PageIconsRegistry pageIconsRegistry = new PageIconsRegistry(); - // PluggableEditorFactoryReader editorReader = new PluggableEditorFactoryReader(Activator.PLUGIN_ID); - // editorReader.populate(pageIconsRegistry); - // servicesRegistry.add(IPageIconsRegistry.class, 1, pageIconsRegistry); - - - // Create PageModelRegistry requested by content provider. - // Also populate it from extensions. - // PageModelFactoryRegistry pageModelRegistry = new PageModelFactoryRegistry(); - // editorReader.populate(pageModelRegistry, servicesRegistry); - - // TODO : create appropriate Resource for the contentProvider, and pass it here. - // This will allow to remove the old sash stuff. - // setContentProvider(createPageProvider(pageModelRegistry, resourceSet.getDiResource(), transactionalEditingDomain)); - // servicesRegistry.add(ISashWindowsContentProvider.class, 1, getContentProvider()); - // servicesRegistry.add(IPageMngr.class, 1, getIPageMngr()); - - // register a basic label provider - // adapter factory used by EMF objects - AdapterFactory factory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); - - /** label provider for EMF objects */ - ILabelProvider labelProvider = new AdapterFactoryLabelProvider(factory) { - - /** - * This implements {@link ILabelProvider}.getText by forwarding it to an object that implements {@link IItemLabelProvider#getText - * IItemLabelProvider.getText} - */ - @Override - public String getText(Object object) { - // Get the adapter from the factory. - // - IItemLabelProvider itemLabelProvider = (IItemLabelProvider)adapterFactory.adapt(object, IItemLabelProvider.class); - if(object instanceof EObject) { - if(((EObject)object).eIsProxy()) { - return "Proxy - " + object; - } - } - return itemLabelProvider != null ? itemLabelProvider.getText(object) : object == null ? "" : object.toString(); - } - }; - servicesRegistry.add(ILabelProvider.class, 1, labelProvider); - - // Start servicesRegistry - IFile file = ((IFileEditorInput)input).getFile(); - try { - // Start the ModelSet first, and load if from the specified File - List> servicesToStart = new ArrayList>(1); - servicesToStart.add(ModelSet.class); - - servicesRegistry.startServicesByClassKeys(servicesToStart); - resourceSet = servicesRegistry.getService(ModelSet.class); - resourceSet.loadModels(file); - - // start remaining services - servicesRegistry.startRegistry(); - } catch (ModelMultiException e) { - log.error(e); - throw new PartInitException("errors in model", e); - } catch (ServiceException e) { - log.error(e); - throw new PartInitException("could not initialize services", e); - } - - - // Get required services - ISashWindowsContentProvider contentProvider = null; - try { - transactionalEditingDomain = servicesRegistry.getService(TransactionalEditingDomain.class); - sashModelMngr = servicesRegistry.getService(DiSashModelMngr.class); - contentProvider = servicesRegistry.getService(ISashWindowsContentProvider.class); - saveAndDirtyService = servicesRegistry.getService(ISaveAndDirtyService.class); - } catch (ServiceException e) { - log.error("A required service is missing.", e); - // if one of the services above fail to start, the editor can't run => stop - throw new PartInitException("could not initialize services", e); - } - - // Set the content provider providing editors. - setContentProvider(contentProvider); - - // Set editor name - setPartName(file.getName()); - - // Listen on contentProvider changes - sashModelMngr.getSashModelContentChangedProvider().addListener(contentChangedListener); - - // Listen on input changed from the ISaveAndDirtyService - saveAndDirtyService.addInputChangedListener(editorInputChangedListener); - } - - /** - * Activate this editor. Called after the SWT.control is created. - */ - @Override - protected void activate() { - // TODO Auto-generated method stub - super.activate(); - initFolderTabMenus(); - - // add page changed listener to sash container to warn page manager - getISashWindowsContainer().addPageChangedListener(getIPageMngr()); - getISashWindowsContainer().addLifeCycleListener(getIPageMngr()); - - try { - // Register ISashWindowsContainer as service - // Should be done only once the container is ready. - getServicesRegistry().add(ISashWindowsContainer.class, 1, getISashWindowsContainer()); - getServicesRegistry().startServicesByClassKeys(ISashWindowsContainer.class); - } catch (ServiceException e) { - log.error(e); - } - } - - @Override - protected void deactivate() { - super.deactivate(); - getISashWindowsContainer().removePageChangedListener(getIPageMngr()); - } - - /** - * Init the contextual menu shown in the folder tabs. - * This popup menu is contributed by the help of Eclipse extensions, using the Commands framework. - * I.e, to add a menu item, create a menu, a command and an handler in the extension. - */ - protected void initFolderTabMenus() { - ISashWindowsContainer container = getISashWindowsContainer(); - - // TODO : use a constant - MenuManager menuManager = new MenuManager("tabmenu"); - menuManager.add(new Separator("tabcommands")); - menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - container.setFolderTabMenuManager(menuManager); - - // TODO : use a constant - getSite().registerContextMenu("org.eclipse.papyrus.core.editor.ui.tabmenu", menuManager, getSite().getSelectionProvider()); - - } - - /** - * Overrides getPropertySheetPage. - * - * {@inheritDoc} - * - * @see org.eclipse.papyrus.core.editor.IMultiDiagramEditor#getPropertySheetPage() - */ - public IPropertySheetPage getPropertySheetPage() { - if(this.tabbedPropertySheetPage == null) { - this.tabbedPropertySheetPage = new TabbedPropertySheetPage(this); - } - return tabbedPropertySheetPage; - } - - /** - * @see org.eclipse.papyrus.sasheditor.editor.AbstractMultiPageSashEditor#dispose() - * - */ - @Override - public void dispose() { - if(sashModelMngr != null) { - sashModelMngr.getSashModelContentChangedProvider().removeListener(contentChangedListener); - } - - // Avoid memory leak - if(resourceSet != null) { - resourceSet.unload(); - } - - // dispose available service - if(servicesRegistry != null) { - try { - servicesRegistry.disposeRegistry(); - } catch (ServiceMultiException e) { - log.error(e); - } - } - - super.dispose(); - } - - /** - * Overrides doSave. - * - * {@inheritDoc} - * - * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - public void doSave(IProgressMonitor monitor) { - - saveAndDirtyService.doSave(monitor); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isDirty() { - return saveAndDirtyService.isDirty(); - } - - /** - * Overrides doSaveAs. - * - * {@inheritDoc} - * - * @see org.eclipse.ui.part.EditorPart#doSaveAs() - */ - @Override - public void doSaveAs() { - - saveAndDirtyService.doSaveAs(); - } - - /** - * Overrides isSaveAsAllowed. - * - * {@inheritDoc} - * - * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed() - */ - @Override - public boolean isSaveAsAllowed() { - return true; - } - - /** - * Overrides getContributorId. - * - * {@inheritDoc} - * - * @see org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor#getContributorId() - */ - public String getContributorId() { - // return Activator.PLUGIN_ID; - return "TreeOutlinePage"; - - } - - // implements IDiagramWorkbenchPart to restore GMF standard behavior - // and delegate to the activeEditor - - /** - * Overrides getDiagram. - * - * {@inheritDoc} - * - * @see org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart#getDiagram() - */ - public org.eclipse.gmf.runtime.notation.Diagram getDiagram() { - IEditorPart activeEditor = getActiveEditor(); - if(activeEditor instanceof DiagramEditor) { - return ((DiagramEditor)activeEditor).getDiagram(); - } else { - return null; - } - } - - /** - * This method is called from a GMF diagram. It should only be called from GMF diagram code. Normally, the Diagram under the Mouse is a GMF - * Diagram. The active Diagram can be another Diagram, not - * under the mouse. This is a GMF issue. - */ - public DiagramEditPart getDiagramEditPart() { - - // Get the editor under the mouse - // IEditorPart activeEditor = rootContainer.getEditorUnderMouse(); - IEditorPart activeEditor = getActiveEditor(); - if(activeEditor == null) { - return null; - } - // IEditorPart activeEditor = getActiveEditor(); - if(activeEditor instanceof DiagramEditor) { - return ((DiagramEditor)activeEditor).getDiagramEditPart(); - } else { - // This case should never happen. - // Return null, as the GMF runtime now support it (since 093009) - return null; - } - } - - /** - * Overrides getDiagramGraphicalViewer. - * - * {@inheritDoc} - * - * @see org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart#getDiagramGraphicalViewer() - */ - public IDiagramGraphicalViewer getDiagramGraphicalViewer() { - IEditorPart activeEditor = getActiveEditor(); - if(activeEditor instanceof DiagramEditor) { - return ((DiagramEditor)activeEditor).getDiagramGraphicalViewer(); - } else { - return null; - } - } - - /** - * Overrides getEditingDomain. - * - * {@inheritDoc} - * - * @see org.eclipse.emf.edit.domain.IEditingDomainProvider#getEditingDomain() - */ - public EditingDomain getEditingDomain() { - return transactionalEditingDomain; - } - - /** - * Throws an UnsupportedOperationException. - * - * @see org.eclipse.papyrus.core.editor.IMultiDiagramEditor#getDiagramEditDomain() - */ - public DiagramEditDomain getDiagramEditDomain() { - throw new UnsupportedOperationException("Not implemented. Should not be called."); - } - - - /** - * Change the editor input.
- * Note: that method should be called within the UI-Thread. - * - * @see org.eclipse.papyrus.core.editor.IMultiDiagramEditor#setEditorInput(org.eclipse.ui.IEditorInput) - * - * @param newInput - * The new input - * @deprecated Not used anymore - */ - - @Deprecated - public void setEditorInput(IEditorInput newInput) { - setInputWithNotify(newInput); - setPartName(newInput.getName()); - } - - public void gotoMarker(IMarker marker) { - IWorkbench wb = PlatformUI.getWorkbench(); - IWorkbenchPage page = wb.getActiveWorkbenchWindow().getActivePage(); - for(IViewReference view : page.getViewReferences()) { - if(view.getId().equals("org.eclipse.papyrus.modelexplorer.modelexplorer")) { - page.activate(view.getPart(false)); - IWorkbenchPart part = view.getPart(false); - if(part instanceof IGotoMarker) { - ((IGotoMarker)part).gotoMarker(marker); - } - } - } - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/DiResourceSetServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/DiResourceSetServiceFactory.java deleted file mode 100644 index 6cebfe199fd..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/DiResourceSetServiceFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.editor; - -import org.eclipse.papyrus.core.services.IServiceFactory; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.resource.ModelSet; - -/** - * A service factory to create the {@link ModelSet} service. This provide a - * nickname for {@link ModelSet} service. This serviceFactory depends on {@link ModelSet} service. - * - * @author cedric dumoulin - * - */ -public class DiResourceSetServiceFactory implements IServiceFactory { - - /** - * The sashModelMangr. - */ - private ModelSet modelSet; - - /** - * @see org.eclipse.papyrus.core.services.IService#init(org.eclipse.papyrus.core.services.ServicesRegistry) - * - * @param servicesRegistry - * @throws ServiceException - */ - public void init(ServicesRegistry servicesRegistry) throws ServiceException { - // Get required services - modelSet = servicesRegistry.getService(ModelSet.class); - - } - - /** - * @see org.eclipse.papyrus.core.services.IService#startService() - * - * @throws ServiceException - */ - public void startService() throws ServiceException { - } - - /** - * @see org.eclipse.papyrus.core.services.IService#disposeService() - * - * @throws ServiceException - */ - public void disposeService() throws ServiceException { - } - - /** - * @see org.eclipse.papyrus.core.services.IServiceFactory#createServiceInstance() - * - * @return - * @throws ServiceException - */ - public Object createServiceInstance() throws ServiceException { - return modelSet; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/DiSashModelMngrServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/DiSashModelMngrServiceFactory.java deleted file mode 100644 index bcb82f3b806..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/DiSashModelMngrServiceFactory.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.editor; - -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.papyrus.core.Activator; -import org.eclipse.papyrus.core.editorsfactory.PageModelFactoryRegistry; -import org.eclipse.papyrus.core.extension.diagrameditor.PluggableEditorFactoryReader; -import org.eclipse.papyrus.core.services.IServiceFactory; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.resource.sasheditor.SashModel; -import org.eclipse.papyrus.resource.sasheditor.SashModelUtils; -import org.eclipse.papyrus.sasheditor.contentprovider.di.DiSashModelMngr; -import org.eclipse.papyrus.sasheditor.contentprovider.di.TransactionalDiSashModelMngr; - -/** - * Service Factory to create the {@link DiSashModelMngr} service. - * - * @author cedric dumoulin - * - */ -public class DiSashModelMngrServiceFactory implements IServiceFactory { - - private TransactionalEditingDomain transactionalEditingDomain; - - private SashModel sashModel; - - private TransactionalDiSashModelMngr sashModelMngr; - - private ServicesRegistry servicesRegistry; - - /** - * @see org.eclipse.papyrus.core.services.IService#init(org.eclipse.papyrus.core.services.ServicesRegistry) - * - * @param servicesRegistry - * @throws ServiceException - */ - public void init(ServicesRegistry servicesRegistry) throws ServiceException { - - this.servicesRegistry = servicesRegistry; - // Get required service - transactionalEditingDomain = servicesRegistry.getService(TransactionalEditingDomain.class); - - // Get the model holding the contentProvider - sashModel = SashModelUtils.getSashModelChecked(servicesRegistry); - - } - - /** - * @see org.eclipse.papyrus.core.services.IService#startService() - * - * @throws ServiceException - */ - public void startService() throws ServiceException { - - // Read declared editors - PageModelFactoryRegistry pageModelRegistry = new PageModelFactoryRegistry(); - PluggableEditorFactoryReader editorReader = new PluggableEditorFactoryReader(Activator.PLUGIN_ID); - editorReader.populate(pageModelRegistry, servicesRegistry); - - if(sashModel.getResource() == null) - throw new ServiceException("Can't start " + this.getClass().getSimpleName() + "'. Required model (SashModel) should be loaded prior starting the service."); - - // create the service - sashModelMngr = new TransactionalDiSashModelMngr(pageModelRegistry, sashModel.getResource(), transactionalEditingDomain); - - } - - /** - * @see org.eclipse.papyrus.core.services.IService#disposeService() - * - * @throws ServiceException - */ - public void disposeService() throws ServiceException { - } - - /** - * @see org.eclipse.papyrus.core.services.IServiceFactory#createServiceInstance() - * - * @return - * @throws ServiceException - */ - public Object createServiceInstance() throws ServiceException { - - // Start locally the service if needed. - // Question: Can createServiceInstance() method be called before - // startService() is called ? - if(sashModelMngr == null) { - startService(); - } - - return sashModelMngr; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/IMultiDiagramEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/IMultiDiagramEditor.java deleted file mode 100644 index f8b60085263..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/IMultiDiagramEditor.java +++ /dev/null @@ -1,91 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.editor; - -import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.views.properties.IPropertySheetPage; - -/** - * Interface implemented by the main multipage editor. This interface list the - * methods available to diagram editors. Diagram editors can relies on this - * interface to retrieve services from the main multi diagram editor.
- * This interface should stay minimalist, as the editor is not designed to - * handle the services itself. A service should be retrieved by using {@link #getServicesRegistry()}. - * - * - * @author cedric dumoulin - * - * TODO remove extends IEditingDomainProvider. This interface should be - * independant of any technology (EMF, GMF, ...). If the EditingDomain - * is required, it can be retrieved by the registry. - * - */ -public interface IMultiDiagramEditor extends IEditorPart { - - /** - * Returns the service registry associated to the editor. - * - * @return the servicesRegistry The registry. - */ - public ServicesRegistry getServicesRegistry(); - - /** - * Return the editor site. - * - * @return - */ - public IEditorSite getEditorSite(); - - /** - * Get the editor input. - * - * @return - */ - public IEditorInput getEditorInput(); - - /** - * Change the editor input. - * - * @param newInput - * The new input. - * @deprecated No replacement. Input can't be changed on multi editors. - */ - public void setEditorInput(IEditorInput newInput); - - /** - * Returns the edit domain shared among editors - * - * @return the edit domain shared among editors - * @deprecated Use {@link #getServicesRegistry()} or {@link #getAdapter(Class)} - */ - // FIXME Remove it (GMF dependency) - public DiagramEditDomain getDiagramEditDomain(); - - /** - * Get the currently active nested Editor. - */ - public IEditorPart getActiveEditor(); - - /** - * Get the property sheet page associated to the Editor. - * - * @return the property sheet page associated to the Editor. - * @deprecated Use {@link #getServicesRegistry()} or {@link #getAdapter(Class)} - */ - public IPropertySheetPage getPropertySheetPage(); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/ModelSetServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/ModelSetServiceFactory.java deleted file mode 100644 index c852ea81440..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/ModelSetServiceFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.editor; - -import org.eclipse.papyrus.core.services.IServiceFactory; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.core.utils.DiResourceSet; -import org.eclipse.papyrus.resource.ModelSet; - -/** - * A service starting the ModelSet - * - * @author cedric dumoulin - * - */ -public class ModelSetServiceFactory implements IServiceFactory { - - /** The ModelSet */ - private ModelSet service; - - /** - * - * @see org.eclipse.papyrus.core.services.IService#init(org.eclipse.papyrus.core.services.ServicesRegistry) - * - * @param servicesRegistry - * @throws ServiceException - */ - public void init(ServicesRegistry servicesRegistry) throws ServiceException { - - } - - /** - * - * @see org.eclipse.papyrus.core.services.IService#startService() - * - * @throws ServiceException - */ - public void startService() throws ServiceException { - } - - /** - * - * @see org.eclipse.papyrus.core.services.IService#disposeService() - * - * @throws ServiceException - */ - public void disposeService() throws ServiceException { - if(service != null) - service.unload(); - } - - /** - * Create the service served by this factory. - */ - public Object createServiceInstance() { - // Return a DiResourceSet for backward compatibility - // TODO return a ModelSet once DiResourceSet is removed - service = new DiResourceSet(); - return service; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/PageIconRegistryServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/PageIconRegistryServiceFactory.java deleted file mode 100644 index c3c44177607..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/PageIconRegistryServiceFactory.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.editor; - -import org.eclipse.papyrus.core.Activator; -import org.eclipse.papyrus.core.editorsfactory.IPageIconsRegistry; -import org.eclipse.papyrus.core.editorsfactory.PageIconsRegistry; -import org.eclipse.papyrus.core.extension.diagrameditor.PluggableEditorFactoryReader; -import org.eclipse.papyrus.core.services.IServiceFactory; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; - -/** - * Service Factory to register {@link IPageIconsRegistry}. - * - * @author cedric dumoulin - * - */ -public class PageIconRegistryServiceFactory implements IServiceFactory { - - private PageIconsRegistry pageIconsRegistry; - - /** - * @see org.eclipse.papyrus.core.services.IService#init(org.eclipse.papyrus.core.services.ServicesRegistry) - * - * @param servicesRegistry - * @throws ServiceException - */ - public void init(ServicesRegistry servicesRegistry) throws ServiceException { - } - - /** - * @see org.eclipse.papyrus.core.services.IService#startService() - * - * @throws ServiceException - */ - public void startService() throws ServiceException { - } - - /** - * @see org.eclipse.papyrus.core.services.IService#disposeService() - * - * @throws ServiceException - */ - public void disposeService() throws ServiceException { - - } - - /** - * Create and populate a {@link PageIconsRegistry}. Return it as the service - * instance. - * - * @return - */ - public Object createServiceInstance() { - if(pageIconsRegistry == null) { - pageIconsRegistry = new PageIconsRegistry(); - PluggableEditorFactoryReader editorReader = new PluggableEditorFactoryReader(Activator.PLUGIN_ID); - editorReader.populate(pageIconsRegistry); - } - return pageIconsRegistry; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/PageMngrServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/PageMngrServiceFactory.java deleted file mode 100644 index ad73218ee28..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editor/PageMngrServiceFactory.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.editor; - -import org.eclipse.papyrus.core.services.IServiceFactory; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.di.DiSashModelMngr; - -/** - * A service factory to create the {@link IPageMngr} service. This - * serviceFactory depends on {@link ISashWindowsContentProvider} service. - * - * @author cedric dumoulin - * - */ -public class PageMngrServiceFactory implements IServiceFactory { - - /** - * The sashModelMangr. - */ - private DiSashModelMngr sashModelMngr; - - /** - * @see org.eclipse.papyrus.core.services.IService#init(org.eclipse.papyrus.core.services.ServicesRegistry) - * - * @param servicesRegistry - * @throws ServiceException - */ - public void init(ServicesRegistry servicesRegistry) throws ServiceException { - - // Get required services - sashModelMngr = servicesRegistry.getService(DiSashModelMngr.class); - } - - /** - * @see org.eclipse.papyrus.core.services.IService#startService() - * - * @throws ServiceException - */ - public void startService() throws ServiceException { - } - - /** - * @see org.eclipse.papyrus.core.services.IService#disposeService() - * - * @throws ServiceException - */ - public void disposeService() throws ServiceException { - } - - /** - * @see org.eclipse.papyrus.core.services.IServiceFactory#createServiceInstance() - * - * @return - * @throws ServiceException - */ - public Object createServiceInstance() throws ServiceException { - return sashModelMngr.getIPageMngr(); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IEditorFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IEditorFactory.java deleted file mode 100644 index 0dccf498ecc..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IEditorFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.editorsfactory; - -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; - -/** - * Factory used to get the Icon associated to the editor used to render the - * specified pageIdentifier. - * - * - * @author cedric dumoulin - * - */ -public interface IEditorFactory { - - /** - * Create the {@link IPageModel} for the specified identifier. TODO throw an - * exception encapsulating problems encountered while creating the model. - * - * @param pageIdentifier - * Object identifying an Editor. - * @return PageModel allowing to create the editor. - */ - public IPageModel createIPageModel(Object pageIdentifier); - - /** - * Return true if the factory can create an IPageModel for the specified - * pageIdentifier. Return false otherwise TODO throw an exception - * encapsulating problems encountered while creating the model. - * - * @param pageIdentifier - * The object representing the page to test - * @return - */ - public boolean isPageModelFactoryFor(Object pageIdentifier); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IEditorIconFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IEditorIconFactory.java deleted file mode 100644 index ead2f932358..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IEditorIconFactory.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.editorsfactory; - -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.di.DiSashModelMngr; -import org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer; -import org.eclipse.swt.graphics.Image; - -/** - * Factory used to create an {@link IPageModel} used by the {@link ISashWindowsContainer} to create an instance of the editor represented - * by the provided Object. Such factory is required by the {@link DiSashModelMngr}. It is called whenever the ISashWindowsContainer need - * to create an editor from an EObject representing this editor in the Di - * implementation of the {@link ISashWindowsContentProvider} - * - * - * @author cedric dumoulin - * - */ -public interface IEditorIconFactory { - - /** - * Get the icon associated to the editor used to render the model. Model - * represent the top level object of a model editor. Can return a cached - * Image. - * - * @param pageIdentifier - * the pageIdentifier representing the Editor. This is usually - * the EObject used to reconstruct the editor. - * @return the icon representing the editor - */ - public Image getEditorIcon(Object pageIdentifier); - - /** - * Create the icon associated to the editor used to render the model. Model - * represent the top level object of a model editor. Always return a newly - * created Image. - * - * @param pageIdentifier - * the pageIdentifier representing the Editor. This is usually - * the EObject used to reconstruct the editor. - * @return the icon representing the editor - */ - public Image createEditorIcon(Object pageIdentifier); - - /** - * Return true if the factory can create an IPageModel for the specified - * pageIdentifier. Return false otherwise TODO throw an exception - * encapsulating problems encountered while creating the model. - * - * @param pageIdentifier - * The object representing the page to test - * @return - */ - public boolean isPageModelFactoryFor(Object pageIdentifier); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IEditorIconFactoryExtended.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IEditorIconFactoryExtended.java deleted file mode 100644 index 877bd0ff2f9..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IEditorIconFactoryExtended.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2011 Atos. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Atos - Initial API and implementation - * - */ -package org.eclipse.papyrus.core.editorsfactory; - -/** - * - * @author "Arthur Daussy arthur.daussy@atos.net" - * - */ -public interface IEditorIconFactoryExtended extends IEditorIconFactory { - - /** - * Return the icon URL associated to the editor used to render the model. Model represent the top level - * object of a model editor. - * - * @param pageIdentifier - * @return - */ - public String getURLMainIcon(Object pageIdentifier); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IPageIconsRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IPageIconsRegistry.java deleted file mode 100644 index 2987676aad8..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IPageIconsRegistry.java +++ /dev/null @@ -1,35 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.editorsfactory; - -import org.eclipse.swt.graphics.Image; - -/** - * Registry used to get Icons associated to an editor. - * - * @author cedric dumoulin - */ -public interface IPageIconsRegistry { - - /** - * Get the icon associated to the editor used to render the model. Model - * represent the top level object of a model editor. - * - * @param model - * the model representing the Editor. This is usually the EObject - * used to reconstruct the editor. - * @return the icon representing the editor - */ - public Image getEditorIcon(Object model); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IPageIconsRegistryExtended.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IPageIconsRegistryExtended.java deleted file mode 100644 index 20c275910d5..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/IPageIconsRegistryExtended.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2011 Atos Origin. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Atos Origin - Initial API and implementation - * - */ -package org.eclipse.papyrus.core.editorsfactory; - -/** - * Extends IPageIconsRegistry in order to offer a second methods which will give back the URL of the requested Icon - * - * @author "Arthur Daussy arthur.daussy@atos.net" - * - */ -public interface IPageIconsRegistryExtended extends IPageIconsRegistry { - - /** - * Get the URL icon associated to the editor used to render the model. Model represent the top level - * object of a model editor. - * - * @param model - * @return {@link String} which represent the URL of the resource - */ - public String getEditorURLIcon(Object model); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/PageIconsRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/PageIconsRegistry.java deleted file mode 100644 index 9da98e6a83e..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/PageIconsRegistry.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.editorsfactory; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.swt.graphics.Image; - -/** - * Concrete implementation of the {@link IPageIconsRegistry}. This - * implementation allows to add and remove {@link IPageIconsRegistry}. - * - * - * @author cedric dumoulin - */ -public class PageIconsRegistry implements IPageIconsRegistryExtended { - - /** list of registered icon factories */ - protected List pageIcons = new ArrayList(); - - /** - * Constructor. - * - * @param editorFactoryRegistry - * @param servicesRegistry - */ - public PageIconsRegistry() { - - } - - /** - * Walk each registered {@link IEditorFactory} to find the one handling the - * specified pageIdentifier. Call the corresponding method in the found - * pageIdentifier. - * - * TODO Throw an exception to report errors. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.di.IPageModelFactory#createIPageModel(java.lang.Object) - */ - public Image getEditorIcon(Object pageIdentifier) { - - for(IEditorIconFactory factory : getPageIcons()) { - if(factory.isPageModelFactoryFor(pageIdentifier)) { - { - // return factory.getEditorIcon(pageIdentifier); - return factory.createEditorIcon(pageIdentifier); - } - } - } - // no editor found ! - // TODO Throw an exception. - // throw new EditorNotFoundException("No editor registered for '" + - // pageIdentifier + "'."); - return null; - } - - /** - * @return the editorFactories - */ - protected List getPageIcons() { - return pageIcons; - } - - /** - * Add the specified {@link IEditorFactory} - * - * @param editorIconFactory - */ - public void add(IEditorIconFactory editorIconFactory) { - // This should never happen - if(editorIconFactory == null) - throw new RuntimeException("Parameter should not be null."); - - pageIcons.add(editorIconFactory); - } - - /** - * Remove the specified {@link IEditorFactory} - * - * @param editorIconFactory - */ - public void remove(IEditorIconFactory editorIconFactory) { - pageIcons.remove(editorIconFactory); - } - - /** - * Return the path to the icon ressource. - * - * @see org.eclipse.papyrus.core.editorsfactory.IPageIconsRegistryExtended#getEditorURLIcon(java.lang.Object) - * - * @param model - * @return - */ - public String getEditorURLIcon(Object model) { - for(IEditorIconFactory factory : getPageIcons()) { - if(factory.isPageModelFactoryFor(model)) { - { - if ( factory instanceof IEditorIconFactoryExtended){ - return ((IEditorIconFactoryExtended)factory).getURLMainIcon(model); - } - } - } - } - return ""; - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/PageModelFactoryRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/PageModelFactoryRegistry.java deleted file mode 100644 index 4d59a68284c..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/editorsfactory/PageModelFactoryRegistry.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.editorsfactory; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.di.IPageModelFactory; - -/** - * Concrete implementation of the {@link IPageModelFactory} required by the di - * implementation of {@link ISashWindowsContentProvider}. This implementation - * allows to add and remove {@link IEditorFactory}. - * - * - * @author cedric dumoulin - */ -public class PageModelFactoryRegistry implements IPageModelFactory { - - /** list of editor factories */ - protected List editorFactories = new ArrayList(); - - /** - * Constructor. - * - * @param editorFactoryRegistry - * @param servicesRegistry - */ - public PageModelFactoryRegistry() { - - } - - /** - * Walk each registered {@link IEditorFactory} to find the one handling the - * specified pageIdentifier. Call the corresponding method in the found - * pageIdentifier. - * - * TODO Throw an exception to report errors. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.di.IPageModelFactory#createIPageModel(java.lang.Object) - */ - public IPageModel createIPageModel(Object pageIdentifier) { - - for(IEditorFactory factory : getEditorFactories()) { - if(factory.isPageModelFactoryFor(pageIdentifier)) { - { - return factory.createIPageModel(pageIdentifier); - } - } - } - // no editor found ! - // TODO Throw an exception. - // throw new EditorNotFoundException("No editor registered for '" + - // pageIdentifier + "'."); - return null; - } - - /** - * @return the editorFactories - */ - protected List getEditorFactories() { - return editorFactories; - } - - /** - * Add the specified {@link IEditorFactory} - * - * @param editorFactory - */ - public void add(IEditorFactory editorFactory) { - // This should never happen - if(editorFactory == null) - throw new RuntimeException("Parameter should not be null."); - - editorFactories.add(editorFactory); - } - - /** - * Remove the specified {@link IEditorFactory} - * - * @param editorFactory - */ - public void remove(IEditorFactory editorFactory) { - editorFactories.remove(editorFactory); - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/BadClassNameException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/BadClassNameException.java deleted file mode 100644 index 24fbf0346d8..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/BadClassNameException.java +++ /dev/null @@ -1,86 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.extension; - -import org.eclipse.core.runtime.IConfigurationElement; - -/** - * Exception thrown as an extension point is parsed at runtime. More accurately, - * it is thrown when one attribute of an extension point that should describe a - * class name does not correspond to a class in the classpath. - * - * @author Cedric Dumoulin - * @author Patrick Tessier - * @author schnekenburger - */ -public class BadClassNameException extends ExtensionException { - - /** - * the name of{@link IConfigurationElement} that is bad build - */ - private String iconfigurationElementName; - - /** - * the name of the attribute of the {@link IConfigurationElement} - */ - private String attributeName; - - private Exception e = null; - - /** - * serial version UID - * - * @generated - */ - private static final long serialVersionUID = 1161426240944647521L; - - /** - * constructor with an exception - * - * @param element - * the IConfigurationElement that raised the error - * @param attributeName - * the bad construct attibute - * @param e - * the associated exception - */ - public BadClassNameException(String msg, String iConfigurationElementName, String attributeName, final Exception e) { - super(msg); - this.iconfigurationElementName = iConfigurationElementName; - this.attributeName = attributeName; - this.e = e; - } - - /** - * constructor without an exception - * - * @param element - * the IConfigurationElement that raised the error - * @param attributeName - * the bad construct attibute - */ - public BadClassNameException(String msg, String iConfigurationElementName, String attributeName) { - super(msg); - this.iconfigurationElementName = iConfigurationElementName; - this.attributeName = attributeName; - } - - /** - * - * {@inheritDoc} - */ - public String toString() { - return super.toString() + " for the extension point " + iconfigurationElementName + "." + attributeName + " " + e; - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/BadNameExtensionException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/BadNameExtensionException.java deleted file mode 100644 index 50e27b8b5d2..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/BadNameExtensionException.java +++ /dev/null @@ -1,70 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.extension; - -/** - * Exception thrown when a bad name is encountered in extension processing. - * - * @author dumoulin - * @author schnekenburger - */ -public class BadNameExtensionException extends ExtensionException { - - /** - * serial version UID - * - * @generated - */ - private static final long serialVersionUID = -2063118856033217385L; - - /** - * Creates a simple BadNameExtensionException - */ - public BadNameExtensionException() { - } - - /** - * Creates a BadNameExtensionException with a specific message. - * - * @param message - * the message of the exception - */ - public BadNameExtensionException(String message) { - super(message); - } - - /** - * Creates a BadNameExtensionException with a specific cause. - * - * @param cause - * the cause of the exception - */ - public BadNameExtensionException(Throwable cause) { - super(cause); - } - - /** - * Creates a BadNameExtensionException with a specific cause and a specific - * message. - * - * @param message - * the message of the exception - * @param cause - * the cause of the exception - */ - public BadNameExtensionException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/ExtensionException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/ExtensionException.java deleted file mode 100644 index 3a3e157cb03..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/ExtensionException.java +++ /dev/null @@ -1,86 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.extension; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.papyrus.core.editor.BackboneException; - -/** - * Base class for extension exceptions - * - * @author dumoulin - * @author schnekenburger - */ -public class ExtensionException extends BackboneException { - - /** - * serial version UID - * - * @generated - */ - private static final long serialVersionUID = -9144153309491137046L; - - /** - * Creates a simple ExtensionException. - */ - public ExtensionException() { - } - - /** - * Creates a ExtensionException with a specific message. - * - * @param message - * the message of the exception - */ - public ExtensionException(String message) { - super(message); - } - - /** - * Creates a ExtensionException with a specific cause. - * - * @param cause - * the cause of the exception - */ - public ExtensionException(Throwable cause) { - super(cause); - - } - - /** - * Creates a ExtensionException with a specific cause and a specific - * message. - * - * @param message - * the message of the exception - * @param cause - * the cause of the exception - */ - public ExtensionException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Return the name of the plugin and extension declaring the extension. - * - * @param element - * the configuration element corresponding to the extension - * @return a string containing the name of the plugin and the name of the - * extension - */ - protected static String declaringExtensionToString(IConfigurationElement element) { - return "plugin:" + element.getContributor().getName() + " extension:" + element.getName(); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/ExtensionUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/ExtensionUtils.java deleted file mode 100644 index 25004e9bc43..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/ExtensionUtils.java +++ /dev/null @@ -1,92 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) patrick.tessier@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.extension; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.InvalidRegistryObjectException; -import org.eclipse.core.runtime.Platform; -import org.osgi.framework.Bundle; - -/** - * Utility methods for Eclipse extension reading. This class can be extended, or - * access throw the unique instance. - * - * @author cedric dumoulin - * @author Patrick Tessier - */ -public abstract class ExtensionUtils { - - /** - * Unique instance that can be used directly. - */ - static public ExtensionUtils INSTANCE = new ExtensionUtils() { - }; - - /** - * used to verify if the name of the {@link IConfigurationElement} is the - * same as the given name - * - * @param element - * an {@link IConfigurationElement} see eclipse extension point - * @param tagName - * the name of the {@link IConfigurationElement} that has to be - * verified - * @throws InvalidRegistryObjectException - * @throws BadNameExtensionException - */ - protected void checkTagName(IConfigurationElement element, String tagName) throws BadNameExtensionException { - String name = element.getName(); - if(!tagName.equals(name)) - throw new BadNameExtensionException("Expected '" + tagName + "', found '" + name + "'."); - } - - /** - * Retrieves the value of a specific attribute in a configuration element - * - * @param element - * the configuration element to parse - * @param attributeName - * the name of the attribute to read - * @param extensionPointName - * Name of the extension point. Used in exception msg. TODO: - * remove ? - * - * @return the class, result of the parsing - * @throws InvalidRegistryObjectException - * @throws BadClassNameException - */ - protected Class parseClass(IConfigurationElement element, String attributeName, String extensionPointName) throws BadClassNameException { - String className = element.getAttribute(attributeName); - - element.getContributor().getName(); - if(className == null || className.length() == 0) { - throw new BadClassNameException(attributeName + "=null ", extensionPointName, attributeName); - } - Class factoryClass; - try { - factoryClass = Class.forName(className); - } catch (ClassNotFoundException e) { - // try another way - try { - String declaringID = element.getContributor().getName(); - Bundle bundle = Platform.getBundle(declaringID); - factoryClass = bundle.loadClass(className); - } catch (ClassNotFoundException e1) { - throw new BadClassNameException(className + " can not be loaded ", extensionPointName, attributeName, e1); - } - } - return factoryClass; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/NotFoundException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/NotFoundException.java deleted file mode 100644 index d058795ce34..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/NotFoundException.java +++ /dev/null @@ -1,70 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.extension; - -/** - * Exception thrown when something is not found when parsing a configuration - * element. - * - * @author dumoulin - * @author schnekenburger - */ -public class NotFoundException extends ExtensionException { - - /** - * serial version UID - * - * @generated - */ - private static final long serialVersionUID = -130754574538610199L; - - /** - * Creates a simple NotFoundException. - */ - public NotFoundException() { - } - - /** - * Creates a NotFoundException with a specific message. - * - * @param message - * the message of the exception - */ - public NotFoundException(String message) { - super(message); - } - - /** - * Creates a NotFoundException with a specific cause. - * - * @param cause - * the cause of the exception - */ - public NotFoundException(Throwable cause) { - super(cause); - } - - /** - * Creates a NotFoundException with a specific cause and a specific message. - * - * @param message - * the message of the exception - * @param cause - * the cause of the exception - */ - public NotFoundException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/CreationCommandDescriptor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/CreationCommandDescriptor.java deleted file mode 100644 index c8b1c4e0de8..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/CreationCommandDescriptor.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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: - * Jerome Benois (Obeo) jerome.benois@obeo.fr - initial API and implementation - * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - add condition to the create command (task #296902) - *******************************************************************************/ -package org.eclipse.papyrus.core.extension.commands; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.papyrus.core.editor.BackboneException; - -/** - * Creation Command Descriptor used to create a new diagram - * - * @author Jerome Benois - */ -public class CreationCommandDescriptor { - - protected Class creationCommandClass; - - protected String commandId; - - protected String label; - - protected ImageDescriptor icon; - - protected String language; - - private ICreationCondition condition; - - public String getCommandId() { - return commandId; - } - - public String getLabel() { - return label; - } - - public ImageDescriptor getIcon() { - return icon; - } - - public String getLanguage() { - return language; - } - - public ICreationCondition getCondition() { - return condition; - } - - public void setCondition(ICreationCondition condition) { - this.condition = condition; - condition.setCommand(getCommandId()); - - } - - /** - * Instance is created when requested. - */ - protected ICreationCommand instance = null; - - /** - * constructor. - * - * @return the creation command - * @throws BackboneException - */ - public ICreationCommand getCommand() throws BackboneException { - if(instance == null) - instance = createCommand(); - - return instance; - } - - private ICreationCommand createCommand() throws BackboneException { - try { - ICreationCommand command = creationCommandClass.newInstance(); - return command; - } catch (SecurityException e) { - // Lets propagate. This is an implementation problem that should be - // solved by - // programmer. - throw new RuntimeException(e); - } catch (InstantiationException e) { - // Lets propagate. This is an implementation problem that should be - // solved by - // programmer. - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - // Lets propagate. This is an implementation problem that should be - // solved by - // programmer. - throw new RuntimeException(e); - } - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/CreationCommandExtensionFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/CreationCommandExtensionFactory.java deleted file mode 100644 index 998b101fece..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/CreationCommandExtensionFactory.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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: - * Jerome Benois (Obeo) jerome.benois@obeo.fr - initial API and implementation - * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - add condition to the create command (task #296902) - *******************************************************************************/ -package org.eclipse.papyrus.core.extension.commands; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.papyrus.core.extension.BadNameExtensionException; -import org.eclipse.papyrus.core.extension.ExtensionUtils; -import org.eclipse.papyrus.core.extension.ExtensionException; -import org.eclipse.papyrus.core.utils.IDebugChannel; -import org.eclipse.papyrus.core.utils.PapyrusTrace; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -/** - * A factory used to create CreationCommand object from Eclipse extensions - * points elements. - * - * @author Jerome Benois - */ -public class CreationCommandExtensionFactory extends ExtensionUtils { - - /** singleton eINSTANCE of this class */ - public final static CreationCommandExtensionFactory eINSTANCE = new CreationCommandExtensionFactory(); - - /** constant for the creation command **/ - public final static String CREATION_COMMAND_EXTENSIONPOINT = "creationCommand"; - - /** constant for the attribute creationCommandClass **/ - public final static String CREATION_COMMAND_CLASS_ATTR = "creationCommandClass"; - - /** constant for the attribute creationCommandClass **/ - public final static String CONDITION_COMMAND_CLASS_ATTR = "creationCondition"; - - /** constant for the attribute label **/ - public final static String LABEL_ATTR = "label"; - - /** constant for the attribute contextId **/ - public final static String ID_ATTRIBUTE = "id"; - - /** constant for the attribute icon **/ - public final static String ICON_ATTR = "icon"; - - /** constant for the attribute language **/ - public final static String LANGUAGE_ATTR = "language"; - - /** - * @return the eINSTANCE - */ - public static CreationCommandExtensionFactory getInstance() { - return eINSTANCE; - } - - /** - * Create a CreationCommand instance corresponding to the - * ConfigurationElement. - * - * @param element - * an {@link IConfigurationElement} see eclipse extension point - * @return a CreationCommandDescriptor structure that contains information - * to the creation diagram command - * @throws BadNameExtensionException - **/ - public CreationCommandDescriptor createCreationCommand(IConfigurationElement element) throws ExtensionException { - CreationCommandDescriptor res; - checkTagName(element, CREATION_COMMAND_EXTENSIONPOINT); - res = new CreationCommandDescriptor(); - res.creationCommandClass = (Class)parseClass(element, CREATION_COMMAND_CLASS_ATTR, CREATION_COMMAND_EXTENSIONPOINT); - res.commandId = element.getAttribute(ID_ATTRIBUTE); - res.label = element.getAttribute(LABEL_ATTR); - res.language = element.getAttribute(LANGUAGE_ATTR); - String iconPath = element.getAttribute(ICON_ATTR); - if(iconPath != null) { - res.icon = AbstractUIPlugin.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), iconPath); - } - String attributeForCreationCondition = element.getAttribute(CONDITION_COMMAND_CLASS_ATTR); - if(attributeForCreationCondition != null && attributeForCreationCondition.length() > 0) { - Class classCondition = (Class)parseClass(element, CONDITION_COMMAND_CLASS_ATTR, CREATION_COMMAND_EXTENSIONPOINT); - if(classCondition != null) { - try { - res.setCondition(classCondition.newInstance()); - } catch (InstantiationException e) { - throw new ExtensionException("can nott instantiate class : " + e.getMessage()); - } catch (IllegalAccessException e) { - throw new ExtensionException("can nott acces to class : " + e.getMessage()); - } - } - } - PapyrusTrace.trace(IDebugChannel.PAPYRUS_EXTENSIONPOINT_LOADING, this, "a creation command ready " + res); - - return res; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/CreationCommandRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/CreationCommandRegistry.java deleted file mode 100644 index c6c10786bcf..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/CreationCommandRegistry.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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: - * Jerome Benois (Obeo) jerome.benois@obeo.fr - initial API and implementation - *******************************************************************************/ -package org.eclipse.papyrus.core.extension.commands; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -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.papyrus.core.Activator; -import org.eclipse.papyrus.core.extension.ExtensionException; -import org.eclipse.papyrus.core.extension.NotFoundException; -import org.eclipse.papyrus.core.utils.IDebugChannel; -import org.eclipse.papyrus.core.utils.PapyrusTrace; - -/** - * {@inheritDoc} - * - * @author Jerome Benois - */ -public class CreationCommandRegistry implements ICreationCommandRegistry { - - private static Map registriesMap = new HashMap(); - - /** - * This static method returns an instance of this class for a specified - * namespace - * - * @param extensionPointNamespace - * @return - */ - public static CreationCommandRegistry getInstance(String extensionPointNamespace) { - synchronized(registriesMap) { - CreationCommandRegistry registry = registriesMap.get(extensionPointNamespace); - if(registry == null) { - registry = new CreationCommandRegistry(extensionPointNamespace); - registriesMap.put(extensionPointNamespace, registry); - } - return registry; - } - } - - /** ID of the editor extension (schema filename) */ - public static final String EDITOR_EXTENSION_ID = "papyrusDiagram"; - - /** Namespace where to look for the extension points. */ - protected String extensionPointNamespace; - - /** - * The icon representing the command - */ - private String icon; - - /** - * Registered creation command descriptors. - */ - private Map creationCommandDescriptors; - - private CreationCommandRegistry(String extensionPointNamespace) { - this.extensionPointNamespace = extensionPointNamespace; - initializeCreationCommandDescriptors(); - } - - /** - * {@inheritDoc} - */ - public Collection getCommandDescriptors() { - return creationCommandDescriptors.values(); - } - - /** - * {@inheritDoc} - * - * @throws NotFoundException - */ - public ICreationCommand getCommand(String commandId) throws NotFoundException { - try { - CreationCommandDescriptor desc = creationCommandDescriptors.get(commandId); - return desc.getCommand(); - } catch (Exception e) { - throw new NotFoundException("No creation command registered under id '" + commandId + "'."); - } - } - - /** - * get the command icon path - * - * @return the editor icon path - */ - public String getIcon() { - return icon; - } - - /** - * set the command icon - * - * @param icon - * the icon path - */ - public void setIcon(String icon) { - this.icon = icon; - } - - /** - * Read command descriptors from extension points. - */ - private void initializeCreationCommandDescriptors() { - - creationCommandDescriptors = new HashMap(); - // Reading data from plugins - IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointNamespace, EDITOR_EXTENSION_ID); - - CreationCommandExtensionFactory extensionReader = new CreationCommandExtensionFactory(); - - for(IConfigurationElement ele : configElements) { - CreationCommandDescriptor desc; - try { - if(CreationCommandExtensionFactory.CREATION_COMMAND_EXTENSIONPOINT.equals(ele.getName())) { - desc = extensionReader.createCreationCommand(ele); - creationCommandDescriptors.put(desc.commandId, desc); - } - } catch (ExtensionException e) { - Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage(), e)); - PapyrusTrace.error(IDebugChannel.PAPYRUS_EXTENSIONPOINT_LOADING, this, "Initialization creation command problem " + e); - } - } - PapyrusTrace.trace(IDebugChannel.PAPYRUS_EXTENSIONPOINT_LOADING, this, "" + creationCommandDescriptors.size() + " creationCommands loaded"); - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ICreationCommand.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ICreationCommand.java deleted file mode 100644 index d593e676cec..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ICreationCommand.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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: - * Jerome Benois (Obeo) jerome.benois@obeo.fr - initial API and implementation - *******************************************************************************/ -package org.eclipse.papyrus.core.extension.commands; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.papyrus.core.utils.DiResourceSet; - -/** - * Define a command use to create new diagram. It use to provide Eclipse - * extension @see {@link PapyrusDiagram#creationCommand} It used by the creation - * model wizard. - * - * @author Jerome Benois - */ -public interface ICreationCommand { - - /** - * Create a new diagram in diResourceSet with the given name and open it. - * - * @param diResourceSet - * the resourceSet containing all diagrams - * @param container - * of the diagram, if container is null, the diagram is contained - * by the top level container - * @param diagramName - * the name of the new diagram or null to use a dialog to choose - * the name - */ - public void createDiagram(DiResourceSet diResourceSet, EObject container, String diagramName); - - /** - * Get a command to create a new diagram in diResourceSet with the given - * name. - * - * @param diResourceSet - * the resourceSet containing all diagrams - * @param container - * of the diagram, if container is null, the diagram is contained - * by the top level container - * @param diagramName - * the name of the new diagram or null to use a dialog to choose - * the name - */ - public ICommand getCreateDiagramCommand(final DiResourceSet diResourceSet, final EObject container, final String diagramName); - - /** - * Get the type of the diagram to create. - * - * @return diagram type - */ - public String getCreatedDiagramType(); - - /** - * Check if the creation of this diagram is strongly attached to its parent - * or if it can be reassigned after creation. - * - * @return true if parent can be reassigned - */ - public boolean isParentReassignable(); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ICreationCommandRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ICreationCommandRegistry.java deleted file mode 100644 index 2fe0420d7f6..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ICreationCommandRegistry.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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: - * Jerome Benois (Obeo) jerome.benois@obeo.fr - initial API and implementation - *******************************************************************************/ -package org.eclipse.papyrus.core.extension.commands; - -import java.util.Collection; - -import org.eclipse.papyrus.core.extension.NotFoundException; - -/** - * Registry containing CreationCommand registered by Eclipse extension. - * - * @author Jerome Benois - */ -public interface ICreationCommandRegistry { - - /** - * Get all registered creation command descriptors - * - * @return collection of command descriptors - */ - public Collection getCommandDescriptors(); - - /** - * Get registered creation with given identifier - * - * @param commandId - * the command id - * @return the registered command - * @throws NotFoundException - * if command not registered - */ - ICreationCommand getCommand(String commandId) throws NotFoundException; -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ICreationCondition.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ICreationCondition.java deleted file mode 100644 index c98120f4cfc..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ICreationCondition.java +++ /dev/null @@ -1,36 +0,0 @@ -/***************************************************************************** - * 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 - * - * Tristan Faure (ATOS ORIGIN) tristan.faure@atosorigin.com - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.extension.commands; - -import org.eclipse.emf.ecore.EObject; - -public interface ICreationCondition { - - /** - * This method returns true if the diagram creation is allowed - * - * @param selectedElement - * the element where the diagram is provided - * @return true if the diagram can be created - */ - boolean create(EObject selectedElement); - - /** - * set the command ID in order to take account the environment in order to - * create a diagram - * - * @param commandID - */ - public void setCommand(String commandID); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/IModelCreationCommand.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/IModelCreationCommand.java deleted file mode 100644 index b38f6324bca..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/IModelCreationCommand.java +++ /dev/null @@ -1,31 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tatiana Fesenko (CEA LIST) - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.extension.commands; - -import org.eclipse.papyrus.core.utils.DiResourceSet; - -/** - * The Interface IModelCreationCommand. - */ -public interface IModelCreationCommand { - - /** - * Creates the model. - * - * @param diResourceSet - * the di resource set - */ - void createModel(final DiResourceSet diResourceSet); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ModelCreationCommandBase.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ModelCreationCommandBase.java deleted file mode 100644 index 4f3774846a2..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/ModelCreationCommandBase.java +++ /dev/null @@ -1,126 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tatiana Fesenko (CEA LIST) - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.extension.commands; - -import java.util.Collections; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; -import org.eclipse.papyrus.core.utils.DiResourceSet; - -/** - * The Class ModelCreationCommandBase. - */ -public abstract class ModelCreationCommandBase implements IModelCreationCommand { - - /** - * @see org.eclipse.papyrus.core.extension.commands.IModelCreationCommand#createModel(org.eclipse.papyrus.core.utils.DiResourceSet) - * - * @param diResourceSet - */ - public void createModel(final DiResourceSet diResourceSet) { - TransactionalEditingDomain transactionalEditingDomain = diResourceSet.getTransactionalEditingDomain(); - RecordingCommand command = new RecordingCommand(transactionalEditingDomain) { - - @Override - protected void doExecute() { - runAsTransaction(diResourceSet); - } - }; - transactionalEditingDomain.getCommandStack().execute(command); - } - - /** - * Run as transaction. - * - * @param diResourceSet - * the di resource set - */ - protected void runAsTransaction(final DiResourceSet diResourceSet) { - // Get the uml element to which the newly created diagram will be - // attached. - // Create the diagram - final Resource modelResource = diResourceSet.getModelResource(); - TransactionalEditingDomain editingDomain = diResourceSet.getTransactionalEditingDomain(); - - AbstractTransactionalCommand command = new AbstractTransactionalCommand(editingDomain, "Initialize model", Collections.EMPTY_LIST) { - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - - CommandResult commandResult = CommandResult.newErrorCommandResult("Error during diagram creation"); - EObject model = getRootElement(modelResource); - attachModelToResource(model, modelResource); - - initializeModel(model); - return CommandResult.newOKCommandResult(); - - } - }; - editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(command)); - } - - /** - * Initialize model. - * - * @param owner - * the owner - */ - protected void initializeModel(EObject owner) { - - } - - /** - * Get the root element associated with canvas. - * - * @param modelResource - * the model resource - * @return the root element - */ - protected EObject getRootElement(Resource modelResource) { - EObject rootElement = null; - if(modelResource != null && modelResource.getContents() != null && modelResource.getContents().size() > 0) { - Object root = modelResource.getContents().get(0); - if(root instanceof EObject) { - rootElement = (EObject)root; - } - } else { - rootElement = createRootElement(); - } - return rootElement; - } - - /** - * Store model element in the resource. - */ - protected void attachModelToResource(EObject root, Resource resource) { - resource.getContents().add(root); - } - - /** - * Create the root element of an EMF model - * - * @return the root element - */ - protected abstract EObject createRootElement(); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/PerspectiveContextDependence.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/PerspectiveContextDependence.java deleted file mode 100644 index 14054198ecd..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/commands/PerspectiveContextDependence.java +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.extension.commands; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.papyrus.core.extension.commands.ICreationCondition; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.internal.Perspective; -import org.eclipse.ui.internal.WorkbenchPage; - -public class PerspectiveContextDependence implements ICreationCondition { - - protected String commandID = null; - - public PerspectiveContextDependence() { - // TODO Auto-generated constructor stub - } - - /** - * {@inheritDoc} - */ - public boolean create(EObject selectedElement) { - // Get the perspective - Perspective perspective = ((WorkbenchPage)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()).getActivePerspective(); - // look for the perspective - // verify if the commannd has to be displayed - if(perspective.getHiddenMenuItems().contains(commandID) && perspective.getHiddenToolbarItems().contains(commandID)) { - return false; - } - return true; - } - - /** - * {@inheritDoc} - */ - public void setCommand(String commandID) { - this.commandID = commandID; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/AbstractEditorFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/AbstractEditorFactory.java deleted file mode 100644 index 1356ae82168..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/AbstractEditorFactory.java +++ /dev/null @@ -1,109 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.extension.diagrameditor; - -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.papyrus.core.editorsfactory.IEditorFactory; -import org.eclipse.papyrus.core.services.ServicesRegistry; - -/** - * Abstract base class for Factory of editors. See {@link IEditorFactory}. - * - * - * @author Remi Schnekenburger - * @author Patrick Tessier - * @author cedric dumoulin - */ -public abstract class AbstractEditorFactory implements IPluggableEditorFactory { - - /** - * Expected Class of the diagram to create. - */ - private Class diagramClass; - - /** Expected diagram type (@see {@link Diagram#getType()}) */ - private String expectedType; - - /** - * EditorDescriptor associated to the factory. TODO : Maybe use individual - * setters to set the requested data (ContributorId and Icon). - */ - protected EditorDescriptor editorDescriptor; - - /** - * ServiceRegistry that can be provided to created editors. - */ - private ServicesRegistry serviceRegistry; - - /** - * Creates a new AbstractEditorFactory. - * - * @param diagramClass - * expected Class of the diagram to create. - * @param expectedType - * expected diagram type (@see {@link Diagram#getType()}) - */ - public AbstractEditorFactory(Class diagramClass, String expectedType) { - assert (expectedType != null); - this.diagramClass = diagramClass; - this.expectedType = expectedType; - } - - /** - * Initialize the factory with useful Classes. - * - * @param serviceRegistry - * Service registry that will be provided to created editor. - * @param editorDescriptor - * Descriptor containing data from the Eclipse Extension. - */ - public void init(ServicesRegistry serviceRegistry, EditorDescriptor editorDescriptor) { - this.editorDescriptor = editorDescriptor; - this.serviceRegistry = serviceRegistry; - - } - - /** - * @return the serviceRegistry - */ - public ServicesRegistry getServiceRegistry() { - return serviceRegistry; - } - - /** - * Returns the expected class for the diagram implementation - * - * @return the expected class for the diagram implementation - */ - public Class getDiagramClass() { - return diagramClass; - } - - /** - * Returns the expected type of the diagram - * - * @return the expected diagram type (@see {@link Diagram#getType()}) - */ - public String getExpectedType() { - return expectedType; - } - - /** - * @return the editorDescriptor - */ - public EditorDescriptor getEditorDescriptor() { - return editorDescriptor; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorDescriptor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorDescriptor.java deleted file mode 100644 index cab8b412872..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorDescriptor.java +++ /dev/null @@ -1,152 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.core.extension.diagrameditor; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -/** - * This descriptor describes a nested diagram. It is used by MultiDiagramEditor - * to know about the nested diagram. It is fill by an extension. - * - * @author Cedric Dumoulin - * - */ -public class EditorDescriptor { - - /** - * Editor factory implementation class. - */ - private Class editorFactoryClass; - - /** - * EditorActionBarContributor Id used to search the - * EditorActionBarContributor requested by the editor. - */ - private String actionBarContributorId; - - /** - * The icon representing the diagram - */ - private ImageDescriptor icon; - /** - * Resource path to the icon - */ - private String inconPath; - - /** - * Constructor. - */ - public EditorDescriptor() { - - } - - /** - * - * @param attribute - */ - public void setActionBarContributorId(String actionBarContributorId) { - this.actionBarContributorId = actionBarContributorId; - - } - - /** - * @see org.eclipse.papyrus.core.extension.diagrameditor.IEditorDescriptor#getActionBarContributorId() - * @return - * - */ - public String getActionBarContributorId() { - return actionBarContributorId; - } - - /** - * get the editor icon path - * - * @return the editor icon path - */ - public ImageDescriptor getIcon() { - return icon; - } - - /** - * set the editor icon - * - * @param icon - * the icon path - */ - public void setIcon(ImageDescriptor icon) { - this.icon = icon; - } - - /** - * get the class of the editor factory - * - * @return the class of the editor - */ - public Class getEditorFactoryClass() { - return editorFactoryClass; - } - - /** - * set the editor facoty to this descriptor - * - * @param editorFactoryClass - * the class that represents the editor factory - */ - public void setEditorFactoryClass(Class editorFactoryClass) { - this.editorFactoryClass = editorFactoryClass; - } - - /** - * - * {@inheritDoc} - */ - public String toString() { - if(editorFactoryClass == null || editorFactoryClass.getName() == null) { - return "[nestedEditor editorFactory:" + editorFactoryClass + "(null)]"; - } - return "[nestedEditor editorFactory:" + editorFactoryClass.getName() + "]"; - } - - /** - * Set the URL of the Icon - * - * @param iconPath - * path of the Icon - */ - public void setIconURL(String iconPath) { - inconPath = iconPath; - } - - /** - * Get the URL of the based images - * - * @return the path of the mai image. can return null if this property is not set - */ - public String getIconURL() { - return inconPath; - } - - /** - * set the Icon thanks to a {@link IConfigurationElement} and {@link String}which represent the path of the Icon - * - * @param element - * @param iconPath - */ - public void setIcon(IConfigurationElement element, String iconPath, String pluginID) { - setIcon(AbstractUIPlugin.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), iconPath)); - setIconURL(element.getNamespaceIdentifier() + '/' + iconPath); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorDescriptorExtensionFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorDescriptorExtensionFactory.java deleted file mode 100644 index 92e77abedf4..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorDescriptorExtensionFactory.java +++ /dev/null @@ -1,82 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.extension.diagrameditor; - -import static org.eclipse.papyrus.core.Activator.log; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.papyrus.core.extension.BadNameExtensionException; -import org.eclipse.papyrus.core.extension.ExtensionException; -import org.eclipse.papyrus.core.extension.ExtensionUtils; - -/** - * A factory used to create editor descriptor object from Eclipse extensions points elements. - * - *@author Cedric Dumoulin - *@author Patrick Tessier - */ -public class EditorDescriptorExtensionFactory extends ExtensionUtils { - - /** singleton eINSTANCE of this class */ - public final static EditorDescriptorExtensionFactory eINSTANCE = new EditorDescriptorExtensionFactory(); - - /** constant for the editor diagram **/ - public final static String EDITOR_DIAGRAM_EXTENSIONPOINT = "editorDiagram"; - - /** constant for the attribute factoryClass **/ - public final static String FACTORYCLASS_ATTRIBUTE = "factoryClass"; - - /** constant for the attribute contextId **/ - public final static String ACTIONBARCONTRIBUTORID_ATTRIBUTE = "actionBarContributorId"; - - /** constant for the attribute icon **/ - public final static String ICON_ATTRIBUTE = "icon"; - - /** - * @return the eINSTANCE - */ - public static EditorDescriptorExtensionFactory getInstance() { - return eINSTANCE; - } - - /** - * Create a descriptor instance corresponding to the ConfigurationElement. - * - * @param element - * an {@link IConfigurationElement} see eclipse extension point - * @return a nestedEditorDescriptor structure that contains information to create diagrams - * @throws BadNameExtensionException - */ - @SuppressWarnings("unchecked") - public EditorDescriptor createNestedEditorDescriptor(IConfigurationElement element) throws ExtensionException { - EditorDescriptor res; - - checkTagName(element, EDITOR_DIAGRAM_EXTENSIONPOINT); - - res = new EditorDescriptor(); - res.setEditorFactoryClass((Class)parseClass(element, FACTORYCLASS_ATTRIBUTE, EDITOR_DIAGRAM_EXTENSIONPOINT)); - res.setActionBarContributorId(element.getAttribute(ACTIONBARCONTRIBUTORID_ATTRIBUTE)); - String iconPath = element.getAttribute(ICON_ATTRIBUTE); - if(iconPath != null) { - /** Implementation which set the icon and register the complete URL of the icon : Bug eclipse 358732*/ - res.setIcon(element, iconPath, org.eclipse.papyrus.core.Activator.PLUGIN_ID); - - } - - if(log.isDebugEnabled()) { - log.debug("Read editor descriptor " + res); - } - return res; - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorFactoryProxy.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorFactoryProxy.java deleted file mode 100644 index 9cd7b1bd4ef..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorFactoryProxy.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.extension.diagrameditor; - -import org.eclipse.papyrus.core.editorsfactory.IEditorFactory; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; - -/** - * A proxy implementation of {@link IEditorFactory} used to do lazy - * instantiation of concrete {@link IPluggableEditorFactory}. This class is used - * by the {@link PluggableEditorFactoryReader} - * - * @author cedric dumoulin - * - */ -public class EditorFactoryProxy implements IEditorFactory { - - /** - * The concrete implementation. - */ - private IPluggableEditorFactory editorFactory; - - /** - * EditorDescriptor associated to the factory. - */ - protected EditorDescriptor editorDescriptor; - - /** - * ServiceRegistry that can be provided to created editors. - */ - private ServicesRegistry serviceRegistry; - - /** - * Constructor. - * - * @param serviceRegistry - * @param editorDescriptor - */ - public EditorFactoryProxy(ServicesRegistry serviceRegistry, EditorDescriptor editorDescriptor) { - this.serviceRegistry = serviceRegistry; - this.editorDescriptor = editorDescriptor; - } - - /** - * @see org.eclipse.papyrus.core.editorsfactory.IEditorFactory#createIPageModel(java.lang.Object) - * - * @param pageIdentifier - * @return - */ - public IPageModel createIPageModel(Object pageIdentifier) { - return getEditorFactory().createIPageModel(pageIdentifier); - } - - /** - * @see org.eclipse.papyrus.core.editorsfactory.IEditorFactory#isPageModelFactoryFor(java.lang.Object) - * - * @param pageIdentifier - * @return - */ - public boolean isPageModelFactoryFor(Object pageIdentifier) { - return getEditorFactory().isPageModelFactoryFor(pageIdentifier); - } - - /** - * @return the editorFactory - */ - protected IPluggableEditorFactory getEditorFactory() { - - if(editorFactory == null) { - editorFactory = createEditorFactory(); - } - - return editorFactory; - - } - - /** - * Create an instance of IPluggableEditorFactory as described in the - * editorDescriptor. TODO let propagate the exceptions. - * - * @return - */ - private IPluggableEditorFactory createEditorFactory() { - // Create the requested class. - try { - editorFactory = editorDescriptor.getEditorFactoryClass().newInstance(); - // Set the descriptor. USed by the factory to get the ActionBarId - // and Icon - editorFactory.init(serviceRegistry, editorDescriptor); - return editorFactory; - } catch (InstantiationException e) { - // Lets propagate. This is an implementation problem that should be - // solved by programmer. - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - // Lets propagate. This is an implementation problem that should be - // solved by programmer. - throw new RuntimeException(e); - } - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorIconFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorIconFactory.java deleted file mode 100644 index 8f516f91f7e..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorIconFactory.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.extension.diagrameditor; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.papyrus.core.editorsfactory.IEditorIconFactory; -import org.eclipse.papyrus.core.editorsfactory.IEditorIconFactoryExtended; -import org.eclipse.swt.graphics.Image; - -/** - * A factory used to create the Icon associated to an editor TODO Lets have a - * common ancestor for {@link EditorIconFactory} and {@link EditorFactoryProxy} - * - * @author cedric dumoulin - * - */ -public class EditorIconFactory implements IEditorIconFactoryExtended { - - /** - * The concrete implementation. - */ - private IPluggableEditorFactory editorFactory; - - /** - * EditorDescriptor associated to the factory. - */ - protected EditorDescriptor editorDescriptor; - - /** - * Cached image for reuse. - */ - protected Image cachedImage; - - /** - * Constructor. - * - * @param serviceRegistry - * @param editorDescriptor - */ - public EditorIconFactory(EditorDescriptor editorDescriptor) { - this.editorDescriptor = editorDescriptor; - } - - /** - * @see org.eclipse.papyrus.core.editorsfactory.IEditorIconFactory#getEditorIcon(java.lang.Object) - * - * @param pageIdentifier - * @return - */ - public Image getEditorIcon(Object pageIdentifier) { - - if(cachedImage == null) { - cachedImage = createEditorIcon(pageIdentifier); - } - - return cachedImage; - } - - /** - * Create an Image associated to the editor used to render the specified - * pageIdentifier - * - * @return - */ - public Image createEditorIcon(Object pageIdentifier) { - ImageDescriptor imageDescriptor = editorDescriptor.getIcon(); - if(imageDescriptor == null) - return null; - Image image = imageDescriptor.createImage(); - return image; - } - - /** - * @see org.eclipse.papyrus.core.editorsfactory.IEditorFactory#isPageModelFactoryFor(java.lang.Object) - * - * @param pageIdentifier - * @return - */ - public boolean isPageModelFactoryFor(Object pageIdentifier) { - return getEditorFactory().isPageModelFactoryFor(pageIdentifier); - } - - /** - * @return the editorFactory - */ - protected IPluggableEditorFactory getEditorFactory() { - - if(editorFactory == null) { - editorFactory = createEditorFactory(); - } - - return editorFactory; - - } - - /** - * Create an instance of IPluggableEditorFactory as described in the - * editorDescriptor. TODO let propagate the exceptions. - * - * @return - */ - private IPluggableEditorFactory createEditorFactory() { - // Create the requested class. - try { - editorFactory = editorDescriptor.getEditorFactoryClass().newInstance(); - // Set the descriptor. USed by the factory to get the ActionBarId - // and Icon - // editorFactory.init(serviceRegistry, editorDescriptor); - return editorFactory; - } catch (InstantiationException e) { - // Lets propagate. This is an implementation problem that should be - // solved by programmer. - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - // Lets propagate. This is an implementation problem that should be - // solved by programmer. - throw new RuntimeException(e); - } - - } - - /** - * Return the URL of the main icon used to create this icon - * - * @see org.eclipse.papyrus.core.editorsfactory.IEditorIconFactory#getURLMainIcon(java.lang.Object) - * - * @param pageIdentifier - * @return - */ - public String getURLMainIcon(Object pageIdentifier) { - return editorDescriptor.getIconURL(); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorNotFoundException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorNotFoundException.java deleted file mode 100644 index a717ebdf00e..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/EditorNotFoundException.java +++ /dev/null @@ -1,53 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.extension.diagrameditor; - -/** - * Editor was not found. - * - * @author dumoulin - * - */ -@SuppressWarnings("serial") -public class EditorNotFoundException extends MultiDiagramException { - - /** - * - */ - public EditorNotFoundException() { - } - - /** - * @param arg0 - */ - public EditorNotFoundException(String arg0) { - super(arg0); - } - - /** - * @param arg0 - */ - public EditorNotFoundException(Throwable arg0) { - super(arg0); - } - - /** - * @param arg0 - * @param arg1 - */ - public EditorNotFoundException(String arg0, Throwable arg1) { - super(arg0, arg1); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/IPluggableEditorFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/IPluggableEditorFactory.java deleted file mode 100644 index 1c56d08599d..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/IPluggableEditorFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.extension.diagrameditor; - -import org.eclipse.papyrus.core.editorsfactory.IEditorFactory; -import org.eclipse.papyrus.core.services.ServicesRegistry; - -/** - * This interface should be implemented by Editor Factories that can be declared - * as Eclipse extension. It extends the {@link IEditorFactory} by adding methods - * to initialize the factory with multieditor ServiceRegistry and associated - * editor data. - * - * @author Cédric Dumoulin - * - */ -public interface IPluggableEditorFactory extends IEditorFactory { - - /** - * Initialize the factory with useful Classes. - * - * @param serviceRegistry - * Service registry that will be provided to created editor. - * @param editorDescriptor - * Descriptor containing data from the Eclipse Extension. - */ - public void init(ServicesRegistry serviceRegistry, EditorDescriptor editorDescriptor); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/MultiDiagramException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/MultiDiagramException.java deleted file mode 100644 index a5ad7af98d4..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/MultiDiagramException.java +++ /dev/null @@ -1,53 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.extension.diagrameditor; - -/** - * Root Exception of MultiDiagram exception - * - * @author dumoulin - * - */ -@SuppressWarnings("serial") -public class MultiDiagramException extends Exception { - - /** - * - */ - public MultiDiagramException() { - } - - /** - * @param arg0 - */ - public MultiDiagramException(String arg0) { - super(arg0); - } - - /** - * @param arg0 - */ - public MultiDiagramException(Throwable arg0) { - super(arg0); - } - - /** - * @param arg0 - * @param arg1 - */ - public MultiDiagramException(String arg0, Throwable arg1) { - super(arg0, arg1); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/PluggableEditorFactoryReader.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/PluggableEditorFactoryReader.java deleted file mode 100644 index 9de43a2944e..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/extension/diagrameditor/PluggableEditorFactoryReader.java +++ /dev/null @@ -1,140 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.extension.diagrameditor; - -import static org.eclipse.papyrus.core.Activator.log; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; -import org.eclipse.papyrus.core.editorsfactory.PageIconsRegistry; -import org.eclipse.papyrus.core.editorsfactory.PageModelFactoryRegistry; -import org.eclipse.papyrus.core.extension.ExtensionException; -import org.eclipse.papyrus.core.services.ServicesRegistry; - -/** - * This reader is used to read PluggableEditorFactory from the Eclipse extension - * declarations. It can be used to populate an {@link PageModelFactoryRegistry}. - */ -public class PluggableEditorFactoryReader { - - /** list of editor descriptors */ - protected List editorDescriptors; - - /** ID of the editor extension (schema filename) */ - public static final String EDITOR_EXTENSION_ID = "papyrusDiagram"; - - /** Namespace where to look for the extension points. */ - protected String extensionPointNamespace; - - /** indicates if extension is loaded or not */ - private boolean isExtensionLoaded = false; - - /** - * Create a new Registry reading extension from the specified namespace. The - * namespace is usually the name of the plugin owning the registry. - * - * @param extensionPointNamespace - */ - public PluggableEditorFactoryReader(String extensionPointNamespace) { - super(); - this.extensionPointNamespace = extensionPointNamespace; - editorDescriptors = new ArrayList(); - } - - /** - * Populate the provided {@link PageModelFactoryRegistry} with {@link IPluggableEditorFactory} read from Eclipse extension declarations. - * For each declared editor, create a proxy encapsulating the real - * EditorFactory. Then the proxy is added to the PageModelFactoryRegistry. - * - * @param pageModelFactoryRegistry - * The object to populate - * @param serviceRegistry - * ServiceRegistry provided to newly instantiated {@link IPluggableEditorFactory}. - */ - public void populate(PageModelFactoryRegistry pageModelFactoryRegistry, ServicesRegistry serviceRegistry) { - - for(EditorDescriptor desc : getEditorDescriptors()) { - - // Create and add a proxy encapsulating the EditorFactory. - pageModelFactoryRegistry.add(new EditorFactoryProxy(serviceRegistry, desc)); - } - } - - /** - * Populate the provided {@link PageIconsRegistry} with icons read from - * Eclipse extension declarations. For each declared editor, create a {@link EditorIconFactory}. - * - * @param pageModelFactoryRegistry - * The object to populate - * @param serviceRegistry - * ServiceRegistry provided to newly instantiated {@link IPluggableEditorFactory}. - */ - public void populate(PageIconsRegistry registry) { - - for(EditorDescriptor desc : getEditorDescriptors()) { - - // Create and add a proxy encapsulating the EditorFactory. - registry.add(new EditorIconFactory(desc)); - } - } - - /** - * Get the list of editor descriptor. - * - * @return the list of editor descriptor. - */ - public List getEditorDescriptors() { - if(!isExtensionLoaded) { - isExtensionLoaded = true; - initializeEditorDescriptors(); - } - return editorDescriptors; - } - - /** - * Read editor descriptors from extension points. - */ - private void initializeEditorDescriptors() { - // Reading data from plugins - IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointNamespace, EDITOR_EXTENSION_ID); - - for(IConfigurationElement ele : configElements) { - EditorDescriptor desc; - try { - if(EditorDescriptorExtensionFactory.EDITOR_DIAGRAM_EXTENSIONPOINT.equals(ele.getName())) { - desc = EditorDescriptorExtensionFactory.eINSTANCE.createNestedEditorDescriptor(ele); - editorDescriptors.add(desc); - } - } catch (ExtensionException e) { - log.error("Initialization editor problem ", e); - } - } - - if(log.isDebugEnabled()) { - log.debug("Read " + editorDescriptors.size() + " editor descriptors from Eclipse extensions"); - } - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return "EditorFactoryRegistry: " + editorDescriptors.toString(); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/DoSaveEvent.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/DoSaveEvent.java deleted file mode 100644 index dc27d32e104..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/DoSaveEvent.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.lifecycleevents; - -import org.eclipse.papyrus.core.editor.IMultiDiagramEditor; -import org.eclipse.papyrus.core.services.ServicesRegistry; - -/** - * Event sent whith a Save or SaveAs. - * - * @author cedric dumoulin - * - */ -public class DoSaveEvent { - - final protected ServicesRegistry serviceRegistry; - - final protected IMultiDiagramEditor multiDiagramEditor; - - /** - * Create an Event that is sent with a Save or SaveAs. The same event can be - * reused. Constructor. - * - * @param serviceRegistry - * @param multiDiagramEditor - */ - public DoSaveEvent(ServicesRegistry serviceRegistry, IMultiDiagramEditor multiDiagramEditor) { - this.serviceRegistry = serviceRegistry; - this.multiDiagramEditor = multiDiagramEditor; - } - - /** - * @return the serviceRegistry - */ - public ServicesRegistry getServiceRegistry() { - return serviceRegistry; - } - - /** - * @return the multiDiagramEditor - */ - public IMultiDiagramEditor getMultiDiagramEditor() { - return multiDiagramEditor; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/IEditorInputChangedListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/IEditorInputChangedListener.java deleted file mode 100644 index a5e317408be..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/IEditorInputChangedListener.java +++ /dev/null @@ -1,41 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 LIFL & CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.core.lifecycleevents; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.part.FileEditorInput; - -/** - * Interface implemented by classes wishing to be notified of the inputChanged - * event after a call to {@link ISaveAndDirtyService#doSaveAs()}. - * - * @author cedric dumoulin - * - */ -public interface IEditorInputChangedListener { - - /** - * - * @param fileEditorInput - * The new value of EditorInput - */ - public void editorInputChanged(FileEditorInput fileEditorInput); - - /** - * Called when the value of the isDirty() flag has changed. - */ - public void isDirtyChanged(); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/ILifeCycleEventsProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/ILifeCycleEventsProvider.java deleted file mode 100644 index d27c2c31b27..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/ILifeCycleEventsProvider.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.lifecycleevents; - -/** - * Concrete implementation of this interface allows to listen on various - * lifecycle events. This interface is the "public" part of the {@link LifeCycleEventsProvider}. - * - * @author cedric dumoulin - * - */ -public interface ILifeCycleEventsProvider { - - /** - * Add specified listener. - * - * @param listener - */ - public void addDoSaveListener(ISaveEventListener listener); - - /** - * Remove specified listener. - * - * @param listener - */ - public void removeDoSaveListener(ISaveEventListener listener); - - /** - * Add specified listener. - * - * @param listener - */ - public void addAboutToDoSaveListener(ISaveEventListener listener); - - /** - * Remove specified listener. - * - * @param listener - */ - public void removeAboutToDoSaveListener(ISaveEventListener listener); - - /** - * Add specified listener. - * - * @param listener - */ - public void addPostDoSaveListener(ISaveEventListener listener); - - /** - * Remove specified listener. - * - * @param listener - */ - public void removePostDoSaveListener(ISaveEventListener listener); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/ISaveAndDirtyService.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/ISaveAndDirtyService.java deleted file mode 100644 index abda177667a..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/ISaveAndDirtyService.java +++ /dev/null @@ -1,56 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 LIFL & CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.core.lifecycleevents; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.ui.ISaveablePart; - -/** - * @author dumoulin - * - */ -public interface ISaveAndDirtyService extends ISaveablePart { - - /** - * Register a nested {@link ISaveablePart} as a listener that will be - * notified each time a {@link #doSave(IProgressMonitor)} or {@link #doSaveAs()} is performed. Also, it will be asked for the - * dirtyState. - * - * @param saveablePart - */ - public abstract void registerIsaveablePart(ISaveablePart saveablePart); - - /** - * Remove the specified {@link ISaveablePart} from the list of listeners. - * - * @param saveablePart - */ - public abstract void removeIsaveablePart(ISaveablePart saveablePart); - - /** - * Add a listeners on input changed event. - * - * @param inputChangedListener - */ - public void addInputChangedListener(IEditorInputChangedListener inputChangedListener); - - /** - * Remove a listeners on input changed event. - * - * @param inputChangedListener - */ - public void removeInputChangedListener(IEditorInputChangedListener inputChangedListener); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/ISaveEventListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/ISaveEventListener.java deleted file mode 100644 index a1171b487e4..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/ISaveEventListener.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.lifecycleevents; - -/** - * Interface used to listen on open, save and saveAs events. - * - * @author cedric dumoulin - * - * @param - * Type of event passed to methods. - */ -public interface ISaveEventListener { - - /** - * - * @param editor - */ - public void doSave(DoSaveEvent event); - - /** - * - * @param editor - */ - public void doSaveAs(DoSaveEvent event); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/LifeCycleEventsProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/LifeCycleEventsProvider.java deleted file mode 100644 index 6da95116a3f..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/LifeCycleEventsProvider.java +++ /dev/null @@ -1,272 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.lifecycleevents; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class provides events about the life cycle of a MultiEditor. Not all - * life cycle events are available. Available events: - *

    - *
  • aboutToDoSave, aboutToDoSaveAs - SaveEventListener
  • - *
  • doSave, doSaveAs - SaveEventListener
  • - *
  • afterDoSave, afterDoSaveAs - SaveEventListener
  • - *
  • - *
  • - *
- * - * - * @author cedric dumoulin - * - */ -public class LifeCycleEventsProvider implements ILifeCycleEventsProvider { - - /** - * - */ - protected SaveEventListenerLazyList preSaveListeners = new SaveEventListenerLazyList(); - - /** - * - */ - protected SaveEventListenerLazyList saveListeners = new SaveEventListenerLazyList(); - - /** - * - */ - protected SaveEventListenerLazyList postSaveListeners = new SaveEventListenerLazyList(); - - /** - * Add specified listener. - * - * @param listener - */ - public void addDoSaveListener(ISaveEventListener listener) { - - saveListeners.addListener(listener); - } - - /** - * Remove specified listener. - * - * @param listener - */ - public void removeDoSaveListener(ISaveEventListener listener) { - saveListeners.removeListener(listener); - } - - /** - * Add specified listener. - * - * @param listener - */ - public void addAboutToDoSaveListener(ISaveEventListener listener) { - - preSaveListeners.addListener(listener); - } - - /** - * Remove specified listener. - * - * @param listener - */ - public void removeAboutToDoSaveListener(ISaveEventListener listener) { - preSaveListeners.removeListener(listener); - } - - /** - * Add specified listener. - * - * @param listener - */ - public void addPostDoSaveListener(ISaveEventListener listener) { - - postSaveListeners.addListener(listener); - } - - /** - * Remove specified listener. - * - * @param listener - */ - public void removePostDoSaveListener(ISaveEventListener listener) { - postSaveListeners.removeListener(listener); - } - - // ****************************************************** // - // Fire events methods // - // ****************************************************** // - - /** - * Fire AboutToSaveEvent to registered Listeners. - * - * @param editorPart - */ - public void fireAboutToDoSaveEvent(DoSaveEvent event) { - preSaveListeners.fireSaveEvent(event); - } - - /** - * Fire AboutToSaveAs to registered Listeners. - * - * @param editorPart - */ - public void fireAboutToDoSaveAsEvent(DoSaveEvent event) { - preSaveListeners.fireSaveAsEvent(event); - } - - /** - * Fire AboutToSaveEvent to registered Listeners. - * - * @param editorPart - */ - public void fireDoSaveEvent(DoSaveEvent event) { - saveListeners.fireSaveEvent(event); - } - - /** - * Fire AboutToSaveAs to registered Listeners. - * - * @param editorPart - */ - public void fireDoSaveAsEvent(DoSaveEvent event) { - saveListeners.fireSaveAsEvent(event); - } - - /** - * Fire AboutToSaveEvent to registered Listeners. - * - * @param editorPart - */ - public void firePostDoSaveEvent(DoSaveEvent event) { - postSaveListeners.fireSaveEvent(event); - } - - /** - * Fire AboutToSaveAs to registered Listeners. - * - * @param editorPart - */ - public void firePostDoSaveAsEvent(DoSaveEvent event) { - postSaveListeners.fireSaveAsEvent(event); - } - - /** - * Fire all Save events (about, events, post) to registered Listeners. - * Exceptions from listeners are propagated and stop the event chain. - * - * @param editorPart - */ - public void fireAllDoSaveEvent(DoSaveEvent event) { - fireAboutToDoSaveEvent(event); - fireDoSaveEvent(event); - firePostDoSaveEvent(event); - } - - /** - * Fire all SaveAs events (about, events, post) to registered Listeners. If - * one of the saveAs event fail, post events are not sent. - * - * @param editorPart - */ - public void fireAllDoSaveAsEvent(DoSaveEvent event) { - fireAboutToDoSaveAsEvent(event); - fireDoSaveAsEvent(event); - firePostDoSaveAsEvent(event); - } - - /** - * Base class encapsulating a lazy creation list. - * - * @author cedric dumoulin - * - * @param - */ - abstract protected class AbstractEventListenersLazyList { - - List listeners; - - /** - * Add specified listener. - * - * @param listener - */ - public void addListener(T listener) { - // Lazy creation - if(listeners == null) - listeners = new ArrayList(); - - // do not add if already present. - if(listeners.contains(listener)) - return; - - listeners.add(listener); - } - - /** - * Remove specified listener. - * - * @param listener - */ - public void removeListener(T listener) { - // Lazy creation - if(listeners == null) - return; - - listeners.remove(listener); - } - - /** - * @return the listeners - */ - protected List getListeners() { - return listeners; - } - - } - - /** - * List of {@link ISaveEventListener}. - * - * @author cedric dumoulin - * - */ - protected class SaveEventListenerLazyList extends AbstractEventListenersLazyList { - - /** - * Fire OpenEvent to registered Listeners. If a listener throw an - * exception, remaining listeners are called, and then the exception is - * resent. - * - * @param editorPart - */ - public void fireSaveEvent(DoSaveEvent event) { - // Lazy creation - if(listeners == null) - return; - - for(ISaveEventListener listener : listeners) { - listener.doSave(event); - } - } - - /** - * Fire OpenEvent to registered Listeners. - * - * @param editorPart - */ - public void fireSaveAsEvent(DoSaveEvent event) { - // Lazy creation - if(listeners == null) - return; - - for(ISaveEventListener listener : listeners) { - listener.doSaveAs(event); - } - - } - - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/LifeCycleEventsProviderServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/LifeCycleEventsProviderServiceFactory.java deleted file mode 100644 index 44d0cc56bab..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/LifeCycleEventsProviderServiceFactory.java +++ /dev/null @@ -1,76 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 LIFL & CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.core.lifecycleevents; - -import org.eclipse.papyrus.core.services.IServiceFactory; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.resource.ModelSet; - -/** - * A service factory to create the {@link ILifeCycleEventsProvider} service. - * This provide a nickname for {@link SaveAndDirtyService} service. This - * serviceFactory depends on {@link SaveAndDirtyService} service. - * - * @author cedric dumoulin - * - */ -public class LifeCycleEventsProviderServiceFactory implements IServiceFactory { - - /** - * The sashModelMangr. - */ - private SaveAndDirtyService saveAndDirtyService; - - /** - * @see org.eclipse.papyrus.core.services.IService#init(org.eclipse.papyrus.core.services.ServicesRegistry) - * - * @param servicesRegistry - * @throws ServiceException - */ - public void init(ServicesRegistry servicesRegistry) throws ServiceException { - // Get required services - // This rely on the real implementation. - saveAndDirtyService = (SaveAndDirtyService)servicesRegistry.getService(ISaveAndDirtyService.class); - - } - - /** - * @see org.eclipse.papyrus.core.services.IService#startService() - * - * @throws ServiceException - */ - public void startService() throws ServiceException { - } - - /** - * @see org.eclipse.papyrus.core.services.IService#disposeService() - * - * @throws ServiceException - */ - public void disposeService() throws ServiceException { - } - - /** - * @see org.eclipse.papyrus.core.services.IServiceFactory#createServiceInstance() - * - * @return - * @throws ServiceException - */ - public Object createServiceInstance() throws ServiceException { - return saveAndDirtyService; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/SaveAndDirtyService.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/SaveAndDirtyService.java deleted file mode 100644 index 71898cbe651..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/lifecycleevents/SaveAndDirtyService.java +++ /dev/null @@ -1,491 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 LIFL & CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.core.lifecycleevents; - -import static org.eclipse.papyrus.core.Activator.log; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.EventObject; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.common.command.BasicCommandStack; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CommandStackListener; -import org.eclipse.emf.transaction.NotificationFilter; -import org.eclipse.emf.transaction.ResourceSetChangeEvent; -import org.eclipse.emf.transaction.ResourceSetListener; -import org.eclipse.emf.transaction.RollbackException; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.papyrus.core.editor.IMultiDiagramEditor; -import org.eclipse.papyrus.core.services.IService; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.core.utils.ServiceUtils; -import org.eclipse.papyrus.resource.ModelSet; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.ISaveablePart; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.dialogs.SaveAsDialog; -import org.eclipse.ui.part.FileEditorInput; - -/** - * A Papyrus Service allowing to perform save and saveAs on Papyrus Models. The - * service also allows to listen on the dirty state of the Models.
- * The service implements the {@link ISaveablePart} interface, and can be used - * directly in part requiring such interface of adapter. - * - *
- * This class allows nested editors to register themselves as nested {@link ISaveablePart}. In this case, the registered part will be notified - * each time a save or saveAs is performed. Also, the nested part will be asked - * for its dirtyState. - * - * TODO : Improve the implementation by registering the isDirty flag value, and - * firing events only if the value really change. Actually, the event is fired - * every time the model is modified, even if the virtual value of the flag - * hasn't changed. - * - * @author cedric dumoulin - * - */ -public class SaveAndDirtyService extends LifeCycleEventsProvider implements ISaveablePart, IService, ISaveAndDirtyService { - - /** - * Class used to propagate life cycle events. This class can be retrieved as - * a service using {@link ILifeCycleEventsProvider}.class. This class - * extends LifeCycleEventsProvider, so the local variable is set with - * ourself (historical reasons). TODO : remove this local variable. - */ - protected LifeCycleEventsProvider lifeCycleEventsProvider = this; - - /** - * Cached event that can be reused. - */ - protected DoSaveEvent lifeCycleEvent; - - /** - * Model set managing models. - */ - private ModelSet resourceSet; - - /** - * - */ - private TransactionalEditingDomain transactionalEditingDomain; - - /** - * The serviceRegistry. - */ - private ServicesRegistry servicesRegistry; - - /** - * Associated editor. Needed by saveAs to synchronize editor input. - */ - private IMultiDiagramEditor multiDiagramEditor; - - /** - * List of registered {@link ISaveablePart}. This are usually nested - * editors. - */ - private ISaveablePartList registeredIsaveablePart; - - /** - * List of listeners on input changed event after a call to saveAs. - */ - private List inputChangedListeners; - - /** - * Listener on commandStack changes. - */ - private final CommandStackListener commandStackListener = new CommandStackListener() { - - public void commandStackChanged(EventObject event) { - - fireIsDirtyChanged(); - }; - }; - - /* - * Listener on ResourceSet - */ - private final ResourceSetListener resourceSetListener = new ResourceSetListener() { - - public NotificationFilter getFilter() { - return null; - } - - public boolean isAggregatePrecommitListener() { - return false; - } - - public boolean isPostcommitOnly() { - return true; - } - - public boolean isPrecommitOnly() { - return false; - } - - public void resourceSetChanged(ResourceSetChangeEvent event) { - if(event.getTransaction() != null && event.getTransaction().getStatus().isOK()) { - fireIsDirtyChanged(); - } - } - - public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException { - return null; - } - - }; - - /** - * Constructor. - * - */ - public SaveAndDirtyService() { - registeredIsaveablePart = new ISaveablePartList(); - inputChangedListeners = new ArrayList(); - } - - /** - * Initialize the service. Retrieve other required services (ModelSet, - * CoreEditor). - * - * @see org.eclipse.papyrus.core.services.IService#init(org.eclipse.papyrus.core.services.ServicesRegistry) - * - * @param servicesRegistry - * @throws ServiceException - */ - public void init(ServicesRegistry servicesRegistry) throws ServiceException { - - this.servicesRegistry = servicesRegistry; - - // Retrieve required services. - resourceSet = servicesRegistry.getService(ModelSet.class); - multiDiagramEditor = servicesRegistry.getService(IMultiDiagramEditor.class); - transactionalEditingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(servicesRegistry); - - // Initialize and register the ILifeCycleEventsProvider service (which - // is ourself). - // This mean that the ILifeCycleEventsProvider is not available until we - // are started. - lifeCycleEvent = new DoSaveEvent(servicesRegistry, multiDiagramEditor); - // servicesRegistry.add(ILifeCycleEventsProvider.class, 1, - // lifeCycleEventsProvider); - - } - - /** - * Do nothing. - * - * @see org.eclipse.papyrus.core.services.IService#startService() - * - * @throws ServiceException - */ - public void startService() throws ServiceException { - - // Listen to the modifications of the EMF model - transactionalEditingDomain.getCommandStack().addCommandStackListener(commandStackListener); - - // Let's listen to the resource set change - transactionalEditingDomain.addResourceSetListener(resourceSetListener); - } - - /** - * @see org.eclipse.papyrus.core.services.IService#disposeService() - * - * @throws ServiceException - */ - public void disposeService() throws ServiceException { - if(transactionalEditingDomain != null) { - transactionalEditingDomain.getCommandStack().removeCommandStackListener(commandStackListener); - transactionalEditingDomain.removeResourceSetListener(resourceSetListener); - } - } - - /** - * Save the Models - * - * @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor) - * - * @param monitor - */ - public void doSave(IProgressMonitor monitor) { - // Sent pre doSave event - lifeCycleEventsProvider.fireAboutToDoSaveEvent(lifeCycleEvent); - - // sent doSaveEvent - lifeCycleEventsProvider.fireDoSaveEvent(lifeCycleEvent); - // Perform local doSave - // TODO : put it in a listener ? - try { - // Save each associated resource - resourceSet.save(monitor); - // notify registered IsaveablePart - registeredIsaveablePart.doSave(monitor); - markSaveLocation(); - } catch (IOException e) { - log.error("Error during save", e); - } - - // Sent post Events - lifeCycleEventsProvider.firePostDoSaveEvent(lifeCycleEvent); - - } - - /** - * @see org.eclipse.ui.ISaveablePart#doSaveAs() - * - */ - public void doSaveAs() { - // Sent pre doSave event - lifeCycleEventsProvider.fireAboutToDoSaveAsEvent(lifeCycleEvent); - - // sent doSaveEvent - lifeCycleEventsProvider.fireDoSaveAsEvent(lifeCycleEvent); - // Perform local doSaveAs - - // Show a SaveAs dialog - Shell shell = multiDiagramEditor.getEditorSite().getWorkbenchWindow().getShell(); - SaveAsDialog dialog = new SaveAsDialog(shell); - dialog.setOriginalFile(((IFileEditorInput)multiDiagramEditor.getEditorInput()).getFile()); - dialog.open(); - final IPath path = dialog.getResult(); - if(path != null) { - // try to save the editor's contents under a different file name - final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); - try { - new ProgressMonitorDialog(shell).run(false, // don't fork - false, // can't cancel - new WorkspaceModifyOperation() { // run this operation - - @Override - public void execute(final IProgressMonitor monitor) { - try { - resourceSet.saveAs(path); - // notify registered IsaveablePart - registeredIsaveablePart.doSave(monitor); - } catch (IOException e) { - log.error("Unable to saveAs the resource set", e); - } - } - }); - // set input to the new file - fireEditorInputChanged(new FileEditorInput(file)); - markSaveLocation(); - } catch (InterruptedException e) { - // should not happen, since the monitor dialog is not cancelable - log.error(e); - } catch (InvocationTargetException e) { - log.error(e); - } - } - - // sent doSaveEvent - lifeCycleEventsProvider.firePostDoSaveAsEvent(lifeCycleEvent); - } - - /** - * Change the input of the underlying editor. - * - * @param fileEditorInput - */ - private void fireEditorInputChanged(FileEditorInput fileEditorInput) { - - for(IEditorInputChangedListener listener : inputChangedListeners) { - try { - listener.editorInputChanged(fileEditorInput); - } catch (Exception e) { - log.error("Can't set input for '" + listener + "'", e); - } - } - - } - - /** - * Fire a PropertyChanged event to registered {@link IEditorInputChangedListener}. - * - * @param propertyId - */ - private void fireIsDirtyChanged() { - - for(IEditorInputChangedListener listener : inputChangedListeners) { - try { - listener.isDirtyChanged(); - } catch (Exception e) { - log.error("Can't call listener '" + listener + "'", e); - } - } - - } - - /** - * Return true if the multiEditor is dirty, false otherwise. The dirty state - * is compute as follow: - *
    - *
  • The {@link TransactionalEditingDomain} commandStack is checked
  • - *
  • and each registered nested Isaveable.isDirty() state is checked
  • - *
  • - *
  • - *
  • - *
  • - *
- * If one of these states is false, the returned value is false.
- * If all of these states are true, the returned value is true. - * - * @see org.eclipse.ui.ISaveablePart#isDirty() - * - * @return - */ - public boolean isDirty() { - // First, look if the model part (EMF) is dirty, else look at the - // Graphical part (GEF/GMF) - return ((BasicCommandStack)transactionalEditingDomain.getCommandStack()).isSaveNeeded() || registeredIsaveablePart.isDirty(); - } - - /** - * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed() - * - * @return - */ - public boolean isSaveAsAllowed() { - return true; - } - - /** - * @see org.eclipse.ui.ISaveablePart#isSaveOnCloseNeeded() - * - * @return - */ - public boolean isSaveOnCloseNeeded() { - return isDirty(); - } - - /** - * Mark the command stack of all sub-editors. Default implementation do - * nothing. - */ - protected void markSaveLocation() { - ((BasicCommandStack)transactionalEditingDomain.getCommandStack()).saveIsDone(); - fireIsDirtyChanged(); - } - - /** - * Register a nested {@link ISaveablePart} as a listener that will be - * notified each time a {@link #doSave(IProgressMonitor)} or {@link #doSaveAs()} is performed. Also, it will be asked for the - * dirtyState. - * - * @param saveablePart - */ - public void registerIsaveablePart(ISaveablePart saveablePart) { - registeredIsaveablePart.add(saveablePart); - } - - /** - * Remove the specified {@link ISaveablePart} from the list of listeners. - * - * @param saveablePart - */ - public void removeIsaveablePart(ISaveablePart saveablePart) { - registeredIsaveablePart.remove(saveablePart); - } - - /** - * Add a listeners on input changed event. - * - * @param inputChangedListener - */ - public void addInputChangedListener(IEditorInputChangedListener inputChangedListener) { - inputChangedListeners.add(inputChangedListener); - } - - /** - * Remove a listeners on input changed event. - * - * @param inputChangedListener - */ - public void removeInputChangedListener(IEditorInputChangedListener inputChangedListener) { - inputChangedListeners.remove(inputChangedListener); - } - - /** - * A list of {@link ISaveablePart}. - * - * @author dumoulin - * - */ - public class ISaveablePartList extends ArrayList { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Return true if one of the part is dirty, false if all part are not - * dirty. - * - * @return - */ - public boolean isDirty() { - for(ISaveablePart part : this) { - if(part.isDirty()) - return true; - } - - return false; - } - - /** - * Call doSave on each registered {@link ISaveablePart}. - * - * @param monitor - */ - public void doSave(IProgressMonitor monitor) { - for(ISaveablePart part : this) { - - try { - part.doSave(monitor); - } catch (Exception e) { - log.error("Can't save ISaveablePart '" + part + "'", e); - } - } - - } - - /** - * Call doSaveAs on each registered {@link ISaveablePart}. - * - * @param monitor - */ - public void doSaveAs() { - for(ISaveablePart part : this) { - try { - part.doSaveAs(); - } catch (Exception e) { - log.error("Can't save ISaveablePart '" + part + "'", e); - } - } - - } - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/listenerservice/IPapyrusListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/listenerservice/IPapyrusListener.java deleted file mode 100644 index b88c6cdaf58..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/listenerservice/IPapyrusListener.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 CEA LIST. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation - *******************************************************************************/ -package org.eclipse.papyrus.core.listenerservice; - -import org.eclipse.emf.common.notify.Notification; - -/** - * This interface is a listener that will listen directly all events in papyrus: - * uml. It will be very useful for external plug-in. - * - * An implementation may be an adapter. - */ -public interface IPapyrusListener { - - /** - * Notifies that a change to some feature has occurred. - * - * @param notification - * - a description of the change. - **/ - public void notifyChanged(Notification notification); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/listenerservice/ModelListenerManager.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/listenerservice/ModelListenerManager.java deleted file mode 100644 index b8b56781a2f..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/listenerservice/ModelListenerManager.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 CEA LIST. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation - *******************************************************************************/ -package org.eclipse.papyrus.core.listenerservice; - -import java.util.Enumeration; -import java.util.Hashtable; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.util.EContentAdapter; -import org.eclipse.papyrus.core.Activator; -import org.osgi.framework.Bundle; - -/** - * This class is a manager that loads all listeners of the uml model - * - */ - -public class ModelListenerManager extends EContentAdapter { - - // list of of listener - private Hashtable listenerRegistry; - - // extension point ID - private String MODELLISTENERID_EXTENSION_ID = "org.eclipse.papyrus.core.modelListener"; - - private String NAME_ID = "name"; - - private String REALIZATION_ID = "realization"; - - /** - * Constructor - */ - public ModelListenerManager() { - super(); - // init stack - listenerRegistry = new Hashtable(); - initializeListenerList(); - } - - /** - * Load all listeners of the model - */ - private void initializeListenerList() { - // Reading data from plugins - IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(MODELLISTENERID_EXTENSION_ID); - for(int i = 0; i < configElements.length; i++) { - inializeOneRule(configElements[i]); - } - - } - - /** - * Load one listener - * - * @param element - * the extension point - */ - private void inializeOneRule(IConfigurationElement element) { - String listenerName = element.getAttribute(NAME_ID); - try { - IPapyrusListener listener = (IPapyrusListener)createExtension(element, element.getAttribute(REALIZATION_ID)); - listenerRegistry.put(listenerName, listener); - } catch (Exception e) { - Activator.log.error("- " + listenerName + " can not be loaded: " + e.getLocalizedMessage(), e); - } - - } - - /** - * Load an instance of a class - * - * @param element - * the extension point - * @param classAttribute - * the name of the class to load - * @return the loaded Class - * @throws Exception - * if the class is not loaded - */ - private static Object createExtension(final IConfigurationElement element, final String classAttribute) throws Exception { - try { - Bundle extensionBundle = Platform.getBundle(element.getDeclaringExtension().getNamespaceIdentifier()); - Class clazz = extensionBundle.loadClass(classAttribute); - Object obj = clazz.newInstance(); - return obj; - // return element.createExecutableExtension(classAttribute); - } catch (Exception e) { - throw new Exception("unable to create Extension" + e); - } - } - - /** - * {@inheritDoc} - */ - public String toString() { - String out = "ModelListener: \n"; - Enumeration keyenum = listenerRegistry.keys(); - // we will call to string in each class - while(keyenum.hasMoreElements()) { - String aKey = keyenum.nextElement(); - out = out + "- " + aKey + " (" + listenerRegistry.get(aKey).toString() + ")\n"; - } - return out; - } - - /** - * {@inheritDoc} - */ - public void notifyChanged(Notification notification) { - super.notifyChanged(notification); - Enumeration papyrusListenersEnum = listenerRegistry.elements(); - while(papyrusListenersEnum.hasMoreElements()) { - papyrusListenersEnum.nextElement().notifyChanged(notification); - } - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/ModelSetQuery.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/ModelSetQuery.java deleted file mode 100644 index c77e9b33c3f..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/ModelSetQuery.java +++ /dev/null @@ -1,43 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.modelsetquery; - -import static org.eclipse.papyrus.core.modelsetquery.impl.ModelSetQueryAdapter.getExistingTypeCacheAdapter; - -import java.util.Collection; - -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.papyrus.core.modelsetquery.impl.IModelSetQueryAdapter; - -/** - * The Class ModelSetQuery provides service to get objects of specified type - * using cache mechanism - */ -public class ModelSetQuery { - - /** - * Return all the objects of specified type - * - * @param eobjectInModelSet - * , the object from which to search starts - * @param type - * , the searched type - * @return the list of the instance of specified type - */ - public static Collection getObjectsOfType(EObject eobjectInModelSet, EClassifier type) { - IModelSetQueryAdapter adapter = getExistingTypeCacheAdapter(eobjectInModelSet); - return adapter.getReachableObjectsOfType(eobjectInModelSet, type); - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/impl/IModelSetQueryAdapter.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/impl/IModelSetQueryAdapter.java deleted file mode 100644 index ad33da41c46..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/impl/IModelSetQueryAdapter.java +++ /dev/null @@ -1,39 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tristan FAURE tristan.faure@atosorigin.com - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.modelsetquery.impl; - -import java.util.Collection; - -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EObject; - -/** - * interface to manage services to return objects from type - * - * @author tfaure - * - */ -public interface IModelSetQueryAdapter { - - /** - * Return all the objects of type type - * - * @param object - * , the object to start the search - * @param type - * , the type searched - * @return the list of the instance of type - */ - Collection getReachableObjectsOfType(EObject object, EClassifier type); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/impl/ModelSetQueryAdapter.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/impl/ModelSetQueryAdapter.java deleted file mode 100644 index 7402f4f0911..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/impl/ModelSetQueryAdapter.java +++ /dev/null @@ -1,485 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tristan FAURE tristan.faure@atosorigin.com - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.modelsetquery.impl; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.util.URI; -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.InternalEObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; - -/** - * This cache creates a map associating EClasses to all the corresponding - * instances - * - * @author Tristan Faure - */ -public class ModelSetQueryAdapter implements IModelSetQueryAdapter, Adapter.Internal { - - /** - * The cache of elements - */ - private Map> cache = Collections.synchronizedMap(new HashMap>()); - - /** - * This cache adapter is only used if the caller don't use correctly - * TypeCacheAdapter. With the simple cache adapter performance are not good - * but a result is still returned - */ - private static SimpleTypeCacheAdapter simpleCacheAdapter = new SimpleTypeCacheAdapter(); - - protected Set unloadedResources = new HashSet(); - - protected Set alreadyLoadedURIs = new HashSet(); - - protected Map unloadedEObjects = new HashMap(); - - public ModelSetQueryAdapter() { - super(); - } - - /** - * Searches the adapter list of the given Notifier for a TypeCacheAdapter. - * If not found, returns null. - * - * @param notifier - * the notifier to search - * @return the TypeCacheAdapter if found or a simple ITypeCacheAdapter which - * calls default method - */ - public static IModelSetQueryAdapter getExistingTypeCacheAdapter(Notifier notifier) { - if(notifier == null) { - return simpleCacheAdapter; - } - for(Adapter adapter : notifier.eAdapters()) { - if(adapter instanceof ModelSetQueryAdapter) { - return (ModelSetQueryAdapter)adapter; - } - } - if(notifier instanceof EObject) { - EObject object = (EObject)notifier; - IModelSetQueryAdapter typeCacheAdapter = getExistingTypeCacheAdapter(object.eResource()); - if(typeCacheAdapter != null) { - object.eAdapters().add((Adapter)typeCacheAdapter); - return typeCacheAdapter; - } - } else if(notifier instanceof Resource) { - Resource resource = (Resource)notifier; - IModelSetQueryAdapter typeCacheAdapter = getExistingTypeCacheAdapter(resource.getResourceSet()); - if(typeCacheAdapter != null) { - if(typeCacheAdapter instanceof Adapter) { - resource.eAdapters().add((Adapter)typeCacheAdapter); - } - return typeCacheAdapter; - } - } - return simpleCacheAdapter; - } - - protected void addAdapter(Notifier notifier) { - if(notifier instanceof EObject) { - EObject eobject = (EObject)notifier; - addObjectInCache(eobject); - } - List eAdapters = notifier.eAdapters(); - if(!eAdapters.contains(this)) { - eAdapters.add(this); - } - } - - protected void handleContainment(Notification notification) { - Object notifier = notification.getNotifier(); - // synchronize cache on ADD and REMOVE notifications - if(notifier instanceof EObject) { - caseEobject(notification); - } else if(notifier instanceof ResourceSet) { - switch(notification.getEventType()) { - case Notification.ADD: - { - if(notification.getNewValue() instanceof Resource) { - Resource r = (Resource)notification.getNewValue(); - if(!r.eAdapters().contains(this)) { - r.eAdapters().add(this); - } - } - } - case Notification.RESOLVE: - { - if(notification.getNewValue() instanceof Resource) { - Resource r = (Resource)notification.getNewValue(); - for(Iterator i = r.getAllContents(); i.hasNext();) { - EObject next = i.next(); - addObjectInCache(next); - } - } - } - case Notification.REMOVE: - { - // MAYBE TODO - } - } - } - } - - private void caseEobject(Notification notification) { - switch(notification.getEventType()) { - case Notification.ADD: - { - Object newValue = notification.getNewValue(); - if(newValue != null && (newValue instanceof EObject)) { - addObjectInCache((EObject)newValue); - } - break; - } - case Notification.ADD_MANY: - { - for(Object newValue : (Collection)notification.getNewValue()) { - if(newValue != null && (newValue instanceof EObject)) { - addObjectInCache((EObject)newValue); - } - } - break; - } - case Notification.REMOVE: - { - Object oldValue = notification.getOldValue(); - if(oldValue != null && (oldValue instanceof EObject)) { - removeObjectFromCache((EObject)oldValue); - } - break; - } - case Notification.REMOVE_MANY: - { - for(Object oldValue : (Collection)notification.getOldValue()) { - if(oldValue != null && (oldValue instanceof EObject)) { - removeObjectFromCache((EObject)oldValue); - } - } - break; - } - } - } - - private void addObjectInCache(EObject newObj) { - EClass eClass = newObj.eClass(); - putObjectInCache(eClass, newObj); - for(EClass eSuperClass : eClass.getEAllSuperTypes()) { - putObjectInCache(eSuperClass, newObj); - } - } - - private void putObjectInCache(EClassifier eClassifier, EObject newObj) { - Collection listOfClassifiers = cache.get(eClassifier); - if(listOfClassifiers != null) { - listOfClassifiers.add(newObj); - } - } - - private void removeObjectFromCache(EObject newObj) { - EClass eClass = newObj.eClass(); - removeObjectFromCache(eClass, newObj); - for(EClass eSuperClass : eClass.getEAllSuperTypes()) { - removeObjectFromCache(eSuperClass, newObj); - } - } - - private void removeObjectFromCache(EClassifier eClassifier, EObject newObj) { - Collection listOfClassifiers = cache.get(eClassifier); - if(listOfClassifiers != null) { - listOfClassifiers.remove(newObj); - } - } - - /** - * @see org.eclipse.emf.common.notify.Adapter#isAdapterForType(java.lang.Object) - */ - public boolean isAdapterForType(Object type) { - return ModelSetQueryAdapter.class.equals(type); - } - - public Collection getReachableObjectsOfType(EObject object, EClassifier type) { - if(!cache.containsKey(type)) { - cache.put(type, new HashSet(ItemPropertyDescriptor.getReachableObjectsOfType(object, type))); - } - return cache.get(type); - } - - public void dispose() { - cache.clear(); - unloadedEObjects.clear(); - unloadedResources.clear(); - cache = null; - } - - /** - * Handles a notification by calling {@link #selfAdapt selfAdapter}. - */ - public void notifyChanged(Notification notification) { - selfAdapt(notification); - } - - /** - * Handles a notification by calling {@link #handleContainment - * handleContainment} for any containment-based notification. - */ - protected void selfAdapt(Notification notification) { - Object notifier = notification.getNotifier(); - if(notifier instanceof EObject) { - Object feature = notification.getFeature(); - if(feature instanceof EReference) { - EReference reference = (EReference)feature; - if(reference.isContainment()) { - handleContainment(notification); - } - } - } else if(notifier instanceof Resource) { - switch(notification.getFeatureID(Resource.class)) { - case Resource.RESOURCE__CONTENTS: - { - if(!unloadedResources.contains(notifier)) { - switch(notification.getEventType()) { - case Notification.REMOVE: - { - Resource resource = (Resource)notifier; - if(!resource.isLoaded()) { - EObject eObject = (EObject)notification.getOldValue(); - unloadedEObjects.put(eObject, resource); - for(Iterator i = EcoreUtil.getAllProperContents(eObject, false); i.hasNext();) { - EObject next = i.next(); - unloadedEObjects.put(next, resource); - removeObjectFromCache(next); - } - } - break; - } - case Notification.REMOVE_MANY: - { - Resource resource = (Resource)notifier; - if(!resource.isLoaded()) { - @SuppressWarnings("unchecked") - List eObjects = (List)notification.getOldValue(); - for(Iterator i = EcoreUtil.getAllProperContents(eObjects, false); i.hasNext();) { - EObject next = i.next(); - unloadedEObjects.put(next, resource); - removeObjectFromCache(next); - } - } - break; - } - default: - { - handleContainment(notification); - break; - } - } - } - break; - } - case Resource.RESOURCE__IS_LOADED: - { - if(notification.getNewBooleanValue()) { - unloadedResources.remove(notifier); - for(Notifier child : ((Resource)notifier).getContents()) { - addAdapter(child); - } - } else { - unloadedResources.add((Resource)notifier); - for(Iterator i = EcoreUtil.getAllProperContents((Resource)notifier, false); i.hasNext();) { - EObject next = i.next(); - removeObjectFromCache(next); - } - } - break; - } - } - } else if(notifier instanceof ResourceSet) { - if(notification.getFeatureID(ResourceSet.class) == ResourceSet.RESOURCE_SET__RESOURCES) { - handleContainment(notification); - } - } - } - - /** - * Handles installation of the adapter by adding the adapter to each of the - * directly contained objects. - */ - public void setTarget(Notifier target) { - if(target instanceof EObject) { - setTarget((EObject)target); - } else if(target instanceof Resource) { - setTarget((Resource)target); - } else if(target instanceof ResourceSet) { - setTarget((ResourceSet)target); - } - } - - /** - * Handles installation of the adapter on an EObject by adding the adapter - * to each of the directly contained objects. - */ - protected void setTarget(EObject target) { - for(@SuppressWarnings("unchecked") - Iterator i = resolve() ? target.eContents().iterator() : (Iterator)((InternalEList)target.eContents()).basicIterator(); i.hasNext();) { - Notifier notifier = i.next(); - addAdapter(notifier); - } - } - - /** - * Handles installation of the adapter on a Resource by adding the adapter - * to each of the directly contained objects. - */ - protected void setTarget(Resource target) { - if(!target.isLoaded()) { - unloadedResources.add(target); - } - List contents = target.getContents(); - for(int i = 0, size = contents.size(); i < size; ++i) { - Notifier notifier = contents.get(i); - addAdapter(notifier); - } - } - - /** - * Handles installation of the adapter on a ResourceSet by adding the - * adapter to each of the directly contained objects. - */ - protected void setTarget(ResourceSet target) { - List resources = target.getResources(); - for(int i = 0; i < resources.size(); ++i) { - Notifier notifier = resources.get(i); - addAdapter(notifier); - } - } - - /** - * Handles undoing the installation of the adapter by removing the adapter - * to each of the directly contained objects. - */ - public void unsetTarget(Notifier target) { - if(target instanceof EObject) { - unsetTarget((EObject)target); - } else if(target instanceof Resource) { - unsetTarget((Resource)target); - } else if(target instanceof ResourceSet) { - unsetTarget((ResourceSet)target); - } - } - - /** - * Handles undoing the installation of the adapter from an EObject by - * removing the adapter to each of the directly contained objects. - */ - protected void unsetTarget(EObject target) { - for(@SuppressWarnings("unchecked") - Iterator i = resolve() ? (Iterator)(Iterator)target.eContents().iterator() : (Iterator)((InternalEList)target.eContents()).basicIterator(); i.hasNext();) { - // Don't remove the adapter if the object is in a different resource - // and that resource (and hence all its contents) are being cross - // referenced. - // - InternalEObject internalEObject = i.next(); - Resource eDirectResource = internalEObject.eDirectResource(); - if(eDirectResource == null || !eDirectResource.eAdapters().contains(this)) { - removeAdapter(internalEObject); - } - } - } - - /** - * Handles undoing the installation of the adapter from a Resource by - * removing the adapter to each of the directly contained objects. - */ - protected void unsetTarget(Resource target) { - List contents = target.getContents(); - for(int i = 0, size = contents.size(); i < size; ++i) { - Notifier notifier = contents.get(i); - removeAdapter(notifier); - } - } - - /** - * Handles undoing the installation of the adapter from a ResourceSet by - * removing the adapter to each of the directly contained objects. - */ - protected void unsetTarget(ResourceSet target) { - List resources = target.getResources(); - for(int i = 0; i < resources.size(); ++i) { - Notifier notifier = resources.get(i); - removeAdapter(notifier); - } - } - - protected void removeAdapter(Notifier notifier) { - notifier.eAdapters().remove(this); - } - - public Notifier getTarget() { - return null; - } - - protected boolean resolve() { - return true; - } - - /** - * This method provides a way for user to force first entries in the cache. - * The list of element must be a HashSet to optimize the performances - * - * @param type - * @param list - */ - public void fillFirstEntryCache(EClassifier type, HashSet list) { - cache.put(type, list); - } - - public boolean isAlreadyComputed(EClassifier type) { - return cache.containsKey(type); - } - - public static IModelSetQueryAdapter getSimpleTypeCacheAdapter() { - return simpleCacheAdapter; - } - - /** - * This implementation uses ItemPropertyDescriptor class to resolve objects - * from type - * - * @author tfaure - */ - private static class SimpleTypeCacheAdapter implements IModelSetQueryAdapter { - - public Collection getReachableObjectsOfType(EObject object, EClassifier type) { - return ItemPropertyDescriptor.getReachableObjectsOfType(object, type); - } - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/impl/ModelSetQueryInitializer.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/impl/ModelSetQueryInitializer.java deleted file mode 100644 index d231156293f..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/modelsetquery/impl/ModelSetQueryInitializer.java +++ /dev/null @@ -1,66 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - *****************************************************************************/ -package org.eclipse.papyrus.core.modelsetquery.impl; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.util.EList; -import org.eclipse.papyrus.resource.IModelSetSnippet; -import org.eclipse.papyrus.resource.ModelSet; - -/** - * This snippet take in charge the initialization of the TypeCache. The snippet - * is attached to the {@link ModelSet} (in the extensions), and called right - * after ModelsManager is initialized. - * - * @author cedric dumoulin - * - */ -public class ModelSetQueryInitializer implements IModelSetSnippet { - - /** - * The type cache adapter used to reference elements from a type - */ - private ModelSetQueryAdapter modelQueryAdapter; - - /** - * @see org.eclipse.papyrus.resource.IModelSetSnippet#start(org.eclipse.papyrus.resource.ModelSet) - * - * @param modelsManager - */ - public void start(ModelSet modelsManager) { - EList eAdapters = modelsManager.eAdapters(); - boolean found = false; - for(Adapter adapter : eAdapters) { - if(adapter instanceof IModelSetQueryAdapter) { - found = true; - modelQueryAdapter = (ModelSetQueryAdapter)adapter; - } - } - if(!found) { - modelQueryAdapter = new ModelSetQueryAdapter(); - eAdapters.add(modelQueryAdapter); - } - - } - - /** - * @see org.eclipse.papyrus.resource.IModelSetSnippet#dispose(org.eclipse.papyrus.resource.ModelSet) - * - * @param modelsManager - */ - public void dispose(ModelSet modelsManager) { - if(modelQueryAdapter != null) { - modelsManager.eAdapters().remove(modelQueryAdapter); - } - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/ActionBarContributorDescriptor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/ActionBarContributorDescriptor.java deleted file mode 100644 index fdc48612671..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/ActionBarContributorDescriptor.java +++ /dev/null @@ -1,71 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.multidiagram.actionbarcontributor; - -import org.eclipse.papyrus.core.editor.BackboneException; -import org.eclipse.ui.part.EditorActionBarContributor; - -/** - * Descriptor of an ActionBarContributor. This descriptor is usually loaded from - * the Eclipse extension mechanism. - * - * @author Cedric Dumoulin - * @author Patrick Tessier - * - */ -public class ActionBarContributorDescriptor { - - protected Class contextClass; - - protected String contextId; - - /** - * Instance is created when requested. - */ - protected EditorActionBarContributor instance = null; - - /** - * constructor. - * - * @return the context descriptor - * @throws BackboneException - */ - protected EditorActionBarContributor getActionBarContributor() throws BackboneException { - if(instance == null) - instance = createActionBarContributor(); - - return instance; - } - - private EditorActionBarContributor createActionBarContributor() throws BackboneException { - try { - EditorActionBarContributor context = contextClass.newInstance(); - return context; - - } catch (SecurityException e) { - // Lets propagate. This is an implementation problem that should be - // solved by programmer. - throw new RuntimeException(e); - } catch (InstantiationException e) { - // Lets propagate. This is an implementation problem that should be - // solved by programmer. - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - // Lets propagate. This is an implementation problem that should be - // solved by programmer. - throw new RuntimeException(e); - } - } - -} // end class diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/ActionBarContributorExtensionFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/ActionBarContributorExtensionFactory.java deleted file mode 100644 index e9dd491a273..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/ActionBarContributorExtensionFactory.java +++ /dev/null @@ -1,72 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.multidiagram.actionbarcontributor; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.papyrus.core.extension.BadNameExtensionException; -import org.eclipse.papyrus.core.extension.ExtensionUtils; -import org.eclipse.papyrus.core.extension.ExtensionException; -import org.eclipse.ui.part.EditorActionBarContributor; - -/** - * A factory used to create ActionBarContributor object from Eclipse extensions - * points elements. - * - * @author Cedric Dumoulin - * @auhtor Patrick Tessier - */ -public class ActionBarContributorExtensionFactory extends ExtensionUtils { - - /** singleton eINSTANCE of this class */ - public final static ActionBarContributorExtensionFactory eINSTANCE = new ActionBarContributorExtensionFactory(); - - /** constant for the editor diagram **/ - public final static String EDITOR_ACTIONBARCONTRIBUTOR_EXTENSIONPOINT = "" + "actionBarContributor"; - - /** constant for the attribute factoryClass **/ - public final static String CONTEXTCLASS_ATTRIBUTE = "implementingClass"; - - /** constant for the attribute contextId **/ - public final static String ID_ATTRIBUTE = "id"; - - /** - * @return the eINSTANCE - */ - public static ActionBarContributorExtensionFactory getInstance() { - return eINSTANCE; - } - - /** - * Create a ContextDescriptor instance corresponding to the - * ConfigurationElement. - * - * @param element - * an {@link IConfigurationElement} see eclipse extension point - * @return a ContextDescriptor structure that contains information to the - * diagram context - * @throws BadNameExtensionException - **/ - public ActionBarContributorDescriptor createActionBarContributorDescriptor(IConfigurationElement element) throws ExtensionException { - ActionBarContributorDescriptor res; - - checkTagName(element, EDITOR_ACTIONBARCONTRIBUTOR_EXTENSIONPOINT); - - res = new ActionBarContributorDescriptor(); - res.contextClass = (Class)parseClass(element, CONTEXTCLASS_ATTRIBUTE, EDITOR_ACTIONBARCONTRIBUTOR_EXTENSIONPOINT); - res.contextId = element.getAttribute(ID_ATTRIBUTE); - - return res; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/ActionBarContributorRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/ActionBarContributorRegistry.java deleted file mode 100644 index d9248e879fe..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/ActionBarContributorRegistry.java +++ /dev/null @@ -1,172 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.multidiagram.actionbarcontributor; - -import static org.eclipse.papyrus.core.Activator.log; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; -import org.eclipse.papyrus.core.editor.BackboneException; -import org.eclipse.papyrus.core.extension.ExtensionException; -import org.eclipse.papyrus.core.extension.NotFoundException; -import org.eclipse.papyrus.core.services.IService; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.ui.part.EditorActionBarContributor; - -/** - * A factory managing ActionBarContributor creation. The factory is loaded from - * ActionBarContributor declared in Eclipse extension mechanism. - * - * @author dumoulin - * - */ -public class ActionBarContributorRegistry implements IActionBarContributorFactory, IService { - - /** ID of the editor extension (schema filename) */ - public static final String EDITOR_EXTENSION_ID = "papyrusDiagram"; - - /** Namespace where to look for the extension points. */ - protected String extensionPointNamespace; - - /** - * Registered context descriptors. - */ - private Map editorContextDescriptors; - - /** - * Constructor. defaultContext, input and site are explicitly required in - * order be sure that they are initialized. The multiEditor should be - * initialized. In particular, getEditorSite(), getEditorInput() and - * getDefaultContext() should return initialized values. - * - * @param multiEditor - * the multieditor - * @param extensionPointNamespace - */ - public ActionBarContributorRegistry(String extensionPointNamespace) { - - this.extensionPointNamespace = extensionPointNamespace; - initializeEditorContextDescriptors(); - } - - /** - * - * {@inheritDoc} - */ - public EditorActionBarContributor getActionBarContributor(Object key) throws BackboneException { - try { - ActionBarContributorDescriptor desc = editorContextDescriptors.get(key); - return desc.getActionBarContributor(); - } catch (NullPointerException e) { - // no context found. - throw new NotFoundException("No ActionBarContributor registered under id '" + key + "'."); - } - } - - /** - * Get the list of descriptors. - * - * @return - * @throws BackboneException - * If a contributor fail to be loaded. - */ - public List getActionBarContributors() throws BackboneException { - List res = new ArrayList(); - for(ActionBarContributorDescriptor desc : editorContextDescriptors.values()) { - res.add(desc.getActionBarContributor()); - } - return res; - } - - /** - * - * {@inheritDoc} - */ - public void registerActionBarContributor(String contextKey, EditorActionBarContributor contributor) { - ActionBarContributorDescriptor desc = new ActionBarContributorDescriptor(); - desc.contextId = contextKey; - desc.instance = contributor; - desc.contextClass = contributor.getClass(); - - editorContextDescriptors.put(contextKey, desc); - } - - /** - * Read context descriptors from extension points. - */ - private void initializeEditorContextDescriptors() { - - editorContextDescriptors = new HashMap(); - // Reading data from plugins - IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointNamespace, EDITOR_EXTENSION_ID); - - ActionBarContributorExtensionFactory extensionReader = new ActionBarContributorExtensionFactory(); - - for(IConfigurationElement ele : configElements) { - ActionBarContributorDescriptor desc; - try { - if(ActionBarContributorExtensionFactory.EDITOR_ACTIONBARCONTRIBUTOR_EXTENSIONPOINT.equals(ele.getName())) { - desc = extensionReader.createActionBarContributorDescriptor(ele); - // Check double - if(editorContextDescriptors.get(desc.contextId) != null) { - // Already exists. Check if it is the same - ActionBarContributorDescriptor existingDesc = editorContextDescriptors.get(desc.contextId); - if(desc.equals(existingDesc)) { - log.warn("More than one ActionBarContributor is registered under the name '" + desc.contextId + "', with different parameters. Extra declaration are discarded."); - } - } else { - editorContextDescriptors.put(desc.contextId, desc); - } - } - } catch (ExtensionException e) { - log.error(e.getMessage(), e); - } - } - - if(log.isDebugEnabled()) { - log.debug(this.getClass().getSimpleName() + " : contributors desc loaded [" + editorContextDescriptors.size() + "]"); - } - } - - /** - * Initialize the service. Do nothing here. - * - * @see org.eclipse.papyrus.core.services.IService#init(org.eclipse.papyrus.core.services.ServicesRegistry) - * - * @param servicesRegistry - */ - public void init(ServicesRegistry servicesRegistry) { - - } - - /** - * Do nothing in this implementation. {@inheritDoc} - * - * @see org.eclipse.papyrus.core.services.IService#startService() - */ - public void startService() { - } - - /** - * Do nothing in this implementation. - */ - public void disposeService() { - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java deleted file mode 100644 index d01e583265d..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java +++ /dev/null @@ -1,117 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.multidiagram.actionbarcontributor; - -import java.util.List; - -import org.eclipse.papyrus.core.Activator; -import org.eclipse.papyrus.core.editor.BackboneException; -import org.eclipse.papyrus.sasheditor.editor.actionbarcontributor.ComposedActionBarContributor; -import org.eclipse.papyrus.sasheditor.editor.actionbarcontributor.IMultiPageEditorActionBarContributor; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.part.EditorActionBarContributor; - -/** - * - * An ActionBarContributor composed of ActionBarContributor from multi editor. - * This ActionBarContributor switch to the contributor dedicated to the active - * editor in a MultiPageEditor environement. - * - * @author dumoulin - * - */ -public class CoreComposedActionBarContributor extends ComposedActionBarContributor implements IMultiPageEditorActionBarContributor { - - /** - * The registry. Used to initialize the registered actionBars. - */ - protected ActionBarContributorRegistry actionBarContributorRegistry; - - protected List contributors; - - /** - * Constructor. - * - * @throws BackboneException - */ - public CoreComposedActionBarContributor() throws BackboneException { - // Init the contributors - loadContributors(); - } - - /** - * - * @throws BackboneException - */ - private void loadContributors() throws BackboneException { - actionBarContributorRegistry = new ActionBarContributorRegistry(Activator.PLUGIN_ID); - - contributors = actionBarContributorRegistry.getActionBarContributors(); - } - - /** - * @return the actionBarContributorRegistry - */ - public ActionBarContributorRegistry getActionBarContributorRegistry() { - return actionBarContributorRegistry; - } - - /** - * Dispose all nested ActionBarContributors. - */ - @Override - public void dispose() { - // Dispose nested contributors. - for(EditorActionBarContributor contributor : contributors) { - contributor.dispose(); - } - super.dispose(); - } - - /** - * Call the same method on each registered nested ActionBarContributors. - */ - @Override - public void init(IActionBars bars, IWorkbenchPage page) { - super.init(bars, page); - buildActions(); - - // init nested contributors. - for(EditorActionBarContributor contributor : contributors) { - contributor.init(bars, page); - } - - } - - /** - * Load default actions (undo/redo/delete) - * - * @see org.eclipse.gef.ui.actions.ActionBarContributor#buildActions() - */ - protected void buildActions() { - // getActionBars().getToolBarManager().add(new UndoRetargetAction()); - // getActionBars().getToolBarManager().add(new RedoRetargetAction()); - } - - @Override - public void setActiveEditor(IEditorPart part) { - super.setActiveEditor(part); - for(EditorActionBarContributor contributor : contributors) { - contributor.setActiveEditor(part); - } - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/IActionBarContributorFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/IActionBarContributorFactory.java deleted file mode 100644 index 128224f75fc..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/IActionBarContributorFactory.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.multidiagram.actionbarcontributor; - -import org.eclipse.papyrus.core.editor.BackboneException; -import org.eclipse.ui.part.EditorActionBarContributor; - -/** - * Interface used to get an ActionBarContributor from its ID. - * - * @author dumoulin - * - */ -public interface IActionBarContributorFactory { - - /** - * Get an ActionBarContributor by its key. If an ActionBarContributor - * already exists for this key, return it. - * - * @param key - * @return - */ - public EditorActionBarContributor getActionBarContributor(Object key) throws BackboneException; -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/BadStateException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/BadStateException.java deleted file mode 100644 index 6ff06b1724e..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/BadStateException.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services; - -/** - * @author cedric dumoulin - * - */ -public class BadStateException extends ServiceException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Constructor. - * - */ - public BadStateException(ServiceState expectedState, ServiceState state, ServiceDescriptor descriptor) { - super("Bad state for service '" + descriptor.getKey() + "'. Expected '" + expectedState + "' found '" + state + "'."); - } - - /** - * - * Constructor. - * - * @param text - * @param state - * @param serviceDescriptor - */ - public BadStateException(String text, ServiceState state, ServiceDescriptor descriptor) { - super(text + " (Service= '" + descriptor.getKey() + ", state= " + state + ")"); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ComposedService.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ComposedService.java deleted file mode 100644 index 9ee20a77f22..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ComposedService.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services; - -import java.util.ArrayList; -import java.util.List; - -/** - * Base class to create a Service composed of other services called Parts. - * ServiceParts register themselves to the ComposedService. The ComposedService - * maintain a list of its part. - * - * @author cedric dumoulin - * - * @param T - * The type of sub-services that can register to this - * ComposedService. - */ -public abstract class ComposedService implements IService { - - /** - * The list of serviceParts composing this Service. - */ - protected List serviceParts = new ArrayList(); - - /** - * Constructor. Constructor. - * - */ - public ComposedService() { - - } - - /** - * Add the provided servicePart. - * - * @param servicePart - */ - public void addServicePart(T servicePart) { - serviceParts.add(servicePart); - } - - /** - * Remove the provided servicePart. - * - * @param servicePart - */ - public void removeServicePart(T servicePart) { - serviceParts.remove(servicePart); - } - - /** - * Do nothing here. - * - * @see org.eclipse.papyrus.core.services.IService#init(org.eclipse.papyrus.core.services.ServicesRegistry) - * - * @param servicesRegistry - * @throws ServiceException - */ - public void init(ServicesRegistry servicesRegistry) throws ServiceException { - } - - /** - * Do nothing here. - * - * @see org.eclipse.papyrus.core.services.IService#startService() - * - * @throws ServiceException - */ - public void startService() throws ServiceException { - } - - /** - * Do nothing here. - * - * @see org.eclipse.papyrus.core.services.IService#disposeService() - * - * @throws ServiceException - */ - public void disposeService() throws ServiceException { - } - - /** - * Get a list of registered sub service parts. - * - * @return List of registered services. - */ - public List getRegisteredServices() { - return serviceParts; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ComposedServicePart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ComposedServicePart.java deleted file mode 100644 index 03ac1ec5a81..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ComposedServicePart.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services; - -/** - * A service that register itself to its associated {@link ComposedService}. - * - * @param T - * The main ComposedService - * - * @author cedric dumoulin - * @param T - * The type of the ComposedService to which this part will be - * registered. - * - */ -@SuppressWarnings("rawtypes") -public abstract class ComposedServicePart implements IService { - - /** - * - */ - protected ServicesRegistry servicesRegistry; - - /** - * Class of the parent ComposedService - */ - private Class composedServiceKey; - - /** - * ComposedService that will own this part. - */ - T parentService; - - public ComposedServicePart(Class composedServiceKey) { - this.composedServiceKey = composedServiceKey; - } - - /** - * Initialize the service. Attach itself to the ComposedService - * - * @see org.eclipse.papyrus.core.services.IService#init(org.eclipse.papyrus.core.services.ServicesRegistry) - * - * @param servicesRegistry - * @throws ServiceException - */ - @SuppressWarnings("unchecked") - public void init(ServicesRegistry servicesRegistry) throws ServiceException { - this.servicesRegistry = servicesRegistry; - parentService = servicesRegistry.getService(composedServiceKey); - parentService.addServicePart(this); - } - - /** - * Start the service. - * - * @see org.eclipse.papyrus.core.services.IService#startService() - * - */ - public void startService() throws ServiceException { - - } - - /** - * - * @see org.eclipse.papyrus.core.services.IService#disposeService() - * - */ - @SuppressWarnings("unchecked") - public void disposeService() { - parentService.removeServicePart(this); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ExtensionServicesRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ExtensionServicesRegistry.java deleted file mode 100644 index c318d9f0609..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ExtensionServicesRegistry.java +++ /dev/null @@ -1,196 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; -import org.eclipse.papyrus.core.services.ServiceDescriptor.ServiceTypeKind; - -/** - * ServiceRegistry reading and registering services declared in Eclipse - * Extensions. - * - * @author dumoulin - * - */ -public class ExtensionServicesRegistry extends ServicesRegistry { - - /** ID of the extension (schema filename) */ - public static final String SERVICE_EXTENSION_ID = "service"; - - /** Namespace where to look for the extension points. */ - protected String extensionPointNamespace; - - /** Extension point name inside the extension description **/ - public final static String SERVICE_EXTENSIONPOINT = "service"; - - /** ServiceFactory Extension point **/ - public final static String SERVICE_FACTORY_ELEMENT_NAME = "serviceFactory"; - - /** constant for the attribute factoryClass **/ - public final static String CONTEXTCLASS_ATTRIBUTE = "contextClass"; - - /** extension point propertyname */ - private final static String STARTKIND_PROPERTY = "startKind"; - - /** name of the dependsOn element */ - private static final String DEPENDSON_ELEMENT_NAME = "dependsOn"; - - /** name of the key attribute inside the DEPENDSON element */ - private static final String DEPENDSON_KEY_ATTRIBUTE_NAME = "serviceKeyRef"; - - /** - * Constructor. - * - * @throws Exception - */ - public ExtensionServicesRegistry(String extensionPointNamespace) throws ServiceException { - this.extensionPointNamespace = extensionPointNamespace; - registerDeclaredExtensions(); - } - - /** - * Register the services declared in Eclipse Extension. - * - * @throws Exception - */ - private void registerDeclaredExtensions() throws ServiceException { - - List descriptors = new ArrayList(); - List exceptions = null; - - // Reading data from plugins - IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointNamespace, SERVICE_EXTENSION_ID); - - for(IConfigurationElement ele : configElements) { - ServiceDescriptor desc; - if(SERVICE_EXTENSIONPOINT.equals(ele.getName())) { - // Read a Service - try { - desc = readServiceDescriptor(ele); - desc.setServiceTypeKind(ServiceTypeKind.service); - // Add created desc - descriptors.add(desc); - } catch (ServiceException e) { - // record exceptions - if(exceptions == null) - exceptions = new ArrayList(); - exceptions.add(e); - } - } else if(SERVICE_FACTORY_ELEMENT_NAME.equals(ele.getName())) { - // Read a Service Factory - try { - desc = readServiceDescriptor(ele); - desc.setServiceTypeKind(ServiceTypeKind.serviceFactory); - // Add created desc - descriptors.add(desc); - } catch (ServiceException e) { - // record exceptions - if(exceptions == null) - exceptions = new ArrayList(); - exceptions.add(e); - } - } - } - - // Add found descriptors - for(ServiceDescriptor desc : descriptors) { - add(desc); - } - - // Throw exceptions if pb encountered - if(exceptions != null) { - if(exceptions.size() == 1) - throw exceptions.get(0); - else - throw new ServiceException("Somme services are not started (first is shown)", exceptions.get(0)); - - } - - } - - /** - * Read descriptor values from provided element. - * - * @param ele - * @return - * @throws ServiceException - */ - private ServiceDescriptor readServiceDescriptor(IConfigurationElement ele) throws ServiceException { - - // classname - String serviceClassname = ele.getAttribute("classname"); - - // key - String key = ele.getAttribute("id"); - if(key == null || key.length() == 0) { - key = serviceClassname; - } - - // Service start kind - ServiceStartKind serviceStartKind = ServiceStartKind.LAZY; - String serviceStartKindStr = ele.getAttribute(STARTKIND_PROPERTY); - if(serviceStartKindStr != null && serviceStartKindStr.length() > 0) { - try { - serviceStartKind = ServiceStartKind.valueOf(serviceStartKindStr.toUpperCase()); - } catch (IllegalArgumentException e) { - // Can't convert property - throw new ServiceException("Can't convert property " + STARTKIND_PROPERTY + "(plugin=" + ele.getContributor() + "declaringExtension=" + ele.getDeclaringExtension() + ")", e); - } - } - - // priority - int priority = 1; - String priorityStr = ele.getAttribute("priority"); - if(priorityStr != null && priorityStr.length() > 0) { - try { - priority = Integer.parseInt(priorityStr); - } catch (NumberFormatException e) { - } - } - - // Read dependsOn keys - List keys = getDependsOn(ele); - - // Create descriptor - ServiceDescriptor desc = new ServiceDescriptor(key, serviceClassname, serviceStartKind, priority); - desc.setClassBundleID(ele.getContributor().getName()); - - if(keys.size() > 0) - desc.setRequiredServiceKeys(keys); - - return desc; - } - - /** - * Add dependsOn keys. - * - * @param parentElement - * @param model - */ - private List getDependsOn(IConfigurationElement parentElement) { - - List keys = new ArrayList(); - - // Get children - IConfigurationElement[] configElements = parentElement.getChildren(DEPENDSON_ELEMENT_NAME); - - for(IConfigurationElement ele : configElements) { - String key = ele.getAttribute(DEPENDSON_KEY_ATTRIBUTE_NAME); - if(key != null && key.length() > 0) { - keys.add(key.trim()); - } - } - - if(keys.size() == 0) - return Collections.emptyList(); - - return keys; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/IService.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/IService.java deleted file mode 100644 index 0961af556cf..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/IService.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services; - -/** - * An Service that can be registered in the {@link ServicesRegistry}. A service - * is a singleton available throw the registry. A service can be shared across - * editors.
- * The life cycle is as follow: - *
    - *
  • service creation
  • - *
  • {@link #init(ServicesRegistry)} - Other service can be retrieved from the registry, but are not started yet.
  • - *
  • {@link #startService()} - service is started.
  • - *
  • Service can be used
  • - *
  • {@link #disposeService()} - service is disposed and should not be used anymore.
  • - *
- * - * @author cedric dumoulin - * - */ -public interface IService { - - /** - * Init the service and set its associated Registry. The registry can be - * used to retrieve other services. - * - * @param servicesRegistry - */ - public void init(ServicesRegistry servicesRegistry) throws ServiceException; - - /** - * Start the service. This method is called when the service is started. - */ - public void startService() throws ServiceException; - - /** - * Dispose the service. - */ - public void disposeService() throws ServiceException; - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/IServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/IServiceFactory.java deleted file mode 100644 index df6aeb7211e..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/IServiceFactory.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services; - -/** - * A factory creating a Service that can be registered in the {@link ServicesRegistry}. - * - * A service is a singleton available throw the registry. A service can be - * shared across editors. The service lifecycle events (init, start and dispose) - * are sent to the factory. The factory is responsible to forward them to the - * real service. - * - * @author dumoulin - * - */ -public interface IServiceFactory extends IService { - - /** - * Create the instance of the service that will be returned by {@link ServicesRegistry#getService(Class)}. - * - * @return The instance of the service. - * @throws ServiceException - * If an error occurs during the operation. - */ - public Object createServiceInstance() throws ServiceException; - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceDescriptor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceDescriptor.java deleted file mode 100644 index 8073b61123d..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceDescriptor.java +++ /dev/null @@ -1,301 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services; - -import java.util.Collections; -import java.util.List; - -/** - * Descriptor of a service. This descriptor describe a service. - * - * @author cedirc dumoulin - * - */ -public class ServiceDescriptor { - - /** - * Possible kind for service types. - * - */ - public enum ServiceTypeKind { - service, serviceFactory, pojo - }; - - /** Classname of the service. USed to start the service */ - private String serviceClassname; - - /** Kind of start for this service */ - private ServiceStartKind serviceStartKind; - - /** Kind of service */ - private ServiceTypeKind serviceTypeKind = ServiceTypeKind.service; - - /** - * Service priority. If two service are registered under the same key, only - * the one with the higher priority is started. - */ - private int priority; - - /** - * Key used to register the service. - */ - private String key; - - /** - * Id of the bundle owning the .class that is referenced by - * serviceClassname. Requested when instanciating the class. - */ - private String classBundleID; - - /** - * If set to true, the service is anonymous : it is not registered and can't - * be retrieved with getService(). - */ - private boolean isAnonymous = false; - - /** - * List of keys of Services required by this service. - */ - private List requiredServices = Collections.emptyList(); - - /** - * Empty list. - */ - private static List EMPTY_LIST_STRING = Collections.emptyList(); - - /** - * Constructor. - * - * @param key - * @param serviceClassname - * @param serviceStartKind - * @param priority - * @param requiredServices - */ - public ServiceDescriptor(String key, String serviceClassname, ServiceStartKind serviceStartKind, int priority, List requiredServices) { - this.key = key; - this.serviceClassname = serviceClassname; - this.serviceStartKind = serviceStartKind; - this.priority = priority; - this.requiredServices = requiredServices; - } - - /** - * Constructor. - * - * @param key - * A class used as key. The classname is used as key. - * @param serviceClassname - * @param serviceStartKind - * @param priority - * @param requiredServices - */ - public ServiceDescriptor(Class key, String serviceClassname, ServiceStartKind serviceStartKind, int priority, List requiredServices) { - this(key.getName(), serviceClassname, serviceStartKind, priority, requiredServices); - } - - /** - * Constructor. - * - * @param key - * A class used as key. The classname is used as key. - * @param serviceClassname - * @param serviceStartKind - * @param priority - * @param isAnonymous - * @param requiredServices - */ - public ServiceDescriptor(String key, String serviceClassname, ServiceStartKind serviceStartKind, int priority, boolean isAnonymous, List requiredServices) { - this.key = key; - this.serviceClassname = serviceClassname; - this.serviceStartKind = serviceStartKind; - this.priority = priority; - this.isAnonymous = isAnonymous; - this.requiredServices = requiredServices; - } - - /** - * Constructor. - * - * @param key - * A class used as key. The classname is used as key. - * @param serviceClassname - * @param serviceStartKind - * @param priority - * @param isAnonymous - * @param requiredServices - */ - public ServiceDescriptor(Class key, String serviceClassname, ServiceStartKind serviceStartKind, int priority, boolean isAnonymous, List requiredServices) { - this(key.getName(), serviceClassname, serviceStartKind, priority, isAnonymous, requiredServices); - } - - /** - * Constructor. - * - * @param key - * @param serviceClassname - * @param serviceStartKind - * @param priority - */ - public ServiceDescriptor(String key, String serviceClassname, ServiceStartKind serviceStartKind, int priority) { - this(key, serviceClassname, serviceStartKind, priority, EMPTY_LIST_STRING); - } - - /** - * Constructor. - * - * @param key - * A class used as key. The classname is used as key. - * @param serviceClassname - * @param serviceStartKind - * @param priority - */ - public ServiceDescriptor(Class key, String serviceClassname, ServiceStartKind serviceStartKind, int priority) { - this(key.getName(), serviceClassname, serviceStartKind, priority, EMPTY_LIST_STRING); - } - - /** - * Constructor. - * - * @param serviceClassname - * @param serviceStartKind - * @param priority - * @param requiredServices - */ - public ServiceDescriptor(String serviceClassname, ServiceStartKind serviceStartKind, int priority, List requiredServices) { - this(serviceClassname, serviceClassname, serviceStartKind, priority, requiredServices); - } - - /** - * Constructor. - * - * @param serviceClassname - * @param serviceStartKind - * @param priority - */ - public ServiceDescriptor(String serviceClassname, ServiceStartKind serviceStartKind, int priority, boolean isAnonymous) { - this(serviceClassname, serviceClassname, serviceStartKind, priority, isAnonymous, EMPTY_LIST_STRING); - } - - /** - * Constructor. - * - * @param serviceClassname - * @param serviceStartKind - * @param priority - */ - public ServiceDescriptor(String serviceClassname, ServiceStartKind serviceStartKind, int priority) { - this(serviceClassname, serviceClassname, serviceStartKind, priority, EMPTY_LIST_STRING); - } - - /** - * @return the serviceStartKind - */ - public ServiceStartKind getServiceStartKind() { - return serviceStartKind; - } - - /** - * Return true if StartKind is 'always'. - * - * @return - */ - public boolean isStartAtStartup() { - return serviceStartKind == ServiceStartKind.STARTUP; - } - - /** - * @return the priority - */ - public int getPriority() { - return priority; - } - - /** - * @return the key - */ - public String getKey() { - return key; - } - - /** - * @return the serviceClassname - */ - public String getServiceClassname() { - return serviceClassname; - } - - /** - * @return the classBundleID - */ - public String getClassBundleID() { - return classBundleID; - } - - /** - * @param classBundleId - * the classBundleID to set - */ - public void setClassBundleID(String classBundleId) { - classBundleID = classBundleId; - } - - /** - * Get the keys of all the required services - * - * @return the requiredServices - */ - public List getRequiredServiceKeys() { - return requiredServices; - } - - /** - * @param requiredServices - * the requiredServices to set - */ - public void setRequiredServiceKeys(List requiredServices) { - this.requiredServices = requiredServices; - } - - /** - * @see java.lang.Object#toString() - * @return - * - */ - @Override - public String toString() { - return "ServiceDescriptor [key=" + key + ", serviceClassname=" + serviceClassname + ", serviceStartKind=" + serviceStartKind + ", priority=" + priority + "]"; - } - - /** - * @return the isAnonymous - */ - public boolean isAnonymous() { - return isAnonymous; - } - - /** - * @param isAnonymous - * the isAnonymous to set - */ - public void setAnonymous(boolean isAnonymous) { - this.isAnonymous = isAnonymous; - } - - /** - * @return the serviceTypeKind - */ - public ServiceTypeKind getServiceTypeKind() { - return serviceTypeKind; - } - - /** - * @param serviceTypeKind - * the serviceTypeKind to set - */ - public void setServiceTypeKind(ServiceTypeKind serviceTypeKind) { - this.serviceTypeKind = serviceTypeKind; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceException.java deleted file mode 100644 index 458d8d379a1..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceException.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services; - -/** - * Root Exception of Services Exception. - * - * @author dumoulin - * - */ -public class ServiceException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Constructor. - */ - public ServiceException() { - // TODO Auto-generated constructor stub - } - - /** - * Constructor. - * - * @param message - */ - public ServiceException(String message) { - super(message); - // TODO Auto-generated constructor stub - } - - /** - * Constructor. - * - * @param cause - */ - public ServiceException(Throwable cause) { - super(cause); - // TODO Auto-generated constructor stub - } - - /** - * Constructor. - * - * @param message - * @param cause - */ - public ServiceException(String message, Throwable cause) { - super(message, cause); - // TODO Auto-generated constructor stub - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceMultiException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceMultiException.java deleted file mode 100644 index cf51be1a527..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceMultiException.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services; - -import java.util.ArrayList; -import java.util.List; - -/** - * An exception encapsulating multiple exceptions. This exception is thrown when - * an operation performed on several Services fails on one or more of these - * Service. The exception contains all the exceptions encoutered while - * opertating on Services. - * - * @author cedric dumoulin - * - */ -public class ServiceMultiException extends ServiceException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * List of encountered exceptions. - */ - List encounteredExceptions = new ArrayList(); - - /** - * List of identifiers corresponding to exceptions. - */ - List serviceIdentifiers = new ArrayList(); - - /** - * @return the encounteredExceptions - */ - public List getExceptions() { - return encounteredExceptions; - } - - /** - * Constructor. - * - */ - public ServiceMultiException() { - super("Multiple exceptions"); - } - - /** - * Constructor. - * - * @param message - */ - public ServiceMultiException(String message) { - super(message); - } - - /** - * Return the first exception. - * - * @see java.lang.Throwable#getCause() - * - * @return - */ - @Override - public Throwable getCause() { - return (encounteredExceptions.size() > 0 ? encounteredExceptions.get(0) : null); - } - - /** - * Return the message if any, or the message of the first exception. - * - * @see java.lang.Throwable#getMessage() - * - * @return - */ - @Override - public String getMessage() { - - StringBuffer buffer = new StringBuffer(); - - String message = super.getMessage(); - if(message != null) - buffer.append(message).append('\n'); - - buffer.append("----- exceptions : ----------\n"); - for(int i = 0; i < encounteredExceptions.size(); i++) { - Throwable exception = encounteredExceptions.get(i); - Object identifierMsg = serviceIdentifiers.get(i); - - if(identifierMsg != null) - buffer.append(identifierMsg.toString()).append(" : "); - String msg = exception.getMessage(); - if(msg != null) - buffer.append(msg).append('\n'); - } - buffer.append("----------------------------- \n"); - - return buffer.toString(); - // // Check for first exception - // if( encounteredExceptions.size() > 1) - // return encounteredExceptions.get(0).getMessage(); - // - // // default - // return null; - } - - /** - * Add an exception to the list of exceptions. - * - * @param exception - */ - public void addException(Throwable exception) { - addException("unknown", exception); - } - - /** - * Add an exception to the list of exceptions. Also record the corresponding - * model identifier if any. - * - * @param exception - */ - public void addException(Object identifier, Throwable exception) { - encounteredExceptions.add(exception); - serviceIdentifiers.add(identifier); - } - - /** - * Merge both exceptions - * - * @param e - */ - public void addAll(ServiceMultiException e) { - encounteredExceptions.addAll(e.encounteredExceptions); - serviceIdentifiers.addAll(serviceIdentifiers); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceNotFoundException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceNotFoundException.java deleted file mode 100644 index 2981042819a..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceNotFoundException.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.eclipse.papyrus.core.services; - -/** - * Service is not found. - * - * @author dumoulin - * - */ -public class ServiceNotFoundException extends ServiceException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Constructor. - */ - public ServiceNotFoundException() { - super(); - } - - /** - * Constructor. - * - * @param message - * @param cause - */ - public ServiceNotFoundException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Constructor. - * - * @param message - */ - public ServiceNotFoundException(String message) { - super(message); - } - - /** - * Constructor. - * - * @param cause - */ - public ServiceNotFoundException(Throwable cause) { - super(cause); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceStartKind.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceStartKind.java deleted file mode 100644 index 316e3d6ebe0..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceStartKind.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services; - -/** - * Kind of possible start method for a service. LAZY - The service start when it - * is requested for the first time. STARTUP - The service start as soon as the - * registry is started, or when the service is added is the registry is already - * started. - * - * @author dumoulin - * - */ -public enum ServiceStartKind { - - LAZY, STARTUP; -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceState.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceState.java deleted file mode 100644 index ef562806824..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServiceState.java +++ /dev/null @@ -1,14 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services; - -/** - * The different states that a service can have. - * - * @author dumoulin - * - */ -public enum ServiceState { - registered, created, initialized, starting, started, disposed, error -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServicesRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServicesRegistry.java deleted file mode 100644 index 7298820738b..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/ServicesRegistry.java +++ /dev/null @@ -1,1042 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.eclipse.papyrus.core.Activator; -import org.eclipse.papyrus.core.services.ServiceDescriptor.ServiceTypeKind; -import org.eclipse.papyrus.core.services.internal.LazyStartupEntry; -import org.eclipse.papyrus.core.services.internal.PojoServiceEntry; -import org.eclipse.papyrus.core.services.internal.ServiceEntry; -import org.eclipse.papyrus.core.services.internal.ServiceFactoryEntry; -import org.eclipse.papyrus.core.services.internal.ServiceStartupEntry; -import org.eclipse.papyrus.core.services.internal.ServiceTypeEntry; -import org.eclipse.papyrus.core.services.internal.StartStartupEntry; - -/** - * A registry of services. This registry allows to get a service by its - * identifier. The identifier is generally the classname of the service. - * Services can be added using the Eclipse extension mechanism (if you use {@link ExtensionServicesRegistry}).
- * A Service is a class providing operations. The ServiceRegistry is used to - * share objects (i.e. services) between nested editors and also the core main - * editor. - * - *
- * In this implementation, services should be added to the registry before the - * call to createServices(). If a service is added after the call, it will not - * be started (except if it is a lazy service).
- * A typical usage is: - * - *
- * 
- *   ServicesRegistry serviceRegistry = new ServiceRegistry();
- *   // Add your services
- *   serviceRegistry.add( ...);
- *   serviceRegistry.add( ...);
- *   
- *   // start the services
- *   serviceRegistry.startRegistry();
- *   
- *   // Retrieve a service
- *   myService = serviceRegistry.getService( serviceKey );
- * 
- * 
- * - * It is possible to register new services after the serviceRegistry has been - * started. In this case, you need to start them explicitly if they are of type - * ServiceStartKind.STARTUP. - * - *
- * 
- *   // Add your new services
- *   serviceRegistry.add( key1, ...);
- *   serviceRegistry.add( key2, ...);
- *   
- *   // start the new services
- *   serviceRegistry.startRegistry(key1, key2);
- * 
- * 
- * - *
    - *
  • - *
  • - *
- * - * @author cedric dumoulin - * - * - */ -public class ServicesRegistry { - - /** Log object */ - protected Logger log = Logger.getLogger(getClass().getName()); - - /** - * Map of existing services. - */ - // private Map services; - - /** - * A Map of services added to the register (thow the addXxx() methods), but - * not yet registered. They will be registered after a call to startXxx(). - */ - private Map addedServices = new HashMap(); - - /** - * Map of services registered with a name. - */ - private Map namedServices = new HashMap(); - - /** - * Map of services registered without a name (anonymous). Such services - * can't be retrieved. - */ - private List anonymousServices = new ArrayList(); - - /** - * Constructor. - */ - public ServicesRegistry() { - } - - /** - * Add a service by its ServiceDescriptor. - * - * @param serviceDescriptor - * Descriptor describing the service. - * @throws ServiceException - * If an error occurs while initializing service. - */ - public void add(ServiceDescriptor serviceDescriptor) { - // Check if the service already exist. - ServiceStartupEntry service = addedServices.get(serviceDescriptor.getKey()); - if(service != null) { - if(service.getDescriptor().getPriority() > serviceDescriptor.getPriority()) - return; - else if(service.getDescriptor().getPriority() == serviceDescriptor.getPriority()) { - log.warning("Two services with same priority (" + serviceDescriptor.getPriority() + ") are declared under key '" + service.getDescriptor().getKey() + "'. Keep the first encountered only. (bundles: " + service.getDescriptor().getClassBundleID() + ", " + serviceDescriptor.getClassBundleID() + ")"); - } - } - - // Compute the service type entry - ServiceTypeEntry serviceTypeEntry; - ServiceTypeKind typeKind = serviceDescriptor.getServiceTypeKind(); - if(typeKind == ServiceTypeKind.service) - serviceTypeEntry = new ServiceEntry(serviceDescriptor); - else if(typeKind == ServiceTypeKind.serviceFactory) - serviceTypeEntry = new ServiceFactoryEntry(serviceDescriptor); - else - serviceTypeEntry = new PojoServiceEntry(serviceDescriptor); - - // Create the entry - ServiceStartupEntry serviceEntry; - if(serviceDescriptor.isStartAtStartup()) { - serviceEntry = new StartStartupEntry(serviceTypeEntry); - } else { - serviceEntry = new LazyStartupEntry(serviceTypeEntry, this); - } - // Add the entry - addedServices.put(serviceDescriptor.getKey(), serviceEntry); - } - - /** - * Add a service. The descriptor will be created. - * - * @param key - * Service key - * @param priority - * service priority - * @param serviceInstance - * The instance of the service - */ - public void add(String key, int priority, IService serviceInstance) { - add(key, priority, serviceInstance, ServiceStartKind.STARTUP); - } - - /** - * Add a service. The descriptor will be created. - * - * @param key - * Service key - * @param priority - * service priority - * @param serviceInstance - * The instance of the service - */ - public void add(Class key, int priority, IService serviceInstance) { - add(key.getName(), priority, serviceInstance, ServiceStartKind.STARTUP); - } - - /** - * Add a service. The descriptor will be created. - * - * @param key - * Service key - * @param priority - * service priority - * @param serviceInstance - * The instance of the service - */ - public void add(String key, int priority, IService serviceInstance, ServiceStartKind startKind) { - // Check if the service already exist. - ServiceStartupEntry service = addedServices.get(key); - if(service != null) { - if(service.getDescriptor().getPriority() > priority) - return; - else if(service.getDescriptor().getPriority() == priority) - log.warning("Two services with same priority (" + priority + ") are declared under key '" + service.getDescriptor().getKey() + "'. Keep the first encountered only."); - } - - // Create descriptor and add service. - ServiceDescriptor descriptor = new ServiceDescriptor(key, serviceInstance.getClass().getName(), startKind, priority); - - if(startKind == ServiceStartKind.STARTUP) - addedServices.put(key, new StartStartupEntry(new ServiceEntry(descriptor, serviceInstance))); - else - addedServices.put(key, new LazyStartupEntry(new ServiceEntry(descriptor, serviceInstance), this)); - } - - /** - * Add a service. The descriptor will be created. - * - * @param key - * Service key Class used as key. The classname is used as key. - * @param priority - * service priority - * @param serviceInstance - * The instance of the service - */ - public void add(Class key, int priority, IService serviceInstance, ServiceStartKind startKind) { - - add(key.getName(), priority, serviceInstance, startKind); - } - - /** - * Add an already instanciated pojo (Plain Old Java Object) as Service. The - * descriptor will be created. No life cycle methods are called on the - * service. - * - * @param key - * Service key - * @param priority - * service priority - * @param serviceInstance - * The instance of the service - */ - public void add(Class key, int priority, Object serviceInstance) { - add(key, priority, serviceInstance, ServiceStartKind.STARTUP); - } - - /** - * Add an already instanciated pojo (Plain Old Java Object) as Service. The - * descriptor will be created. No life cycle methods are called on the - * service. - * - * @param key - * Service key - * @param priority - * service priority - * @param serviceInstance - * The instance of the service - * @param startKind - * - */ - public void add(String key, int priority, Object serviceInstance, ServiceStartKind startKind) { - // Check if the service already exist. - ServiceStartupEntry service = addedServices.get(key); - if(service != null) { - if(service.getDescriptor().getPriority() > priority) - return; - else if(service.getDescriptor().getPriority() == priority) - log.warning("Two services with same priority (" + priority + ") are declared under key '" + service.getDescriptor().getKey() + "'. Keep the first encountered only."); - } - - // Create descriptor and add service. - ServiceDescriptor descriptor = new ServiceDescriptor(key, serviceInstance.getClass().getName(), startKind, priority); - - if(startKind == ServiceStartKind.STARTUP) - addedServices.put(key, new StartStartupEntry(new PojoServiceEntry(descriptor, serviceInstance))); - else - addedServices.put(key, new LazyStartupEntry(new PojoServiceEntry(descriptor, serviceInstance), this)); - - } - - /** - * Add an already instanciated pojo (Plain Old Java Object) as Service. The - * descriptor will be created. No life cycle methods are called on the - * service. - * - * @param key - * Service key Class used as key. The classname is used as key. - * @param priority - * service priority - * @param serviceInstance - * The instance of the service - * @param startKind - * - */ - public void add(Class key, int priority, Object serviceInstance, ServiceStartKind startKind) { - - add(key.getName(), priority, serviceInstance, startKind); - } - - /** - * Remove the specified service from the registry. - * - * @param key - */ - public void remove(ServiceDescriptor serviceDescriptor) throws ServiceException { - remove(serviceDescriptor.getKey()); - } - - /** - * Remove the specified service from the registry. - * - * @param key - */ - public void remove(Object key) throws ServiceException { - ServiceStartupEntry service = namedServices.remove(key); - if(service == null) { - return; - } - - // Stop the service - service.disposeService(); - } - - /** - * Get the requested service by its key. The key is usually the classname of - * the service. - * - * @param serviceClass - * @return - * @throws ServiceException - * If servive can't be started - */ - public Object getService(Object key) throws ServiceException { - ServiceStartupEntry service = namedServices.get(key); - if(service == null) { - // throw an exception. - // If added, say it. - service = addedServices.get(key); - if(service != null) - throw new BadStateException("Registry should be started before.", service.getState(), service.getDescriptor()); - else - throw new ServiceNotFoundException("No service registered under '" + key + "'"); - } - - return service.getServiceInstance(); - } - - /** - * Get the requested service by its class (the service has to be registered - * by its class object). - * - * @param key - * The service class. - * @return The service. - * @throws ServiceException - * If service can't be started - */ - @SuppressWarnings("unchecked") - public S getService(Class key) throws ServiceException { - - String realKey = key.getName(); - ServiceStartupEntry service = namedServices.get(realKey); - - if(service == null) { - // throw an exception. - // If added, say it. - service = addedServices.get(realKey); - if(service != null) - throw new BadStateException("Registry should be started before.", service.getState(), service.getDescriptor()); - else - throw new ServiceNotFoundException("No service registered under '" + key + "'"); - } - - return (S)service.getServiceInstance(); - } - - /** - * Return true if the service is instantiated. Return false otherwise. - * - * @return - */ - public boolean isStarted(Object key) throws ServiceNotFoundException { - ServiceStartupEntry service = namedServices.get(key); - if(service == null) { - throw new ServiceNotFoundException("No service registered under '" + key + "'"); - } - - return service.isStarted(); - } - - /** - * Return the state of the specified service. - * - * @return - */ - public ServiceState serviceState(Object key) throws ServiceNotFoundException { - ServiceStartupEntry service = namedServices.get(key); - if(service == null) { - throw new ServiceNotFoundException("No service registered under '" + key + "'"); - } - - return service.getState(); - } - - /** - * Start the registry. Start all services marked as start = STARTUP are - * started. All services are first created, then initialized and finally - * started. If an error occur on a service during one of this step, the - * service is removed from the registry and and the error is logged. - * - * @throws ServiceMultiException - * - * @throws ServiceException - * If a service can't be started. - */ - public void startRegistry() throws ServiceMultiException { - - // Build the lookup maps - LookupMap map = new LookupMap(addedServices, namedServices); - - // Check if all dependencies exist. - checkDependencies(addedServices.values(), map); - - // Get all roots : LAZY and START - Collection roots = getServiceRoots(addedServices.values(), map); - // showServices(" Roots:", roots); - // Detect cycles - checkCycle(roots, map); - // Retain only services with startupkind = START - roots = retainsToStartServices(roots); - // - List toStart = buildTopologicalListOfServicesToStart(roots, map); - - if(Activator.log.isDebugEnabled()) { - showServices(" Services to start:", toStart); - } - - // Create an object to collect errors if any. - ServiceMultiException errors = new ServiceMultiException(); - - createServices(toStart, errors); - // Register all new services : lazy and start - registerServices(addedServices.values()); - initServices(toStart, errors); - startServices(toStart, errors); - - // Report errors if any - if(errors.getExceptions().size() > 0) - throw errors; - - } - - /** - * Start the specified services, and their required services. The specifies - * services should be in the addServices or already registered. Start all - * services marked as start = STARTUP . All eligible services are first - * created, then initialized and finally started. If an error occur on a - * service during one of this step, the service is removed from the registry - * and and the error is logged. - * - * @param serviceKeys - * Keys of services to start. - * @throws ServiceMultiException - * @throws ServiceNotFoundException - * If a service can't be retrieved by its key. - * - * @throws ServiceException - * If a service can't be started. - */ - public void startServices(List serviceKeys) throws ServiceMultiException, ServiceNotFoundException { - - // Build the lookup maps - LookupMap map = new LookupMap(addedServices, namedServices); - - // Get the services - List services = keysToServices(serviceKeys, map); - - // Start them - startServices(services, map); - } - - /** - * Same as {@link #startServices(List)}, but with an array as input. - * - * @see #startServices(List) - * - * @param serviceKeys - * Keys of services to start. - * @throws ServiceMultiException - * @throws ServiceNotFoundException - * If a service can't be retrieved by its key. - * - * @throws ServiceException - * If a service can't be started. - */ - public void startServices(String... serviceKeys) throws ServiceMultiException, ServiceNotFoundException { - - List serviceKeysList = Arrays.asList(serviceKeys); - startServices(serviceKeysList); - } - - /** - * Start the specified services, and their required services. The specifies - * services should be in the addServices or already registered. Start all - * services marked as start = STARTUP . All eligible services are first - * created, then initialized and finally started. If an error occur on a - * service during one of this step, the service is removed from the registry - * and and the error is logged. - * - * @param serviceKeys - * Keys of services to start. Keys will be translated to the - * classname. - * @throws ServiceMultiException - * @throws ServiceNotFoundException - * If a service can't be retrieved by its key. - * - * @throws ServiceException - * If a service can't be started. - */ - public void startServicesByClassKeys(List> serviceKeys) throws ServiceMultiException, ServiceNotFoundException { - - // Build the lookup maps - LookupMap map = new LookupMap(addedServices, namedServices); - - // Get the services - List services = classKeysToServices(serviceKeys, map); - - // Start them - startServices(services, map); - } - - /** - * Same as {@link #startServicesByClassKeys(List)}, but with an array as - * input. - * - * @see #startServices(List) - * - * @param serviceKeys - * Keys of services to start. - * @throws ServiceMultiException - * @throws ServiceNotFoundException - * If a service can't be retrieved by its key. - * - * @throws ServiceException - * If a service can't be started. - */ - public void startServicesByClassKeys(Class... serviceKeys) throws ServiceMultiException, ServiceNotFoundException { - - List> serviceKeysList = Arrays.asList(serviceKeys); - startServicesByClassKeys(serviceKeysList); - } - - /** - * Start the specified services, and their required services. The specifies - * services should be in the specified map. The map is also used to resolves - * dependencies. Start all services marked as start = STARTUP . All eligible - * services are first created, then initialized and finally started. If an - * error occur on a service during one of this step, the service is removed - * from the registry and and the error is logged. - * - * @param services - * Services to start - * @param map - * a table of (key, service) used to get a service by its key. - * @throws ServiceMultiException - * If a service can't be started. - */ - private void startServices(List services, LookupMap map) throws ServiceMultiException { - // Check if all dependencies exist. - checkDependencies(services, map); - - // Get all roots : LAZY and START - Collection roots = getServiceRoots(services, map); - if(Activator.log.isDebugEnabled()) { - showServices(" Roots:", roots); - } - // Detect cycles - checkCycle(roots, map); - // Retain only services with startupkind == START and state == - // REGISTERED - roots = retainsToStartServices(roots); - // - List toStart = buildTopologicalListOfServicesToStart(roots, map); - - // Remove already started services - toStart = retainsToStartServices(toStart); - - // if( log.isLoggable(Level.FINE)) - // { - showServices(" Services to start:", toStart); - // } - - // Create an object to collect errors if any. - ServiceMultiException errors = new ServiceMultiException(); - - createServices(toStart, errors); - // Register all started services - registerServices(toStart); - initServices(toStart, errors); - startServices(toStart, errors); - - // Report errors if any - if(errors.getExceptions().size() > 0) - throw errors; - } - - /** - * Return a list of services from a list of services keys. - * - * @param serviceKeys - * @param map - * @return - * @throws ServiceNotFoundException - * If a service can't be retrieved by its key. - */ - private List keysToServices(List serviceKeys, LookupMap map) throws ServiceNotFoundException { - - List result = new ArrayList(serviceKeys.size()); - - for(String key : serviceKeys) { - result.add(map.getChecked(key)); - } - return result; - } - - /** - * Return a list of services from a list of services keys. - * - * @param serviceKeys - * @param map - * @return - * @throws ServiceNotFoundException - * If a service can't be retrieved by its key. - */ - private List classKeysToServices(List> serviceKeys, LookupMap map) throws ServiceNotFoundException { - - List result = new ArrayList(serviceKeys.size()); - - for(Class key : serviceKeys) { - result.add(map.getChecked(key.getName())); - } - return result; - } - - /** - * Print the services. For debug purpose - * - * @param roots - */ - private void showServices(String message, Collection roots) { - StringBuffer buffer = new StringBuffer(); - buffer.append("--------------------------\n"); - buffer.append(message); - buffer.append("\n"); - for(ServiceStartupEntry service : roots) { - buffer.append(" "); - buffer.append(service.getDescriptor().toString()); - buffer.append("\n"); - } - buffer.append("--------- done -----------\n"); - Activator.log.debug(buffer.toString()); - } - - /** - * Check if all dependencies exist. Throw an error if a declared dependency - * has no corresponding service. - * - * @param services - * Services to check - * @param map - * Map of services by keys. - * @throws ServiceMultiException - */ - private void checkDependencies(Collection services, LookupMap map) throws ServiceMultiException { - - ServiceMultiException errors = new ServiceMultiException(); - - // Walk each service and check if its required services exist. - for(ServiceStartupEntry service : services) { - ServiceDescriptor desc = service.getDescriptor(); - - // Check each required service - for(String key : desc.getRequiredServiceKeys()) { - - // Check if service can be found - try { - map.getChecked(key); - } catch (ServiceNotFoundException e) { - errors.addException(desc.getKey(), e); - } - } - } - - // Throw errors if any - if(errors.getExceptions().size() > 0) - throw errors; - } - - /** - * Retains only the services that should be started. Retains only services - * with startupkind = START and state == REGISTERED - * - * @param services - * Collection to filter - * @return a new Collection containing the services to start. - */ - private List retainsToStartServices(Collection services) { - - List result = new ArrayList(); - for(ServiceStartupEntry service : services) { - ServiceDescriptor desc = service.getDescriptor(); - if(service.getState() == ServiceState.registered && desc.isStartAtStartup()) { - result.add(service); - } - } - - return result; - } - - /** - * Check for cycles. Throws an exception if a cycle is discovered. Each root - * is checked to see if it contains a cycle. - * - * @param roots - * @param map - */ - private void checkCycle(Collection roots, LookupMap map) { - // TODO Auto-generated method stub - - } - - /** - * Build a list of services to start, in the topological order (right - * order). The required services are placed before the dependent services in - * the list. Services already started are disguarded. - * - * @param roots - * @param map - * Map used to resolve the entry by their key. - * @return - */ - private List buildTopologicalListOfServicesToStart(Collection roots, LookupMap map) { - - List result = new ArrayList(); - - // Each root represent a graph. Walk the root and its child in the list, - // in the right order. - for(ServiceStartupEntry root : roots) { - walkGraphDepthFirst(result, root, map); - } - - return result; - } - - /** - * Add recursively the provided node, and then its direct children. - * - * @param result - * The list where the node are added - * @param node - * The node to add - * @param map - */ - private void walkGraphDepthFirst(List result, ServiceStartupEntry node, LookupMap map) { - - // Do not add already added or started node. - if(result.contains(node) || node.isStarted()) - return; - - // add direct child - for(String serviceKey : node.getDescriptor().getRequiredServiceKeys()) { - try { - ServiceStartupEntry child = map.getChecked(serviceKey); - walkGraphDepthFirst(result, child, map); - } catch (ServiceNotFoundException e) { - // Do nothing, we have already reported the problems with - // checkServices; - } - } - - // Now add the node - result.add(node); - } - - /** - * Create a List of the root services. The roots are services that are not - * required by any service. - * - * @param addedServices - * A collection from which roots are required. The collection is - * unmodified. - * @param map - * @return - */ - private Collection getServiceRoots(Collection addedServices, LookupMap keyServiceMap) { - - // Create a copy of the list of services - Collection services = new ArrayList(addedServices); - - List allRequired = new ArrayList(); - - // The roots are services that are not required by any service. - // Build a list of the services required by all other services. - for(ServiceStartupEntry service : services) { - // Add each child to the list of required - for(String serviceKey : service.getDescriptor().getRequiredServiceKeys()) { - try { - - ServiceStartupEntry child = keyServiceMap.getChecked(serviceKey); - allRequired.add(child); - } catch (ServiceNotFoundException e) { - // Do nothing, we have already reported the problems with - // checkServices; - } - } - - } - - // Roots are those that are not required. - // So it is the original list minus the required. - services.removeAll(allRequired); - - return services; - } - - /** - * Dispose all services. - * - * @throws ServiceMultiException - */ - public void disposeRegistry() throws ServiceMultiException { - - // List of keys of service in error. - ServiceMultiException errors = new ServiceMultiException(); - disposeServices(namedServices.values(), errors); - disposeServices(anonymousServices, errors); - - // Report errors if any - if(errors.getExceptions().size() > 0) - throw errors; - } - - /** - * Create all services provided in the list - * - * @param toStart - * List of services to create. - * @param errors - * Exception to collect errors. - * - * @throws ServiceMultiException - * If an error occure during the creation - * - * @throws ServiceException - * If a service can't be started. - */ - private void createServices(List toStart, ServiceMultiException errors) throws ServiceMultiException { - - // Loop on all services - for(ServiceStartupEntry serviceEntry : toStart) { - try { - - serviceEntry.createService(); - } catch (ServiceException e) { - log.log(Level.SEVERE, "Can't create service '" + serviceEntry + "'", e); - - errors.addException(serviceEntry.getDescriptor().getKey(), e); - } - } - - } - - /** - * Register all services provided in the list. After this operation, - * services are available thru {@link #getService(Class)}. - * - * @param toStart - * List of services to register. - * - * @throws ServiceException - * If a service can't be started. - */ - private void registerServices(Collection toStart) { - - // Loop on all services - for(ServiceStartupEntry serviceEntry : toStart) { - ServiceDescriptor desc = serviceEntry.getDescriptor(); - if(desc.isAnonymous()) { - anonymousServices.add(serviceEntry); - } else { - namedServices.put(desc.getKey(), serviceEntry); - } - } - } - - /** - * Init all services provided in the list - * - * @param toStart - * List of services to init. - * @param errors - * - * @throws ServiceMultiException - * If an error occure during the process - * - * @throws ServiceException - * If a service can't be started. - */ - private void initServices(List toStart, ServiceMultiException errors) throws ServiceMultiException { - - // Loop on all services - for(ServiceStartupEntry serviceEntry : toStart) { - try { - - serviceEntry.initService(this); - } catch (ServiceException e) { - log.log(Level.SEVERE, "Can't initialize service '" + serviceEntry + "'", e); - errors.addException(serviceEntry.getDescriptor().getKey(), e); - } - } - - } - - /** - * Init all services provided in the list - * - * @param toStart - * List of services to init. - * @param errors - * - * @throws ServiceMultiException - * If an error occure during the process - * - * @throws ServiceException - * If a service can't be started. - */ - private void startServices(List toStart, ServiceMultiException errors) throws ServiceMultiException { - - // Loop on all services - for(ServiceStartupEntry serviceEntry : toStart) { - try { - - serviceEntry.startService(); - } catch (ServiceException e) { - log.log(Level.SEVERE, "Can't start service '" + serviceEntry + "'", e); - - errors.addException(serviceEntry.getDescriptor().getKey(), e); - } - } - - } - - /** - * Dispose all started services. - * - * @throws ServiceMultiException - * - * @throws ServiceException - * If a service can't be started. - */ - private void disposeServices(Collection services, ServiceMultiException errors) { - - // Dispose services - for(ServiceStartupEntry serviceEntry : services) { - try { - serviceEntry.disposeService(); - } catch (ServiceException e) { - log.log(Level.SEVERE, "Can't dispose service '" + serviceEntry.getDescriptor().getKey() + "'", e); - errors.addException(serviceEntry.getDescriptor(), e); - } - } - } - - /** - * This class represents a union of two maps of . It provide specific methods to retrieve a {@link ServiceStartupEntry} by its key. - * - * @author cedric dumoulin - * - */ - private class LookupMap { - - Map map1; - - Map map2; - - /** - * - * Constructor. Build a union of two maps. - * - * @param map1 - * @param map2 - */ - public LookupMap(Map map1, Map map2) { - this.map1 = map1; - this.map2 = map2; - } - - /** - * - * Constructor. Build a union of one map (sic). - * - * @param map - */ - @SuppressWarnings("unused") - public LookupMap(Map map) { - this(map, null); - } - - /** - * Get a service by its key. - * - * @param key - * @return the service or null if not found. - */ - @SuppressWarnings("unused") - public ServiceStartupEntry get(String key) { - - ServiceStartupEntry res = map1.get(key); - if(res != null) - return res; - if(map2 != null) - res = map2.get(key); - - return res; - } - - /** - * Get a service by its key. - * - * @param key - * @return The requested service. - * @throws ServiceNotFoundException - * if the service can't be found. - */ - public ServiceStartupEntry getChecked(String key) throws ServiceNotFoundException { - - ServiceStartupEntry res = map1.get(key); - if(res != null) - return res; - if(map2 != null) - res = map2.get(key); - if(res != null) - return res; - - throw new ServiceNotFoundException("No service found under key '" + key.toString() + "'"); - } - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ErrorServiceTypeEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ErrorServiceTypeEntry.java deleted file mode 100644 index 2be4cf905ee..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ErrorServiceTypeEntry.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services.internal; - -import org.eclipse.papyrus.core.services.BadStateException; -import org.eclipse.papyrus.core.services.ServiceDescriptor; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServiceState; -import org.eclipse.papyrus.core.services.ServicesRegistry; - -/** - * A service entry used for faulty services. In this implementation, methods do - * nothings or throw an error. - * - * - * @author cedric dumoulin - * - */ -public class ErrorServiceTypeEntry extends ServiceTypeEntry { - - /** - * The original service descriptor. - */ - private ServiceDescriptor descriptor; - - /** - * - * Constructor. - * - * @param descriptor - */ - public ErrorServiceTypeEntry(ServiceDescriptor descriptor) { - super(descriptor); - } - - /** - * - * @see org.eclipse.papyrus.core.services.internal.ServiceTypeEntry#getServiceInstance() - * - * @return - * @throws ServiceException - */ - @Override - public Object getServiceInstance() throws ServiceException { - throw new BadStateException("Service has not started.", ServiceState.error, descriptor); - } - - /** - * - * @see org.eclipse.papyrus.core.services.internal.ServiceTypeEntry#createService() - * - * @throws ServiceException - */ - @Override - public void createService() throws ServiceException { - // do nothing - - } - - /** - * - * @see org.eclipse.papyrus.core.services.internal.ServiceTypeEntry#initService(ServicesRegistry) - * - * @param servicesRegistry - * @throws ServiceException - */ - @Override - public void initService(ServicesRegistry servicesRegistry) throws ServiceException { - // do nothing - - } - - /** - * - * @see org.eclipse.papyrus.core.services.internal.ServiceTypeEntry#startService() - * - * @throws ServiceException - */ - @Override - public void startService() throws ServiceException { - // do nothing - - } - - /** - * - * @see org.eclipse.papyrus.core.services.internal.ServiceTypeEntry#disposeService() - * - * @throws ServiceException - */ - @Override - public void disposeService() throws ServiceException { - // do nothing - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/LazyStartupEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/LazyStartupEntry.java deleted file mode 100644 index c16c7f9ee6c..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/LazyStartupEntry.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services.internal; - -import org.eclipse.papyrus.core.services.IService; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServiceState; -import org.eclipse.papyrus.core.services.ServicesRegistry; - -/** - * An ServiceEntry managing {@link IService} registered as lazy start. - * - * @author cedric dumoulin - * - */ -public class LazyStartupEntry extends ServiceStartupEntry { - - protected ServicesRegistry registry; - - /** - * Constructor. - * - * @param serviceDescriptor - * @param registry - */ - public LazyStartupEntry(ServiceTypeEntry serviceEntry, ServicesRegistry registry) { - - super(serviceEntry); - this.registry = registry; - } - - /** - * - * @see org.eclipse.papyrus.core.services.internal.ServiceStartupEntry#getServiceInstance() - * - * @return - * @throws ServiceException - */ - @Override - public Object getServiceInstance() throws ServiceException { - if(serviceEntry.getState() == ServiceState.registered) { - // Start the service - try { - serviceEntry.createService(); - serviceEntry.initService(registry); - serviceEntry.startService(); - } catch (Exception e) { - // There was an error. The service is in error - serviceEntry = new ErrorServiceTypeEntry(serviceEntry.getDescriptor()); - } - } - - // Return the instance - return serviceEntry.getServiceInstance(); - } - - /** - * Do nothing - * - * @throws ServiceException - */ - @Override - public void createService() throws ServiceException { - } - - /** - * Do nothing - * - * @param servicesRegistry - * @throws ServiceException - */ - @Override - public void initService(ServicesRegistry servicesRegistry) throws ServiceException { - } - - /** - * Do nothing. - * - * @throws ServiceException - */ - @Override - public void startService() throws ServiceException { - } - - /** - * @see org.eclipse.papyrus.core.services.AbstractServiceEntry#disposeService() - * - * @throws ServiceException - */ - @Override - public void disposeService() throws ServiceException { - serviceEntry.disposeService(); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/PojoServiceEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/PojoServiceEntry.java deleted file mode 100644 index 1b6746150eb..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/PojoServiceEntry.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services.internal; - -import org.eclipse.papyrus.core.services.BadStateException; -import org.eclipse.papyrus.core.services.ServiceDescriptor; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServiceState; -import org.eclipse.papyrus.core.services.ServicesRegistry; - -/** - * Entry for a service provided as POJO. - * - * - * @author cedric dumoulin - */ -public class PojoServiceEntry extends ServiceTypeEntry { - - /** Instance of the service, if started. */ - private Object serviceInstance; - - /** - * Constructor. - * - * @param serviceDescriptor - */ - public PojoServiceEntry(ServiceDescriptor serviceDescriptor) { - super(serviceDescriptor); - setState(ServiceState.registered); - } - - /** - * Create an entry for an already created service. Constructor. - * - * @param descriptor - * Descriptor of the service. Key and priority should be set. - * @param serviceInstance - * The service Instance - */ - public PojoServiceEntry(ServiceDescriptor descriptor, Object serviceInstance) { - super(descriptor); - this.serviceInstance = serviceInstance; - setState(ServiceState.registered); - } - - /** - * Get the service instance. - * - * @return - * @throws ServiceException - * If service can't be started. - */ - public Object getServiceInstance() throws ServiceException { - - if(serviceInstance == null) - throw new BadStateException("Service is not created.", state, serviceDescriptor); - - return serviceInstance; - } - - /** - * Already created : do nothing. - * - * @throws ServiceException - */ - public void createService() throws ServiceException { - checkState(ServiceState.registered); - // Exit if already created. - if(serviceInstance != null) { - setState(ServiceState.created); - return; - } - - // Create it - try { - // Create the instance - serviceInstance = instanciateService(); - } catch (Exception e) { - setState(ServiceState.error); - throw new ServiceException(e); - } - setState(ServiceState.created); - } - - /** - * Pojo : can't initialize the service. Do nothing. - * - * @param servicesRegistry - * The servicesRegistry containing this service. - * - * @throws ServiceException - */ - public void initService(ServicesRegistry servicesRegistry) throws ServiceException { - setState(ServiceState.initialized); - } - - /** - * Already started : do nothing. - * - * @throws ServiceException - */ - public void startService() throws ServiceException { - setState(ServiceState.started); - } - - /** - * Do nothing. - */ - public void disposeService() throws ServiceException { - if(serviceInstance == null) - return; - - serviceInstance = null; - setState(ServiceState.disposed); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceEntry.java deleted file mode 100644 index 5e9f547fdb2..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceEntry.java +++ /dev/null @@ -1,160 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services.internal; - -import org.eclipse.papyrus.core.services.BadStateException; -import org.eclipse.papyrus.core.services.IService; -import org.eclipse.papyrus.core.services.ServiceDescriptor; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServiceState; -import org.eclipse.papyrus.core.services.ServicesRegistry; - -/** - * Entry of a Service implementing {@link IService}. This class provide methods - * to manage the Service life cycle. - * - * @author cedric dumoulin - * - */ -public class ServiceEntry extends ServiceTypeEntry { - - /** Instance of the service, if started. */ - private IService serviceInstance; - - /** - * Constructor. - * - * @param serviceDescriptor - * @param registry - */ - public ServiceEntry(ServiceDescriptor serviceDescriptor) { - super(serviceDescriptor); - setState(ServiceState.registered); - - } - - /** - * Create an entry for an already created service. Constructor. - * - * @param descriptor - * Descriptor of the service. Key and priority should be set. - * @param serviceInstance - * The service Instance - */ - public ServiceEntry(ServiceDescriptor descriptor, IService serviceInstance) { - super(descriptor); - this.serviceInstance = serviceInstance; - setState(ServiceState.registered); - } - - /** - * Get the service instance, even if it is not started. The service should - * be created. - * - * @return - * @throws ServiceException - * If service can't be started. - */ - public Object getServiceInstance() throws ServiceException { - - if(serviceInstance == null) - throw new BadStateException("Service is not created.", state, serviceDescriptor); - - return serviceInstance; - - } - - /** - * @see java.lang.Object#toString() - * @return - * - */ - @Override - public String toString() { - return "ServiceEntry [serviceDescriptor=" + serviceDescriptor.toString() + ", serviceInstance=" + serviceInstance + "]"; - } - - /** - * Create the associated service if not a Lazy Service. - * - * @throws ServiceException - */ - public void createService() throws ServiceException { - checkState(ServiceState.registered); - // Exit if already created. - if(serviceInstance != null) { - setState(ServiceState.created); - return; - } - - // Create it - try { - // Create the instance - serviceInstance = (IService)instanciateService(); - } catch (Exception e) { - setState(ServiceState.error); - throw new ServiceException(e); - } - setState(ServiceState.created); - } - - /** - * Start the associated service if not a Lazy Service. - * - * @param servicesRegistry - * The servicesRegistry containing this service. - * - * @throws ServiceException - */ - public void initService(ServicesRegistry servicesRegistry) throws ServiceException { - checkState(ServiceState.created); - try { - serviceInstance.init(servicesRegistry); - } catch (ServiceException e) { - setState(ServiceState.error); - throw e; - } catch (Exception e) { - setState(ServiceState.error); - throw new ServiceException(e); - } - - setState(ServiceState.initialized); - } - - /** - * Start the associated service if not a Lazy Service. - * - * @throws ServiceException - */ - public void startService() throws ServiceException { - - checkState(ServiceState.initialized); - setState(ServiceState.starting); - - try { - serviceInstance.startService(); - } catch (ServiceException e) { - setState(ServiceState.error); - throw e; - } catch (Exception e) { - setState(ServiceState.error); - throw new ServiceException(e); - } - - setState(ServiceState.started); - } - - /** - * Dispose the service. - */ - public void disposeService() throws ServiceException { - if(serviceInstance == null) - return; - - serviceInstance.disposeService(); - serviceInstance = null; - setState(ServiceState.disposed); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceFactoryEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceFactoryEntry.java deleted file mode 100644 index ecf1b3b5de5..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceFactoryEntry.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services.internal; - -import org.eclipse.papyrus.core.services.BadStateException; -import org.eclipse.papyrus.core.services.IServiceFactory; -import org.eclipse.papyrus.core.services.ServiceDescriptor; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServiceState; -import org.eclipse.papyrus.core.services.ServicesRegistry; - -/** - * Entry of a Service implementing {@link IServiceFactory}. This class provide - * methods to manage the Service life cycle. - * - * @author cedric dumoulin - * - */ -public class ServiceFactoryEntry extends ServiceTypeEntry { - - /** Instance of the service, if started. */ - private Object serviceInstance; - - /** Instance of the factory, if created. */ - private IServiceFactory factoryInstance; - - /** - * Constructor. - * - * @param serviceDescriptor - * @param registry - */ - public ServiceFactoryEntry(ServiceDescriptor serviceDescriptor) { - super(serviceDescriptor); - setState(ServiceState.registered); - - } - - /** - * Create an entry for an already created service. Constructor. - * - * @param descriptor - * Descriptor of the service. Key and priority should be set. - * @param serviceInstance - * The service Instance - */ - public ServiceFactoryEntry(ServiceDescriptor descriptor, IServiceFactory factoryInstance) { - super(descriptor); - this.factoryInstance = factoryInstance; - setState(ServiceState.registered); - } - - /** - * Get the service instance, even if it is not started. The service should - * be created. - * - * @return - * @throws ServiceException - * If service can't be started. - */ - public Object getServiceInstance() throws ServiceException { - - if(factoryInstance == null) - throw new BadStateException("Service is not created.", state, serviceDescriptor); - - // Get the service instance if needed. - if(serviceInstance == null) { - serviceInstance = factoryInstance.createServiceInstance(); - if(serviceInstance == null) { - throw new ServiceException("Service Factory '" + getDescriptor().getKey() + " return a null service. It should return a valid service."); - } - } - - return serviceInstance; - - } - - /** - * @see java.lang.Object#toString() - * @return - * - */ - @Override - public String toString() { - return "ServiceEntry [serviceDescriptor=" + serviceDescriptor.toString() + ", serviceInstance=" + serviceInstance + "]"; - } - - /** - * Create the associated service if not a Lazy Service. - * - * @throws ServiceException - */ - public void createService() throws ServiceException { - checkState(ServiceState.registered); - // Exit if already created. - if(factoryInstance != null) { - setState(ServiceState.created); - return; - } - - // Create it - try { - // Create the instance - factoryInstance = (IServiceFactory)instanciateService(); - } catch (Exception e) { - setState(ServiceState.error); - throw new ServiceException(e); - } - setState(ServiceState.created); - } - - /** - * Start the associated service if not a Lazy Service. - * - * @param servicesRegistry - * The servicesRegistry containing this service. - * - * @throws ServiceException - */ - public void initService(ServicesRegistry servicesRegistry) throws ServiceException { - checkState(ServiceState.created); - try { - factoryInstance.init(servicesRegistry); - } catch (ServiceException e) { - setState(ServiceState.error); - throw e; - } catch (Exception e) { - setState(ServiceState.error); - throw new ServiceException(e); - } - - setState(ServiceState.initialized); - } - - /** - * Start the associated service if not a Lazy Service. - * - * @throws ServiceException - */ - public void startService() throws ServiceException { - - checkState(ServiceState.initialized); - setState(ServiceState.starting); - - try { - factoryInstance.startService(); - } catch (ServiceException e) { - setState(ServiceState.error); - throw e; - } catch (Exception e) { - setState(ServiceState.error); - throw new ServiceException(e); - } - - setState(ServiceState.started); - } - - /** - * Dispose the service. - */ - public void disposeService() throws ServiceException { - if(factoryInstance == null) - return; - - factoryInstance.disposeService(); - factoryInstance = null; - setState(ServiceState.disposed); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceStartupEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceStartupEntry.java deleted file mode 100644 index d88d1f6a861..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceStartupEntry.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services.internal; - -import java.util.Collection; -import java.util.List; - -import org.eclipse.papyrus.core.services.ServiceDescriptor; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServiceState; -import org.eclipse.papyrus.core.services.ServicesRegistry; - -/** - * Base class for the different types of service startups (lazy, synchronized). - * - * @author cedric dumoulin - * - */ -public abstract class ServiceStartupEntry { - - /** - * The ServiceEntry, according to its type. - */ - protected ServiceTypeEntry serviceEntry; - - /** - * Entries of Services required by this service. - */ - protected List requiredServices; - - /** - * - * Constructor. - * - * @param serviceDescriptor - */ - public ServiceStartupEntry(ServiceTypeEntry serviceEntry) { - this.serviceEntry = serviceEntry; - } - - /** - * Create the associated service if not a Lazy Service. - * - * @throws ServiceException - */ - abstract public void createService() throws ServiceException; - - /** - * Init the associated service if not a Lazy Service. - * - * @param servicesRegistry - * The servicesRegistry containing this service. - * - * @throws ServiceException - */ - abstract public void initService(ServicesRegistry servicesRegistry) throws ServiceException; - - /** - * Start the associated service if not a Lazy Service. - * - * @throws ServiceException - */ - abstract public void startService() throws ServiceException; - - /** - * Get the service instance. - * - * @return - * @throws ServiceException - */ - abstract public Object getServiceInstance() throws ServiceException; - - /** - * Dispose associated service. - */ - abstract public void disposeService() throws ServiceException; - - /** - * Return the list of the {@link ServiceStartupEntry} required by this - * service. - * - * @return - */ - public Collection getRequiredServices() { - - throw new UnsupportedOperationException("Not yet implemented"); - // return requiredServices; - } - - /** - * Get {@link ServiceDescriptor} associated to this entry. - * - * @return - */ - public ServiceDescriptor getDescriptor() { - return serviceEntry.getDescriptor(); - } - - /** - * @return the state of the service - */ - public ServiceState getState() { - return serviceEntry.getState(); - } - - /** - * Return true if the service is started. Return false otherwise. - * - * @return - */ - public boolean isStarted() { - return serviceEntry.isStarted(); - } - - /** - * - * @see java.lang.Object#toString() - * - * @return - */ - @Override - public String toString() { - return super.toString() + ": key=" + getDescriptor().getKey(); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceTypeEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceTypeEntry.java deleted file mode 100644 index f00ea5de29f..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/ServiceTypeEntry.java +++ /dev/null @@ -1,201 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services.internal; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.papyrus.core.services.BadStateException; -import org.eclipse.papyrus.core.services.ServiceDescriptor; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServiceState; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.osgi.framework.Bundle; - -/** - * Base class for the different types of service entries (PoJo, Service, - * ServiceFactory, ...). - * - * @author cedric dumoulin - */ -public abstract class ServiceTypeEntry { - - /** - * Current state of the service. - */ - protected ServiceState state = ServiceState.registered; - - /** - * Descriptor of the service associated to this entry. - */ - protected ServiceDescriptor serviceDescriptor; - - /** - * - * Constructor. - * - */ - public ServiceTypeEntry(ServiceDescriptor serviceDescriptor) { - this.serviceDescriptor = serviceDescriptor; - } - - /** - * Change the state of the service. - * - * @param newState - */ - protected void setState(ServiceState newState) { - state = newState; - } - - /** - * @return the state - */ - public ServiceState getState() { - return state; - } - - /** - * Check if the current state is the proposed state. Throws an exception if - * the state is different. - * - * @param expectedState - * @throws BadStateException - */ - protected void checkState(ServiceState expectedState) throws BadStateException { - if(expectedState != state) { - throw new BadStateException(expectedState, state, serviceDescriptor); - } - } - - /** - * Get the descriptor of the service associated to this entry. - * - * @return - */ - public ServiceDescriptor getDescriptor() { - return serviceDescriptor; - } - - /** - * Instanciate the service as specified in serviceClassname. - * - * @return the created service. - * @throws ServiceException - */ - protected Object instanciateService() throws ServiceException { - - // Load the Class of the service - String serviceClassname = serviceDescriptor.getServiceClassname(); - Class classname = loadClass(); - - // Try to get the one arg constructor. - // This require the ServiceRegistry. Old stuff, not more used. - // try { - // Constructor constructor = - // classname.getConstructor(ServicesRegistry.class); - // return constructor.newInstance(registry); - // } catch (SecurityException e) { - // // Do nothing, try next constructor - // } catch (NoSuchMethodException e) { - // // Do nothing, try next constructor - // } catch (IllegalArgumentException e) { - // throw new ServiceException("Can't instanciate '" + serviceClassname + - // "' with args ServicesRegistry.", e); - // } catch (InstantiationException e) { - // throw new ServiceException("Can't instanciate '" + serviceClassname + - // "' with args ServicesRegistry.", e); - // } catch (IllegalAccessException e) { - // throw new ServiceException("Can't instanciate '" + serviceClassname + - // "' with args ServicesRegistry.", e); - // } catch (InvocationTargetException e) { - // throw new ServiceException("Can't instanciate '" + serviceClassname + - // "' with args ServicesRegistry.", e); - // } - - // Try with zero arg constructor. - try { - return classname.newInstance(); - } catch (SecurityException e) { - throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e); - } catch (IllegalArgumentException e) { - throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e); - } catch (InstantiationException e) { - throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e); - } catch (IllegalAccessException e) { - throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e); - } - } - - /** - * Load the Class object. Try from current ClassLoader, then try using the - * plugin referenced in the serviceDescriptor.PluginId - * - * @return - * @throws ServiceException - */ - private Class loadClass() throws ServiceException { - String serviceClassname = serviceDescriptor.getServiceClassname(); - Class serviceClass; - try { - serviceClass = Class.forName(serviceClassname); - } catch (ClassNotFoundException e1) { - // Try using bundle - try { - String bundleID = serviceDescriptor.getClassBundleID(); - Bundle bundle = Platform.getBundle(bundleID); - serviceClass = bundle.loadClass(serviceClassname); - } catch (ClassNotFoundException e2) { - throw new ServiceException("Can't find class for the name '" + serviceClassname + "'.", e2); - } - } - - return serviceClass; - } - - /** - * Return true if the service is started. Return false otherwise. - * - * @return - */ - public boolean isStarted() { - return state == ServiceState.started; - } - - /** - * Get the service instance. - * - * @return - * @throws ServiceException - */ - abstract public Object getServiceInstance() throws ServiceException; - - /** - * Create the associated service if not a Lazy Service. - * - * @throws ServiceException - */ - abstract public void createService() throws ServiceException; - - /** - * Start the associated service if not a Lazy Service. - * - * @param servicesRegistry - * The servicesRegistry containing this service. - * - * @throws ServiceException - */ - abstract public void initService(ServicesRegistry servicesRegistry) throws ServiceException; - - /** - * Start the associated service if not a Lazy Service. - * - * @throws ServiceException - */ - abstract public void startService() throws ServiceException; - - /** - * Dispose associated service. - */ - abstract public void disposeService() throws ServiceException; - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/StartStartupEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/StartStartupEntry.java deleted file mode 100644 index e35764aa16f..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/services/internal/StartStartupEntry.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.core.services.internal; - -import org.eclipse.papyrus.core.services.IService; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; - -/** - * An ServiceEntry managing {@link IService} that should be started when the - * registry is started. - * - * @author cedric dumoulin - * - */ -public class StartStartupEntry extends ServiceStartupEntry { - - /** - * Constructor. - * - * @param serviceDescriptor - * @param registry - */ - public StartStartupEntry(ServiceTypeEntry serviceEntry) { - - super(serviceEntry); - } - - /** - * - * @see org.eclipse.papyrus.core.services.internal.ServiceStartupEntry#getServiceInstance() - * - * @return - * @throws ServiceException - */ - @Override - public Object getServiceInstance() throws ServiceException { - // Return the instance - return serviceEntry.getServiceInstance(); - } - - /** - * Do nothing - * - * @throws ServiceException - */ - @Override - public void createService() throws ServiceException { - serviceEntry.createService(); - } - - /** - * Do nothing - * - * @param servicesRegistry - * @throws ServiceException - */ - @Override - public void initService(ServicesRegistry servicesRegistry) throws ServiceException { - serviceEntry.initService(servicesRegistry); - } - - /** - * Do nothing. - * - * @throws ServiceException - */ - @Override - public void startService() throws ServiceException { - serviceEntry.startService(); - } - - /** - * @see org.eclipse.papyrus.core.services.AbstractServiceEntry#disposeService() - * - * @throws ServiceException - */ - @Override - public void disposeService() throws ServiceException { - serviceEntry.disposeService(); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/ui/IRevealSemanticElement.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/ui/IRevealSemanticElement.java deleted file mode 100644 index 64f98801eff..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/ui/IRevealSemanticElement.java +++ /dev/null @@ -1,34 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation - */ -package org.eclipse.papyrus.core.ui; - -import java.util.List; - -/** - * this interface is used to reveal element that are given in parameter. Example - * of the use case: the class that implements this interface can be a diagram - * that select all editparts that are linked to the given list of semantic - * element - * - */ -public interface IRevealSemanticElement { - - /** - * reveal all elements that represent an element in the given list. - * - * @param elementList - * list of semantic element that we want to reveal, cannot be - * null - */ - public void revealSemanticElement(List elementList); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/AbstractServiceUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/AbstractServiceUtils.java deleted file mode 100644 index b72dac2cc68..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/AbstractServiceUtils.java +++ /dev/null @@ -1,121 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 LIFL & CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.core.utils; - -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.papyrus.core.lifecycleevents.ILifeCycleEventsProvider; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.resource.ModelSet; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; -import org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer; -import org.eclipse.ui.IEditorPart; - -/** - * Set of utility methods for accessing core Services. This class provide - * methods to access the Papyrus well known services. - * - *
- * This is the base class for concrete classes providing these utility methods. - * Concrete class need to provide method {@link #getServiceRegistry(Object)} implementing how the ServiceRegistry is retrieved from the provided - * object. - * Subclasses can also provide a Singleton pattern (getInstance()) in order to - * allow access to the utility methods in a static way.
- * - * @author cedri dumoulin - * - */ -public abstract class AbstractServiceUtils { - - /** - * Get the service registry from the specified parameter. - * - * @param from - * @return - */ - abstract public ServicesRegistry getServiceRegistry(T from) throws ServiceException; - - /** - * Gets the {@link TransactionalEditingDomain} registered in the {@link ServicesRegistry}. - * - * @param from - * @return - * @throws ServiceException - * If an error occurs while getting the requested service. - */ - public TransactionalEditingDomain getTransactionalEditingDomain(T from) throws ServiceException { - return getServiceRegistry(from).getService(TransactionalEditingDomain.class); - } - - /** - * Gets the {@link IPageMngr} registered in the {@link ServicesRegistry}. - * - * @param from - * @return - * @throws ServiceException - * If an error occurs while getting the requested service. - */ - public IPageMngr getIPageMngr(T from) throws ServiceException { - return getServiceRegistry(from).getService(IPageMngr.class); - } - - /** - * Gets the {@link IPageMngr} registered in the {@link ServicesRegistry}. - * - * @param from - * @return - * @throws ServiceException - * If an error occurs while getting the requested service. - */ - public ModelSet getModelSet(T from) throws ServiceException { - return getServiceRegistry(from).getService(ModelSet.class); - } - - /** - * Gets the {@link ILifeCycleEventsProvider} registered in the {@link ServicesRegistry}. - * - * @param from - * @return - * @throws ServiceException - * If an error occurs while getting the requested service. - */ - public ILifeCycleEventsProvider getILifeCycleEventsProvider(T from) throws ServiceException { - return getServiceRegistry(from).getService(ILifeCycleEventsProvider.class); - } - - /** - * Gets the {@link ISashWindowsContainer} registered in the {@link ServicesRegistry}. - * - * @param from - * @return - * @throws ServiceException - * If an error occurs while getting the requested service. - */ - public ISashWindowsContainer getISashWindowsContainer(T from) throws ServiceException { - return getServiceRegistry(from).getService(ISashWindowsContainer.class); - } - - /** - * Gets the {@link IEditorPart} of the currently nested active editor. - * - * @param from - * @return - * @throws ServiceException - * If an error occurs while getting the requested service. - */ - public IEditorPart getNestedActiveIEditorPart(T from) throws ServiceException { - return getISashWindowsContainer(from).getActiveEditor(); - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/BusinessModelResolver.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/BusinessModelResolver.java deleted file mode 100644 index f76b3d9772c..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/BusinessModelResolver.java +++ /dev/null @@ -1,102 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.core.utils; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPart; -import org.eclipse.gmf.runtime.notation.View; - -/** - * This class allows to retrieve the business object from an object representing - * a graphical artifact in a diagram. Each diagram can register its resolver - * which will be added to the list of resolvers. Some common resolvers are - * already registered : gef.EditPart TODO Use extensions to register additional - * resolvers. - */ -public class BusinessModelResolver { - - /** - * The unique instance - */ - public static BusinessModelResolver instance = new BusinessModelResolver(); - - public BusinessModelResolver() { - - } - - /** - * Get the business object associated to this object, if any. This method - * navigate throw the object if the object is an graphical artefact or a - * diagram artifact. - * - * @param object - * @return Object - */ - public Object getBusinessModel(Object object) { - if(object instanceof EditPart) { - // Check model. It can be a GraphNode. - Object model = ((EditPart)object).getModel(); - if(model instanceof View) { // Notation / GMF - return getBusinessElement((View)((EditPart)object).getModel()); - } else { - return model; - } - - } else if(object instanceof View) { - return ((View)object).getElement(); - - } else if(object instanceof IAdaptable) { - // Among others this is useful to retrieve the selected object from - // an explorer item. - return ((IAdaptable)object).getAdapter(EObject.class); - - } else { - return object; - } - } - - /** - * Get the business object from a GraphElement. - * - * @param object - * @return - */ - protected Object getBusinessElement(View object) { - try { - return object.getElement(); - } catch (NullPointerException e) { - // no business element - return null; - } - } - - /** - * Get the graphical object accessible from to this diagram object, if any. - * - * @param object - * @return Object - */ - public Object getGraphicalModel(Object object) { - throw new UnsupportedOperationException("Not yet implemented."); - } - - /** - * @return BusinessModelResolver - */ - public static BusinessModelResolver getInstance() { - return instance; - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/DiResourceSet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/DiResourceSet.java deleted file mode 100644 index 9cb27814a8e..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/DiResourceSet.java +++ /dev/null @@ -1,339 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.utils; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.papyrus.resource.ModelException; -import org.eclipse.papyrus.resource.ModelMultiException; -import org.eclipse.papyrus.resource.ModelSet; -import org.eclipse.papyrus.resource.ModelsReader; -import org.eclipse.papyrus.resource.notation.NotationModel; -import org.eclipse.papyrus.resource.notation.NotationUtils; -import org.eclipse.papyrus.resource.sasheditor.DiModelUtils; -import org.eclipse.papyrus.resource.sasheditor.SashModelUtils; -import org.eclipse.papyrus.resource.uml.UmlModel; -import org.eclipse.papyrus.resource.uml.UmlUtils; - -/** - * ResourceSet Manager for UML and DI files, and also other loaded models. - * - * @author Cedric dumoulin - * @author Jerome Benois - * @author Thomas Szadel - * - * @deprecated Use ModelSet instead. - */ -public class DiResourceSet extends ModelSet { - - /** - * - * Constructor. - * - */ - public DiResourceSet() { - super(); - // Register declared models - ModelsReader reader = new ModelsReader(); - reader.readModel(this); - } - - /** - * Just loads the model into the current resource set. - * - * @returns The loaded model or null if the model is not loaded. - * @deprecated load requested model and get its resource. See implementation - * for example. - */ - public Resource loadModelResource(IFile file) { - - UmlModel model = null; - try { - model = (UmlModel)loadModel(UmlModel.MODEL_ID, file); - } catch (ModelException e) { - return null; - } - return model.getResource(); - } - - /** - * Returns the extension of the model. Seem to be unused. - * - * @deprecated Use {@link UmlModel#UML_FILE_EXTENSION} - */ - public String getModelFileExtension() { - throw new UnsupportedOperationException("deprecated method."); - // if(modelFileExtension == null) { - // modelFileExtension = modelResource.getURI().fileExtension(); - // } - // return modelFileExtension; - } - - /** - * Load both files (DI and UML) from an handle on one of the two files. - * - * @param file - * The file to load (no matter the extension)Model - * @deprecated use {@link ModelSet#loadModels(IFile)} instead. - */ - public void loadResources(IFile file) { - try { - loadModels(file); - } catch (ModelMultiException e) { - e.printStackTrace(); - } - - // // Extract file name, without extension - // IPath fullPath = file.getFullPath().removeFileExtension(); - // - // // load DI2 - // URI diUri = - // getPlatformURI(fullPath.addFileExtension(DI_FILE_EXTENSION)); - // diResource = getResource(diUri, true); - // - // // load notation - // URI notationURI = - // getPlatformURI(fullPath.addFileExtension(NOTATION_FILE_EXTENSION)); - // notationResource = getResource(notationURI, true); - // - // if(notationResource != null) { - // // look for a model associated with a diagram in notation - // for(EObject eObject : notationResource.getContents()) { - // if(eObject instanceof Diagram) { - // Diagram diagram = (Diagram)eObject; - // if(diagram.getElement() != null) { - // modelResource = diagram.getElement().eResource(); - // break; - // } - // } - // } - // } - // - // - // // if modelResource is still null, we look for a file with the same - // name and a supported extension - // if(modelResource == null) { - // IContainer folder = file.getParent(); - // try { - // IResource[] files = folder.members(); - // for(IResource r : files) { - // String extension = r.getFullPath().getFileExtension(); - // if(r.getFullPath().removeFileExtension().lastSegment().equals(fullPath.lastSegment()) - // && !DI_FILE_EXTENSION.equalsIgnoreCase(extension) && - // !NOTATION_FILE_EXTENSION.equalsIgnoreCase(extension)) { - // if(Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().get(extension) - // != null) { - // modelResource = getResource(getPlatformURI(r.getFullPath()), true); - // break; - // } - // } - // } - // } catch (CoreException e) { - // // never happens. - // } - // } - // - // modelFileExtension = modelResource.getURI().fileExtension(); - // - // // TODO move next line away from DiResourceSet ? Define a place - // // where Resource initialization can take place. - // // move this line to centralize all the adapters - // modelResource.eAdapters().add(new ModelListenerManager()); - } - - /** - * Create both files (DI and UML) from a filename. - * - * @param newFile - * The file from which path is extracted to create the new files - * - * @deprecated Use {@link ModelSet#createsModels(IFile)} instead. - */ - public void createModelResources(IFile newFile, String eContentType, String modelExtension) { - - // Check if parameters are those expected. - // If not, throws an exception to inform the programmer. - if(!("org.eclipse.uml2.uml".equals(eContentType) && "uml".equals(modelExtension))) { - throw new UnsupportedOperationException(""); - } - // Create models - createsModels(newFile); - - // // create the di resource URI - // URI diUri = getPlatformURI(newFile.getFullPath()); - // // Create the di Resource for the sashcontainer - // // The model will be automatically initialized by the SashContainer - // if needed (if it is empty). - // // Normally the resource should contains models set by previous use - // from the SashContainer - // diResource = createResource(diUri); - // - // IPath filenameWithoutExtension = - // newFile.getFullPath().removeFileExtension(); - // // if the model is not loaded, create resource - // if(modelResource == null) { - // // create the model URI - // URI modelUri = - // getPlatformURI(filenameWithoutExtension.addFileExtension(modelExtension)); - // // create the model resource - // modelResource = createResource(modelUri, eContentType); - // this.modelFileExtension = modelExtension; - // } - // // create the notation URI - // URI notationURI = - // getPlatformURI(filenameWithoutExtension.addFileExtension(NOTATION_FILE_EXTENSION)); - // // create the notation resource - // notationResource = createResource(notationURI); - - } - - /** - * 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); - } - - /** - * Returns the notation resource. - * - * @return the notationResource - * @deprecated Use NotationUtils.getNotationModel(this).getResource(); - * instead. - */ - public Resource getNotationResource() { - return NotationUtils.getNotationModel(this).getResource(); - } - - /** - * - * - * @return the diResource - * @deprecated Use NotationUtils.getSashModel(this).getResource(); instead. - */ - public Resource getDiResource() { - return SashModelUtils.getSashModel(this).getResource(); - } - - /** - * Retrieve the di resource associated with a given model element. - * - * @param modelElement - * @return the di resource or null - * @deprecated a model should be modified/created to correctly handle - * controlled resources - */ - public Resource getAssociatedDiResource(EObject modelElement) { - // return the "base" di since we want the opened tabs in a unique di - return getDiResource(); - } - - /** - * Retrieve the notation resource associated with a given model element. - * - * @param modelElement - * @return the notation resource or null - * @deprecated a model should be modified/created to correctly handle - * controlled resources - */ - public Resource getAssociatedNotationResource(EObject modelElement) { - if(modelElement != null) { - Resource modelResource = modelElement.eResource(); - if(modelResource != null && !modelResource.equals(getModelResource())) { - // handle controlled resource - return getAssociatedResource(modelResource, NotationModel.NOTATION_FILE_EXTENSION); - } - } - return getNotationResource(); - } - - /** - * Retrieve the model resource associated with a given model element. Please - * refers to {@link ResourceSet#getResource(URI, boolean)} for the meaning - * of loadOnDemand. - * - * @param modelElement - * @return the model resource or null - * @deprecated a model should be modified/created to correctly handle - * controlled resources - */ - public Resource getAssociatedModelResource(EObject modelElement) { - if(modelElement != null && modelElement.eResource() != null) { - return modelElement.eResource(); - } - return getModelResource(); - } - - private Resource getAssociatedResource(Resource modelResource, String associatedResourceExtension) { - URI trimmedModelURI = modelResource.getURI().trimFileExtension(); - Resource r = null; - try { - r = getResource(trimmedModelURI.appendFileExtension(associatedResourceExtension), true); - } catch (Exception e) { - } - return r; - } - - /** - * Returns the model resource. - * - * @return the modelResource - * @deprecated Use NotationUtils.getUmlModel(this).getResource(); instead. - */ - public Resource getModelResource() { - return UmlUtils.getUmlModel(this).getResource(); - } - - /** - * Returns the additional resources. - * - * @return The additional resources. - */ - public List getAdditionalResources() { - List additionnalResources = new ArrayList(); - for(Resource resource : getResources()) { - // ignore di, notation and domain resources - - if(resource != getDiResource() && resource != getNotationResource() && resource != getModelResource()) { - additionnalResources.add(resource); - } - } - - return additionnalResources; - } - - /** - * Returns the related di file. - * - * @param file - * A file (di, model or notation). - * @return The associated DI file. - * @deprecated use {@link DiModelUtils#getRelatedDiFile(IFile)} - */ - public static IFile getRelatedDiFile(IFile file) { - return DiModelUtils.getRelatedDiFile(file); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/DisplayUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/DisplayUtils.java deleted file mode 100644 index 8a8bc452052..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/DisplayUtils.java +++ /dev/null @@ -1,44 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.core.utils; - -import static org.eclipse.papyrus.core.Activator.log; - -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; - -/** - * Util class for display in Papyrus (label providers, etc...) - */ -public class DisplayUtils { - - /** - * Gets the shared label provider. - * - * @return Get the current {@link ILabelProvider} or null if - * not found - */ - public static ILabelProvider getLabelProvider() { - try { - ServicesRegistry registry = EditorUtils.getServiceRegistry(); - return registry == null ? null : registry.getService(ILabelProvider.class); - } catch (IllegalStateException e) { - // Registry can't be found, do nothing. - log.error(e); - } catch (ServiceException e) { - log.error(e); - } - return null; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/EditorUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/EditorUtils.java deleted file mode 100644 index 50424fdab52..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/EditorUtils.java +++ /dev/null @@ -1,652 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * Thomas Szadel: Code simplification and NPE - * management. - * - *****************************************************************************/ -package org.eclipse.papyrus.core.utils; - -import static org.eclipse.papyrus.core.Activator.log; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.papyrus.core.editor.BackboneException; -import org.eclipse.papyrus.core.editor.CoreMultiDiagramEditor; -import org.eclipse.papyrus.core.editor.IMultiDiagramEditor; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServiceNotFoundException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.resource.sasheditor.DiModelUtils; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; -import org.eclipse.papyrus.sasheditor.contentprovider.ISashWindowsContentProvider; -import org.eclipse.papyrus.sasheditor.contentprovider.di.DiSashModelMngr; -import org.eclipse.papyrus.sasheditor.contentprovider.di.TransactionalDiSashModelMngr; -import org.eclipse.papyrus.sasheditor.editor.IPage; -import org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * Set of utility methods for the CoreEditor.
- * WARNING : Some of these methods rely on - * PlatformUI.getWorkbench().getActiveWorkbenchWindow()getActivePage() to lookup - * for shared objects owned by the main editor. This doesn't work during the - * initialization of the main editor because the main editor is not yet - * registered in the Eclipse workbench. This can lead to a null or an exception, - * and sometime this can lead to getting the shared object of another main - * editor ! - * - * @author cedric dumoulin - * @author Thomas Szadel - */ -// FIXME throws Exception (eg: NotFoundException) instead of null -public class EditorUtils { - - /** - * Gets the {@link IMultiDiagramEditor} interface of the a Eclipse active - * editor, if possible, or null if not possible.
- * WARNING - This method doesn't work during the initialization of the main - * editor. See note in class doc.
- * This method return null if there is no active editor, or if the editor is - * not instance of IMultiDiagramEditor.
- * This method is designed to be used by ui actions that interact with the - * active editor.
- * This method should not be used during the editor initialization phase.
- * In any case, a check should be done on the returned value that can be - * null. Usage of this method is discouraged. Use {@link #getMultiDiagramEditorChecked()} instead. - * - * - * @return Get the current {@link IMultiDiagramEditor} or null if not found. - */ - public static IMultiDiagramEditor getMultiDiagramEditor() { - // Lookup ServiceRegistry - IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if(workbenchWindow == null) { - return null; - } - IWorkbenchPage page = workbenchWindow.getActivePage(); - if(page == null) { - return null; - } - IEditorPart editor = page.getActiveEditor(); - if(editor instanceof IMultiDiagramEditor) { - return (IMultiDiagramEditor)editor; - } else { - return null; - } - } - - /** - * Gets the {@link IMultiDiagramEditor} interface of the a Eclipse active - * editor, if possible, or throw an exception if not possible.
- * WARNING - This method throw an exception during the initialization of the - * main editor. This method throws an exception if there is no active - * editor, or if the editor is not instance of IMultiDiagramEditor.
- * This method is designed to be used by ui actions that interact with the - * active editor.
- * - * - * @return Get the current {@link IMultiDiagramEditor} or null if not found. - * @throws BackboneException - * If it is not possible to get an instanceof {@link IMultiDiagramEditor} - */ - public static IMultiDiagramEditor getMultiDiagramEditorChecked() throws BackboneException { - IEditorPart editor; - try { - editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - } catch (NullPointerException e) { - // Can't get the active editor - throw new BackboneException("Can't get the current Eclipse Active Editor: There is no active editor at this time."); - } - - if(editor instanceof IMultiDiagramEditor) { - return (IMultiDiagramEditor)editor; - } else { - throw new BackboneException("Can't get an Active Editor instance of IMultiDiagramEditor. (actual type:" + editor.getClass().getName() + ")"); - } - } - - /** - * Gets the opened multi-diagram editors. - * - * @return The opened {@link IMultiDiagramEditor} or null if an error - * occured. - */ - public static IMultiDiagramEditor[] getMultiDiagramEditors() { - // Lookup ServiceRegistry - IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if(workbenchWindow == null) { - return null; - } - IWorkbenchPage page = workbenchWindow.getActivePage(); - if(page == null) { - return null; - } - List list = new ArrayList(); - for(IEditorReference editorRef : page.getEditorReferences()) { - IEditorPart editorPart = editorRef.getEditor(false); - if(editorPart instanceof IMultiDiagramEditor) { - list.add((IMultiDiagramEditor)editorPart); - } - } - return list.toArray(new IMultiDiagramEditor[list.size()]); - } - - /** - * Returns the editors that are related to to given file.
- * - * @param file - * The file (model, di or notation). - * @return The associated editors. - */ - public static IMultiDiagramEditor[] getRelatedEditors(IFile file) { - // Get the DI file - IFile diFile = DiModelUtils.getRelatedDiFile(file); - if(diFile == null || !diFile.exists()) { - return new IMultiDiagramEditor[0]; - } - - IMultiDiagramEditor[] openedEditors = EditorUtils.getMultiDiagramEditors(); - if(openedEditors == null) { - return new IMultiDiagramEditor[0]; - } - List list = new ArrayList(openedEditors.length); - - for(IMultiDiagramEditor editorPart : openedEditors) { - if(editorPart.getEditorInput() instanceof IFileEditorInput && diFile.equals(((IFileEditorInput)editorPart.getEditorInput()).getFile())) { - list.add(editorPart); - } - } - return list.toArray(new IMultiDiagramEditor[list.size()]); - } - - /** - * Get the {@link ServicesRegistry}of the currently active eclipse editor.
- * WARNING - This method doesn't work during the initialization of the main - * editor. See note in class doc.
- * This method return null if the ServicesRegistry can not be found.
- * This method is designed to be used by ui actions that interact with the - * active editor.
- * This method should not be used during the editor initialization phase.
- * In any case, a check should be done on the returned value that can be - * null. An alternative is to use {@link #getServiceRegistryChecked()} and - * to catch the exception.
- * It is preferable to retrieve the ServiceRegistry from elsewhere whenever - * it is possible.
- * In GMF EditParts or EditPolicies, the ServiceRegistry can be retrieved - * with methods from - * org.eclipse.papyrus.diagram.common.util.ServiceUtilsForGMF - * - *
- * WARNING: This method can return null if there is no Active Editor. This - * happen during the editor initialization, especially when there is no - * other editor opened. - * - * @return The {@link ServicesRegistry} or null if not found. - * @deprecated Check - * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments - * /cookbook/PapyrusCookBook.odt and use one of the replacement: - *
    - *
  • org.eclipse.papyrus.core.utils.ServiceUtils
  • - *
  • - * org.eclipse.papyrus.diagram.common.util.ServiceUtilsForGMF
  • - *
  • - * org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • - *
- */ - static public ServicesRegistry getServiceRegistry() { - // Lookup ServiceRegistry - IMultiDiagramEditor editor = getMultiDiagramEditor(); - return editor == null ? null : (ServicesRegistry)editor.getAdapter(ServicesRegistry.class); - } - - /** - * Get the service registry of the currently active main editor.
- * WARNING - This method doesn't work during the initialization of the main - * editor. See note in class doc. - * - * @return The {@link ServicesRegistry} or null if not found. - * @throws ServiceException - * If an error occurs. - * @deprecated Check - * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments - * /cookbook/PapyrusCookBook.odt and use one of the replacement: - *
    - *
  • org.eclipse.papyrus.core.utils.ServiceUtils
  • - *
  • - * org.eclipse.papyrus.diagram.common.util.ServiceUtilsForGMF
  • - *
  • - * org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • - *
- */ - static public ServicesRegistry getServiceRegistryChecked() throws ServiceException { - // Lookup ServiceRegistry - IMultiDiagramEditor editor = getMultiDiagramEditor(); - if(editor == null) { - throw new ServiceException("Can't get ServiceRegistry"); - } - - return (ServicesRegistry)editor.getAdapter(ServicesRegistry.class); - } - - /** - * Get the ISashWindowsContentProvider of the active Eclipse Editor, if - * possible.
- * This method return null if the ServiceRegistry can not be found or if an - * error occur.
- * This method is designed to be used by ui actions that interact with the - * active editor.
- * This method should not be used during the editor initialization phase.
- * In any case, a check should be done on the returned value that can be - * null.
- * - * @return the ISashWindowsContentProvider from the main editor or null if - * not found. - * @deprecated Check - * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments - * /cookbook/PapyrusCookBook.odt and use one of the replacement: - *
    - *
  • org.eclipse.papyrus.core.utils.ServiceUtils
  • - *
  • - * org.eclipse.papyrus.diagram.common.util.ServiceUtilsForGMF
  • - *
  • - * org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • - *
- */ - static public ISashWindowsContentProvider getISashWindowsContentProvider() { - - try { - return getServiceRegistryChecked().getService(ISashWindowsContentProvider.class); - } catch (ServiceException e) { - // The contract says that we return null if not found - return null; - } - } - - /** - * Get the ISashWindowsContentProvider of the active Eclipse Editor, if - * possible.
- * This method return null if the ServiceRegistry can not be found or if an - * error occur.
- * This method is designed to be used by ui actions that interact with the - * active editor.
- * This method should not be used during the editor initialization phase.
- * In any case, a check should be done on the returned value that can be - * null. - * - * @return the ISashWindowsContentProvider from the main editor or null if - * not found. - * @deprecated Check - * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments - * /cookbook/PapyrusCookBook.odt and use one of the replacement: - *
    - *
  • org.eclipse.papyrus.core.utils.ServiceUtils
  • - *
  • - * org.eclipse.papyrus.diagram.common.util.ServiceUtilsForGMF
  • - *
  • - * org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • - *
- */ - public static IPageMngr getIPageMngr() { - - try { - return getServiceRegistryChecked().getService(IPageMngr.class); - } catch (ServiceException e) { - // The contract says that we return null if not found - return null; - } - } - - /** - * Get the Eclipse ActiveEditor. - * - * @return The active {@link CoreMultiDiagramEditor} or null if not found. - * @deprecated Use {@link EditorUtils#getMultiDiagramEditor()} - */ - @Deprecated - protected static IEditorPart getWorkbenchActiveEditor() { - IMultiDiagramEditor editorPart = getMultiDiagramEditor(); - if(editorPart instanceof CoreMultiDiagramEditor) { - return editorPart; - } else { - return null; - } - } - - /** - * Create an instance of IPageMngr acting on the provided resource. This - * instance is suitable to add, remove, close or open diagrams. - * - * @param diResource - * @return The non transactional implementation of IPageMngr - */ - public static IPageMngr getIPageMngr(Resource diResource) { - return DiSashModelMngr.createIPageMngr(diResource); - } - - /** - * Create an instance of IPageMngr acting on the provided resource. This - * instance is suitable to add, remove, close or open diagrams. - * - * @param diResource - * @param editingDomain - * - * @return The transactional implementation of IPageMngr - */ - public static IPageMngr getTransactionalIPageMngr(Resource diResource, TransactionalEditingDomain editingDomain) { - return TransactionalDiSashModelMngr.createIPageMngr(diResource, editingDomain); - } - - /** - * Lookup the currently active Diagram from the Papyrus editor. Return the - * current Diagram or null if none is active.
- * WARNING - This method doesn't work during the initialization of the main - * editor. See note in class doc.
- * This method return null if the ServicesRegistry can not be found.
- * TODO This method introduce dependency on GMF. It can be moved to a GMF - * plugin. - * - * @return The active diagram or null if not found. - * - * @deprecated The core do make suppositions about the type of nested - * Editors, GMF stuff should be moved in GMF projects. In many - * case, {@link #lookupActiveNestedIEditor()} can be used. - */ - public static Diagram lookupEditorActiveDiagram() { - DiagramEditor diagEditor = lookupActiveDiagramEditor(); - return diagEditor == null ? null : diagEditor.getDiagram(); - } - - /** - * Lookup the currently active Diagram from the Papyrus editor. Return the - * current Diagram or null if none is active.
- * WARNING - This method doesn't work during the initialization of the main - * editor. See note in class doc.
- * This method return null if the ServicesRegistry can not be found.
- * TODO This method introduce dependency on GMF. It can be moved to a GMF - * plugin. - * - * @return the active diagram editor or null if not found. - * - * @deprecated The core do make suppositions about the type of nested - * Editors, GMF stuff should be moved in GMF projects. In many - * case, {@link #lookupActiveNestedIEditor()} can be used. - */ - public static DiagramEditor lookupActiveDiagramEditor() { - // Get the active page within the sashcontainer - IEditorPart activeEditor = lookupActiveNestedIEditor(); - // Check if it is a GMF DiagramEditor - if(activeEditor instanceof DiagramEditor) { - return ((DiagramEditor)activeEditor); - } else { - // Not found - return null; - } - - } - - /** - * Lookup the currently active {@link IEditorPart} from the Papyrus editor. - * Return the current nested editor part, or null if it can not be found.
- * WARNING - This method doesn't work during the initialization of the main - * editor. See note in class doc.
- * This method return null if the ServicesRegistry can not be found.
- * This method is designed to be used by ui actions that interact with the - * active editor.
- * This method should not be used during the editor initialization phase.
- * In any case, a check should be done on the returned value that can be - * null. An alternative is to use - * serviceRegistry.getService(ISashWindowsContainer - * .class).getActiveEditor();
- * It is preferable to retrieve the ServiceRegistry from elsewhere whenever - * it is possible.
- * - * - * @return - * @deprecated Check - * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments - * /cookbook/PapyrusCookBook.odt and use one of the replacement: - *
    - *
  • org.eclipse.papyrus.core.utils.ServiceUtils
  • - *
  • - * org.eclipse.papyrus.diagram.common.util.ServiceUtilsForGMF
  • - *
  • - * org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • - *
- */ - public static IEditorPart lookupActiveNestedIEditor() { - // Get the sashwindow container - ISashWindowsContainer container = getSashWindowContainer(); - // Get the active page within the sashcontainer - return container == null ? null : container.getActiveEditor(); - } - - /** - * Lookup the currently active IEditor in the SashSystem. If the currently - * eclipse active editor doesn't contains a {@link ISashWindowsContainer}, - * return null. If the current SashSystem page is not a IEditor, return - * null.
- * WARNING - This method doesn't work during the initialization of the main - * editor. See note in class doc.
- * This method return null if the ServicesRegistry can not be found.
- * This method is designed to be used by ui actions that interact with the - * active editor.
- * This method should not be used during the editor initialization phase.
- * In any case, a check should be done on the returned value that can be - * null. An alternative is to use - * serviceRegistry.getService(ISashWindowsContainer - * .class).getActiveSashWindowsPage();
- * It is preferable to retrieve the ServiceRegistry from elsewhere whenever - * it is possible. - * - * @return - * @deprecated Check - * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments - * /cookbook/PapyrusCookBook.odt and use one of the replacement: - *
    - *
  • org.eclipse.papyrus.core.utils.ServiceUtils
  • - *
  • - * org.eclipse.papyrus.diagram.common.util.ServiceUtilsForGMF
  • - *
  • - * org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • - *
- */ - public static IPage lookupActiveNestedPage() { - - // Get the sashwindow container - ISashWindowsContainer container = getSashWindowContainer(); - // Get the active page within the sashcontainer - return container == null ? null : container.getActiveSashWindowsPage(); - } - - /** - * - * @return - */ - private static ISashWindowsContainer getSashWindowContainer() { - - try { - return getServiceRegistryChecked().getService(ISashWindowsContainer.class); - } catch (ServiceException e) { - // The contract says that we return null if not found - return null; - } - } - - /** - * Gets the di resource set. - * - * @return Get the current {@link DiResourceSet} or null if not found. - * @deprecated Check - * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments - * /cookbook/PapyrusCookBook.odt and use one of the replacement: - *
    - *
  • org.eclipse.papyrus.core.utils.ServiceUtils
  • - *
  • - * org.eclipse.papyrus.diagram.common.util.ServiceUtilsForGMF
  • - *
  • - * org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • - *
- */ - public static DiResourceSet getDiResourceSet() { - try { - ServicesRegistry registry = getServiceRegistry(); - return registry == null ? null : registry.getService(DiResourceSet.class); - } catch (ServiceException e) { - log.error(e); - } - return null; - } - - /** - * Gets the {@link TransactionalEditingDomain} of the current active Eclipse - * Editor. This method should be used only when it is sure that the active - * editor exist, and that you want the EditingDomain of this editor.
- * This method return null if the TransactionalEditingDomain can not be - * found.
- * This method is designed to be used by ui actions that interact with the - * active editor.
- * This method should not be used during the editor initialization phase.
- * In any case, a check should be done on the returned value that can be - * null. An alternative is to use {@link #getTransactionalEditingDomainChecked()} and to catch the - * exception.
- * It is preferable to use {@link #getTransactionalEditingDomain(ServicesRegistry)} whenever it is - * possible.
- * In GMF EditParts or EditPolicies, the ServiceRegistry can be retrieved - * with methods from - * org.eclipse.papyrus.diagram.common.util.DiagramCoreServiceUtils
- * WARNING: This method can return null if there is no Active Editor. This - * happen during the editor initialization, especially when there is no - * other editor opened. - * - * @return Get the current {@link TransactionalEditingDomain} or null if not - * found - * @deprecated Check - * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments - * /cookbook/PapyrusCookBook.odt and use one of the replacement: - *
    - *
  • org.eclipse.papyrus.core.utils.ServiceUtils
  • - *
  • - * org.eclipse.papyrus.diagram.common.util.ServiceUtilsForGMF
  • - *
  • - * org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • - *
- */ - public static TransactionalEditingDomain getTransactionalEditingDomain() { - try { - ServicesRegistry registry = getServiceRegistry(); - return registry == null ? null : registry.getService(TransactionalEditingDomain.class); - } catch (IllegalStateException e) { - // Registry can't be found, do nothing. - } catch (ServiceException e) { - log.error(e); - } - return null; - } - - /** - * Gets the {@link TransactionalEditingDomain} of the current active Eclipse - * Editor. This method should be used only when it is sure that the active - * editor exist, and that you want the EditingDomain of this editor.
- * This method is designed to be used by ui actions that interact with the - * active editor.
- * This method should not be used during the editor initialization phase.
- * It is preferable to use {@link #getTransactionalEditingDomain(ServicesRegistry)} whenever it is - * possible.
- * This method throw a {@link ServiceException} if the - * TransactionalEditingDomain can not be found.
- * In GMF EditParts or EditPolicies, the ServiceRegistry can be retrieved - * with methods from - * org.eclipse.papyrus.diagram.common.util.DiagramCoreServiceUtils - * - * - * WARNING: This method throws an exception when no Active Editor is found. - * This happen during the editor initialization, especially when there is no - * other editor opened. - * - * @return Get the current {@link TransactionalEditingDomain} - * @throws ServiceException - * @throws ServiceNotFoundException - * @deprecated Check - * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments - * /cookbook/PapyrusCookBook.odt and use one of the replacement: - *
    - *
  • org.eclipse.papyrus.core.utils.ServiceUtils
  • - *
  • - * org.eclipse.papyrus.diagram.common.util.ServiceUtilsForGMF
  • - *
  • - * org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • - *
- */ - public static TransactionalEditingDomain getTransactionalEditingDomainChecked() throws ServiceException { - try { - ServicesRegistry registry = getServiceRegistryChecked(); - return registry.getService(TransactionalEditingDomain.class); - } catch (IllegalStateException e) { - throw new ServiceException(e); - } catch (Exception e) { - throw new ServiceException(e); - } - } - - /** - * Gets the {@link TransactionalEditingDomain} registered in the {@link ServicesRegistry}. - * - * @param servicesRegistry - * @return - * @deprecated Check - * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments - * /cookbook/PapyrusCookBook.odt and use one of the replacement: - *
    - *
  • org.eclipse.papyrus.core.utils.ServiceUtils
  • - *
- */ - public static TransactionalEditingDomain getTransactionalEditingDomain(ServicesRegistry registry) { - try { - return registry.getService(TransactionalEditingDomain.class); - } catch (IllegalStateException e) { - // Registry can't be found, do nothing. - } catch (ServiceException e) { - log.error(e); - } - return null; - } - - /** - * Gets the {@link TransactionalEditingDomain} registered in the {@link ServicesRegistry}. - * - * @param servicesRegistry - * @return - * @throws ServiceException - * If the TransactionalEditingDomain can not be found. - * @deprecated Check - * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments - * /cookbook/PapyrusCookBook.odt and use one of the replacement: - *
    - *
  • org.eclipse.papyrus.core.utils.ServiceUtils
  • - *
- */ - public static TransactionalEditingDomain getTransactionalEditingDomainChecked(ServicesRegistry registry) throws ServiceException { - return registry.getService(TransactionalEditingDomain.class); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/FilteredCollectionView.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/FilteredCollectionView.java deleted file mode 100644 index aeb26e4f9e6..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/FilteredCollectionView.java +++ /dev/null @@ -1,217 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.utils; - -import java.util.AbstractCollection; -import java.util.Collection; -import java.util.Iterator; -import java.util.NoSuchElementException; - -/** - * A unmodifiable view on a specified list. The view filters the original list - * according to the provided filter. - */ -public class FilteredCollectionView extends AbstractCollection implements Collection { - - /** The original collection */ - private Collection list; - - /** The filter for the view */ - private IFilter filter; - - /** - * The cached size. Compute only once, so change in the underlying - * collection is not reflected - */ - private int size = -1; - - /** - * Creates a new FilteredCollectionView. - * - * @param list - * the list to filter - * @param filter - * the filter for the view - */ - public FilteredCollectionView(Collection list, IFilter filter) { - this.list = list; - this.filter = filter; - } - - /** - * Sets the value of the list property. - * - * @param aList - * the new value of the list property - */ - public void setBackupCollection(Collection aList) { - list = aList; - } - - /** - * Sets the value of the filter property. - * - * @param aFilter - * the new value of the filter property - */ - public void setFilter(IFilter aFilter) { - filter = aFilter; - } - - /** - * Returns the value of the filter property. - * - * @return the new value of the filter property - */ - public IFilter getFilter() { - return filter; - } - - /** - * The size of the filtered list. - * - * @return the number of elements in the filtered list - */ - @Override - public int size() { - if(size == -1) { // compute the size - size = 0; - Iterator i = iterator(); - while(i.hasNext()) { - size++; - i.next(); - } - } - return size; - } - - /** - * Return true if the filteredCollection contains the object. - * - * @see java.util.AbstractCollection#contains(java.lang.Object) - * @param o - * @return - * - */ - @Override - public boolean contains(Object o) { - return list.contains(o); - } - - /** - * remove the object. Throw an UnsupportedOperationException, as the - * FilteredCollection is ReadOnly. - * - * @see java.util.AbstractCollection#remove(java.lang.Object) - * @param o - * @return - * - */ - @Override - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - - /** - * Return the value to be returned by the iterator.next() method. This - * method can be overloaded by subclasses in order to return another value - * than the objects belonging to the underlying list. - * - * @param ele - * The iterated object. This is the object iterated inside the - * underlying list. - * @return - */ - protected T returnedValue(T ele) { - return ele; - } - - /** - * listIterator. - * - * @return ListIterator - */ - @Override - public Iterator iterator() { - return new FilteredIterator(); - } - - /** - * Iterator other the filtered collection - */ - private class FilteredIterator implements Iterator { - - /** the next object */ - T next; - - /** The original list iterator */ - Iterator listIterator; - - /** - * Creates a new FilteredIterator - */ - public FilteredIterator() { - listIterator = list.iterator(); - next = nextFilteredObject(); - } - - /** - * Unsupported operation, as this is just a view of a list. - */ - public void remove() { - throw new UnsupportedOperationException(); - } - - /** - * Returns the next object of the list, when filter is applied - * - * @return - */ - protected T nextFilteredObject() { - while(listIterator.hasNext()) { - T ele = listIterator.next(); - if(filter.isAllowed(ele)) { - return returnedValue(ele); - } - } // end loop - return null; - } - - /** - * hasNext. - * - * @return boolean - */ - public boolean hasNext() { - return next != null; - } - - /** - * Compute the next field (null or next value), and return the previous - * value of the next field. - * - * @return Object - */ - public T next() { - if(next == null) { - throw new NoSuchElementException(); - } - T ele = next; - next = nextFilteredObject(); - return ele; - } - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/FilteredCollectionViewFromIterator.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/FilteredCollectionViewFromIterator.java deleted file mode 100644 index 84cf91ac4fe..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/FilteredCollectionViewFromIterator.java +++ /dev/null @@ -1,255 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -//Source file: H:\\temp\\generated\\modTransf\\util\\FilteredListView.java -package org.eclipse.papyrus.core.utils; - -import java.util.AbstractCollection; -import java.util.Collection; -import java.util.Iterator; -import java.util.NoSuchElementException; - -/** - * A unmodifiable view on a specified list from its iterator. The view filters - * the original list according to the provided filter. - * - * @param - * the type of objects in the filtered collection - */ -public class FilteredCollectionViewFromIterator extends AbstractCollection implements Collection { - - /** - * The iterator provider linked to the backup list. - */ - private IteratorProvider iter; - - /** - * - */ - private IFilter filter; - - /** - * The cached size. Compute only once, so change in the underlying - * collection is not reflected - */ - private int size = -1; - - /** - * - * - * @param filter - * @param list - * * - * @param iter - */ - public FilteredCollectionViewFromIterator(IteratorProvider iter, IFilter filter) { - this.iter = iter; - this.filter = filter; - } - - /** - * Sets the value of the list property. - * - * @param iter - * the new value of the list property - */ - public void setBackupCollection(IteratorProvider iter) { - this.iter = iter; - } - - /** - * - * - * @return - */ - Iterator getBackupIterator() { - return iter.iterator(); - } - - /** - * Sets the value of the filter property. - * - * @param aFilter - * the new value of the filter property - */ - public void setFilter(IFilter aFilter) { - filter = aFilter; - } - - /** - * Sets the value of the filter property. - * - * @return the new value of the filter property - */ - public IFilter getFilter() { - return filter; - } - - /** - * size. - * - * @return int - */ - @Override - public int size() { - if(size == -1) { // compute the size - size = 0; - Iterator i = iterator(); - while(i.hasNext()) { - size++; - i.next(); - } - } - return size; - } - - /** - * Removes a single instance of the specified element from this collection, - * if it is present (optional operation). More formally, removes an element e such that (o==null ? e==null : - * o.equals(e)), if the collection contains one or more such elements. - * Returns true if the collection contained the specified element - * (or equivalently, if the collection changed as a result of the call). - *

- * - * This implementation call the remove method on the underlying collection. - *

- * - * @param o - * element to be removed from this collection, if present. - * - * @return true if the collection contained the specified element. - * - * @throws UnsupportedOperationException - * if the remove method is not supported by this - * collection. - */ - @Override - public boolean remove(Object o) { - // return list.remove(o); - throw new UnsupportedOperationException(); - } - - /** - * Return the value to be returned by the iterator.next() method. This - * method can be overloaded by subclasses in order to return another value - * than the objects belonging to the underlying list. - * - * @param ele - * The iterated object. This is the object iterated inside the - * underlying list. - * - * @return - */ - protected E returnedValue(E ele) { - return ele; - } - - /** - * listIterator. - * - * @param index - * int - * - * @return ListIterator - */ - @Override - public Iterator iterator() { - return new FilteredIterator(); - } - - /** - * - */ - private class FilteredIterator implements Iterator { - - /** - * - */ - E next; - - /** - * - */ - Iterator listIterator; - - /** - * - */ - public FilteredIterator() { - listIterator = getBackupIterator(); - next = nextFilteredObject(); - } - - /** - * remove. - */ - public void remove() { - throw new UnsupportedOperationException(); - } - - /** - * - * - * @return - */ - protected E nextFilteredObject() { - while(listIterator.hasNext()) { - E ele = listIterator.next(); - if(filter.isAllowed(ele)) { - return returnedValue(ele); - } - } // end loop - return null; - } - - /** - * hasNext. - * - * @return boolean - */ - public boolean hasNext() { - return next != null; - } - - /** - * Compute the next field (null or next value), and return the previous - * value of the next field. - * - * @return Object - */ - public E next() { - if(next == null) { - throw new NoSuchElementException(); - } - E ele = next; - next = nextFilteredObject(); - return ele; - } - - } - - /** - * Inner class. Provide an iterator used internally in the unmodifiable - * collection view.. - */ - public interface IteratorProvider { - - /** - * provide a new iterator over the list. - * - * @return - */ - Iterator iterator(); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/FilteredListView.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/FilteredListView.java deleted file mode 100644 index fde7d99cf3b..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/FilteredListView.java +++ /dev/null @@ -1,376 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.utils; - -import java.util.AbstractSequentialList; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.NoSuchElementException; - -/** - * A unmodifiable view on a specified list. The view filters the original list - * according to the provided filter. - */ -public class FilteredListView extends AbstractSequentialList implements List { - - /** - * - */ - private List list; - - /** - * - */ - private IFilter filter; - - /** - * The cached size. Copute only once, so change in the underlying collection - * is not reflected - */ - private int size = -1; - - /** - * - * - * @param filter - * @param list - */ - public FilteredListView(List list, IFilter filter) { - this.list = list; - this.filter = filter; - } - - /** - * Sets the value of the list property. - * - * @param aList - * the new value of the list property - */ - public void setBackupList(List aList) { - list = aList; - } - - /** - * Sets the value of the filter property. - * - * @param aFilter - * the new value of the filter property - */ - public void setFilter(IFilter aFilter) { - filter = aFilter; - } - - /** - * size. - * - * @return int - */ - @Override - public int size() { - if(size == -1) { // compute the size - size = 0; - Iterator i = iterator(); - while(i.hasNext()) { - size++; - i.next(); - } - } - return size; - } - - /** - * Returns true if this collection contains the specified element. - * More formally, returns true if and only if this collection - * contains at least one element e such that (o==null ? e==null : o.equals(e)). - *

- * - * @param o - * object to be checked for containment in this collection. - * - * @return true if this collection contains the specified element. - */ - @Override - public boolean contains(Object o) { - return list.contains(o); - } - - /** - * Removes a single instance of the specified element from this collection, - * if it is present (optional operation). More formally, removes an element e such that (o==null ? e==null : - * o.equals(e)), if the collection contains one or more such elements. - * Returns true if the collection contained the specified element - * (or equivalently, if the collection changed as a result of the call). - *

- * - * This implementation call the remove method on the underlying collection. - *

- * - * @param o - * element to be removed from this collection, if present. - * - * @return true if the collection contained the specified element. - * - * @throws UnsupportedOperationException - * if the remove method is not supported by this - * collection. - */ - @Override - public boolean remove(Object o) { - // return list.remove(o); - throw new UnsupportedOperationException(); - } - - /** - * listIterator. - * - * @param index - * int - * - * @return ListIterator - */ - @Override - public ListIterator listIterator(int index) { - return new FilteredListIterator(index); - } - - /** - * - */ - private class FilteredListIterator implements ListIterator { - - /** - * - */ - Object current; - - /** - * - */ - Object next; - - /** - * - */ - Object previous; - - /** - * Index of the current element (last returned) in the backup list. - */ - int currentIndex; - - /** - * - */ - int previousIndex; - - /** - * - */ - int nextIndex; - - /** - * Index of the last returned element. - */ - int eleIndex = -1; - - /** - * Index of the boundary. - */ - int index = 0; - - /** - * - */ - ListIterator listIterator; - - /** - * - * - * @param index - */ - FilteredListIterator(int index) { - listIterator = list.listIterator(0); - nextIndex = -1; - next = nextFilteredObject(); - - previous = null; - previousIndex = -1; - current = next; - currentIndex = 0; - - // Go to the specified index - while(hasNext() && (nextIndex() < index)) { - next(); - } - } - - /** - * - * - * @return - */ - protected Object nextFilteredObject() { - while(listIterator.hasNext()) { - - int curIndex = listIterator.nextIndex(); // This is the current - // index in the list - Object ele = listIterator.next(); - if(filter.isAllowed(ele) && (curIndex > nextIndex)) { - nextIndex = curIndex; - return ele; - } - } // end loop - return null; - } - - /** - * - * - * @return - */ - protected Object previousFilteredObject() { - while(listIterator.hasPrevious()) { - int curIndex = listIterator.previousIndex(); // This is the - // current index - // in the list - Object ele = listIterator.previous(); - if(filter.isAllowed(ele) && (curIndex < previousIndex)) { - previousIndex = curIndex; - return ele; - } - } // end loop - return null; - } - - /** - * /** nextIndex. - * - * @return int - */ - public int nextIndex() { - return index; - } - - /** - * previousIndex. - * - * @return int - */ - public int previousIndex() { - return index - 1; - } - - /** - * remove. - */ - public void remove() { - throw new UnsupportedOperationException(); - } - - /** - * hasNext. - * - * @return boolean - */ - public boolean hasNext() { - return next != null; - } - - /** - * hasPrevious. - * - * @return boolean - */ - public boolean hasPrevious() { - return previous != null; - } - - /** - * next. - * - * @return Object - */ - public Object next() { - if(next == null) { - throw new NoSuchElementException(); - } - - if(index > eleIndex) { // previous was up, continue - previous = current; - previousIndex = currentIndex; - current = next; - currentIndex = nextIndex; - next = nextFilteredObject(); - - index++; - eleIndex++; - return current; - } else { // previous was down, turn back - index++; - return current; - } - } - - /** - * previous. - * - * @return Object - */ - public Object previous() { - if(previous == null) { - throw new NoSuchElementException(); - } - - if(index > eleIndex) { // previous was up, turn back - index--; - return current; - } else { // previuos was done, continue - next = current; - nextIndex = currentIndex; - current = previous; - currentIndex = previousIndex; - previous = previousFilteredObject(); - - index--; - eleIndex--; - return current; - - } - - } - - /** - * add. - * - * @param o - * Object - */ - public void add(Object o) { - throw new UnsupportedOperationException(); - } - - /** - * set. - * - * @param o - * Object - */ - public void set(Object o) { - throw new UnsupportedOperationException(); - } - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/GMFtoEMFCommandWrapper.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/GMFtoEMFCommandWrapper.java deleted file mode 100644 index 1ce3e95ea4f..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/GMFtoEMFCommandWrapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 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: Mario Cervera Ubeda (Prodevelop) - * - ******************************************************************************/ -package org.eclipse.papyrus.core.utils; - -import org.eclipse.gmf.runtime.common.core.command.ICommand; - -/** - * A EMF Command that wraps a GMF command. Each method is redirected to the GMF - * one. - * - * @deprecated use {@link org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper} instead - */ -public class GMFtoEMFCommandWrapper extends org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper { - - /** - * Constructor. - * - * @param gmfCommand - * the gmf command - */ - public GMFtoEMFCommandWrapper(ICommand gmfCommand) { - super(gmfCommand); - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/IDebugChannel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/IDebugChannel.java deleted file mode 100644 index 79b9f462618..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/IDebugChannel.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 CEA LIST. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation - *******************************************************************************/ -package org.eclipse.papyrus.core.utils; - -/** - * This interface contains all channels to trace papyrus - * - * @author Patrick Tessier - */ -public interface IDebugChannel { - - /** - * constant used to trace the core running - */ - public static final String PAPYRUS_CORE = "org.eclipse.papyrus.core/debug/core"; - - /** - * constant used to trace the loading of extension point - */ - public static final String PAPYRUS_EXTENSIONPOINT_LOADING = "org.eclipse.papyrus.core/debug/extensionpoint"; - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/IFilter.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/IFilter.java deleted file mode 100644 index 8621796e0a1..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/IFilter.java +++ /dev/null @@ -1,30 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.utils; - -/** - * A filter. - */ -public interface IFilter { - - /** - * Is the specified object allowed ? Return true if the filter allow this - * object. Return false if the filter doesn't allows the object. - * - * @param object - * - * @return boolean - */ - public boolean isAllowed(Object object); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/OpenDiagramCommand.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/OpenDiagramCommand.java deleted file mode 100644 index 36cfae74d81..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/OpenDiagramCommand.java +++ /dev/null @@ -1,96 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.utils; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; - -/** - * The Class OpenDiagramCommand. - * - * @deprecated This method use GMF stuff. It should not be in the core package. - */ -public class OpenDiagramCommand extends AbstractTransactionalCommand { - - /** The diagram to open. */ - private EObject diagramToOpen = null; - - private ICommand previousCreateDiagramCommand = null; - - /** - * Instantiates a new open diagram command. - * - * @param domain - * the domain - * @param diagram - * the diagram - */ - public OpenDiagramCommand(TransactionalEditingDomain editingDomain, EObject diagram) { - super(editingDomain, "Open diagram", null); - diagramToOpen = diagram; - } - - public OpenDiagramCommand(TransactionalEditingDomain editingDomain, ICommand previousCreateDiagramCommand) { - super(editingDomain, "Open diagram", null); - this.previousCreateDiagramCommand = previousCreateDiagramCommand; - } - - /** - * {@inheritedDoc} - */ - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - try { - if(diagramToOpen == null && previousCreateDiagramCommand != null) { - Object possibleDiagramToOpen = previousCreateDiagramCommand.getCommandResult().getReturnValue(); - if(possibleDiagramToOpen instanceof EObject) { - diagramToOpen = (EObject)possibleDiagramToOpen; - } - } - - - - if(diagramToOpen != null) { - IPageMngr pageMngr; - final ServicesRegistry serviceRegistry = EditorUtils.getServiceRegistry(); - if(serviceRegistry != null) { - pageMngr =serviceRegistry.getService(IPageMngr.class); - } else if(getEditingDomain().getResourceSet() instanceof DiResourceSet){ - DiResourceSet diResourceSet = (DiResourceSet)getEditingDomain().getResourceSet(); - pageMngr = EditorUtils.getIPageMngr(diResourceSet.getDiResource()); - } else { - throw new IllegalStateException("Enable to get the page manager");////$NON-NLS-1$ - } - - - if(pageMngr.isOpen(diagramToOpen)) { - pageMngr.closePage(diagramToOpen); - } - pageMngr.openPage(diagramToOpen); - } - - return CommandResult.newOKCommandResult(); - } catch (Exception e) { - throw new ExecutionException("Can't open diagram", e); - } - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/PapyrusEcoreUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/PapyrusEcoreUtils.java deleted file mode 100644 index 4d56f002909..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/PapyrusEcoreUtils.java +++ /dev/null @@ -1,86 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.core.utils; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.EStructuralFeature.Setting; -import org.eclipse.emf.ecore.util.ECrossReferenceAdapter; -import org.eclipse.emf.ecore.util.EcoreUtil; - -public class PapyrusEcoreUtils { - - /** - * Gets the usages. - * - * @param source - * the source - * - * @return the usages or null if there is no usages - */ - public static Collection getUsages(EObject source) { - Collection collection = null; - ECrossReferenceAdapter crossReferenceAdapter = ECrossReferenceAdapter.getCrossReferenceAdapter(source); - if(crossReferenceAdapter != null) { - collection = crossReferenceAdapter.getNonNavigableInverseReferences(source); - } else { - collection = EcoreUtil.UsageCrossReferencer.find(source, source.eResource().getResourceSet()); - } - return collection; - } - - /** - *
-	 * Test if the used element is referenced by other elements than the known
-	 * referencer (except its container). It ignores references from an other meta-model.
-	 * 
- * - * @param usedObject - * the used object - * @param knownReferencer - * the known referencer - * @return true if the known referencer is the only referencer. - */ - public static boolean isOnlyUsage(EObject usedObject, EObject knownReferencer) { - boolean isUsed = false; - EPackage mmPackage = usedObject.eClass().getEPackage(); - - // Retrieve the list of elements referencing the usedObject. - Set crossReferences = new HashSet(); - for(Setting setting : PapyrusEcoreUtils.getUsages(usedObject)) { - EObject eObj = setting.getEObject(); - if(eObj.eClass().getEPackage().equals(mmPackage)) { - crossReferences.add(eObj); - } - } - - // Remove the container of used object. - crossReferences.remove(usedObject.eContainer()); - // Remove the knownReferencer from the list of references. - crossReferences.remove(knownReferencer); - - // If no referencer remains in the list, the known element is the only - // usage. - if(crossReferences.isEmpty()) { - isUsed = true; - } - - return isUsed; - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/PapyrusImageUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/PapyrusImageUtils.java deleted file mode 100644 index 703c7a64a42..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/PapyrusImageUtils.java +++ /dev/null @@ -1,67 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tristan Faure (ATOS ORIGIN INTEGRATION) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.core.utils; - -import java.io.IOException; -import java.net.URL; - -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.papyrus.core.Activator; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; - -/** - * Services to access to Papyrus images - * - * @author tristan faure - * - */ -public class PapyrusImageUtils { - - private static final String default_icon_32 = "/icons/papyrus/32x32/Papyrus_32x32_t.gif"; - - private static final String default_icon = "/icons/papyrus/Papyrus.gif"; - - /** - * get the default icon for Papyrus the image does not have to be disposed - * as it is registered in an ImageRegistry - * - * @return the Image - */ - public static Image getDefaultIcon() { - return getIcon(default_icon); - } - - /** - * get the default icon 32x32 for Papyrus the image does not have to be - * disposed as it is registered in an ImageRegistry - * - * @return the Image - */ - public static Image getDefaultIcon32() { - return getIcon(default_icon_32); - } - - private static Image getIcon(String path) { - String key = Activator.PLUGIN_ID + path; - Image result = JFaceResources.getImageRegistry().get(key); - if(result == null) { - URL url = Activator.getDefault().getBundle().getEntry(path); - try { - result = new Image(Display.getDefault(), url.openStream()); - JFaceResources.getImageRegistry().put(key, result); - } catch (IOException e) { - } - } - return result; - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/PapyrusTrace.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/PapyrusTrace.java deleted file mode 100644 index 2fbf9a1d3d9..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/PapyrusTrace.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 CEA LIST. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation - *******************************************************************************/ -package org.eclipse.papyrus.core.utils; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.papyrus.core.Activator; -import org.eclipse.papyrus.log.LogHelper; - -/** - * Utility class to log errors or debug information either in the plugin'log or - * in the console. - *

- * A set of channels is used to separate different traces for different aspects. A short list is displayed at the end of the file to give an example of channels - * - * @deprecated Use {@link LogHelper} instead - **/ -@Deprecated -public class PapyrusTrace implements IDebugChannel { - - public static final String PAPYRUS_CORE = "org.eclipse.papyrus.core/debug"; - - /** - * Display a debug trace. - * - * @param element - * that provides the trace - * @param text - * message to display - * @param traceOption - * channel of the trace (see {@link IDebugChannel}) - */ - public static void trace(String traceOption, Object element, String text) { - if(!Platform.inDebugMode()) { - return; - } - String globalTraceValue = Platform.getDebugOption(PAPYRUS_CORE); - String value = Platform.getDebugOption(traceOption); - if(null != globalTraceValue && globalTraceValue.equals("true") && null != value && value.equals("true")) { - if(element != null) { - log(IStatus.INFO, "[" + traceOption + "]: " + element.getClass() + " --> " + text); - } else { - log(IStatus.INFO, "[" + traceOption + "] --> " + text); - } - } - } - - /** - * display error. - * - * @param element - * that provides the trace - * @param text - * to display - * @param traceOption - * channel of the trace - */ - public static void error(String traceOption, Object element, String text) { - if(!Platform.inDebugMode()) { - return; - } - String globalTraceValue = Platform.getDebugOption(PAPYRUS_CORE); - String value = Platform.getDebugOption(traceOption); - if(null != globalTraceValue && globalTraceValue.equals("true") && null != value && value.equals("true")) { - if(element != null) { - log(IStatus.ERROR, "[" + traceOption + "]: " + element.getClass() + " --> " + text); - } else { - log(IStatus.ERROR, "[" + traceOption + "] --> " + text); - } - } - } - - /** - * Log an exception into the plugin log. - * - * @param exception - * the exception to log. - * @param e - * the message to log - */ - public static void log(Exception e) { - final IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.OK, e.getMessage(), e); - Activator.getDefault().getLog().log(status); - } - - /** - * Log a message into the plugin log. - * - * @param message - * the message to log - * @param severity - * the severity : one of OK, ERROR, INFO, WARNING, or CANCEL - */ - public static void log(int severity, String message) { - final IStatus status = new Status(severity, Activator.PLUGIN_ID, IStatus.OK, message, null); - Activator.getDefault().getLog().log(status); - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/ServiceUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/ServiceUtils.java deleted file mode 100644 index bb9645aae12..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/ServiceUtils.java +++ /dev/null @@ -1,49 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 LIFL & CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.core.utils; - -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; - -/** - * @author cedric dumoulin - * - */ -public class ServiceUtils extends AbstractServiceUtils { - - private final static ServiceUtils instance = new ServiceUtils(); - - /** - * Get the singleton instance of the class. - * - * @return - */ - public static final ServiceUtils getInstance() { - return instance; - } - - /** - * @see org.eclipse.papyrus.core.utils.AbstractServiceUtils#getServiceRegistry(java.lang.Object) - * - * @param from - * @return - * @throws ServiceException - */ - @Override - public ServicesRegistry getServiceRegistry(ServicesRegistry from) throws ServiceException { - return from; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/ServiceUtilsForActionHandlers.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/ServiceUtilsForActionHandlers.java deleted file mode 100644 index 77cbb33567e..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/core/utils/ServiceUtilsForActionHandlers.java +++ /dev/null @@ -1,148 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 LIFL & CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.core.utils; - -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.papyrus.core.editor.IMultiDiagramEditor; -import org.eclipse.papyrus.core.lifecycleevents.ILifeCycleEventsProvider; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServiceNotFoundException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.resource.ModelSet; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr; -import org.eclipse.papyrus.sasheditor.editor.ISashWindowsContainer; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PlatformUI; - -/** - * Set of utility methods for accessing core Services. This class provide - * methods to access the Papyrus well known services. This class is designed to - * be used from ui Action Handlers or from any code relying on the Eclipse - * Active Editor.
- * All methods from this class rely on the Eclipse Active Editor, which should - * be an instance of {@link IMultiDiagramEditor}. If this is not the case, - * methods throw an exception {@link ServiceException}. - * - * @author cedric dumoulin - * - */ -public class ServiceUtilsForActionHandlers { - - private final static ServiceUtilsForActionHandlers instance = new ServiceUtilsForActionHandlers(); - - /** - * Get the singleton instance of the class. - * - * @return - */ - public static final ServiceUtilsForActionHandlers getInstance() { - return instance; - } - - /** - * Get the service registry from the specified parameter. - * - * @param from - * @return - */ - public ServicesRegistry getServiceRegistry() throws ServiceException { - - IEditorPart editor; - try { - editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - } catch (NullPointerException e) { - // Can't get the active editor - throw new ServiceNotFoundException("Can't get the current Eclipse Active Editor. No ServiceRegistry found."); - } - - ServicesRegistry serviceRegistry = (ServicesRegistry)editor.getAdapter(ServicesRegistry.class); - if(serviceRegistry != null) { - return serviceRegistry; - } - - // Not found - throw new ServiceNotFoundException("Can't get the ServiceRegistry from current Eclipse Active Editor"); - - } - - /** - * Gets the {@link TransactionalEditingDomain} registered in the {@link ServicesRegistry}. - * - * @return - * @throws ServiceException - * If an error occurs while getting the requested service. - */ - public TransactionalEditingDomain getTransactionalEditingDomain() throws ServiceException { - return getServiceRegistry().getService(TransactionalEditingDomain.class); - } - - /** - * Gets the {@link IPageMngr} registered in the {@link ServicesRegistry}. - * - * @return - * @throws ServiceException - * If an error occurs while getting the requested service. - */ - public IPageMngr getIPageMngr() throws ServiceException { - return getServiceRegistry().getService(IPageMngr.class); - } - - /** - * Gets the {@link IPageMngr} registered in the {@link ServicesRegistry}. - * - * @return - * @throws ServiceException - * If an error occurs while getting the requested service. - */ - public ModelSet getModelSet() throws ServiceException { - return getServiceRegistry().getService(ModelSet.class); - } - - /** - * Gets the {@link ILifeCycleEventsProvider} registered in the {@link ServicesRegistry}. - * - * @param from - * @return - * @throws ServiceException - * If an error occurs while getting the requested service. - */ - public ILifeCycleEventsProvider getILifeCycleEventsProvider() throws ServiceException { - return getServiceRegistry().getService(ILifeCycleEventsProvider.class); - } - - /** - * Gets the {@link ISashWindowsContainer} registered in the {@link ServicesRegistry}. - * - * @param from - * @return - * @throws ServiceException - * If an error occurs while getting the requested service. - */ - public ISashWindowsContainer getISashWindowsContainer() throws ServiceException { - return getServiceRegistry().getService(ISashWindowsContainer.class); - } - - /** - * Gets the {@link IEditorPart} of the currently nested active editor. - * - * @param from - * @return - * @throws ServiceException - * If an error occurs while getting the requested service. - */ - public IEditorPart getNestedActiveIEditorPart() throws ServiceException { - return getISashWindowsContainer().getActiveEditor(); - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/Activator.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/Activator.java new file mode 100644 index 00000000000..e315ad22cad --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/Activator.java @@ -0,0 +1,78 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core; + +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 + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.core"; + + // The shared instance + private static Activator plugin; + + /** Logging helper */ + public static LogHelper log = new LogHelper(); + + /** + * 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; + // register the login helper + log.setPlugin(plugin); + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext + * ) + */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + log = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/IElementWithSemantic.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/IElementWithSemantic.java new file mode 100644 index 00000000000..a3972b79f98 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/IElementWithSemantic.java @@ -0,0 +1,34 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + */ +package org.eclipse.papyrus.infra.core; + +/** + * + * all implementation is used to give the semantic element form a wrapper + * + * the implementation can call method getAdapter for example for notation + * element return semantic element, for edit part return the semantic element + * and not the view... + */ +public interface IElementWithSemantic { + + /** + * return the semantic element linked to this wrapper + * + * @param wrapper + * an object that wrapped or are linked to a semantic element + * cannot be null + * @return null or the semantic element + */ + public Object getSemanticElement(Object wrapper); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/contentoutline/ContentOutlineRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/contentoutline/ContentOutlineRegistry.java new file mode 100644 index 00000000000..bce9ed01a88 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/contentoutline/ContentOutlineRegistry.java @@ -0,0 +1,256 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.contentoutline; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.papyrus.infra.core.editor.BackboneException; +import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; +import org.eclipse.papyrus.infra.core.extension.BadClassNameException; +import org.eclipse.papyrus.infra.core.extension.NotFoundException; +import org.eclipse.papyrus.infra.core.extension.diagrameditor.EditorDescriptorExtensionFactory; +import org.osgi.framework.Bundle; + +public class ContentOutlineRegistry { + + /** ID of the editor extension (schema filename) */ + public static final String EDITOR_EXTENSION_ID = "papyrusContentOutline"; + + private static String classAttributeName = "class"; + + private static String actionBarContributorIdPropertyName = "actionBarContributorId"; + + /** Namespace where to look for the extension points. */ + protected String extensionPointNamespace; + + /** + * The selected content outline. + */ + protected IPapyrusContentOutlinePage contentOutline; + + /** + * Associated editor. + */ + private IMultiDiagramEditor multiEditor; + + /** + * Constructor. defaultContext, input and site are explicitly required in + * order be sure that they are initialized. The multiEditor should be + * initialized. In particular, getEditorSite(), getEditorInput() and + * getDefaultContext() should return initialized values. + * + * @param multiEditor + * @param defaultContext + * @param input + * @param site + * @param extensionPointNamespace + */ + public ContentOutlineRegistry(IMultiDiagramEditor multiEditor, String extensionPointNamespace) { + this.multiEditor = multiEditor; + this.extensionPointNamespace = extensionPointNamespace; + } + + /** + * Returns the single instance of the content outline. Creates one if + * necessary. + * + * @return the contentOutline the single instance of the content outline + * @throws BackboneException + * exception thrown when the outline can not be created. + */ + public IPapyrusContentOutlinePage getContentOutline() throws BackboneException { + if(contentOutline == null) { + createContentOutline(); + } + return contentOutline; + } + + /** + * Return the {@link ContentOutlineDescriptor} with the highest priority. + * + * @return + * @throws BackboneException + * @throws NotFoundException + * If no ContentOutline can be found in extensions + */ + private ContentOutlineDescriptor getContentOutlineDescriptor() throws BackboneException { + IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointNamespace, EDITOR_EXTENSION_ID); + ContentOutlineDescriptor found = null; + + // look for the one with the highest priority + for(IConfigurationElement ele : configElements) { + ContentOutlineDescriptor desc = new ContentOutlineDescriptor(ele); + if(desc.isHigher(found)) + found = desc; + } + + // Instanciate the object + if(found == null) + throw new NotFoundException("No ContentOutline registered."); + + return found; + + } + + /** + * Creates the content outline from the selected extension. + * + * @throws BackboneException + * exception thrown when the outline can not be created. + */ + private void createContentOutline() throws BackboneException { + + ContentOutlineDescriptor found = getContentOutlineDescriptor(); + // Instanciate the object + if(found != null) { + contentOutline = found.createContentOutlinePage(); + } + } + + /** + * Inner Descriptor for content outline. This class load data from Eclipse + * extension mechanism TODO Change the parent class. It is here just to have + * quick code. + */ + protected class ContentOutlineDescriptor extends EditorDescriptorExtensionFactory { + + private int priority; + + private String className; + + private String actionBarContributorID; + + private IConfigurationElement element; + + /** + * Instance is created when requested. + */ + protected IPapyrusContentOutlinePage instance = null; + + /** + * Create a descriptor backuped by the config element. + */ + protected ContentOutlineDescriptor(IConfigurationElement element) throws BackboneException { + String tagName = "contentoutline"; + checkTagName(element, tagName); + this.className = element.getAttribute(classAttributeName); + this.actionBarContributorID = element.getAttribute(actionBarContributorIdPropertyName); + try { + this.priority = Integer.parseInt(element.getAttribute("priority")); + } catch (NumberFormatException e) { + this.priority = 0; + } + + this.element = element; + // check parameters + if(className == null) + throw new BadClassNameException("Class name must be set", "contentoutline", classAttributeName); + + } + + /** + * Compare priority. The highest priority win. + */ + public boolean isHigher(ContentOutlineDescriptor found) { + if(found == null) { + return true; + } + return this.getPriority() > found.getPriority(); + } + + /** + * Return the higher value of the descriptor. This value is used to + * order the contentOutline. The highest priority win. + */ + private int getPriority() { + return priority; + } + + /** + * @return the actionBarContributorID + */ + public String getActionBarContributorID() { + return actionBarContributorID; + } + + /** + * Returns the content outline page instance (lazy initialization) + * + * @return the context outline page + * @throws BackboneException + * exception thrown when a problem occurs. + */ + protected IPapyrusContentOutlinePage getContentOutline() throws BackboneException { + if(instance == null) { + instance = createContentOutlinePage(); + } + return instance; + } + + /** + * Create the class corresponding to the class attribute. + */ + private Class loadClass() throws BadClassNameException { + if(className == null || className.length() == 0) { + throw new BadClassNameException("Classname should be set.", "contentoutline", classAttributeName); + } + Class factoryClass; + try { + factoryClass = (Class)Class.forName(className); + } catch (ClassNotFoundException e) { + // try another way + try { + String declaringID = element.getContributor().getName(); + Bundle bundle = Platform.getBundle(declaringID); + factoryClass = (Class)bundle.loadClass(className); + } catch (ClassNotFoundException e1) { + throw new BadClassNameException("", "contentoutline", classAttributeName, e1); + } + } + return factoryClass; + } + + /** + * create the outlinepage by calling constructor without parameter and + * then call init method + * + * @return the outline. + * @throws BackboneException + */ + protected IPapyrusContentOutlinePage createContentOutlinePage() throws BackboneException { + try { + IPapyrusContentOutlinePage outline = loadClass().newInstance(); + outline.init(multiEditor); + return outline; + + } catch (SecurityException e) { + // Lets propagate. This is an implementation problem that should + // be solved by programmer. + throw new RuntimeException(e); + } + + catch (InstantiationException e) { + // Lets propagate. This is an implementation problem that should + // be solved by programmer. + // throw new RuntimeException(e); + } catch (IllegalAccessException e) { + // Lets propagate. This is an implementation problem that should + // be solved by programmer. + throw new RuntimeException(e); + } + return null; + } + + } // end class +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/contentoutline/IPapyrusContentOutlinePage.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/contentoutline/IPapyrusContentOutlinePage.java new file mode 100644 index 00000000000..b868f66ae9d --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/contentoutline/IPapyrusContentOutlinePage.java @@ -0,0 +1,34 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.contentoutline; + +import org.eclipse.papyrus.infra.core.editor.BackboneException; +import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; + +/** + * Extends the original interface to add the init method. + */ +public interface IPapyrusContentOutlinePage extends org.eclipse.ui.views.contentoutline.IContentOutlinePage { + + /** + * Init the content outline. + * + * @param multiEditor + * the multiEditor is used to access to the context + * @throws BackboneException + * during research of the associated context. + */ + void init(IMultiDiagramEditor multiEditor) throws BackboneException; + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/BackboneException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/BackboneException.java new file mode 100644 index 00000000000..3dca09296a1 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/BackboneException.java @@ -0,0 +1,71 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.editor; + +/** + * Root of Backbone Exception + * + * @author dumoulin + * + */ +public class BackboneException extends Exception { + + /** + * serial version UID + * + * @generated + */ + private static final long serialVersionUID = 4859634627616979417L; + + /** + * Creates a new BackboneException. + */ + public BackboneException() { + super(); + } + + /** + * Creates a new BackboneException with the specified message. + * + * @param message + * the message of the exception + */ + public BackboneException(String message) { + super(message); + } + + /** + * Creates a new BackboneException with the specified cause. + * + * @param cause + * the cause of the exception + */ + public BackboneException(Throwable cause) { + super(cause); + } + + /** + * Creates a new BackboneException with a specified message and the + * specified cause. + * + * @param message + * the message of the exception + * @param cause + * the cause of the exception + */ + public BackboneException(String arg0, Throwable arg1) { + super(arg0, arg1); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/ContentProviderServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/ContentProviderServiceFactory.java new file mode 100644 index 00000000000..55c11650fa5 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/ContentProviderServiceFactory.java @@ -0,0 +1,64 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.editor; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelMngr; +import org.eclipse.papyrus.infra.core.services.IServiceFactory; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * A service factory to create the {@link ISashWindowsContentProvider} service. + * This service depends on {@link DiSashModelMngrServiceFactory}. + * + * @author cedric dumoulin + * + */ +public class ContentProviderServiceFactory implements IServiceFactory { + + /** + * The sashModelMangr. + */ + private DiSashModelMngr sashModelMngr; + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry) + * + * @param servicesRegistry + * @throws ServiceException + */ + public void init(ServicesRegistry servicesRegistry) throws ServiceException { + // Get required services + sashModelMngr = servicesRegistry.getService(DiSashModelMngr.class); + + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#startService() + * + * @throws ServiceException + */ + public void startService() throws ServiceException { + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#disposeService() + * + * @throws ServiceException + */ + public void disposeService() throws ServiceException { + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IServiceFactory#createServiceInstance() + * + * @return + * @throws ServiceException + */ + public Object createServiceInstance() throws ServiceException { + return sashModelMngr.getISashWindowsContentProvider(); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java new file mode 100644 index 00000000000..7f9e319b187 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java @@ -0,0 +1,809 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.editor; + +import static org.eclipse.papyrus.infra.core.Activator.log; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.commands.operations.IUndoContext; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.edit.domain.IEditingDomainProvider; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gef.ui.actions.ActionRegistry; +import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; +import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain; +import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor; +import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer; +import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart; +import org.eclipse.gmf.runtime.emf.commands.core.command.EditingDomainUndoContext; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.papyrus.infra.core.Activator; +import org.eclipse.papyrus.infra.core.contentoutline.ContentOutlineRegistry; +import org.eclipse.papyrus.infra.core.lifecycleevents.DoSaveEvent; +import org.eclipse.papyrus.infra.core.lifecycleevents.IEditorInputChangedListener; +import org.eclipse.papyrus.infra.core.lifecycleevents.ISaveAndDirtyService; +import org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor.ActionBarContributorRegistry; +import org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor.CoreComposedActionBarContributor; +import org.eclipse.papyrus.infra.core.resource.ModelMultiException; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedListener; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelMngr; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IPageModelFactory; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.TransactionalDiSashModelMngr; +import org.eclipse.papyrus.infra.core.sasheditor.editor.AbstractMultiPageSashEditor; +import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer; +import org.eclipse.papyrus.infra.core.sasheditor.editor.gef.MultiDiagramEditorGefDelegate; +import org.eclipse.papyrus.infra.core.services.ExtensionServicesRegistry; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServiceMultiException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.core.utils.BusinessModelResolver; +import org.eclipse.ui.IEditorActionBarContributor; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IGotoMarker; +import org.eclipse.ui.part.FileEditorInput; +import org.eclipse.ui.views.contentoutline.IContentOutlinePage; +import org.eclipse.ui.views.properties.IPropertySheetPage; +import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor; +import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; + +/** + * Multi diagram editor allowing to plug various kind of editors. Editors are registered with the help of the Eclipse extension mechanism. This + * implementation allows to register editors and context + * separately. An editor should specify which context it need to run. This multi diagram editor allows to show editor side by side in one or more sash + * windows. + * + * The real implementation for the generic type T of SashMultiPageEditorPart is actually di2.Diagram + * + * @author cedric dumoulin + * @author Jerome Benois + * @author Thomas Szadel Refactoring. + * + * TODO : remove GMF dependency ! + */ +public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implements IMultiDiagramEditor, ITabbedPropertySheetPageContributor, IDiagramWorkbenchPart, IGotoMarker { + + /** Gef adapter */ + private MultiDiagramEditorGefDelegate gefAdaptorDelegate; + + /** ContentOutline registry */ + private ContentOutlineRegistry contentOutlineRegistry; + + /** Services registry. Used to get registered services */ + private ServicesRegistry servicesRegistry; + + /** + * ActionBarContributor Registry. Allows to get an ActionBar by its Id. The registry is initialized from the Eclipse extension mechanism. + */ + private ActionBarContributorRegistry actionBarContributorRegistry; + + /** SashModelMngr to add pages */ + protected DiSashModelMngr sashModelMngr; + + /** + * Service used to maintain the dirty state and to perform save and saveAs. + */ + protected ISaveAndDirtyService saveAndDirtyService; + + /** + * Listener on {@link ISaveAndDirtyService#addInputChangedListener(IEditorInputChangedListener)} + */ + protected IEditorInputChangedListener editorInputChangedListener = new IEditorInputChangedListener() { + + /** + * This method is called when the editor input is changed from the ISaveAndDirtyService. + * + * @see org.eclipse.papyrus.infra.core.lifecycleevents.IEditorInputChangedListener#editorInputChanged(org.eclipse.ui.part.FileEditorInput) + * + * @param fileEditorInput + */ + public void editorInputChanged(FileEditorInput fileEditorInput) { + // Change the editor input. + setInputWithNotify(fileEditorInput); + setPartName(fileEditorInput.getName()); + } + + /** + * The isDirty flag has changed, reflect its new value + * + * @see org.eclipse.papyrus.infra.core.lifecycleevents.IEditorInputChangedListener#isDirtyChanged() + * + */ + public void isDirtyChanged() { + + // Run it in async way. + getSite().getShell().getDisplay().asyncExec(new Runnable() { + + public void run() { + firePropertyChange(IEditorPart.PROP_DIRTY); + } + }); + } + }; + + private TransactionalEditingDomain transactionalEditingDomain; + + /** + * Object managing models lifeCycle. + */ + protected ModelSet resourceSet; + + /** + * Cached event that can be reused. + */ + protected DoSaveEvent lifeCycleEvent; + + /** + * + */ + private TabbedPropertySheetPage tabbedPropertySheetPage = null; + + /** + * My editing domain provider. + */ + private IEditingDomainProvider domainProvider = new IEditingDomainProvider() { + + public EditingDomain getEditingDomain() { + return transactionalEditingDomain; + } + }; + + /** + * A listener on model change events. + */ + private IContentChangedListener contentChangedListener = new IContentChangedListener() { + + /** + * Called when the content is changed. RefreshTabs. + */ + public void contentChanged(ContentEvent event) { + refreshTabs(); + } + }; + + /** + * Undo context used to have the same undo context in all Papyrus related views and editors. + * TODO : move away, use a version independent of GMF, add a listener that will add + * the context to all commands modifying attached Resources (==> linked to ModelSet ?) + */ + private EditingDomainUndoContext undoContext; + + /** + * Get the contentOutlineRegistry. Create it if needed. + * + * @return the contentOutlineRegistry + */ + protected ContentOutlineRegistry getContentOutlineRegistry() { + if(contentOutlineRegistry == null) { + createContentOutlineRegistry(); + } + + return contentOutlineRegistry; + } + + /** + * Create the contentOutlineRegistry. + */ + private void createContentOutlineRegistry() { + contentOutlineRegistry = new ContentOutlineRegistry(this, Activator.PLUGIN_ID); + } + + /** + * Returns the service registry associated to the editor. + * + * @return the servicesRegistry The registry. + */ + public ServicesRegistry getServicesRegistry() { + if(servicesRegistry == null) { + servicesRegistry = createServicesRegistry(); + } + return servicesRegistry; + } + + /** + * Create the ServicesRegistry. + * + * @return + */ + private ServicesRegistry createServicesRegistry() { + // Create Services Registry + try { + ServicesRegistry servicesRegistry = new ExtensionServicesRegistry(Activator.PLUGIN_ID); + // servicesRegistry.startRegistry(); + return servicesRegistry; + } catch (ServiceException e) { + // Show log and error + log.error(e.getMessage(), e); + } + return null; + } + + /** + * Do nothing as we create the provider before any calls to this method. + * Should not be called by subclasses. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.AbstractMultiPageSashEditor#createPageProvider() + */ + @Override + protected ISashWindowsContentProvider createPageProvider() { + throw new UnsupportedOperationException("Not implemented. Should not be called as the ContentProvider is already initialized."); + } + + /** + * Create the pageContentProvider. + * + * @param pageFactory + * @param diResource + * Resource used to load/save the SashModel. + */ + protected ISashWindowsContentProvider createPageProvider(IPageModelFactory pageFactory, Resource diResource, TransactionalEditingDomain editingDomain) { + + sashModelMngr = new TransactionalDiSashModelMngr(pageFactory, diResource, editingDomain); + + ISashWindowsContentProvider pageProvider = sashModelMngr.getISashWindowsContentProvider(); + + return pageProvider; + } + + /** + * Get The {@link IPageMngr} used to add, open, remove or close a diagram in the + * SashWindow. + * This method is available as soon as the {@link CoreMultiDiagramEditor#init(IEditorSite, IEditorInput)} method is called. + * + * @return + */ + protected IPageMngr getIPageMngr() throws IllegalStateException { + try { + return sashModelMngr.getIPageMngr(); + } catch (Exception e) { + throw new IllegalStateException("Method should be called after CoreMultiDiagramEditor#init(IEditorSite, IEditorInput) is called"); + } + } + + /** + * Get the ActionBarContributorRegistry. Creates it if necessary. + * + * @return + */ + protected ActionBarContributorRegistry getActionBarContributorRegistry() { + if(actionBarContributorRegistry != null) { + return actionBarContributorRegistry; + } + + // Try to got it from CoreComposedActionBarContributor + // The ActionBarContributorRegistry is initialized by the Contributor. + // Get it from the contributor. + IEditorActionBarContributor contributor = getEditorSite().getActionBarContributor(); + if(contributor instanceof CoreComposedActionBarContributor) { + log.debug(getClass().getSimpleName() + " - ActionBarContributorRegistry loaded from CoreComposedActionBarContributor."); + return ((CoreComposedActionBarContributor)contributor).getActionBarContributorRegistry(); + } else { + // Create a registry. + log.debug(getClass().getSimpleName() + " - create an ActionBarContributorRegistry."); + return createActionBarContributorRegistry(); + } + + } + + /** + * Create the ActionBarContributorRegistry. + * + * @return + */ + private ActionBarContributorRegistry createActionBarContributorRegistry() { + return new ActionBarContributorRegistry(Activator.PLUGIN_ID); + } + + /** + * + * + * @param adapter + * + * @return + */ + @SuppressWarnings("rawtypes") + @Override + public Object getAdapter(Class adapter) { + + if(ServicesRegistry.class == adapter) { + return getServicesRegistry(); + } + + if(IPageMngr.class == adapter) { + return getIPageMngr(); + } + + if(IPropertySheetPage.class == adapter) { + // Do not test if tabbedPropertySheetPage is null before calling new + // this is managed by Eclipse which only call current method when necessary + return getPropertySheetPage(); + } + + // Add a viewer + if(IContentOutlinePage.class == adapter) { + try { + IContentOutlinePage contentOutline = getContentOutlineRegistry().getContentOutline(); + if(contentOutline != null) { + return contentOutline; + } + } catch (BackboneException e) { + // TODO change next exception to more appropriate one + throw new RuntimeException(e); + } + } + + if(EditingDomain.class == adapter) { + return transactionalEditingDomain; + } + + /** + * Return context used for undo/redo. + * All papyrus views should use this context. + */ + if(IUndoContext.class == adapter) { + if(undoContext != null) { + return undoContext; + } + + undoContext = new EditingDomainUndoContext(transactionalEditingDomain); + return undoContext; + } + + // EMF requirements + if(IEditingDomainProvider.class == adapter) { + + // return (IEditingDomainProvider) defaultContext.getTransactionalEditingDomain().getResourceSet(); + return domainProvider; + } + + // GEF diagram requirements + if(adapter == ActionRegistry.class) { + return gefAdaptorDelegate.getActionRegistry(); + } + + // // GEF diagram requirements + // if (adapter == SelectionSynchronizer.class) { + // return gefAdaptorDelegate.getSelectionSynchronizer(); + // } + + // TODO : following code is GMF dependent. It should be moved to adapter + // Do we really need it? Who use it ? + // -> It seems to be needed, see bug 354050 + if(adapter == IDiagramGraphicalViewer.class) { + IEditorPart activeEditor = getActiveEditor(); + if(activeEditor instanceof DiagramEditor) { + return ((DiagramEditor)activeEditor).getDiagramGraphicalViewer(); + } + return null; + } + + return super.getAdapter(adapter); + } + + /** + * Init the editor. + */ + @Override + public void init(IEditorSite site, IEditorInput input) throws PartInitException { + + // Init super + super.init(site, input); + + // Used to get the appropriate domain object from a graphical object (EditPart, ...) + BusinessModelResolver.getInstance(); + + // Load resources + // resourceSet = new DiResourceSet(); + // IFile file = ((IFileEditorInput)input).getFile(); + // resourceSet.loadResources(file); + + // Create the 2 edit domains + // transactionalEditingDomain = resourceSet.getTransactionalEditingDomain(); + + // Create Gef adaptor + gefAdaptorDelegate = new MultiDiagramEditorGefDelegate(); + + + // Create ServicesRegistry and register services + servicesRegistry = createServicesRegistry(); + + // Add itself as a service + servicesRegistry.add(IMultiDiagramEditor.class, 1, this); + + // Create lifeCycle event provider and the event that is used when the editor fire a save event. + // lifeCycleEventsProvider = new LifeCycleEventsProvider(); + // lifeCycleEvent = new DoSaveEvent(servicesRegistry, this); + // servicesRegistry.add(ILifeCycleEventsProvider.class, 1, lifeCycleEventsProvider); + + // register services + servicesRegistry.add(ActionBarContributorRegistry.class, 1, getActionBarContributorRegistry()); + // servicesRegistry.add(TransactionalEditingDomain.class, 1, transactionalEditingDomain); + // servicesRegistry.add(DiResourceSet.class, 1, resourceSet); + + // Create and initalize editor icons service + // PageIconsRegistry pageIconsRegistry = new PageIconsRegistry(); + // PluggableEditorFactoryReader editorReader = new PluggableEditorFactoryReader(Activator.PLUGIN_ID); + // editorReader.populate(pageIconsRegistry); + // servicesRegistry.add(IPageIconsRegistry.class, 1, pageIconsRegistry); + + + // Create PageModelRegistry requested by content provider. + // Also populate it from extensions. + // PageModelFactoryRegistry pageModelRegistry = new PageModelFactoryRegistry(); + // editorReader.populate(pageModelRegistry, servicesRegistry); + + // TODO : create appropriate Resource for the contentProvider, and pass it here. + // This will allow to remove the old sash stuff. + // setContentProvider(createPageProvider(pageModelRegistry, resourceSet.getDiResource(), transactionalEditingDomain)); + // servicesRegistry.add(ISashWindowsContentProvider.class, 1, getContentProvider()); + // servicesRegistry.add(IPageMngr.class, 1, getIPageMngr()); + + // register a basic label provider + // adapter factory used by EMF objects + AdapterFactory factory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); + + /** label provider for EMF objects */ + ILabelProvider labelProvider = new AdapterFactoryLabelProvider(factory) { + + /** + * This implements {@link ILabelProvider}.getText by forwarding it to an object that implements {@link IItemLabelProvider#getText + * IItemLabelProvider.getText} + */ + @Override + public String getText(Object object) { + // Get the adapter from the factory. + // + IItemLabelProvider itemLabelProvider = (IItemLabelProvider)adapterFactory.adapt(object, IItemLabelProvider.class); + if(object instanceof EObject) { + if(((EObject)object).eIsProxy()) { + return "Proxy - " + object; + } + } + return itemLabelProvider != null ? itemLabelProvider.getText(object) : object == null ? "" : object.toString(); + } + }; + servicesRegistry.add(ILabelProvider.class, 1, labelProvider); + + // Start servicesRegistry + IFile file = ((IFileEditorInput)input).getFile(); + try { + // Start the ModelSet first, and load if from the specified File + List> servicesToStart = new ArrayList>(1); + servicesToStart.add(ModelSet.class); + + servicesRegistry.startServicesByClassKeys(servicesToStart); + resourceSet = servicesRegistry.getService(ModelSet.class); + resourceSet.loadModels(file); + + // start remaining services + servicesRegistry.startRegistry(); + } catch (ModelMultiException e) { + log.error(e); + throw new PartInitException("errors in model", e); + } catch (ServiceException e) { + log.error(e); + throw new PartInitException("could not initialize services", e); + } + + + // Get required services + ISashWindowsContentProvider contentProvider = null; + try { + transactionalEditingDomain = servicesRegistry.getService(TransactionalEditingDomain.class); + sashModelMngr = servicesRegistry.getService(DiSashModelMngr.class); + contentProvider = servicesRegistry.getService(ISashWindowsContentProvider.class); + saveAndDirtyService = servicesRegistry.getService(ISaveAndDirtyService.class); + } catch (ServiceException e) { + log.error("A required service is missing.", e); + // if one of the services above fail to start, the editor can't run => stop + throw new PartInitException("could not initialize services", e); + } + + // Set the content provider providing editors. + setContentProvider(contentProvider); + + // Set editor name + setPartName(file.getName()); + + // Listen on contentProvider changes + sashModelMngr.getSashModelContentChangedProvider().addListener(contentChangedListener); + + // Listen on input changed from the ISaveAndDirtyService + saveAndDirtyService.addInputChangedListener(editorInputChangedListener); + } + + /** + * Activate this editor. Called after the SWT.control is created. + */ + @Override + protected void activate() { + // TODO Auto-generated method stub + super.activate(); + initFolderTabMenus(); + + // add page changed listener to sash container to warn page manager + getISashWindowsContainer().addPageChangedListener(getIPageMngr()); + getISashWindowsContainer().addLifeCycleListener(getIPageMngr()); + + try { + // Register ISashWindowsContainer as service + // Should be done only once the container is ready. + getServicesRegistry().add(ISashWindowsContainer.class, 1, getISashWindowsContainer()); + getServicesRegistry().startServicesByClassKeys(ISashWindowsContainer.class); + } catch (ServiceException e) { + log.error(e); + } + } + + @Override + protected void deactivate() { + super.deactivate(); + getISashWindowsContainer().removePageChangedListener(getIPageMngr()); + } + + /** + * Init the contextual menu shown in the folder tabs. + * This popup menu is contributed by the help of Eclipse extensions, using the Commands framework. + * I.e, to add a menu item, create a menu, a command and an handler in the extension. + */ + protected void initFolderTabMenus() { + ISashWindowsContainer container = getISashWindowsContainer(); + + // TODO : use a constant + MenuManager menuManager = new MenuManager("tabmenu"); + menuManager.add(new Separator("tabcommands")); + menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + container.setFolderTabMenuManager(menuManager); + + // TODO : use a constant + getSite().registerContextMenu("org.eclipse.papyrus.infra.core.editor.ui.tabmenu", menuManager, getSite().getSelectionProvider()); + + } + + /** + * Overrides getPropertySheetPage. + * + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor#getPropertySheetPage() + */ + public IPropertySheetPage getPropertySheetPage() { + if(this.tabbedPropertySheetPage == null) { + this.tabbedPropertySheetPage = new TabbedPropertySheetPage(this); + } + return tabbedPropertySheetPage; + } + + /** + * @see org.eclipse.papyrus.infra.core.sasheditor.editor.AbstractMultiPageSashEditor#dispose() + * + */ + @Override + public void dispose() { + if(sashModelMngr != null) { + sashModelMngr.getSashModelContentChangedProvider().removeListener(contentChangedListener); + } + + // Avoid memory leak + if(resourceSet != null) { + resourceSet.unload(); + } + + // dispose available service + if(servicesRegistry != null) { + try { + servicesRegistry.disposeRegistry(); + } catch (ServiceMultiException e) { + log.error(e); + } + } + + super.dispose(); + } + + /** + * Overrides doSave. + * + * {@inheritDoc} + * + * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void doSave(IProgressMonitor monitor) { + + saveAndDirtyService.doSave(monitor); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isDirty() { + return saveAndDirtyService.isDirty(); + } + + /** + * Overrides doSaveAs. + * + * {@inheritDoc} + * + * @see org.eclipse.ui.part.EditorPart#doSaveAs() + */ + @Override + public void doSaveAs() { + + saveAndDirtyService.doSaveAs(); + } + + /** + * Overrides isSaveAsAllowed. + * + * {@inheritDoc} + * + * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed() + */ + @Override + public boolean isSaveAsAllowed() { + return true; + } + + /** + * Overrides getContributorId. + * + * {@inheritDoc} + * + * @see org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor#getContributorId() + */ + public String getContributorId() { + // return Activator.PLUGIN_ID; + return "TreeOutlinePage"; + + } + + // implements IDiagramWorkbenchPart to restore GMF standard behavior + // and delegate to the activeEditor + + /** + * Overrides getDiagram. + * + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart#getDiagram() + */ + public org.eclipse.gmf.runtime.notation.Diagram getDiagram() { + IEditorPart activeEditor = getActiveEditor(); + if(activeEditor instanceof DiagramEditor) { + return ((DiagramEditor)activeEditor).getDiagram(); + } else { + return null; + } + } + + /** + * This method is called from a GMF diagram. It should only be called from GMF diagram code. Normally, the Diagram under the Mouse is a GMF + * Diagram. The active Diagram can be another Diagram, not + * under the mouse. This is a GMF issue. + */ + public DiagramEditPart getDiagramEditPart() { + + // Get the editor under the mouse + // IEditorPart activeEditor = rootContainer.getEditorUnderMouse(); + IEditorPart activeEditor = getActiveEditor(); + if(activeEditor == null) { + return null; + } + // IEditorPart activeEditor = getActiveEditor(); + if(activeEditor instanceof DiagramEditor) { + return ((DiagramEditor)activeEditor).getDiagramEditPart(); + } else { + // This case should never happen. + // Return null, as the GMF runtime now support it (since 093009) + return null; + } + } + + /** + * Overrides getDiagramGraphicalViewer. + * + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart#getDiagramGraphicalViewer() + */ + public IDiagramGraphicalViewer getDiagramGraphicalViewer() { + IEditorPart activeEditor = getActiveEditor(); + if(activeEditor instanceof DiagramEditor) { + return ((DiagramEditor)activeEditor).getDiagramGraphicalViewer(); + } else { + return null; + } + } + + /** + * Overrides getEditingDomain. + * + * {@inheritDoc} + * + * @see org.eclipse.emf.edit.domain.IEditingDomainProvider#getEditingDomain() + */ + public EditingDomain getEditingDomain() { + return transactionalEditingDomain; + } + + /** + * Throws an UnsupportedOperationException. + * + * @see org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor#getDiagramEditDomain() + */ + public DiagramEditDomain getDiagramEditDomain() { + throw new UnsupportedOperationException("Not implemented. Should not be called."); + } + + + /** + * Change the editor input.
+ * Note: that method should be called within the UI-Thread. + * + * @see org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor#setEditorInput(org.eclipse.ui.IEditorInput) + * + * @param newInput + * The new input + * @deprecated Not used anymore + */ + + @Deprecated + public void setEditorInput(IEditorInput newInput) { + setInputWithNotify(newInput); + setPartName(newInput.getName()); + } + + public void gotoMarker(IMarker marker) { + IWorkbench wb = PlatformUI.getWorkbench(); + IWorkbenchPage page = wb.getActiveWorkbenchWindow().getActivePage(); + for(IViewReference view : page.getViewReferences()) { + if(view.getId().equals("org.eclipse.papyrus.views.modelexplorer.modelexplorer")) { + page.activate(view.getPart(false)); + IWorkbenchPart part = view.getPart(false); + if(part instanceof IGotoMarker) { + ((IGotoMarker)part).gotoMarker(marker); + } + } + } + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/DiResourceSetServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/DiResourceSetServiceFactory.java new file mode 100644 index 00000000000..de316a87c6a --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/DiResourceSetServiceFactory.java @@ -0,0 +1,63 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.editor; + +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.services.IServiceFactory; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * A service factory to create the {@link ModelSet} service. This provide a + * nickname for {@link ModelSet} service. This serviceFactory depends on {@link ModelSet} service. + * + * @author cedric dumoulin + * + */ +public class DiResourceSetServiceFactory implements IServiceFactory { + + /** + * The sashModelMangr. + */ + private ModelSet modelSet; + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry) + * + * @param servicesRegistry + * @throws ServiceException + */ + public void init(ServicesRegistry servicesRegistry) throws ServiceException { + // Get required services + modelSet = servicesRegistry.getService(ModelSet.class); + + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#startService() + * + * @throws ServiceException + */ + public void startService() throws ServiceException { + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#disposeService() + * + * @throws ServiceException + */ + public void disposeService() throws ServiceException { + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IServiceFactory#createServiceInstance() + * + * @return + * @throws ServiceException + */ + public Object createServiceInstance() throws ServiceException { + return modelSet; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/DiSashModelMngrServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/DiSashModelMngrServiceFactory.java new file mode 100644 index 00000000000..ce4eca6eda3 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/DiSashModelMngrServiceFactory.java @@ -0,0 +1,97 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.editor; + +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.infra.core.Activator; +import org.eclipse.papyrus.infra.core.editorsfactory.PageModelFactoryRegistry; +import org.eclipse.papyrus.infra.core.extension.diagrameditor.PluggableEditorFactoryReader; +import org.eclipse.papyrus.infra.core.resource.sasheditor.SashModel; +import org.eclipse.papyrus.infra.core.resource.sasheditor.SashModelUtils; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelMngr; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.TransactionalDiSashModelMngr; +import org.eclipse.papyrus.infra.core.services.IServiceFactory; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * Service Factory to create the {@link DiSashModelMngr} service. + * + * @author cedric dumoulin + * + */ +public class DiSashModelMngrServiceFactory implements IServiceFactory { + + private TransactionalEditingDomain transactionalEditingDomain; + + private SashModel sashModel; + + private TransactionalDiSashModelMngr sashModelMngr; + + private ServicesRegistry servicesRegistry; + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry) + * + * @param servicesRegistry + * @throws ServiceException + */ + public void init(ServicesRegistry servicesRegistry) throws ServiceException { + + this.servicesRegistry = servicesRegistry; + // Get required service + transactionalEditingDomain = servicesRegistry.getService(TransactionalEditingDomain.class); + + // Get the model holding the contentProvider + sashModel = SashModelUtils.getSashModelChecked(servicesRegistry); + + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#startService() + * + * @throws ServiceException + */ + public void startService() throws ServiceException { + + // Read declared editors + PageModelFactoryRegistry pageModelRegistry = new PageModelFactoryRegistry(); + PluggableEditorFactoryReader editorReader = new PluggableEditorFactoryReader(Activator.PLUGIN_ID); + editorReader.populate(pageModelRegistry, servicesRegistry); + + if(sashModel.getResource() == null) + throw new ServiceException("Can't start " + this.getClass().getSimpleName() + "'. Required model (SashModel) should be loaded prior starting the service."); + + // create the service + sashModelMngr = new TransactionalDiSashModelMngr(pageModelRegistry, sashModel.getResource(), transactionalEditingDomain); + + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#disposeService() + * + * @throws ServiceException + */ + public void disposeService() throws ServiceException { + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IServiceFactory#createServiceInstance() + * + * @return + * @throws ServiceException + */ + public Object createServiceInstance() throws ServiceException { + + // Start locally the service if needed. + // Question: Can createServiceInstance() method be called before + // startService() is called ? + if(sashModelMngr == null) { + startService(); + } + + return sashModelMngr; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/IMultiDiagramEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/IMultiDiagramEditor.java new file mode 100644 index 00000000000..680f442df14 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/IMultiDiagramEditor.java @@ -0,0 +1,91 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.editor; + +import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.views.properties.IPropertySheetPage; + +/** + * Interface implemented by the main multipage editor. This interface list the + * methods available to diagram editors. Diagram editors can relies on this + * interface to retrieve services from the main multi diagram editor.
+ * This interface should stay minimalist, as the editor is not designed to + * handle the services itself. A service should be retrieved by using {@link #getServicesRegistry()}. + * + * + * @author cedric dumoulin + * + * TODO remove extends IEditingDomainProvider. This interface should be + * independant of any technology (EMF, GMF, ...). If the EditingDomain + * is required, it can be retrieved by the registry. + * + */ +public interface IMultiDiagramEditor extends IEditorPart { + + /** + * Returns the service registry associated to the editor. + * + * @return the servicesRegistry The registry. + */ + public ServicesRegistry getServicesRegistry(); + + /** + * Return the editor site. + * + * @return + */ + public IEditorSite getEditorSite(); + + /** + * Get the editor input. + * + * @return + */ + public IEditorInput getEditorInput(); + + /** + * Change the editor input. + * + * @param newInput + * The new input. + * @deprecated No replacement. Input can't be changed on multi editors. + */ + public void setEditorInput(IEditorInput newInput); + + /** + * Returns the edit domain shared among editors + * + * @return the edit domain shared among editors + * @deprecated Use {@link #getServicesRegistry()} or {@link #getAdapter(Class)} + */ + // FIXME Remove it (GMF dependency) + public DiagramEditDomain getDiagramEditDomain(); + + /** + * Get the currently active nested Editor. + */ + public IEditorPart getActiveEditor(); + + /** + * Get the property sheet page associated to the Editor. + * + * @return the property sheet page associated to the Editor. + * @deprecated Use {@link #getServicesRegistry()} or {@link #getAdapter(Class)} + */ + public IPropertySheetPage getPropertySheetPage(); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/ModelSetServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/ModelSetServiceFactory.java new file mode 100644 index 00000000000..5da0ca92d53 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/ModelSetServiceFactory.java @@ -0,0 +1,64 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.editor; + +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.services.IServiceFactory; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.core.utils.DiResourceSet; + +/** + * A service starting the ModelSet + * + * @author cedric dumoulin + * + */ +public class ModelSetServiceFactory implements IServiceFactory { + + /** The ModelSet */ + private ModelSet service; + + /** + * + * @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry) + * + * @param servicesRegistry + * @throws ServiceException + */ + public void init(ServicesRegistry servicesRegistry) throws ServiceException { + + } + + /** + * + * @see org.eclipse.papyrus.infra.core.services.IService#startService() + * + * @throws ServiceException + */ + public void startService() throws ServiceException { + } + + /** + * + * @see org.eclipse.papyrus.infra.core.services.IService#disposeService() + * + * @throws ServiceException + */ + public void disposeService() throws ServiceException { + if(service != null) + service.unload(); + } + + /** + * Create the service served by this factory. + */ + public Object createServiceInstance() { + // Return a DiResourceSet for backward compatibility + // TODO return a ModelSet once DiResourceSet is removed + service = new DiResourceSet(); + return service; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/PageIconRegistryServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/PageIconRegistryServiceFactory.java new file mode 100644 index 00000000000..c1ea2425977 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/PageIconRegistryServiceFactory.java @@ -0,0 +1,65 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.editor; + +import org.eclipse.papyrus.infra.core.Activator; +import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry; +import org.eclipse.papyrus.infra.core.editorsfactory.PageIconsRegistry; +import org.eclipse.papyrus.infra.core.extension.diagrameditor.PluggableEditorFactoryReader; +import org.eclipse.papyrus.infra.core.services.IServiceFactory; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * Service Factory to register {@link IPageIconsRegistry}. + * + * @author cedric dumoulin + * + */ +public class PageIconRegistryServiceFactory implements IServiceFactory { + + private PageIconsRegistry pageIconsRegistry; + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry) + * + * @param servicesRegistry + * @throws ServiceException + */ + public void init(ServicesRegistry servicesRegistry) throws ServiceException { + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#startService() + * + * @throws ServiceException + */ + public void startService() throws ServiceException { + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#disposeService() + * + * @throws ServiceException + */ + public void disposeService() throws ServiceException { + + } + + /** + * Create and populate a {@link PageIconsRegistry}. Return it as the service + * instance. + * + * @return + */ + public Object createServiceInstance() { + if(pageIconsRegistry == null) { + pageIconsRegistry = new PageIconsRegistry(); + PluggableEditorFactoryReader editorReader = new PluggableEditorFactoryReader(Activator.PLUGIN_ID); + editorReader.populate(pageIconsRegistry); + } + return pageIconsRegistry; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/PageMngrServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/PageMngrServiceFactory.java new file mode 100644 index 00000000000..5e9873d34b6 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/PageMngrServiceFactory.java @@ -0,0 +1,65 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.editor; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelMngr; +import org.eclipse.papyrus.infra.core.services.IServiceFactory; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * A service factory to create the {@link IPageMngr} service. This + * serviceFactory depends on {@link ISashWindowsContentProvider} service. + * + * @author cedric dumoulin + * + */ +public class PageMngrServiceFactory implements IServiceFactory { + + /** + * The sashModelMangr. + */ + private DiSashModelMngr sashModelMngr; + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry) + * + * @param servicesRegistry + * @throws ServiceException + */ + public void init(ServicesRegistry servicesRegistry) throws ServiceException { + + // Get required services + sashModelMngr = servicesRegistry.getService(DiSashModelMngr.class); + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#startService() + * + * @throws ServiceException + */ + public void startService() throws ServiceException { + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#disposeService() + * + * @throws ServiceException + */ + public void disposeService() throws ServiceException { + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IServiceFactory#createServiceInstance() + * + * @return + * @throws ServiceException + */ + public Object createServiceInstance() throws ServiceException { + return sashModelMngr.getIPageMngr(); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IEditorFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IEditorFactory.java new file mode 100644 index 00000000000..dac3a481c3a --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IEditorFactory.java @@ -0,0 +1,39 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.editorsfactory; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; + +/** + * Factory used to get the Icon associated to the editor used to render the + * specified pageIdentifier. + * + * + * @author cedric dumoulin + * + */ +public interface IEditorFactory { + + /** + * Create the {@link IPageModel} for the specified identifier. TODO throw an + * exception encapsulating problems encountered while creating the model. + * + * @param pageIdentifier + * Object identifying an Editor. + * @return PageModel allowing to create the editor. + */ + public IPageModel createIPageModel(Object pageIdentifier); + + /** + * Return true if the factory can create an IPageModel for the specified + * pageIdentifier. Return false otherwise TODO throw an exception + * encapsulating problems encountered while creating the model. + * + * @param pageIdentifier + * The object representing the page to test + * @return + */ + public boolean isPageModelFactoryFor(Object pageIdentifier); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IEditorIconFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IEditorIconFactory.java new file mode 100644 index 00000000000..924eb87e744 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IEditorIconFactory.java @@ -0,0 +1,59 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.editorsfactory; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelMngr; +import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer; +import org.eclipse.swt.graphics.Image; + +/** + * Factory used to create an {@link IPageModel} used by the {@link ISashWindowsContainer} to create an instance of the editor represented + * by the provided Object. Such factory is required by the {@link DiSashModelMngr}. It is called whenever the ISashWindowsContainer need + * to create an editor from an EObject representing this editor in the Di + * implementation of the {@link ISashWindowsContentProvider} + * + * + * @author cedric dumoulin + * + */ +public interface IEditorIconFactory { + + /** + * Get the icon associated to the editor used to render the model. Model + * represent the top level object of a model editor. Can return a cached + * Image. + * + * @param pageIdentifier + * the pageIdentifier representing the Editor. This is usually + * the EObject used to reconstruct the editor. + * @return the icon representing the editor + */ + public Image getEditorIcon(Object pageIdentifier); + + /** + * Create the icon associated to the editor used to render the model. Model + * represent the top level object of a model editor. Always return a newly + * created Image. + * + * @param pageIdentifier + * the pageIdentifier representing the Editor. This is usually + * the EObject used to reconstruct the editor. + * @return the icon representing the editor + */ + public Image createEditorIcon(Object pageIdentifier); + + /** + * Return true if the factory can create an IPageModel for the specified + * pageIdentifier. Return false otherwise TODO throw an exception + * encapsulating problems encountered while creating the model. + * + * @param pageIdentifier + * The object representing the page to test + * @return + */ + public boolean isPageModelFactoryFor(Object pageIdentifier); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IEditorIconFactoryExtended.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IEditorIconFactoryExtended.java new file mode 100644 index 00000000000..33055f5f15e --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IEditorIconFactoryExtended.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2011 Atos. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Atos - Initial API and implementation + * + */ +package org.eclipse.papyrus.infra.core.editorsfactory; + +/** + * + * @author "Arthur Daussy arthur.daussy@atos.net" + * + */ +public interface IEditorIconFactoryExtended extends IEditorIconFactory { + + /** + * Return the icon URL associated to the editor used to render the model. Model represent the top level + * object of a model editor. + * + * @param pageIdentifier + * @return + */ + public String getURLMainIcon(Object pageIdentifier); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IPageIconsRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IPageIconsRegistry.java new file mode 100644 index 00000000000..6ecbb0b0c78 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IPageIconsRegistry.java @@ -0,0 +1,35 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.editorsfactory; + +import org.eclipse.swt.graphics.Image; + +/** + * Registry used to get Icons associated to an editor. + * + * @author cedric dumoulin + */ +public interface IPageIconsRegistry { + + /** + * Get the icon associated to the editor used to render the model. Model + * represent the top level object of a model editor. + * + * @param model + * the model representing the Editor. This is usually the EObject + * used to reconstruct the editor. + * @return the icon representing the editor + */ + public Image getEditorIcon(Object model); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IPageIconsRegistryExtended.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IPageIconsRegistryExtended.java new file mode 100644 index 00000000000..fadf389f752 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/IPageIconsRegistryExtended.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2011 Atos Origin. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Atos Origin - Initial API and implementation + * + */ +package org.eclipse.papyrus.infra.core.editorsfactory; + +/** + * Extends IPageIconsRegistry in order to offer a second methods which will give back the URL of the requested Icon + * + * @author "Arthur Daussy arthur.daussy@atos.net" + * + */ +public interface IPageIconsRegistryExtended extends IPageIconsRegistry { + + /** + * Get the URL icon associated to the editor used to render the model. Model represent the top level + * object of a model editor. + * + * @param model + * @return {@link String} which represent the URL of the resource + */ + public String getEditorURLIcon(Object model); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/PageIconsRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/PageIconsRegistry.java new file mode 100644 index 00000000000..85a107f965e --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/PageIconsRegistry.java @@ -0,0 +1,108 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.editorsfactory; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.swt.graphics.Image; + +/** + * Concrete implementation of the {@link IPageIconsRegistry}. This + * implementation allows to add and remove {@link IPageIconsRegistry}. + * + * + * @author cedric dumoulin + */ +public class PageIconsRegistry implements IPageIconsRegistryExtended { + + /** list of registered icon factories */ + protected List pageIcons = new ArrayList(); + + /** + * Constructor. + * + * @param editorFactoryRegistry + * @param servicesRegistry + */ + public PageIconsRegistry() { + + } + + /** + * Walk each registered {@link IEditorFactory} to find the one handling the + * specified pageIdentifier. Call the corresponding method in the found + * pageIdentifier. + * + * TODO Throw an exception to report errors. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IPageModelFactory#createIPageModel(java.lang.Object) + */ + public Image getEditorIcon(Object pageIdentifier) { + + for(IEditorIconFactory factory : getPageIcons()) { + if(factory.isPageModelFactoryFor(pageIdentifier)) { + { + // return factory.getEditorIcon(pageIdentifier); + return factory.createEditorIcon(pageIdentifier); + } + } + } + // no editor found ! + // TODO Throw an exception. + // throw new EditorNotFoundException("No editor registered for '" + + // pageIdentifier + "'."); + return null; + } + + /** + * @return the editorFactories + */ + protected List getPageIcons() { + return pageIcons; + } + + /** + * Add the specified {@link IEditorFactory} + * + * @param editorIconFactory + */ + public void add(IEditorIconFactory editorIconFactory) { + // This should never happen + if(editorIconFactory == null) + throw new RuntimeException("Parameter should not be null."); + + pageIcons.add(editorIconFactory); + } + + /** + * Remove the specified {@link IEditorFactory} + * + * @param editorIconFactory + */ + public void remove(IEditorIconFactory editorIconFactory) { + pageIcons.remove(editorIconFactory); + } + + /** + * Return the path to the icon ressource. + * + * @see org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistryExtended#getEditorURLIcon(java.lang.Object) + * + * @param model + * @return + */ + public String getEditorURLIcon(Object model) { + for(IEditorIconFactory factory : getPageIcons()) { + if(factory.isPageModelFactoryFor(model)) { + { + if ( factory instanceof IEditorIconFactoryExtended){ + return ((IEditorIconFactoryExtended)factory).getURLMainIcon(model); + } + } + } + } + return ""; + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/PageModelFactoryRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/PageModelFactoryRegistry.java new file mode 100644 index 00000000000..80316506272 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editorsfactory/PageModelFactoryRegistry.java @@ -0,0 +1,89 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.editorsfactory; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IPageModelFactory; + +/** + * Concrete implementation of the {@link IPageModelFactory} required by the di + * implementation of {@link ISashWindowsContentProvider}. This implementation + * allows to add and remove {@link IEditorFactory}. + * + * + * @author cedric dumoulin + */ +public class PageModelFactoryRegistry implements IPageModelFactory { + + /** list of editor factories */ + protected List editorFactories = new ArrayList(); + + /** + * Constructor. + * + * @param editorFactoryRegistry + * @param servicesRegistry + */ + public PageModelFactoryRegistry() { + + } + + /** + * Walk each registered {@link IEditorFactory} to find the one handling the + * specified pageIdentifier. Call the corresponding method in the found + * pageIdentifier. + * + * TODO Throw an exception to report errors. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IPageModelFactory#createIPageModel(java.lang.Object) + */ + public IPageModel createIPageModel(Object pageIdentifier) { + + for(IEditorFactory factory : getEditorFactories()) { + if(factory.isPageModelFactoryFor(pageIdentifier)) { + { + return factory.createIPageModel(pageIdentifier); + } + } + } + // no editor found ! + // TODO Throw an exception. + // throw new EditorNotFoundException("No editor registered for '" + + // pageIdentifier + "'."); + return null; + } + + /** + * @return the editorFactories + */ + protected List getEditorFactories() { + return editorFactories; + } + + /** + * Add the specified {@link IEditorFactory} + * + * @param editorFactory + */ + public void add(IEditorFactory editorFactory) { + // This should never happen + if(editorFactory == null) + throw new RuntimeException("Parameter should not be null."); + + editorFactories.add(editorFactory); + } + + /** + * Remove the specified {@link IEditorFactory} + * + * @param editorFactory + */ + public void remove(IEditorFactory editorFactory) { + editorFactories.remove(editorFactory); + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/BadClassNameException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/BadClassNameException.java new file mode 100644 index 00000000000..4edf1dd041f --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/BadClassNameException.java @@ -0,0 +1,86 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension; + +import org.eclipse.core.runtime.IConfigurationElement; + +/** + * Exception thrown as an extension point is parsed at runtime. More accurately, + * it is thrown when one attribute of an extension point that should describe a + * class name does not correspond to a class in the classpath. + * + * @author Cedric Dumoulin + * @author Patrick Tessier + * @author schnekenburger + */ +public class BadClassNameException extends ExtensionException { + + /** + * the name of{@link IConfigurationElement} that is bad build + */ + private String iconfigurationElementName; + + /** + * the name of the attribute of the {@link IConfigurationElement} + */ + private String attributeName; + + private Exception e = null; + + /** + * serial version UID + * + * @generated + */ + private static final long serialVersionUID = 1161426240944647521L; + + /** + * constructor with an exception + * + * @param element + * the IConfigurationElement that raised the error + * @param attributeName + * the bad construct attibute + * @param e + * the associated exception + */ + public BadClassNameException(String msg, String iConfigurationElementName, String attributeName, final Exception e) { + super(msg); + this.iconfigurationElementName = iConfigurationElementName; + this.attributeName = attributeName; + this.e = e; + } + + /** + * constructor without an exception + * + * @param element + * the IConfigurationElement that raised the error + * @param attributeName + * the bad construct attibute + */ + public BadClassNameException(String msg, String iConfigurationElementName, String attributeName) { + super(msg); + this.iconfigurationElementName = iConfigurationElementName; + this.attributeName = attributeName; + } + + /** + * + * {@inheritDoc} + */ + public String toString() { + return super.toString() + " for the extension point " + iconfigurationElementName + "." + attributeName + " " + e; + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/BadNameExtensionException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/BadNameExtensionException.java new file mode 100644 index 00000000000..fc7003dfb04 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/BadNameExtensionException.java @@ -0,0 +1,70 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension; + +/** + * Exception thrown when a bad name is encountered in extension processing. + * + * @author dumoulin + * @author schnekenburger + */ +public class BadNameExtensionException extends ExtensionException { + + /** + * serial version UID + * + * @generated + */ + private static final long serialVersionUID = -2063118856033217385L; + + /** + * Creates a simple BadNameExtensionException + */ + public BadNameExtensionException() { + } + + /** + * Creates a BadNameExtensionException with a specific message. + * + * @param message + * the message of the exception + */ + public BadNameExtensionException(String message) { + super(message); + } + + /** + * Creates a BadNameExtensionException with a specific cause. + * + * @param cause + * the cause of the exception + */ + public BadNameExtensionException(Throwable cause) { + super(cause); + } + + /** + * Creates a BadNameExtensionException with a specific cause and a specific + * message. + * + * @param message + * the message of the exception + * @param cause + * the cause of the exception + */ + public BadNameExtensionException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/ExtensionException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/ExtensionException.java new file mode 100644 index 00000000000..98e425642c8 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/ExtensionException.java @@ -0,0 +1,86 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.papyrus.infra.core.editor.BackboneException; + +/** + * Base class for extension exceptions + * + * @author dumoulin + * @author schnekenburger + */ +public class ExtensionException extends BackboneException { + + /** + * serial version UID + * + * @generated + */ + private static final long serialVersionUID = -9144153309491137046L; + + /** + * Creates a simple ExtensionException. + */ + public ExtensionException() { + } + + /** + * Creates a ExtensionException with a specific message. + * + * @param message + * the message of the exception + */ + public ExtensionException(String message) { + super(message); + } + + /** + * Creates a ExtensionException with a specific cause. + * + * @param cause + * the cause of the exception + */ + public ExtensionException(Throwable cause) { + super(cause); + + } + + /** + * Creates a ExtensionException with a specific cause and a specific + * message. + * + * @param message + * the message of the exception + * @param cause + * the cause of the exception + */ + public ExtensionException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Return the name of the plugin and extension declaring the extension. + * + * @param element + * the configuration element corresponding to the extension + * @return a string containing the name of the plugin and the name of the + * extension + */ + protected static String declaringExtensionToString(IConfigurationElement element) { + return "plugin:" + element.getContributor().getName() + " extension:" + element.getName(); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/ExtensionUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/ExtensionUtils.java new file mode 100644 index 00000000000..36abff9c502 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/ExtensionUtils.java @@ -0,0 +1,92 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.InvalidRegistryObjectException; +import org.eclipse.core.runtime.Platform; +import org.osgi.framework.Bundle; + +/** + * Utility methods for Eclipse extension reading. This class can be extended, or + * access throw the unique instance. + * + * @author cedric dumoulin + * @author Patrick Tessier + */ +public abstract class ExtensionUtils { + + /** + * Unique instance that can be used directly. + */ + static public ExtensionUtils INSTANCE = new ExtensionUtils() { + }; + + /** + * used to verify if the name of the {@link IConfigurationElement} is the + * same as the given name + * + * @param element + * an {@link IConfigurationElement} see eclipse extension point + * @param tagName + * the name of the {@link IConfigurationElement} that has to be + * verified + * @throws InvalidRegistryObjectException + * @throws BadNameExtensionException + */ + protected void checkTagName(IConfigurationElement element, String tagName) throws BadNameExtensionException { + String name = element.getName(); + if(!tagName.equals(name)) + throw new BadNameExtensionException("Expected '" + tagName + "', found '" + name + "'."); + } + + /** + * Retrieves the value of a specific attribute in a configuration element + * + * @param element + * the configuration element to parse + * @param attributeName + * the name of the attribute to read + * @param extensionPointName + * Name of the extension point. Used in exception msg. TODO: + * remove ? + * + * @return the class, result of the parsing + * @throws InvalidRegistryObjectException + * @throws BadClassNameException + */ + protected Class parseClass(IConfigurationElement element, String attributeName, String extensionPointName) throws BadClassNameException { + String className = element.getAttribute(attributeName); + + element.getContributor().getName(); + if(className == null || className.length() == 0) { + throw new BadClassNameException(attributeName + "=null ", extensionPointName, attributeName); + } + Class factoryClass; + try { + factoryClass = Class.forName(className); + } catch (ClassNotFoundException e) { + // try another way + try { + String declaringID = element.getContributor().getName(); + Bundle bundle = Platform.getBundle(declaringID); + factoryClass = bundle.loadClass(className); + } catch (ClassNotFoundException e1) { + throw new BadClassNameException(className + " can not be loaded ", extensionPointName, attributeName, e1); + } + } + return factoryClass; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/NotFoundException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/NotFoundException.java new file mode 100644 index 00000000000..7f339dbf10f --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/NotFoundException.java @@ -0,0 +1,70 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension; + +/** + * Exception thrown when something is not found when parsing a configuration + * element. + * + * @author dumoulin + * @author schnekenburger + */ +public class NotFoundException extends ExtensionException { + + /** + * serial version UID + * + * @generated + */ + private static final long serialVersionUID = -130754574538610199L; + + /** + * Creates a simple NotFoundException. + */ + public NotFoundException() { + } + + /** + * Creates a NotFoundException with a specific message. + * + * @param message + * the message of the exception + */ + public NotFoundException(String message) { + super(message); + } + + /** + * Creates a NotFoundException with a specific cause. + * + * @param cause + * the cause of the exception + */ + public NotFoundException(Throwable cause) { + super(cause); + } + + /** + * Creates a NotFoundException with a specific cause and a specific message. + * + * @param message + * the message of the exception + * @param cause + * the cause of the exception + */ + public NotFoundException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/CreationCommandDescriptor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/CreationCommandDescriptor.java new file mode 100644 index 00000000000..7b855753e49 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/CreationCommandDescriptor.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2008 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: + * Jerome Benois (Obeo) jerome.benois@obeo.fr - initial API and implementation + * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - add condition to the create command (task #296902) + *******************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.commands; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.papyrus.infra.core.editor.BackboneException; + +/** + * Creation Command Descriptor used to create a new diagram + * + * @author Jerome Benois + */ +public class CreationCommandDescriptor { + + protected Class creationCommandClass; + + protected String commandId; + + protected String label; + + protected ImageDescriptor icon; + + protected String language; + + private ICreationCondition condition; + + public String getCommandId() { + return commandId; + } + + public String getLabel() { + return label; + } + + public ImageDescriptor getIcon() { + return icon; + } + + public String getLanguage() { + return language; + } + + public ICreationCondition getCondition() { + return condition; + } + + public void setCondition(ICreationCondition condition) { + this.condition = condition; + condition.setCommand(getCommandId()); + + } + + /** + * Instance is created when requested. + */ + protected ICreationCommand instance = null; + + /** + * constructor. + * + * @return the creation command + * @throws BackboneException + */ + public ICreationCommand getCommand() throws BackboneException { + if(instance == null) + instance = createCommand(); + + return instance; + } + + private ICreationCommand createCommand() throws BackboneException { + try { + ICreationCommand command = creationCommandClass.newInstance(); + return command; + } catch (SecurityException e) { + // Lets propagate. This is an implementation problem that should be + // solved by + // programmer. + throw new RuntimeException(e); + } catch (InstantiationException e) { + // Lets propagate. This is an implementation problem that should be + // solved by + // programmer. + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + // Lets propagate. This is an implementation problem that should be + // solved by + // programmer. + throw new RuntimeException(e); + } + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/CreationCommandExtensionFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/CreationCommandExtensionFactory.java new file mode 100644 index 00000000000..4a1dda77365 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/CreationCommandExtensionFactory.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * Copyright (c) 2008 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: + * Jerome Benois (Obeo) jerome.benois@obeo.fr - initial API and implementation + * Tristan Faure (Atos Origin) tristan.faure@atosorigin.com - add condition to the create command (task #296902) + *******************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.commands; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.papyrus.infra.core.extension.BadNameExtensionException; +import org.eclipse.papyrus.infra.core.extension.ExtensionException; +import org.eclipse.papyrus.infra.core.extension.ExtensionUtils; +import org.eclipse.papyrus.infra.core.utils.IDebugChannel; +import org.eclipse.papyrus.infra.core.utils.PapyrusTrace; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +/** + * A factory used to create CreationCommand object from Eclipse extensions + * points elements. + * + * @author Jerome Benois + */ +public class CreationCommandExtensionFactory extends ExtensionUtils { + + /** singleton eINSTANCE of this class */ + public final static CreationCommandExtensionFactory eINSTANCE = new CreationCommandExtensionFactory(); + + /** constant for the creation command **/ + public final static String CREATION_COMMAND_EXTENSIONPOINT = "creationCommand"; + + /** constant for the attribute creationCommandClass **/ + public final static String CREATION_COMMAND_CLASS_ATTR = "creationCommandClass"; + + /** constant for the attribute creationCommandClass **/ + public final static String CONDITION_COMMAND_CLASS_ATTR = "creationCondition"; + + /** constant for the attribute label **/ + public final static String LABEL_ATTR = "label"; + + /** constant for the attribute contextId **/ + public final static String ID_ATTRIBUTE = "id"; + + /** constant for the attribute icon **/ + public final static String ICON_ATTR = "icon"; + + /** constant for the attribute language **/ + public final static String LANGUAGE_ATTR = "language"; + + /** + * @return the eINSTANCE + */ + public static CreationCommandExtensionFactory getInstance() { + return eINSTANCE; + } + + /** + * Create a CreationCommand instance corresponding to the + * ConfigurationElement. + * + * @param element + * an {@link IConfigurationElement} see eclipse extension point + * @return a CreationCommandDescriptor structure that contains information + * to the creation diagram command + * @throws BadNameExtensionException + **/ + public CreationCommandDescriptor createCreationCommand(IConfigurationElement element) throws ExtensionException { + CreationCommandDescriptor res; + checkTagName(element, CREATION_COMMAND_EXTENSIONPOINT); + res = new CreationCommandDescriptor(); + res.creationCommandClass = (Class)parseClass(element, CREATION_COMMAND_CLASS_ATTR, CREATION_COMMAND_EXTENSIONPOINT); + res.commandId = element.getAttribute(ID_ATTRIBUTE); + res.label = element.getAttribute(LABEL_ATTR); + res.language = element.getAttribute(LANGUAGE_ATTR); + String iconPath = element.getAttribute(ICON_ATTR); + if(iconPath != null) { + res.icon = AbstractUIPlugin.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), iconPath); + } + String attributeForCreationCondition = element.getAttribute(CONDITION_COMMAND_CLASS_ATTR); + if(attributeForCreationCondition != null && attributeForCreationCondition.length() > 0) { + Class classCondition = (Class)parseClass(element, CONDITION_COMMAND_CLASS_ATTR, CREATION_COMMAND_EXTENSIONPOINT); + if(classCondition != null) { + try { + res.setCondition(classCondition.newInstance()); + } catch (InstantiationException e) { + throw new ExtensionException("can nott instantiate class : " + e.getMessage()); + } catch (IllegalAccessException e) { + throw new ExtensionException("can nott acces to class : " + e.getMessage()); + } + } + } + PapyrusTrace.trace(IDebugChannel.PAPYRUS_EXTENSIONPOINT_LOADING, this, "a creation command ready " + res); + + return res; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/CreationCommandRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/CreationCommandRegistry.java new file mode 100644 index 00000000000..66f4e66069e --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/CreationCommandRegistry.java @@ -0,0 +1,142 @@ +/******************************************************************************* + * Copyright (c) 2008 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: + * Jerome Benois (Obeo) jerome.benois@obeo.fr - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.commands; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +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.papyrus.infra.core.Activator; +import org.eclipse.papyrus.infra.core.extension.ExtensionException; +import org.eclipse.papyrus.infra.core.extension.NotFoundException; +import org.eclipse.papyrus.infra.core.utils.IDebugChannel; +import org.eclipse.papyrus.infra.core.utils.PapyrusTrace; + +/** + * {@inheritDoc} + * + * @author Jerome Benois + */ +public class CreationCommandRegistry implements ICreationCommandRegistry { + + private static Map registriesMap = new HashMap(); + + /** + * This static method returns an instance of this class for a specified + * namespace + * + * @param extensionPointNamespace + * @return + */ + public static CreationCommandRegistry getInstance(String extensionPointNamespace) { + synchronized(registriesMap) { + CreationCommandRegistry registry = registriesMap.get(extensionPointNamespace); + if(registry == null) { + registry = new CreationCommandRegistry(extensionPointNamespace); + registriesMap.put(extensionPointNamespace, registry); + } + return registry; + } + } + + /** ID of the editor extension (schema filename) */ + public static final String EDITOR_EXTENSION_ID = "papyrusDiagram"; + + /** Namespace where to look for the extension points. */ + protected String extensionPointNamespace; + + /** + * The icon representing the command + */ + private String icon; + + /** + * Registered creation command descriptors. + */ + private Map creationCommandDescriptors; + + private CreationCommandRegistry(String extensionPointNamespace) { + this.extensionPointNamespace = extensionPointNamespace; + initializeCreationCommandDescriptors(); + } + + /** + * {@inheritDoc} + */ + public Collection getCommandDescriptors() { + return creationCommandDescriptors.values(); + } + + /** + * {@inheritDoc} + * + * @throws NotFoundException + */ + public ICreationCommand getCommand(String commandId) throws NotFoundException { + try { + CreationCommandDescriptor desc = creationCommandDescriptors.get(commandId); + return desc.getCommand(); + } catch (Exception e) { + throw new NotFoundException("No creation command registered under id '" + commandId + "'."); + } + } + + /** + * get the command icon path + * + * @return the editor icon path + */ + public String getIcon() { + return icon; + } + + /** + * set the command icon + * + * @param icon + * the icon path + */ + public void setIcon(String icon) { + this.icon = icon; + } + + /** + * Read command descriptors from extension points. + */ + private void initializeCreationCommandDescriptors() { + + creationCommandDescriptors = new HashMap(); + // Reading data from plugins + IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointNamespace, EDITOR_EXTENSION_ID); + + CreationCommandExtensionFactory extensionReader = new CreationCommandExtensionFactory(); + + for(IConfigurationElement ele : configElements) { + CreationCommandDescriptor desc; + try { + if(CreationCommandExtensionFactory.CREATION_COMMAND_EXTENSIONPOINT.equals(ele.getName())) { + desc = extensionReader.createCreationCommand(ele); + creationCommandDescriptors.put(desc.commandId, desc); + } + } catch (ExtensionException e) { + Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage(), e)); + PapyrusTrace.error(IDebugChannel.PAPYRUS_EXTENSIONPOINT_LOADING, this, "Initialization creation command problem " + e); + } + } + PapyrusTrace.trace(IDebugChannel.PAPYRUS_EXTENSIONPOINT_LOADING, this, "" + creationCommandDescriptors.size() + " creationCommands loaded"); + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ICreationCommand.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ICreationCommand.java new file mode 100644 index 00000000000..0491a3243f4 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ICreationCommand.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2008 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: + * Jerome Benois (Obeo) jerome.benois@obeo.fr - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.commands; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.papyrus.infra.core.utils.DiResourceSet; + +/** + * Define a command use to create new diagram. It use to provide Eclipse + * extension @see {@link PapyrusDiagram#creationCommand} It used by the creation + * model wizard. + * + * @author Jerome Benois + */ +public interface ICreationCommand { + + /** + * Create a new diagram in diResourceSet with the given name and open it. + * + * @param diResourceSet + * the resourceSet containing all diagrams + * @param container + * of the diagram, if container is null, the diagram is contained + * by the top level container + * @param diagramName + * the name of the new diagram or null to use a dialog to choose + * the name + */ + public void createDiagram(DiResourceSet diResourceSet, EObject container, String diagramName); + + /** + * Get a command to create a new diagram in diResourceSet with the given + * name. + * + * @param diResourceSet + * the resourceSet containing all diagrams + * @param container + * of the diagram, if container is null, the diagram is contained + * by the top level container + * @param diagramName + * the name of the new diagram or null to use a dialog to choose + * the name + */ + public ICommand getCreateDiagramCommand(final DiResourceSet diResourceSet, final EObject container, final String diagramName); + + /** + * Get the type of the diagram to create. + * + * @return diagram type + */ + public String getCreatedDiagramType(); + + /** + * Check if the creation of this diagram is strongly attached to its parent + * or if it can be reassigned after creation. + * + * @return true if parent can be reassigned + */ + public boolean isParentReassignable(); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ICreationCommandRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ICreationCommandRegistry.java new file mode 100644 index 00000000000..066285bcec5 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ICreationCommandRegistry.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2008 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: + * Jerome Benois (Obeo) jerome.benois@obeo.fr - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.commands; + +import java.util.Collection; + +import org.eclipse.papyrus.infra.core.extension.NotFoundException; + +/** + * Registry containing CreationCommand registered by Eclipse extension. + * + * @author Jerome Benois + */ +public interface ICreationCommandRegistry { + + /** + * Get all registered creation command descriptors + * + * @return collection of command descriptors + */ + public Collection getCommandDescriptors(); + + /** + * Get registered creation with given identifier + * + * @param commandId + * the command id + * @return the registered command + * @throws NotFoundException + * if command not registered + */ + ICreationCommand getCommand(String commandId) throws NotFoundException; +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ICreationCondition.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ICreationCondition.java new file mode 100644 index 00000000000..7f8288c631f --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ICreationCondition.java @@ -0,0 +1,36 @@ +/***************************************************************************** + * 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 + * + * Tristan Faure (ATOS ORIGIN) tristan.faure@atosorigin.com - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.commands; + +import org.eclipse.emf.ecore.EObject; + +public interface ICreationCondition { + + /** + * This method returns true if the diagram creation is allowed + * + * @param selectedElement + * the element where the diagram is provided + * @return true if the diagram can be created + */ + boolean create(EObject selectedElement); + + /** + * set the command ID in order to take account the environment in order to + * create a diagram + * + * @param commandID + */ + public void setCommand(String commandID); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/IModelCreationCommand.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/IModelCreationCommand.java new file mode 100644 index 00000000000..87451d77221 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/IModelCreationCommand.java @@ -0,0 +1,31 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tatiana Fesenko (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.commands; + +import org.eclipse.papyrus.infra.core.utils.DiResourceSet; + +/** + * The Interface IModelCreationCommand. + */ +public interface IModelCreationCommand { + + /** + * Creates the model. + * + * @param diResourceSet + * the di resource set + */ + void createModel(final DiResourceSet diResourceSet); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ModelCreationCommandBase.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ModelCreationCommandBase.java new file mode 100644 index 00000000000..bdcdc4c22be --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/ModelCreationCommandBase.java @@ -0,0 +1,126 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tatiana Fesenko (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.commands; + +import java.util.Collections; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.core.utils.DiResourceSet; + +/** + * The Class ModelCreationCommandBase. + */ +public abstract class ModelCreationCommandBase implements IModelCreationCommand { + + /** + * @see org.eclipse.papyrus.infra.core.extension.commands.IModelCreationCommand#createModel(org.eclipse.papyrus.infra.core.utils.DiResourceSet) + * + * @param diResourceSet + */ + public void createModel(final DiResourceSet diResourceSet) { + TransactionalEditingDomain transactionalEditingDomain = diResourceSet.getTransactionalEditingDomain(); + RecordingCommand command = new RecordingCommand(transactionalEditingDomain) { + + @Override + protected void doExecute() { + runAsTransaction(diResourceSet); + } + }; + transactionalEditingDomain.getCommandStack().execute(command); + } + + /** + * Run as transaction. + * + * @param diResourceSet + * the di resource set + */ + protected void runAsTransaction(final DiResourceSet diResourceSet) { + // Get the uml element to which the newly created diagram will be + // attached. + // Create the diagram + final Resource modelResource = diResourceSet.getModelResource(); + TransactionalEditingDomain editingDomain = diResourceSet.getTransactionalEditingDomain(); + + AbstractTransactionalCommand command = new AbstractTransactionalCommand(editingDomain, "Initialize model", Collections.EMPTY_LIST) { + + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + + CommandResult commandResult = CommandResult.newErrorCommandResult("Error during diagram creation"); + EObject model = getRootElement(modelResource); + attachModelToResource(model, modelResource); + + initializeModel(model); + return CommandResult.newOKCommandResult(); + + } + }; + editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(command)); + } + + /** + * Initialize model. + * + * @param owner + * the owner + */ + protected void initializeModel(EObject owner) { + + } + + /** + * Get the root element associated with canvas. + * + * @param modelResource + * the model resource + * @return the root element + */ + protected EObject getRootElement(Resource modelResource) { + EObject rootElement = null; + if(modelResource != null && modelResource.getContents() != null && modelResource.getContents().size() > 0) { + Object root = modelResource.getContents().get(0); + if(root instanceof EObject) { + rootElement = (EObject)root; + } + } else { + rootElement = createRootElement(); + } + return rootElement; + } + + /** + * Store model element in the resource. + */ + protected void attachModelToResource(EObject root, Resource resource) { + resource.getContents().add(root); + } + + /** + * Create the root element of an EMF model + * + * @return the root element + */ + protected abstract EObject createRootElement(); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/PerspectiveContextDependence.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/PerspectiveContextDependence.java new file mode 100644 index 00000000000..0e3666bc94e --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/commands/PerspectiveContextDependence.java @@ -0,0 +1,51 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.commands; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.core.extension.commands.ICreationCondition; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.internal.Perspective; +import org.eclipse.ui.internal.WorkbenchPage; + +public class PerspectiveContextDependence implements ICreationCondition { + + protected String commandID = null; + + public PerspectiveContextDependence() { + // TODO Auto-generated constructor stub + } + + /** + * {@inheritDoc} + */ + public boolean create(EObject selectedElement) { + // Get the perspective + Perspective perspective = ((WorkbenchPage)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()).getActivePerspective(); + // look for the perspective + // verify if the commannd has to be displayed + if(perspective.getHiddenMenuItems().contains(commandID) && perspective.getHiddenToolbarItems().contains(commandID)) { + return false; + } + return true; + } + + /** + * {@inheritDoc} + */ + public void setCommand(String commandID) { + this.commandID = commandID; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/AbstractEditorFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/AbstractEditorFactory.java new file mode 100644 index 00000000000..cf9a53c85aa --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/AbstractEditorFactory.java @@ -0,0 +1,109 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.diagrameditor; + +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.papyrus.infra.core.editorsfactory.IEditorFactory; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * Abstract base class for Factory of editors. See {@link IEditorFactory}. + * + * + * @author Remi Schnekenburger + * @author Patrick Tessier + * @author cedric dumoulin + */ +public abstract class AbstractEditorFactory implements IPluggableEditorFactory { + + /** + * Expected Class of the diagram to create. + */ + private Class diagramClass; + + /** Expected diagram type (@see {@link Diagram#getType()}) */ + private String expectedType; + + /** + * EditorDescriptor associated to the factory. TODO : Maybe use individual + * setters to set the requested data (ContributorId and Icon). + */ + protected EditorDescriptor editorDescriptor; + + /** + * ServiceRegistry that can be provided to created editors. + */ + private ServicesRegistry serviceRegistry; + + /** + * Creates a new AbstractEditorFactory. + * + * @param diagramClass + * expected Class of the diagram to create. + * @param expectedType + * expected diagram type (@see {@link Diagram#getType()}) + */ + public AbstractEditorFactory(Class diagramClass, String expectedType) { + assert (expectedType != null); + this.diagramClass = diagramClass; + this.expectedType = expectedType; + } + + /** + * Initialize the factory with useful Classes. + * + * @param serviceRegistry + * Service registry that will be provided to created editor. + * @param editorDescriptor + * Descriptor containing data from the Eclipse Extension. + */ + public void init(ServicesRegistry serviceRegistry, EditorDescriptor editorDescriptor) { + this.editorDescriptor = editorDescriptor; + this.serviceRegistry = serviceRegistry; + + } + + /** + * @return the serviceRegistry + */ + public ServicesRegistry getServiceRegistry() { + return serviceRegistry; + } + + /** + * Returns the expected class for the diagram implementation + * + * @return the expected class for the diagram implementation + */ + public Class getDiagramClass() { + return diagramClass; + } + + /** + * Returns the expected type of the diagram + * + * @return the expected diagram type (@see {@link Diagram#getType()}) + */ + public String getExpectedType() { + return expectedType; + } + + /** + * @return the editorDescriptor + */ + public EditorDescriptor getEditorDescriptor() { + return editorDescriptor; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorDescriptor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorDescriptor.java new file mode 100644 index 00000000000..3ed2fac57a7 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorDescriptor.java @@ -0,0 +1,152 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.diagrameditor; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +/** + * This descriptor describes a nested diagram. It is used by MultiDiagramEditor + * to know about the nested diagram. It is fill by an extension. + * + * @author Cedric Dumoulin + * + */ +public class EditorDescriptor { + + /** + * Editor factory implementation class. + */ + private Class editorFactoryClass; + + /** + * EditorActionBarContributor Id used to search the + * EditorActionBarContributor requested by the editor. + */ + private String actionBarContributorId; + + /** + * The icon representing the diagram + */ + private ImageDescriptor icon; + /** + * Resource path to the icon + */ + private String inconPath; + + /** + * Constructor. + */ + public EditorDescriptor() { + + } + + /** + * + * @param attribute + */ + public void setActionBarContributorId(String actionBarContributorId) { + this.actionBarContributorId = actionBarContributorId; + + } + + /** + * @see org.eclipse.papyrus.infra.core.extension.diagrameditor.IEditorDescriptor#getActionBarContributorId() + * @return + * + */ + public String getActionBarContributorId() { + return actionBarContributorId; + } + + /** + * get the editor icon path + * + * @return the editor icon path + */ + public ImageDescriptor getIcon() { + return icon; + } + + /** + * set the editor icon + * + * @param icon + * the icon path + */ + public void setIcon(ImageDescriptor icon) { + this.icon = icon; + } + + /** + * get the class of the editor factory + * + * @return the class of the editor + */ + public Class getEditorFactoryClass() { + return editorFactoryClass; + } + + /** + * set the editor facoty to this descriptor + * + * @param editorFactoryClass + * the class that represents the editor factory + */ + public void setEditorFactoryClass(Class editorFactoryClass) { + this.editorFactoryClass = editorFactoryClass; + } + + /** + * + * {@inheritDoc} + */ + public String toString() { + if(editorFactoryClass == null || editorFactoryClass.getName() == null) { + return "[nestedEditor editorFactory:" + editorFactoryClass + "(null)]"; + } + return "[nestedEditor editorFactory:" + editorFactoryClass.getName() + "]"; + } + + /** + * Set the URL of the Icon + * + * @param iconPath + * path of the Icon + */ + public void setIconURL(String iconPath) { + inconPath = iconPath; + } + + /** + * Get the URL of the based images + * + * @return the path of the mai image. can return null if this property is not set + */ + public String getIconURL() { + return inconPath; + } + + /** + * set the Icon thanks to a {@link IConfigurationElement} and {@link String}which represent the path of the Icon + * + * @param element + * @param iconPath + */ + public void setIcon(IConfigurationElement element, String iconPath, String pluginID) { + setIcon(AbstractUIPlugin.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), iconPath)); + setIconURL(element.getNamespaceIdentifier() + '/' + iconPath); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorDescriptorExtensionFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorDescriptorExtensionFactory.java new file mode 100644 index 00000000000..c94ae59b3b9 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorDescriptorExtensionFactory.java @@ -0,0 +1,82 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.diagrameditor; + +import static org.eclipse.papyrus.infra.core.Activator.log; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.papyrus.infra.core.extension.BadNameExtensionException; +import org.eclipse.papyrus.infra.core.extension.ExtensionException; +import org.eclipse.papyrus.infra.core.extension.ExtensionUtils; + +/** + * A factory used to create editor descriptor object from Eclipse extensions points elements. + * + *@author Cedric Dumoulin + *@author Patrick Tessier + */ +public class EditorDescriptorExtensionFactory extends ExtensionUtils { + + /** singleton eINSTANCE of this class */ + public final static EditorDescriptorExtensionFactory eINSTANCE = new EditorDescriptorExtensionFactory(); + + /** constant for the editor diagram **/ + public final static String EDITOR_DIAGRAM_EXTENSIONPOINT = "editorDiagram"; + + /** constant for the attribute factoryClass **/ + public final static String FACTORYCLASS_ATTRIBUTE = "factoryClass"; + + /** constant for the attribute contextId **/ + public final static String ACTIONBARCONTRIBUTORID_ATTRIBUTE = "actionBarContributorId"; + + /** constant for the attribute icon **/ + public final static String ICON_ATTRIBUTE = "icon"; + + /** + * @return the eINSTANCE + */ + public static EditorDescriptorExtensionFactory getInstance() { + return eINSTANCE; + } + + /** + * Create a descriptor instance corresponding to the ConfigurationElement. + * + * @param element + * an {@link IConfigurationElement} see eclipse extension point + * @return a nestedEditorDescriptor structure that contains information to create diagrams + * @throws BadNameExtensionException + */ + @SuppressWarnings("unchecked") + public EditorDescriptor createNestedEditorDescriptor(IConfigurationElement element) throws ExtensionException { + EditorDescriptor res; + + checkTagName(element, EDITOR_DIAGRAM_EXTENSIONPOINT); + + res = new EditorDescriptor(); + res.setEditorFactoryClass((Class)parseClass(element, FACTORYCLASS_ATTRIBUTE, EDITOR_DIAGRAM_EXTENSIONPOINT)); + res.setActionBarContributorId(element.getAttribute(ACTIONBARCONTRIBUTORID_ATTRIBUTE)); + String iconPath = element.getAttribute(ICON_ATTRIBUTE); + if(iconPath != null) { + /** Implementation which set the icon and register the complete URL of the icon : Bug eclipse 358732*/ + res.setIcon(element, iconPath, org.eclipse.papyrus.infra.core.Activator.PLUGIN_ID); + + } + + if(log.isDebugEnabled()) { + log.debug("Read editor descriptor " + res); + } + return res; + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorFactoryProxy.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorFactoryProxy.java new file mode 100644 index 00000000000..9c9c91cb6a2 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorFactoryProxy.java @@ -0,0 +1,105 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.extension.diagrameditor; + +import org.eclipse.papyrus.infra.core.editorsfactory.IEditorFactory; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * A proxy implementation of {@link IEditorFactory} used to do lazy + * instantiation of concrete {@link IPluggableEditorFactory}. This class is used + * by the {@link PluggableEditorFactoryReader} + * + * @author cedric dumoulin + * + */ +public class EditorFactoryProxy implements IEditorFactory { + + /** + * The concrete implementation. + */ + private IPluggableEditorFactory editorFactory; + + /** + * EditorDescriptor associated to the factory. + */ + protected EditorDescriptor editorDescriptor; + + /** + * ServiceRegistry that can be provided to created editors. + */ + private ServicesRegistry serviceRegistry; + + /** + * Constructor. + * + * @param serviceRegistry + * @param editorDescriptor + */ + public EditorFactoryProxy(ServicesRegistry serviceRegistry, EditorDescriptor editorDescriptor) { + this.serviceRegistry = serviceRegistry; + this.editorDescriptor = editorDescriptor; + } + + /** + * @see org.eclipse.papyrus.infra.core.editorsfactory.IEditorFactory#createIPageModel(java.lang.Object) + * + * @param pageIdentifier + * @return + */ + public IPageModel createIPageModel(Object pageIdentifier) { + return getEditorFactory().createIPageModel(pageIdentifier); + } + + /** + * @see org.eclipse.papyrus.infra.core.editorsfactory.IEditorFactory#isPageModelFactoryFor(java.lang.Object) + * + * @param pageIdentifier + * @return + */ + public boolean isPageModelFactoryFor(Object pageIdentifier) { + return getEditorFactory().isPageModelFactoryFor(pageIdentifier); + } + + /** + * @return the editorFactory + */ + protected IPluggableEditorFactory getEditorFactory() { + + if(editorFactory == null) { + editorFactory = createEditorFactory(); + } + + return editorFactory; + + } + + /** + * Create an instance of IPluggableEditorFactory as described in the + * editorDescriptor. TODO let propagate the exceptions. + * + * @return + */ + private IPluggableEditorFactory createEditorFactory() { + // Create the requested class. + try { + editorFactory = editorDescriptor.getEditorFactoryClass().newInstance(); + // Set the descriptor. USed by the factory to get the ActionBarId + // and Icon + editorFactory.init(serviceRegistry, editorDescriptor); + return editorFactory; + } catch (InstantiationException e) { + // Lets propagate. This is an implementation problem that should be + // solved by programmer. + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + // Lets propagate. This is an implementation problem that should be + // solved by programmer. + throw new RuntimeException(e); + } + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorIconFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorIconFactory.java new file mode 100644 index 00000000000..f1cdcb9592a --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorIconFactory.java @@ -0,0 +1,135 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.extension.diagrameditor; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.papyrus.infra.core.editorsfactory.IEditorIconFactory; +import org.eclipse.papyrus.infra.core.editorsfactory.IEditorIconFactoryExtended; +import org.eclipse.swt.graphics.Image; + +/** + * A factory used to create the Icon associated to an editor TODO Lets have a + * common ancestor for {@link EditorIconFactory} and {@link EditorFactoryProxy} + * + * @author cedric dumoulin + * + */ +public class EditorIconFactory implements IEditorIconFactoryExtended { + + /** + * The concrete implementation. + */ + private IPluggableEditorFactory editorFactory; + + /** + * EditorDescriptor associated to the factory. + */ + protected EditorDescriptor editorDescriptor; + + /** + * Cached image for reuse. + */ + protected Image cachedImage; + + /** + * Constructor. + * + * @param serviceRegistry + * @param editorDescriptor + */ + public EditorIconFactory(EditorDescriptor editorDescriptor) { + this.editorDescriptor = editorDescriptor; + } + + /** + * @see org.eclipse.papyrus.infra.core.editorsfactory.IEditorIconFactory#getEditorIcon(java.lang.Object) + * + * @param pageIdentifier + * @return + */ + public Image getEditorIcon(Object pageIdentifier) { + + if(cachedImage == null) { + cachedImage = createEditorIcon(pageIdentifier); + } + + return cachedImage; + } + + /** + * Create an Image associated to the editor used to render the specified + * pageIdentifier + * + * @return + */ + public Image createEditorIcon(Object pageIdentifier) { + ImageDescriptor imageDescriptor = editorDescriptor.getIcon(); + if(imageDescriptor == null) + return null; + Image image = imageDescriptor.createImage(); + return image; + } + + /** + * @see org.eclipse.papyrus.infra.core.editorsfactory.IEditorFactory#isPageModelFactoryFor(java.lang.Object) + * + * @param pageIdentifier + * @return + */ + public boolean isPageModelFactoryFor(Object pageIdentifier) { + return getEditorFactory().isPageModelFactoryFor(pageIdentifier); + } + + /** + * @return the editorFactory + */ + protected IPluggableEditorFactory getEditorFactory() { + + if(editorFactory == null) { + editorFactory = createEditorFactory(); + } + + return editorFactory; + + } + + /** + * Create an instance of IPluggableEditorFactory as described in the + * editorDescriptor. TODO let propagate the exceptions. + * + * @return + */ + private IPluggableEditorFactory createEditorFactory() { + // Create the requested class. + try { + editorFactory = editorDescriptor.getEditorFactoryClass().newInstance(); + // Set the descriptor. USed by the factory to get the ActionBarId + // and Icon + // editorFactory.init(serviceRegistry, editorDescriptor); + return editorFactory; + } catch (InstantiationException e) { + // Lets propagate. This is an implementation problem that should be + // solved by programmer. + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + // Lets propagate. This is an implementation problem that should be + // solved by programmer. + throw new RuntimeException(e); + } + + } + + /** + * Return the URL of the main icon used to create this icon + * + * @see org.eclipse.papyrus.infra.core.editorsfactory.IEditorIconFactory#getURLMainIcon(java.lang.Object) + * + * @param pageIdentifier + * @return + */ + public String getURLMainIcon(Object pageIdentifier) { + return editorDescriptor.getIconURL(); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorNotFoundException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorNotFoundException.java new file mode 100644 index 00000000000..30bdc483b58 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/EditorNotFoundException.java @@ -0,0 +1,53 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.diagrameditor; + +/** + * Editor was not found. + * + * @author dumoulin + * + */ +@SuppressWarnings("serial") +public class EditorNotFoundException extends MultiDiagramException { + + /** + * + */ + public EditorNotFoundException() { + } + + /** + * @param arg0 + */ + public EditorNotFoundException(String arg0) { + super(arg0); + } + + /** + * @param arg0 + */ + public EditorNotFoundException(Throwable arg0) { + super(arg0); + } + + /** + * @param arg0 + * @param arg1 + */ + public EditorNotFoundException(String arg0, Throwable arg1) { + super(arg0, arg1); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/IPluggableEditorFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/IPluggableEditorFactory.java new file mode 100644 index 00000000000..a857de05485 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/IPluggableEditorFactory.java @@ -0,0 +1,39 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.diagrameditor; + +import org.eclipse.papyrus.infra.core.editorsfactory.IEditorFactory; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * This interface should be implemented by Editor Factories that can be declared + * as Eclipse extension. It extends the {@link IEditorFactory} by adding methods + * to initialize the factory with multieditor ServiceRegistry and associated + * editor data. + * + * @author Cédric Dumoulin + * + */ +public interface IPluggableEditorFactory extends IEditorFactory { + + /** + * Initialize the factory with useful Classes. + * + * @param serviceRegistry + * Service registry that will be provided to created editor. + * @param editorDescriptor + * Descriptor containing data from the Eclipse Extension. + */ + public void init(ServicesRegistry serviceRegistry, EditorDescriptor editorDescriptor); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/MultiDiagramException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/MultiDiagramException.java new file mode 100644 index 00000000000..141711080ce --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/MultiDiagramException.java @@ -0,0 +1,53 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.diagrameditor; + +/** + * Root Exception of MultiDiagram exception + * + * @author dumoulin + * + */ +@SuppressWarnings("serial") +public class MultiDiagramException extends Exception { + + /** + * + */ + public MultiDiagramException() { + } + + /** + * @param arg0 + */ + public MultiDiagramException(String arg0) { + super(arg0); + } + + /** + * @param arg0 + */ + public MultiDiagramException(Throwable arg0) { + super(arg0); + } + + /** + * @param arg0 + * @param arg1 + */ + public MultiDiagramException(String arg0, Throwable arg1) { + super(arg0, arg1); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/PluggableEditorFactoryReader.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/PluggableEditorFactoryReader.java new file mode 100644 index 00000000000..f92ac0763e2 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/extension/diagrameditor/PluggableEditorFactoryReader.java @@ -0,0 +1,140 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.extension.diagrameditor; + +import static org.eclipse.papyrus.infra.core.Activator.log; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.papyrus.infra.core.editorsfactory.PageIconsRegistry; +import org.eclipse.papyrus.infra.core.editorsfactory.PageModelFactoryRegistry; +import org.eclipse.papyrus.infra.core.extension.ExtensionException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * This reader is used to read PluggableEditorFactory from the Eclipse extension + * declarations. It can be used to populate an {@link PageModelFactoryRegistry}. + */ +public class PluggableEditorFactoryReader { + + /** list of editor descriptors */ + protected List editorDescriptors; + + /** ID of the editor extension (schema filename) */ + public static final String EDITOR_EXTENSION_ID = "papyrusDiagram"; + + /** Namespace where to look for the extension points. */ + protected String extensionPointNamespace; + + /** indicates if extension is loaded or not */ + private boolean isExtensionLoaded = false; + + /** + * Create a new Registry reading extension from the specified namespace. The + * namespace is usually the name of the plugin owning the registry. + * + * @param extensionPointNamespace + */ + public PluggableEditorFactoryReader(String extensionPointNamespace) { + super(); + this.extensionPointNamespace = extensionPointNamespace; + editorDescriptors = new ArrayList(); + } + + /** + * Populate the provided {@link PageModelFactoryRegistry} with {@link IPluggableEditorFactory} read from Eclipse extension declarations. + * For each declared editor, create a proxy encapsulating the real + * EditorFactory. Then the proxy is added to the PageModelFactoryRegistry. + * + * @param pageModelFactoryRegistry + * The object to populate + * @param serviceRegistry + * ServiceRegistry provided to newly instantiated {@link IPluggableEditorFactory}. + */ + public void populate(PageModelFactoryRegistry pageModelFactoryRegistry, ServicesRegistry serviceRegistry) { + + for(EditorDescriptor desc : getEditorDescriptors()) { + + // Create and add a proxy encapsulating the EditorFactory. + pageModelFactoryRegistry.add(new EditorFactoryProxy(serviceRegistry, desc)); + } + } + + /** + * Populate the provided {@link PageIconsRegistry} with icons read from + * Eclipse extension declarations. For each declared editor, create a {@link EditorIconFactory}. + * + * @param pageModelFactoryRegistry + * The object to populate + * @param serviceRegistry + * ServiceRegistry provided to newly instantiated {@link IPluggableEditorFactory}. + */ + public void populate(PageIconsRegistry registry) { + + for(EditorDescriptor desc : getEditorDescriptors()) { + + // Create and add a proxy encapsulating the EditorFactory. + registry.add(new EditorIconFactory(desc)); + } + } + + /** + * Get the list of editor descriptor. + * + * @return the list of editor descriptor. + */ + public List getEditorDescriptors() { + if(!isExtensionLoaded) { + isExtensionLoaded = true; + initializeEditorDescriptors(); + } + return editorDescriptors; + } + + /** + * Read editor descriptors from extension points. + */ + private void initializeEditorDescriptors() { + // Reading data from plugins + IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointNamespace, EDITOR_EXTENSION_ID); + + for(IConfigurationElement ele : configElements) { + EditorDescriptor desc; + try { + if(EditorDescriptorExtensionFactory.EDITOR_DIAGRAM_EXTENSIONPOINT.equals(ele.getName())) { + desc = EditorDescriptorExtensionFactory.eINSTANCE.createNestedEditorDescriptor(ele); + editorDescriptors.add(desc); + } + } catch (ExtensionException e) { + log.error("Initialization editor problem ", e); + } + } + + if(log.isDebugEnabled()) { + log.debug("Read " + editorDescriptors.size() + " editor descriptors from Eclipse extensions"); + } + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return "EditorFactoryRegistry: " + editorDescriptors.toString(); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/DoSaveEvent.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/DoSaveEvent.java new file mode 100644 index 00000000000..b4975145830 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/DoSaveEvent.java @@ -0,0 +1,47 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.lifecycleevents; + +import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * Event sent whith a Save or SaveAs. + * + * @author cedric dumoulin + * + */ +public class DoSaveEvent { + + final protected ServicesRegistry serviceRegistry; + + final protected IMultiDiagramEditor multiDiagramEditor; + + /** + * Create an Event that is sent with a Save or SaveAs. The same event can be + * reused. Constructor. + * + * @param serviceRegistry + * @param multiDiagramEditor + */ + public DoSaveEvent(ServicesRegistry serviceRegistry, IMultiDiagramEditor multiDiagramEditor) { + this.serviceRegistry = serviceRegistry; + this.multiDiagramEditor = multiDiagramEditor; + } + + /** + * @return the serviceRegistry + */ + public ServicesRegistry getServiceRegistry() { + return serviceRegistry; + } + + /** + * @return the multiDiagramEditor + */ + public IMultiDiagramEditor getMultiDiagramEditor() { + return multiDiagramEditor; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/IEditorInputChangedListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/IEditorInputChangedListener.java new file mode 100644 index 00000000000..8a1ef3a8c8b --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/IEditorInputChangedListener.java @@ -0,0 +1,41 @@ +/***************************************************************************** + * Copyright (c) 2010 LIFL & CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.lifecycleevents; + +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.part.FileEditorInput; + +/** + * Interface implemented by classes wishing to be notified of the inputChanged + * event after a call to {@link ISaveAndDirtyService#doSaveAs()}. + * + * @author cedric dumoulin + * + */ +public interface IEditorInputChangedListener { + + /** + * + * @param fileEditorInput + * The new value of EditorInput + */ + public void editorInputChanged(FileEditorInput fileEditorInput); + + /** + * Called when the value of the isDirty() flag has changed. + */ + public void isDirtyChanged(); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/ILifeCycleEventsProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/ILifeCycleEventsProvider.java new file mode 100644 index 00000000000..387b9c6c828 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/ILifeCycleEventsProvider.java @@ -0,0 +1,57 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.lifecycleevents; + +/** + * Concrete implementation of this interface allows to listen on various + * lifecycle events. This interface is the "public" part of the {@link LifeCycleEventsProvider}. + * + * @author cedric dumoulin + * + */ +public interface ILifeCycleEventsProvider { + + /** + * Add specified listener. + * + * @param listener + */ + public void addDoSaveListener(ISaveEventListener listener); + + /** + * Remove specified listener. + * + * @param listener + */ + public void removeDoSaveListener(ISaveEventListener listener); + + /** + * Add specified listener. + * + * @param listener + */ + public void addAboutToDoSaveListener(ISaveEventListener listener); + + /** + * Remove specified listener. + * + * @param listener + */ + public void removeAboutToDoSaveListener(ISaveEventListener listener); + + /** + * Add specified listener. + * + * @param listener + */ + public void addPostDoSaveListener(ISaveEventListener listener); + + /** + * Remove specified listener. + * + * @param listener + */ + public void removePostDoSaveListener(ISaveEventListener listener); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/ISaveAndDirtyService.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/ISaveAndDirtyService.java new file mode 100644 index 00000000000..520cd741437 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/ISaveAndDirtyService.java @@ -0,0 +1,56 @@ +/***************************************************************************** + * Copyright (c) 2010 LIFL & CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.lifecycleevents; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.ui.ISaveablePart; + +/** + * @author dumoulin + * + */ +public interface ISaveAndDirtyService extends ISaveablePart { + + /** + * Register a nested {@link ISaveablePart} as a listener that will be + * notified each time a {@link #doSave(IProgressMonitor)} or {@link #doSaveAs()} is performed. Also, it will be asked for the + * dirtyState. + * + * @param saveablePart + */ + public abstract void registerIsaveablePart(ISaveablePart saveablePart); + + /** + * Remove the specified {@link ISaveablePart} from the list of listeners. + * + * @param saveablePart + */ + public abstract void removeIsaveablePart(ISaveablePart saveablePart); + + /** + * Add a listeners on input changed event. + * + * @param inputChangedListener + */ + public void addInputChangedListener(IEditorInputChangedListener inputChangedListener); + + /** + * Remove a listeners on input changed event. + * + * @param inputChangedListener + */ + public void removeInputChangedListener(IEditorInputChangedListener inputChangedListener); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/ISaveEventListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/ISaveEventListener.java new file mode 100644 index 00000000000..6263e804700 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/ISaveEventListener.java @@ -0,0 +1,27 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.lifecycleevents; + +/** + * Interface used to listen on open, save and saveAs events. + * + * @author cedric dumoulin + * + * @param + * Type of event passed to methods. + */ +public interface ISaveEventListener { + + /** + * + * @param editor + */ + public void doSave(DoSaveEvent event); + + /** + * + * @param editor + */ + public void doSaveAs(DoSaveEvent event); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/LifeCycleEventsProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/LifeCycleEventsProvider.java new file mode 100644 index 00000000000..efca7f9d6f4 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/LifeCycleEventsProvider.java @@ -0,0 +1,272 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.lifecycleevents; + +import java.util.ArrayList; +import java.util.List; + +/** + * This class provides events about the life cycle of a MultiEditor. Not all + * life cycle events are available. Available events: + *

    + *
  • aboutToDoSave, aboutToDoSaveAs - SaveEventListener
  • + *
  • doSave, doSaveAs - SaveEventListener
  • + *
  • afterDoSave, afterDoSaveAs - SaveEventListener
  • + *
  • + *
  • + *
+ * + * + * @author cedric dumoulin + * + */ +public class LifeCycleEventsProvider implements ILifeCycleEventsProvider { + + /** + * + */ + protected SaveEventListenerLazyList preSaveListeners = new SaveEventListenerLazyList(); + + /** + * + */ + protected SaveEventListenerLazyList saveListeners = new SaveEventListenerLazyList(); + + /** + * + */ + protected SaveEventListenerLazyList postSaveListeners = new SaveEventListenerLazyList(); + + /** + * Add specified listener. + * + * @param listener + */ + public void addDoSaveListener(ISaveEventListener listener) { + + saveListeners.addListener(listener); + } + + /** + * Remove specified listener. + * + * @param listener + */ + public void removeDoSaveListener(ISaveEventListener listener) { + saveListeners.removeListener(listener); + } + + /** + * Add specified listener. + * + * @param listener + */ + public void addAboutToDoSaveListener(ISaveEventListener listener) { + + preSaveListeners.addListener(listener); + } + + /** + * Remove specified listener. + * + * @param listener + */ + public void removeAboutToDoSaveListener(ISaveEventListener listener) { + preSaveListeners.removeListener(listener); + } + + /** + * Add specified listener. + * + * @param listener + */ + public void addPostDoSaveListener(ISaveEventListener listener) { + + postSaveListeners.addListener(listener); + } + + /** + * Remove specified listener. + * + * @param listener + */ + public void removePostDoSaveListener(ISaveEventListener listener) { + postSaveListeners.removeListener(listener); + } + + // ****************************************************** // + // Fire events methods // + // ****************************************************** // + + /** + * Fire AboutToSaveEvent to registered Listeners. + * + * @param editorPart + */ + public void fireAboutToDoSaveEvent(DoSaveEvent event) { + preSaveListeners.fireSaveEvent(event); + } + + /** + * Fire AboutToSaveAs to registered Listeners. + * + * @param editorPart + */ + public void fireAboutToDoSaveAsEvent(DoSaveEvent event) { + preSaveListeners.fireSaveAsEvent(event); + } + + /** + * Fire AboutToSaveEvent to registered Listeners. + * + * @param editorPart + */ + public void fireDoSaveEvent(DoSaveEvent event) { + saveListeners.fireSaveEvent(event); + } + + /** + * Fire AboutToSaveAs to registered Listeners. + * + * @param editorPart + */ + public void fireDoSaveAsEvent(DoSaveEvent event) { + saveListeners.fireSaveAsEvent(event); + } + + /** + * Fire AboutToSaveEvent to registered Listeners. + * + * @param editorPart + */ + public void firePostDoSaveEvent(DoSaveEvent event) { + postSaveListeners.fireSaveEvent(event); + } + + /** + * Fire AboutToSaveAs to registered Listeners. + * + * @param editorPart + */ + public void firePostDoSaveAsEvent(DoSaveEvent event) { + postSaveListeners.fireSaveAsEvent(event); + } + + /** + * Fire all Save events (about, events, post) to registered Listeners. + * Exceptions from listeners are propagated and stop the event chain. + * + * @param editorPart + */ + public void fireAllDoSaveEvent(DoSaveEvent event) { + fireAboutToDoSaveEvent(event); + fireDoSaveEvent(event); + firePostDoSaveEvent(event); + } + + /** + * Fire all SaveAs events (about, events, post) to registered Listeners. If + * one of the saveAs event fail, post events are not sent. + * + * @param editorPart + */ + public void fireAllDoSaveAsEvent(DoSaveEvent event) { + fireAboutToDoSaveAsEvent(event); + fireDoSaveAsEvent(event); + firePostDoSaveAsEvent(event); + } + + /** + * Base class encapsulating a lazy creation list. + * + * @author cedric dumoulin + * + * @param + */ + abstract protected class AbstractEventListenersLazyList { + + List listeners; + + /** + * Add specified listener. + * + * @param listener + */ + public void addListener(T listener) { + // Lazy creation + if(listeners == null) + listeners = new ArrayList(); + + // do not add if already present. + if(listeners.contains(listener)) + return; + + listeners.add(listener); + } + + /** + * Remove specified listener. + * + * @param listener + */ + public void removeListener(T listener) { + // Lazy creation + if(listeners == null) + return; + + listeners.remove(listener); + } + + /** + * @return the listeners + */ + protected List getListeners() { + return listeners; + } + + } + + /** + * List of {@link ISaveEventListener}. + * + * @author cedric dumoulin + * + */ + protected class SaveEventListenerLazyList extends AbstractEventListenersLazyList { + + /** + * Fire OpenEvent to registered Listeners. If a listener throw an + * exception, remaining listeners are called, and then the exception is + * resent. + * + * @param editorPart + */ + public void fireSaveEvent(DoSaveEvent event) { + // Lazy creation + if(listeners == null) + return; + + for(ISaveEventListener listener : listeners) { + listener.doSave(event); + } + } + + /** + * Fire OpenEvent to registered Listeners. + * + * @param editorPart + */ + public void fireSaveAsEvent(DoSaveEvent event) { + // Lazy creation + if(listeners == null) + return; + + for(ISaveEventListener listener : listeners) { + listener.doSaveAs(event); + } + + } + + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/LifeCycleEventsProviderServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/LifeCycleEventsProviderServiceFactory.java new file mode 100644 index 00000000000..3af757207b7 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/LifeCycleEventsProviderServiceFactory.java @@ -0,0 +1,76 @@ +/***************************************************************************** + * Copyright (c) 2010 LIFL & CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.lifecycleevents; + +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.services.IServiceFactory; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * A service factory to create the {@link ILifeCycleEventsProvider} service. + * This provide a nickname for {@link SaveAndDirtyService} service. This + * serviceFactory depends on {@link SaveAndDirtyService} service. + * + * @author cedric dumoulin + * + */ +public class LifeCycleEventsProviderServiceFactory implements IServiceFactory { + + /** + * The sashModelMangr. + */ + private SaveAndDirtyService saveAndDirtyService; + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry) + * + * @param servicesRegistry + * @throws ServiceException + */ + public void init(ServicesRegistry servicesRegistry) throws ServiceException { + // Get required services + // This rely on the real implementation. + saveAndDirtyService = (SaveAndDirtyService)servicesRegistry.getService(ISaveAndDirtyService.class); + + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#startService() + * + * @throws ServiceException + */ + public void startService() throws ServiceException { + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#disposeService() + * + * @throws ServiceException + */ + public void disposeService() throws ServiceException { + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IServiceFactory#createServiceInstance() + * + * @return + * @throws ServiceException + */ + public Object createServiceInstance() throws ServiceException { + return saveAndDirtyService; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/SaveAndDirtyService.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/SaveAndDirtyService.java new file mode 100644 index 00000000000..0baf6e32d93 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/SaveAndDirtyService.java @@ -0,0 +1,491 @@ +/***************************************************************************** + * Copyright (c) 2010 LIFL & CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.lifecycleevents; + +import static org.eclipse.papyrus.infra.core.Activator.log; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.common.command.BasicCommandStack; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CommandStackListener; +import org.eclipse.emf.transaction.NotificationFilter; +import org.eclipse.emf.transaction.ResourceSetChangeEvent; +import org.eclipse.emf.transaction.ResourceSetListener; +import org.eclipse.emf.transaction.RollbackException; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.services.IService; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.core.utils.ServiceUtils; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.ISaveablePart; +import org.eclipse.ui.actions.WorkspaceModifyOperation; +import org.eclipse.ui.dialogs.SaveAsDialog; +import org.eclipse.ui.part.FileEditorInput; + +/** + * A Papyrus Service allowing to perform save and saveAs on Papyrus Models. The + * service also allows to listen on the dirty state of the Models.
+ * The service implements the {@link ISaveablePart} interface, and can be used + * directly in part requiring such interface of adapter. + * + *
+ * This class allows nested editors to register themselves as nested {@link ISaveablePart}. In this case, the registered part will be notified + * each time a save or saveAs is performed. Also, the nested part will be asked + * for its dirtyState. + * + * TODO : Improve the implementation by registering the isDirty flag value, and + * firing events only if the value really change. Actually, the event is fired + * every time the model is modified, even if the virtual value of the flag + * hasn't changed. + * + * @author cedric dumoulin + * + */ +public class SaveAndDirtyService extends LifeCycleEventsProvider implements ISaveablePart, IService, ISaveAndDirtyService { + + /** + * Class used to propagate life cycle events. This class can be retrieved as + * a service using {@link ILifeCycleEventsProvider}.class. This class + * extends LifeCycleEventsProvider, so the local variable is set with + * ourself (historical reasons). TODO : remove this local variable. + */ + protected LifeCycleEventsProvider lifeCycleEventsProvider = this; + + /** + * Cached event that can be reused. + */ + protected DoSaveEvent lifeCycleEvent; + + /** + * Model set managing models. + */ + private ModelSet resourceSet; + + /** + * + */ + private TransactionalEditingDomain transactionalEditingDomain; + + /** + * The serviceRegistry. + */ + private ServicesRegistry servicesRegistry; + + /** + * Associated editor. Needed by saveAs to synchronize editor input. + */ + private IMultiDiagramEditor multiDiagramEditor; + + /** + * List of registered {@link ISaveablePart}. This are usually nested + * editors. + */ + private ISaveablePartList registeredIsaveablePart; + + /** + * List of listeners on input changed event after a call to saveAs. + */ + private List inputChangedListeners; + + /** + * Listener on commandStack changes. + */ + private final CommandStackListener commandStackListener = new CommandStackListener() { + + public void commandStackChanged(EventObject event) { + + fireIsDirtyChanged(); + }; + }; + + /* + * Listener on ResourceSet + */ + private final ResourceSetListener resourceSetListener = new ResourceSetListener() { + + public NotificationFilter getFilter() { + return null; + } + + public boolean isAggregatePrecommitListener() { + return false; + } + + public boolean isPostcommitOnly() { + return true; + } + + public boolean isPrecommitOnly() { + return false; + } + + public void resourceSetChanged(ResourceSetChangeEvent event) { + if(event.getTransaction() != null && event.getTransaction().getStatus().isOK()) { + fireIsDirtyChanged(); + } + } + + public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException { + return null; + } + + }; + + /** + * Constructor. + * + */ + public SaveAndDirtyService() { + registeredIsaveablePart = new ISaveablePartList(); + inputChangedListeners = new ArrayList(); + } + + /** + * Initialize the service. Retrieve other required services (ModelSet, + * CoreEditor). + * + * @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry) + * + * @param servicesRegistry + * @throws ServiceException + */ + public void init(ServicesRegistry servicesRegistry) throws ServiceException { + + this.servicesRegistry = servicesRegistry; + + // Retrieve required services. + resourceSet = servicesRegistry.getService(ModelSet.class); + multiDiagramEditor = servicesRegistry.getService(IMultiDiagramEditor.class); + transactionalEditingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(servicesRegistry); + + // Initialize and register the ILifeCycleEventsProvider service (which + // is ourself). + // This mean that the ILifeCycleEventsProvider is not available until we + // are started. + lifeCycleEvent = new DoSaveEvent(servicesRegistry, multiDiagramEditor); + // servicesRegistry.add(ILifeCycleEventsProvider.class, 1, + // lifeCycleEventsProvider); + + } + + /** + * Do nothing. + * + * @see org.eclipse.papyrus.infra.core.services.IService#startService() + * + * @throws ServiceException + */ + public void startService() throws ServiceException { + + // Listen to the modifications of the EMF model + transactionalEditingDomain.getCommandStack().addCommandStackListener(commandStackListener); + + // Let's listen to the resource set change + transactionalEditingDomain.addResourceSetListener(resourceSetListener); + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#disposeService() + * + * @throws ServiceException + */ + public void disposeService() throws ServiceException { + if(transactionalEditingDomain != null) { + transactionalEditingDomain.getCommandStack().removeCommandStackListener(commandStackListener); + transactionalEditingDomain.removeResourceSetListener(resourceSetListener); + } + } + + /** + * Save the Models + * + * @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor) + * + * @param monitor + */ + public void doSave(IProgressMonitor monitor) { + // Sent pre doSave event + lifeCycleEventsProvider.fireAboutToDoSaveEvent(lifeCycleEvent); + + // sent doSaveEvent + lifeCycleEventsProvider.fireDoSaveEvent(lifeCycleEvent); + // Perform local doSave + // TODO : put it in a listener ? + try { + // Save each associated resource + resourceSet.save(monitor); + // notify registered IsaveablePart + registeredIsaveablePart.doSave(monitor); + markSaveLocation(); + } catch (IOException e) { + log.error("Error during save", e); + } + + // Sent post Events + lifeCycleEventsProvider.firePostDoSaveEvent(lifeCycleEvent); + + } + + /** + * @see org.eclipse.ui.ISaveablePart#doSaveAs() + * + */ + public void doSaveAs() { + // Sent pre doSave event + lifeCycleEventsProvider.fireAboutToDoSaveAsEvent(lifeCycleEvent); + + // sent doSaveEvent + lifeCycleEventsProvider.fireDoSaveAsEvent(lifeCycleEvent); + // Perform local doSaveAs + + // Show a SaveAs dialog + Shell shell = multiDiagramEditor.getEditorSite().getWorkbenchWindow().getShell(); + SaveAsDialog dialog = new SaveAsDialog(shell); + dialog.setOriginalFile(((IFileEditorInput)multiDiagramEditor.getEditorInput()).getFile()); + dialog.open(); + final IPath path = dialog.getResult(); + if(path != null) { + // try to save the editor's contents under a different file name + final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); + try { + new ProgressMonitorDialog(shell).run(false, // don't fork + false, // can't cancel + new WorkspaceModifyOperation() { // run this operation + + @Override + public void execute(final IProgressMonitor monitor) { + try { + resourceSet.saveAs(path); + // notify registered IsaveablePart + registeredIsaveablePart.doSave(monitor); + } catch (IOException e) { + log.error("Unable to saveAs the resource set", e); + } + } + }); + // set input to the new file + fireEditorInputChanged(new FileEditorInput(file)); + markSaveLocation(); + } catch (InterruptedException e) { + // should not happen, since the monitor dialog is not cancelable + log.error(e); + } catch (InvocationTargetException e) { + log.error(e); + } + } + + // sent doSaveEvent + lifeCycleEventsProvider.firePostDoSaveAsEvent(lifeCycleEvent); + } + + /** + * Change the input of the underlying editor. + * + * @param fileEditorInput + */ + private void fireEditorInputChanged(FileEditorInput fileEditorInput) { + + for(IEditorInputChangedListener listener : inputChangedListeners) { + try { + listener.editorInputChanged(fileEditorInput); + } catch (Exception e) { + log.error("Can't set input for '" + listener + "'", e); + } + } + + } + + /** + * Fire a PropertyChanged event to registered {@link IEditorInputChangedListener}. + * + * @param propertyId + */ + private void fireIsDirtyChanged() { + + for(IEditorInputChangedListener listener : inputChangedListeners) { + try { + listener.isDirtyChanged(); + } catch (Exception e) { + log.error("Can't call listener '" + listener + "'", e); + } + } + + } + + /** + * Return true if the multiEditor is dirty, false otherwise. The dirty state + * is compute as follow: + *
    + *
  • The {@link TransactionalEditingDomain} commandStack is checked
  • + *
  • and each registered nested Isaveable.isDirty() state is checked
  • + *
  • + *
  • + *
  • + *
  • + *
+ * If one of these states is false, the returned value is false.
+ * If all of these states are true, the returned value is true. + * + * @see org.eclipse.ui.ISaveablePart#isDirty() + * + * @return + */ + public boolean isDirty() { + // First, look if the model part (EMF) is dirty, else look at the + // Graphical part (GEF/GMF) + return ((BasicCommandStack)transactionalEditingDomain.getCommandStack()).isSaveNeeded() || registeredIsaveablePart.isDirty(); + } + + /** + * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed() + * + * @return + */ + public boolean isSaveAsAllowed() { + return true; + } + + /** + * @see org.eclipse.ui.ISaveablePart#isSaveOnCloseNeeded() + * + * @return + */ + public boolean isSaveOnCloseNeeded() { + return isDirty(); + } + + /** + * Mark the command stack of all sub-editors. Default implementation do + * nothing. + */ + protected void markSaveLocation() { + ((BasicCommandStack)transactionalEditingDomain.getCommandStack()).saveIsDone(); + fireIsDirtyChanged(); + } + + /** + * Register a nested {@link ISaveablePart} as a listener that will be + * notified each time a {@link #doSave(IProgressMonitor)} or {@link #doSaveAs()} is performed. Also, it will be asked for the + * dirtyState. + * + * @param saveablePart + */ + public void registerIsaveablePart(ISaveablePart saveablePart) { + registeredIsaveablePart.add(saveablePart); + } + + /** + * Remove the specified {@link ISaveablePart} from the list of listeners. + * + * @param saveablePart + */ + public void removeIsaveablePart(ISaveablePart saveablePart) { + registeredIsaveablePart.remove(saveablePart); + } + + /** + * Add a listeners on input changed event. + * + * @param inputChangedListener + */ + public void addInputChangedListener(IEditorInputChangedListener inputChangedListener) { + inputChangedListeners.add(inputChangedListener); + } + + /** + * Remove a listeners on input changed event. + * + * @param inputChangedListener + */ + public void removeInputChangedListener(IEditorInputChangedListener inputChangedListener) { + inputChangedListeners.remove(inputChangedListener); + } + + /** + * A list of {@link ISaveablePart}. + * + * @author dumoulin + * + */ + public class ISaveablePartList extends ArrayList { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Return true if one of the part is dirty, false if all part are not + * dirty. + * + * @return + */ + public boolean isDirty() { + for(ISaveablePart part : this) { + if(part.isDirty()) + return true; + } + + return false; + } + + /** + * Call doSave on each registered {@link ISaveablePart}. + * + * @param monitor + */ + public void doSave(IProgressMonitor monitor) { + for(ISaveablePart part : this) { + + try { + part.doSave(monitor); + } catch (Exception e) { + log.error("Can't save ISaveablePart '" + part + "'", e); + } + } + + } + + /** + * Call doSaveAs on each registered {@link ISaveablePart}. + * + * @param monitor + */ + public void doSaveAs() { + for(ISaveablePart part : this) { + try { + part.doSaveAs(); + } catch (Exception e) { + log.error("Can't save ISaveablePart '" + part + "'", e); + } + } + + } + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/listenerservice/IPapyrusListener.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/listenerservice/IPapyrusListener.java new file mode 100644 index 00000000000..70fdda8f588 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/listenerservice/IPapyrusListener.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2008 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.infra.core.listenerservice; + +import org.eclipse.emf.common.notify.Notification; + +/** + * This interface is a listener that will listen directly all events in papyrus: + * uml. It will be very useful for external plug-in. + * + * An implementation may be an adapter. + */ +public interface IPapyrusListener { + + /** + * Notifies that a change to some feature has occurred. + * + * @param notification + * - a description of the change. + **/ + public void notifyChanged(Notification notification); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/listenerservice/ModelListenerManager.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/listenerservice/ModelListenerManager.java new file mode 100644 index 00000000000..412c1b7e402 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/listenerservice/ModelListenerManager.java @@ -0,0 +1,126 @@ +/******************************************************************************* + * Copyright (c) 2008 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.infra.core.listenerservice; + +import java.util.Enumeration; +import java.util.Hashtable; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.util.EContentAdapter; +import org.eclipse.papyrus.infra.core.Activator; +import org.osgi.framework.Bundle; + +/** + * This class is a manager that loads all listeners of the uml model + * + */ + +public class ModelListenerManager extends EContentAdapter { + + // list of of listener + private Hashtable listenerRegistry; + + // extension point ID + private String MODELLISTENERID_EXTENSION_ID = "org.eclipse.papyrus.infra.core.modelListener"; + + private String NAME_ID = "name"; + + private String REALIZATION_ID = "realization"; + + /** + * Constructor + */ + public ModelListenerManager() { + super(); + // init stack + listenerRegistry = new Hashtable(); + initializeListenerList(); + } + + /** + * Load all listeners of the model + */ + private void initializeListenerList() { + // Reading data from plugins + IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(MODELLISTENERID_EXTENSION_ID); + for(int i = 0; i < configElements.length; i++) { + inializeOneRule(configElements[i]); + } + + } + + /** + * Load one listener + * + * @param element + * the extension point + */ + private void inializeOneRule(IConfigurationElement element) { + String listenerName = element.getAttribute(NAME_ID); + try { + IPapyrusListener listener = (IPapyrusListener)createExtension(element, element.getAttribute(REALIZATION_ID)); + listenerRegistry.put(listenerName, listener); + } catch (Exception e) { + Activator.log.error("- " + listenerName + " can not be loaded: " + e.getLocalizedMessage(), e); + } + + } + + /** + * Load an instance of a class + * + * @param element + * the extension point + * @param classAttribute + * the name of the class to load + * @return the loaded Class + * @throws Exception + * if the class is not loaded + */ + private static Object createExtension(final IConfigurationElement element, final String classAttribute) throws Exception { + try { + Bundle extensionBundle = Platform.getBundle(element.getDeclaringExtension().getNamespaceIdentifier()); + Class clazz = extensionBundle.loadClass(classAttribute); + Object obj = clazz.newInstance(); + return obj; + // return element.createExecutableExtension(classAttribute); + } catch (Exception e) { + throw new Exception("unable to create Extension" + e); + } + } + + /** + * {@inheritDoc} + */ + public String toString() { + String out = "ModelListener: \n"; + Enumeration keyenum = listenerRegistry.keys(); + // we will call to string in each class + while(keyenum.hasMoreElements()) { + String aKey = keyenum.nextElement(); + out = out + "- " + aKey + " (" + listenerRegistry.get(aKey).toString() + ")\n"; + } + return out; + } + + /** + * {@inheritDoc} + */ + public void notifyChanged(Notification notification) { + super.notifyChanged(notification); + Enumeration papyrusListenersEnum = listenerRegistry.elements(); + while(papyrusListenersEnum.hasMoreElements()) { + papyrusListenersEnum.nextElement().notifyChanged(notification); + } + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/ModelSetQuery.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/ModelSetQuery.java new file mode 100644 index 00000000000..777a3ba48e4 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/ModelSetQuery.java @@ -0,0 +1,43 @@ +/***************************************************************************** + * 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.infra.core.modelsetquery; + +import static org.eclipse.papyrus.infra.core.modelsetquery.impl.ModelSetQueryAdapter.getExistingTypeCacheAdapter; + +import java.util.Collection; + +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.core.modelsetquery.impl.IModelSetQueryAdapter; + +/** + * The Class ModelSetQuery provides service to get objects of specified type + * using cache mechanism + */ +public class ModelSetQuery { + + /** + * Return all the objects of specified type + * + * @param eobjectInModelSet + * , the object from which to search starts + * @param type + * , the searched type + * @return the list of the instance of specified type + */ + public static Collection getObjectsOfType(EObject eobjectInModelSet, EClassifier type) { + IModelSetQueryAdapter adapter = getExistingTypeCacheAdapter(eobjectInModelSet); + return adapter.getReachableObjectsOfType(eobjectInModelSet, type); + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/IModelSetQueryAdapter.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/IModelSetQueryAdapter.java new file mode 100644 index 00000000000..62da5c1859e --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/IModelSetQueryAdapter.java @@ -0,0 +1,39 @@ +/***************************************************************************** + * 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: + * Tristan FAURE tristan.faure@atosorigin.com - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.modelsetquery.impl; + +import java.util.Collection; + +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EObject; + +/** + * interface to manage services to return objects from type + * + * @author tfaure + * + */ +public interface IModelSetQueryAdapter { + + /** + * Return all the objects of type type + * + * @param object + * , the object to start the search + * @param type + * , the type searched + * @return the list of the instance of type + */ + Collection getReachableObjectsOfType(EObject object, EClassifier type); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/ModelSetQueryAdapter.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/ModelSetQueryAdapter.java new file mode 100644 index 00000000000..a5144350a7d --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/ModelSetQueryAdapter.java @@ -0,0 +1,485 @@ +/***************************************************************************** + * 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: + * Tristan FAURE tristan.faure@atosorigin.com - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.modelsetquery.impl; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.URI; +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.InternalEObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; + +/** + * This cache creates a map associating EClasses to all the corresponding + * instances + * + * @author Tristan Faure + */ +public class ModelSetQueryAdapter implements IModelSetQueryAdapter, Adapter.Internal { + + /** + * The cache of elements + */ + private Map> cache = Collections.synchronizedMap(new HashMap>()); + + /** + * This cache adapter is only used if the caller don't use correctly + * TypeCacheAdapter. With the simple cache adapter performance are not good + * but a result is still returned + */ + private static SimpleTypeCacheAdapter simpleCacheAdapter = new SimpleTypeCacheAdapter(); + + protected Set unloadedResources = new HashSet(); + + protected Set alreadyLoadedURIs = new HashSet(); + + protected Map unloadedEObjects = new HashMap(); + + public ModelSetQueryAdapter() { + super(); + } + + /** + * Searches the adapter list of the given Notifier for a TypeCacheAdapter. + * If not found, returns null. + * + * @param notifier + * the notifier to search + * @return the TypeCacheAdapter if found or a simple ITypeCacheAdapter which + * calls default method + */ + public static IModelSetQueryAdapter getExistingTypeCacheAdapter(Notifier notifier) { + if(notifier == null) { + return simpleCacheAdapter; + } + for(Adapter adapter : notifier.eAdapters()) { + if(adapter instanceof ModelSetQueryAdapter) { + return (ModelSetQueryAdapter)adapter; + } + } + if(notifier instanceof EObject) { + EObject object = (EObject)notifier; + IModelSetQueryAdapter typeCacheAdapter = getExistingTypeCacheAdapter(object.eResource()); + if(typeCacheAdapter != null) { + object.eAdapters().add((Adapter)typeCacheAdapter); + return typeCacheAdapter; + } + } else if(notifier instanceof Resource) { + Resource resource = (Resource)notifier; + IModelSetQueryAdapter typeCacheAdapter = getExistingTypeCacheAdapter(resource.getResourceSet()); + if(typeCacheAdapter != null) { + if(typeCacheAdapter instanceof Adapter) { + resource.eAdapters().add((Adapter)typeCacheAdapter); + } + return typeCacheAdapter; + } + } + return simpleCacheAdapter; + } + + protected void addAdapter(Notifier notifier) { + if(notifier instanceof EObject) { + EObject eobject = (EObject)notifier; + addObjectInCache(eobject); + } + List eAdapters = notifier.eAdapters(); + if(!eAdapters.contains(this)) { + eAdapters.add(this); + } + } + + protected void handleContainment(Notification notification) { + Object notifier = notification.getNotifier(); + // synchronize cache on ADD and REMOVE notifications + if(notifier instanceof EObject) { + caseEobject(notification); + } else if(notifier instanceof ResourceSet) { + switch(notification.getEventType()) { + case Notification.ADD: + { + if(notification.getNewValue() instanceof Resource) { + Resource r = (Resource)notification.getNewValue(); + if(!r.eAdapters().contains(this)) { + r.eAdapters().add(this); + } + } + } + case Notification.RESOLVE: + { + if(notification.getNewValue() instanceof Resource) { + Resource r = (Resource)notification.getNewValue(); + for(Iterator i = r.getAllContents(); i.hasNext();) { + EObject next = i.next(); + addObjectInCache(next); + } + } + } + case Notification.REMOVE: + { + // MAYBE TODO + } + } + } + } + + private void caseEobject(Notification notification) { + switch(notification.getEventType()) { + case Notification.ADD: + { + Object newValue = notification.getNewValue(); + if(newValue != null && (newValue instanceof EObject)) { + addObjectInCache((EObject)newValue); + } + break; + } + case Notification.ADD_MANY: + { + for(Object newValue : (Collection)notification.getNewValue()) { + if(newValue != null && (newValue instanceof EObject)) { + addObjectInCache((EObject)newValue); + } + } + break; + } + case Notification.REMOVE: + { + Object oldValue = notification.getOldValue(); + if(oldValue != null && (oldValue instanceof EObject)) { + removeObjectFromCache((EObject)oldValue); + } + break; + } + case Notification.REMOVE_MANY: + { + for(Object oldValue : (Collection)notification.getOldValue()) { + if(oldValue != null && (oldValue instanceof EObject)) { + removeObjectFromCache((EObject)oldValue); + } + } + break; + } + } + } + + private void addObjectInCache(EObject newObj) { + EClass eClass = newObj.eClass(); + putObjectInCache(eClass, newObj); + for(EClass eSuperClass : eClass.getEAllSuperTypes()) { + putObjectInCache(eSuperClass, newObj); + } + } + + private void putObjectInCache(EClassifier eClassifier, EObject newObj) { + Collection listOfClassifiers = cache.get(eClassifier); + if(listOfClassifiers != null) { + listOfClassifiers.add(newObj); + } + } + + private void removeObjectFromCache(EObject newObj) { + EClass eClass = newObj.eClass(); + removeObjectFromCache(eClass, newObj); + for(EClass eSuperClass : eClass.getEAllSuperTypes()) { + removeObjectFromCache(eSuperClass, newObj); + } + } + + private void removeObjectFromCache(EClassifier eClassifier, EObject newObj) { + Collection listOfClassifiers = cache.get(eClassifier); + if(listOfClassifiers != null) { + listOfClassifiers.remove(newObj); + } + } + + /** + * @see org.eclipse.emf.common.notify.Adapter#isAdapterForType(java.lang.Object) + */ + public boolean isAdapterForType(Object type) { + return ModelSetQueryAdapter.class.equals(type); + } + + public Collection getReachableObjectsOfType(EObject object, EClassifier type) { + if(!cache.containsKey(type)) { + cache.put(type, new HashSet(ItemPropertyDescriptor.getReachableObjectsOfType(object, type))); + } + return cache.get(type); + } + + public void dispose() { + cache.clear(); + unloadedEObjects.clear(); + unloadedResources.clear(); + cache = null; + } + + /** + * Handles a notification by calling {@link #selfAdapt selfAdapter}. + */ + public void notifyChanged(Notification notification) { + selfAdapt(notification); + } + + /** + * Handles a notification by calling {@link #handleContainment + * handleContainment} for any containment-based notification. + */ + protected void selfAdapt(Notification notification) { + Object notifier = notification.getNotifier(); + if(notifier instanceof EObject) { + Object feature = notification.getFeature(); + if(feature instanceof EReference) { + EReference reference = (EReference)feature; + if(reference.isContainment()) { + handleContainment(notification); + } + } + } else if(notifier instanceof Resource) { + switch(notification.getFeatureID(Resource.class)) { + case Resource.RESOURCE__CONTENTS: + { + if(!unloadedResources.contains(notifier)) { + switch(notification.getEventType()) { + case Notification.REMOVE: + { + Resource resource = (Resource)notifier; + if(!resource.isLoaded()) { + EObject eObject = (EObject)notification.getOldValue(); + unloadedEObjects.put(eObject, resource); + for(Iterator i = EcoreUtil.getAllProperContents(eObject, false); i.hasNext();) { + EObject next = i.next(); + unloadedEObjects.put(next, resource); + removeObjectFromCache(next); + } + } + break; + } + case Notification.REMOVE_MANY: + { + Resource resource = (Resource)notifier; + if(!resource.isLoaded()) { + @SuppressWarnings("unchecked") + List eObjects = (List)notification.getOldValue(); + for(Iterator i = EcoreUtil.getAllProperContents(eObjects, false); i.hasNext();) { + EObject next = i.next(); + unloadedEObjects.put(next, resource); + removeObjectFromCache(next); + } + } + break; + } + default: + { + handleContainment(notification); + break; + } + } + } + break; + } + case Resource.RESOURCE__IS_LOADED: + { + if(notification.getNewBooleanValue()) { + unloadedResources.remove(notifier); + for(Notifier child : ((Resource)notifier).getContents()) { + addAdapter(child); + } + } else { + unloadedResources.add((Resource)notifier); + for(Iterator i = EcoreUtil.getAllProperContents((Resource)notifier, false); i.hasNext();) { + EObject next = i.next(); + removeObjectFromCache(next); + } + } + break; + } + } + } else if(notifier instanceof ResourceSet) { + if(notification.getFeatureID(ResourceSet.class) == ResourceSet.RESOURCE_SET__RESOURCES) { + handleContainment(notification); + } + } + } + + /** + * Handles installation of the adapter by adding the adapter to each of the + * directly contained objects. + */ + public void setTarget(Notifier target) { + if(target instanceof EObject) { + setTarget((EObject)target); + } else if(target instanceof Resource) { + setTarget((Resource)target); + } else if(target instanceof ResourceSet) { + setTarget((ResourceSet)target); + } + } + + /** + * Handles installation of the adapter on an EObject by adding the adapter + * to each of the directly contained objects. + */ + protected void setTarget(EObject target) { + for(@SuppressWarnings("unchecked") + Iterator i = resolve() ? target.eContents().iterator() : (Iterator)((InternalEList)target.eContents()).basicIterator(); i.hasNext();) { + Notifier notifier = i.next(); + addAdapter(notifier); + } + } + + /** + * Handles installation of the adapter on a Resource by adding the adapter + * to each of the directly contained objects. + */ + protected void setTarget(Resource target) { + if(!target.isLoaded()) { + unloadedResources.add(target); + } + List contents = target.getContents(); + for(int i = 0, size = contents.size(); i < size; ++i) { + Notifier notifier = contents.get(i); + addAdapter(notifier); + } + } + + /** + * Handles installation of the adapter on a ResourceSet by adding the + * adapter to each of the directly contained objects. + */ + protected void setTarget(ResourceSet target) { + List resources = target.getResources(); + for(int i = 0; i < resources.size(); ++i) { + Notifier notifier = resources.get(i); + addAdapter(notifier); + } + } + + /** + * Handles undoing the installation of the adapter by removing the adapter + * to each of the directly contained objects. + */ + public void unsetTarget(Notifier target) { + if(target instanceof EObject) { + unsetTarget((EObject)target); + } else if(target instanceof Resource) { + unsetTarget((Resource)target); + } else if(target instanceof ResourceSet) { + unsetTarget((ResourceSet)target); + } + } + + /** + * Handles undoing the installation of the adapter from an EObject by + * removing the adapter to each of the directly contained objects. + */ + protected void unsetTarget(EObject target) { + for(@SuppressWarnings("unchecked") + Iterator i = resolve() ? (Iterator)(Iterator)target.eContents().iterator() : (Iterator)((InternalEList)target.eContents()).basicIterator(); i.hasNext();) { + // Don't remove the adapter if the object is in a different resource + // and that resource (and hence all its contents) are being cross + // referenced. + // + InternalEObject internalEObject = i.next(); + Resource eDirectResource = internalEObject.eDirectResource(); + if(eDirectResource == null || !eDirectResource.eAdapters().contains(this)) { + removeAdapter(internalEObject); + } + } + } + + /** + * Handles undoing the installation of the adapter from a Resource by + * removing the adapter to each of the directly contained objects. + */ + protected void unsetTarget(Resource target) { + List contents = target.getContents(); + for(int i = 0, size = contents.size(); i < size; ++i) { + Notifier notifier = contents.get(i); + removeAdapter(notifier); + } + } + + /** + * Handles undoing the installation of the adapter from a ResourceSet by + * removing the adapter to each of the directly contained objects. + */ + protected void unsetTarget(ResourceSet target) { + List resources = target.getResources(); + for(int i = 0; i < resources.size(); ++i) { + Notifier notifier = resources.get(i); + removeAdapter(notifier); + } + } + + protected void removeAdapter(Notifier notifier) { + notifier.eAdapters().remove(this); + } + + public Notifier getTarget() { + return null; + } + + protected boolean resolve() { + return true; + } + + /** + * This method provides a way for user to force first entries in the cache. + * The list of element must be a HashSet to optimize the performances + * + * @param type + * @param list + */ + public void fillFirstEntryCache(EClassifier type, HashSet list) { + cache.put(type, list); + } + + public boolean isAlreadyComputed(EClassifier type) { + return cache.containsKey(type); + } + + public static IModelSetQueryAdapter getSimpleTypeCacheAdapter() { + return simpleCacheAdapter; + } + + /** + * This implementation uses ItemPropertyDescriptor class to resolve objects + * from type + * + * @author tfaure + */ + private static class SimpleTypeCacheAdapter implements IModelSetQueryAdapter { + + public Collection getReachableObjectsOfType(EObject object, EClassifier type) { + return ItemPropertyDescriptor.getReachableObjectsOfType(object, type); + } + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/ModelSetQueryInitializer.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/ModelSetQueryInitializer.java new file mode 100644 index 00000000000..3a07a78f9d6 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/ModelSetQueryInitializer.java @@ -0,0 +1,66 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.modelsetquery.impl; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.util.EList; +import org.eclipse.papyrus.infra.core.resource.IModelSetSnippet; +import org.eclipse.papyrus.infra.core.resource.ModelSet; + +/** + * This snippet take in charge the initialization of the TypeCache. The snippet + * is attached to the {@link ModelSet} (in the extensions), and called right + * after ModelsManager is initialized. + * + * @author cedric dumoulin + * + */ +public class ModelSetQueryInitializer implements IModelSetSnippet { + + /** + * The type cache adapter used to reference elements from a type + */ + private ModelSetQueryAdapter modelQueryAdapter; + + /** + * @see org.eclipse.papyrus.infra.core.resource.IModelSetSnippet#start(org.eclipse.papyrus.infra.core.resource.ModelSet) + * + * @param modelsManager + */ + public void start(ModelSet modelsManager) { + EList eAdapters = modelsManager.eAdapters(); + boolean found = false; + for(Adapter adapter : eAdapters) { + if(adapter instanceof IModelSetQueryAdapter) { + found = true; + modelQueryAdapter = (ModelSetQueryAdapter)adapter; + } + } + if(!found) { + modelQueryAdapter = new ModelSetQueryAdapter(); + eAdapters.add(modelQueryAdapter); + } + + } + + /** + * @see org.eclipse.papyrus.infra.core.resource.IModelSetSnippet#dispose(org.eclipse.papyrus.infra.core.resource.ModelSet) + * + * @param modelsManager + */ + public void dispose(ModelSet modelsManager) { + if(modelQueryAdapter != null) { + modelsManager.eAdapters().remove(modelQueryAdapter); + } + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/ActionBarContributorDescriptor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/ActionBarContributorDescriptor.java new file mode 100644 index 00000000000..46dfe14b299 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/ActionBarContributorDescriptor.java @@ -0,0 +1,71 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor; + +import org.eclipse.papyrus.infra.core.editor.BackboneException; +import org.eclipse.ui.part.EditorActionBarContributor; + +/** + * Descriptor of an ActionBarContributor. This descriptor is usually loaded from + * the Eclipse extension mechanism. + * + * @author Cedric Dumoulin + * @author Patrick Tessier + * + */ +public class ActionBarContributorDescriptor { + + protected Class contextClass; + + protected String contextId; + + /** + * Instance is created when requested. + */ + protected EditorActionBarContributor instance = null; + + /** + * constructor. + * + * @return the context descriptor + * @throws BackboneException + */ + protected EditorActionBarContributor getActionBarContributor() throws BackboneException { + if(instance == null) + instance = createActionBarContributor(); + + return instance; + } + + private EditorActionBarContributor createActionBarContributor() throws BackboneException { + try { + EditorActionBarContributor context = contextClass.newInstance(); + return context; + + } catch (SecurityException e) { + // Lets propagate. This is an implementation problem that should be + // solved by programmer. + throw new RuntimeException(e); + } catch (InstantiationException e) { + // Lets propagate. This is an implementation problem that should be + // solved by programmer. + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + // Lets propagate. This is an implementation problem that should be + // solved by programmer. + throw new RuntimeException(e); + } + } + +} // end class diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/ActionBarContributorExtensionFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/ActionBarContributorExtensionFactory.java new file mode 100644 index 00000000000..3b79fec085b --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/ActionBarContributorExtensionFactory.java @@ -0,0 +1,72 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.papyrus.infra.core.extension.BadNameExtensionException; +import org.eclipse.papyrus.infra.core.extension.ExtensionException; +import org.eclipse.papyrus.infra.core.extension.ExtensionUtils; +import org.eclipse.ui.part.EditorActionBarContributor; + +/** + * A factory used to create ActionBarContributor object from Eclipse extensions + * points elements. + * + * @author Cedric Dumoulin + * @auhtor Patrick Tessier + */ +public class ActionBarContributorExtensionFactory extends ExtensionUtils { + + /** singleton eINSTANCE of this class */ + public final static ActionBarContributorExtensionFactory eINSTANCE = new ActionBarContributorExtensionFactory(); + + /** constant for the editor diagram **/ + public final static String EDITOR_ACTIONBARCONTRIBUTOR_EXTENSIONPOINT = "" + "actionBarContributor"; + + /** constant for the attribute factoryClass **/ + public final static String CONTEXTCLASS_ATTRIBUTE = "implementingClass"; + + /** constant for the attribute contextId **/ + public final static String ID_ATTRIBUTE = "id"; + + /** + * @return the eINSTANCE + */ + public static ActionBarContributorExtensionFactory getInstance() { + return eINSTANCE; + } + + /** + * Create a ContextDescriptor instance corresponding to the + * ConfigurationElement. + * + * @param element + * an {@link IConfigurationElement} see eclipse extension point + * @return a ContextDescriptor structure that contains information to the + * diagram context + * @throws BadNameExtensionException + **/ + public ActionBarContributorDescriptor createActionBarContributorDescriptor(IConfigurationElement element) throws ExtensionException { + ActionBarContributorDescriptor res; + + checkTagName(element, EDITOR_ACTIONBARCONTRIBUTOR_EXTENSIONPOINT); + + res = new ActionBarContributorDescriptor(); + res.contextClass = (Class)parseClass(element, CONTEXTCLASS_ATTRIBUTE, EDITOR_ACTIONBARCONTRIBUTOR_EXTENSIONPOINT); + res.contextId = element.getAttribute(ID_ATTRIBUTE); + + return res; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/ActionBarContributorRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/ActionBarContributorRegistry.java new file mode 100644 index 00000000000..3a430daf027 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/ActionBarContributorRegistry.java @@ -0,0 +1,172 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor; + +import static org.eclipse.papyrus.infra.core.Activator.log; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.papyrus.infra.core.editor.BackboneException; +import org.eclipse.papyrus.infra.core.extension.ExtensionException; +import org.eclipse.papyrus.infra.core.extension.NotFoundException; +import org.eclipse.papyrus.infra.core.services.IService; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.ui.part.EditorActionBarContributor; + +/** + * A factory managing ActionBarContributor creation. The factory is loaded from + * ActionBarContributor declared in Eclipse extension mechanism. + * + * @author dumoulin + * + */ +public class ActionBarContributorRegistry implements IActionBarContributorFactory, IService { + + /** ID of the editor extension (schema filename) */ + public static final String EDITOR_EXTENSION_ID = "papyrusDiagram"; + + /** Namespace where to look for the extension points. */ + protected String extensionPointNamespace; + + /** + * Registered context descriptors. + */ + private Map editorContextDescriptors; + + /** + * Constructor. defaultContext, input and site are explicitly required in + * order be sure that they are initialized. The multiEditor should be + * initialized. In particular, getEditorSite(), getEditorInput() and + * getDefaultContext() should return initialized values. + * + * @param multiEditor + * the multieditor + * @param extensionPointNamespace + */ + public ActionBarContributorRegistry(String extensionPointNamespace) { + + this.extensionPointNamespace = extensionPointNamespace; + initializeEditorContextDescriptors(); + } + + /** + * + * {@inheritDoc} + */ + public EditorActionBarContributor getActionBarContributor(Object key) throws BackboneException { + try { + ActionBarContributorDescriptor desc = editorContextDescriptors.get(key); + return desc.getActionBarContributor(); + } catch (NullPointerException e) { + // no context found. + throw new NotFoundException("No ActionBarContributor registered under id '" + key + "'."); + } + } + + /** + * Get the list of descriptors. + * + * @return + * @throws BackboneException + * If a contributor fail to be loaded. + */ + public List getActionBarContributors() throws BackboneException { + List res = new ArrayList(); + for(ActionBarContributorDescriptor desc : editorContextDescriptors.values()) { + res.add(desc.getActionBarContributor()); + } + return res; + } + + /** + * + * {@inheritDoc} + */ + public void registerActionBarContributor(String contextKey, EditorActionBarContributor contributor) { + ActionBarContributorDescriptor desc = new ActionBarContributorDescriptor(); + desc.contextId = contextKey; + desc.instance = contributor; + desc.contextClass = contributor.getClass(); + + editorContextDescriptors.put(contextKey, desc); + } + + /** + * Read context descriptors from extension points. + */ + private void initializeEditorContextDescriptors() { + + editorContextDescriptors = new HashMap(); + // Reading data from plugins + IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointNamespace, EDITOR_EXTENSION_ID); + + ActionBarContributorExtensionFactory extensionReader = new ActionBarContributorExtensionFactory(); + + for(IConfigurationElement ele : configElements) { + ActionBarContributorDescriptor desc; + try { + if(ActionBarContributorExtensionFactory.EDITOR_ACTIONBARCONTRIBUTOR_EXTENSIONPOINT.equals(ele.getName())) { + desc = extensionReader.createActionBarContributorDescriptor(ele); + // Check double + if(editorContextDescriptors.get(desc.contextId) != null) { + // Already exists. Check if it is the same + ActionBarContributorDescriptor existingDesc = editorContextDescriptors.get(desc.contextId); + if(desc.equals(existingDesc)) { + log.warn("More than one ActionBarContributor is registered under the name '" + desc.contextId + "', with different parameters. Extra declaration are discarded."); + } + } else { + editorContextDescriptors.put(desc.contextId, desc); + } + } + } catch (ExtensionException e) { + log.error(e.getMessage(), e); + } + } + + if(log.isDebugEnabled()) { + log.debug(this.getClass().getSimpleName() + " : contributors desc loaded [" + editorContextDescriptors.size() + "]"); + } + } + + /** + * Initialize the service. Do nothing here. + * + * @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry) + * + * @param servicesRegistry + */ + public void init(ServicesRegistry servicesRegistry) { + + } + + /** + * Do nothing in this implementation. {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.services.IService#startService() + */ + public void startService() { + } + + /** + * Do nothing in this implementation. + */ + public void disposeService() { + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java new file mode 100644 index 00000000000..c2bdad24a28 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java @@ -0,0 +1,117 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor; + +import java.util.List; + +import org.eclipse.papyrus.infra.core.Activator; +import org.eclipse.papyrus.infra.core.editor.BackboneException; +import org.eclipse.papyrus.infra.core.sasheditor.editor.actionbarcontributor.ComposedActionBarContributor; +import org.eclipse.papyrus.infra.core.sasheditor.editor.actionbarcontributor.IMultiPageEditorActionBarContributor; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.part.EditorActionBarContributor; + +/** + * + * An ActionBarContributor composed of ActionBarContributor from multi editor. + * This ActionBarContributor switch to the contributor dedicated to the active + * editor in a MultiPageEditor environement. + * + * @author dumoulin + * + */ +public class CoreComposedActionBarContributor extends ComposedActionBarContributor implements IMultiPageEditorActionBarContributor { + + /** + * The registry. Used to initialize the registered actionBars. + */ + protected ActionBarContributorRegistry actionBarContributorRegistry; + + protected List contributors; + + /** + * Constructor. + * + * @throws BackboneException + */ + public CoreComposedActionBarContributor() throws BackboneException { + // Init the contributors + loadContributors(); + } + + /** + * + * @throws BackboneException + */ + private void loadContributors() throws BackboneException { + actionBarContributorRegistry = new ActionBarContributorRegistry(Activator.PLUGIN_ID); + + contributors = actionBarContributorRegistry.getActionBarContributors(); + } + + /** + * @return the actionBarContributorRegistry + */ + public ActionBarContributorRegistry getActionBarContributorRegistry() { + return actionBarContributorRegistry; + } + + /** + * Dispose all nested ActionBarContributors. + */ + @Override + public void dispose() { + // Dispose nested contributors. + for(EditorActionBarContributor contributor : contributors) { + contributor.dispose(); + } + super.dispose(); + } + + /** + * Call the same method on each registered nested ActionBarContributors. + */ + @Override + public void init(IActionBars bars, IWorkbenchPage page) { + super.init(bars, page); + buildActions(); + + // init nested contributors. + for(EditorActionBarContributor contributor : contributors) { + contributor.init(bars, page); + } + + } + + /** + * Load default actions (undo/redo/delete) + * + * @see org.eclipse.gef.ui.actions.ActionBarContributor#buildActions() + */ + protected void buildActions() { + // getActionBars().getToolBarManager().add(new UndoRetargetAction()); + // getActionBars().getToolBarManager().add(new RedoRetargetAction()); + } + + @Override + public void setActiveEditor(IEditorPart part) { + super.setActiveEditor(part); + for(EditorActionBarContributor contributor : contributors) { + contributor.setActiveEditor(part); + } + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/IActionBarContributorFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/IActionBarContributorFactory.java new file mode 100644 index 00000000000..5b25e708b65 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/multidiagram/actionbarcontributor/IActionBarContributorFactory.java @@ -0,0 +1,25 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor; + +import org.eclipse.papyrus.infra.core.editor.BackboneException; +import org.eclipse.ui.part.EditorActionBarContributor; + +/** + * Interface used to get an ActionBarContributor from its ID. + * + * @author dumoulin + * + */ +public interface IActionBarContributorFactory { + + /** + * Get an ActionBarContributor by its key. If an ActionBarContributor + * already exists for this key, return it. + * + * @param key + * @return + */ + public EditorActionBarContributor getActionBarContributor(Object key) throws BackboneException; +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractBaseModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractBaseModel.java new file mode 100644 index 00000000000..acd978a5fe1 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractBaseModel.java @@ -0,0 +1,221 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource; + +import java.io.IOException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IPath; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; + +/** + * An abstract implmeentation of model. This class should be subclassed to fit + * the required model. + * + * @author cedric dumoulin + * + */ +public abstract class AbstractBaseModel implements IModel { + + /** + * The associated ModelManager. + */ + private ModelSet modelSet; + + /** + * List of attached snippets. + */ + private ModelSnippetList snippets = new ModelSnippetList(); + + /** + * The associated resource. + */ + protected Resource resource; + + /** + * The resource URI. + */ + protected URI resourceURI; + + /** + * @see org.eclipse.papyrus.infra.core.resource.IModel#init(org.eclipse.papyrus.infra.core.resource.ModelSet) + * + * @param modelManager + */ + public void init(ModelSet modelManager) { + this.modelSet = modelManager; + + } + + /** + * @return the modelManager + */ + protected ModelSet getModelManager() { + return modelSet; + } + + /** + * Get the associated ResourceSet containing the resources of this model. + * + * @return + */ + protected ResourceSet getResourceSet() { + return modelSet; + } + + /** + * @return the resource + */ + public Resource getResource() { + return resource; + } + + /** + * @return the resourceURI + */ + public URI getResourceURI() { + return resourceURI; + } + + /** + * Get the model identifier. + * + * @return + */ + abstract public String getIdentifier(); + + /** + * Get the file extension used by the resource. + * + * @return + */ + abstract protected String getModelFileExtension(); + + /** + * Return true if the resource is set, false otherwise. When the resource is + * set, this mean that the model is loaded or created. + * + * @return + */ + protected boolean resourceIsSet() { + return resource != null; + } + + /** + * @see org.eclipse.papyrus.infra.core.resource.IModel#createModel(org.eclipse.core.runtime.IPath) + * + * @param fullPath + */ + public void createModel(IPath fullPath) { + + // Compute model URI + resourceURI = getPlatformURI(fullPath.addFileExtension(getModelFileExtension())); + + // Create Resource of appropriate type + resource = getModelManager().createResource(resourceURI); + } + + /** + * Get a platform resource URI of the given path + * + * @param path + * the path + * @return the uri + */ + protected URI getPlatformURI(IPath path) { + return URI.createPlatformResourceURI(path.toString(), true); + } + + /** + * Load the model repository. The URI is calculated by removing the + * extension and replacing it by the model extension. + * + * @param file + * The file selected by user requesting load. Should be used as a + * bases to guess the model IPath. + */ + public void loadModel(IFile file) { + // Get the full path and call the load method with it. + loadModel(file.getFullPath().removeFileExtension()); + } + + /** + * Load the model by using the provided fullpath as a hint for the resource + * URI. In this implementation, simply add the model extension. + * + * @param fullPathWithoutExtension + */ + public void loadModel(IPath fullPathWithoutExtension) { + + // Compute model URI + resourceURI = getPlatformURI(fullPathWithoutExtension.addFileExtension(getModelFileExtension())); + + // Create Resource of appropriate type + resource = modelSet.getResource(resourceURI, true); + // call registered snippets + snippets.performStart(this); + } + + /** + * Import the model by using the provided fullpath as a hint for the + * resource URI. In this implementation, simply call {@link #loadModel(IPath)} + * + * @param fullPathWithoutExtension + */ + public void importModel(IPath fullPathWithoutExtension) { + + loadModel(fullPathWithoutExtension); + } + + /** + * @throws IOException + * @see org.eclipse.papyrus.infra.core.resource.IModel#saveModel() + * + */ + public void saveModel() throws IOException { + resource.save(null); + } + + /** + * @see org.eclipse.papyrus.infra.core.resource.IModel#changeModelPath(org.eclipse.core.runtime.IPath) + * + * @param nameWithoutExt + */ + public void changeModelPath(IPath fullPath) { + // Compute model URI + resourceURI = getPlatformURI(fullPath.addFileExtension(getModelFileExtension())); + + resource.setURI(resourceURI); + } + + /** + * @see org.eclipse.papyrus.infra.core.resource.IModel#dispose() + * + */ + public void unload() { + // call registered snippets + snippets.performDispose(this); + + // Do unloading + if(resource != null) { + resource.unload(); + resource = null; + } + } + + /** + * Add a snippet to this model. The snippet is called just after model is + * initialized, and before it is disposed or unloaded. Snippet can be shared + * among models. + * + * @param snippet + * The snippet to add. + */ + public void addModelSnippet(IModelSnippet snippet) { + snippets.add(snippet); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java new file mode 100644 index 00000000000..281c63ece7d --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java @@ -0,0 +1,184 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; + +/** + * Base class for models sharing a common {@link Resource}. To share a common {@link Resource}, one of the model should be Master, while the other are + * slaves. The Master is the one performing the save operation. All the model + * should use the same file extension. So, {@link #getModelFileExtension()} should return the same value for all models. + * + * @author cedric dumoulin + * + * @param T + * Type of the roots of the model. + */ +public abstract class AbstractModelWithSharedResource extends AbstractBaseModel { + + /** + * Possible type for this model: master or slave + */ + public enum ModelKind { + master, slave + } + + /** + * Model kind. + */ + private ModelKind modelKind;; + + /** + * + * Constructor. + * + * @param modelKind + */ + public AbstractModelWithSharedResource(ModelKind modelKind) { + this.modelKind = modelKind; + } + + /** + * By default, we are a slave. Constructor. + * + * @param modelKind + */ + public AbstractModelWithSharedResource() { + this.modelKind = ModelKind.slave; + } + + /** + * Attach the model to its resource if this is not already done. + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#loadModel(org.eclipse.core.runtime.IPath) + * + * @param fullPathWithoutExtension + */ + @Override + public void loadModel(IPath fullPathWithoutExtension) { + + // Look for the resource + lookupResource(fullPathWithoutExtension); + // Check if model is loaded. + if(resourceIsSet()) + return; + // model is not loaded, do it. + super.loadModel(fullPathWithoutExtension); + } + + /** + * Create the model if this is not already done. + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#createModel(org.eclipse.core.runtime.IPath) + * + * @param fullPath + */ + @Override + public void createModel(IPath fullPath) { + + // Look for the resource + lookupResource(fullPath); + // Check if model is loaded. + if(resourceIsSet()) + return; + // model is not loaded, do it. + super.createModel(fullPath); + } + + /** + * Lookup for the resource in the resourceSet. Return the resource or null + * if not found. + * + * @param fullPath + */ + private void lookupResource(IPath fullPath) { + + // Compute model URI + resourceURI = getPlatformURI(fullPath.addFileExtension(getModelFileExtension())); + + resource = getResourceSet().getResource(resourceURI, false); + + } + + /** + * Do nothing as we are slave. The Resource is save by the master model. + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#saveModel() + * + * @throws IOException + */ + @Override + public void saveModel() throws IOException { + + // Do nothing if we are a slave + if(modelKind == ModelKind.slave) + return; + + // Do the save + super.saveModel(); + } + + /** + * Get the root of this model. Lookup in the associated {@link Resource} for + * the root. + * + * @return The root of the model, or null if no root exist. + */ + @SuppressWarnings("unchecked") + public T getModelRoot() { + + for(EObject object : getResource().getContents()) { + + if(isModelRoot(object)) { + return (T)object; + } + } + + // Not found + return null; + } + + /** + * Get the roots of this model. Lookup in the associated {@link Resource} for the roots. + * + * @return A list containing the roots of the model. The list is empty if + * there is no root. + */ + @SuppressWarnings("unchecked") + public List getModelRoots() { + + List roots = new ArrayList(); + + for(EObject object : getResource().getContents()) { + if(isModelRoot(object)) + roots.add((T)object); + } + + return roots; + } + + /** + * Return true if the provided object is a root of the model, false + * otherwise. This method should be implemented by subclasses. + * + * @param object + * @return + */ + protected abstract boolean isModelRoot(EObject object); + + /** + * Add a root to this model. + * + * @param root + */ + public void addModelRoot(T root) { + getResource().getContents().add(root); + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/BadStateException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/BadStateException.java new file mode 100644 index 00000000000..be31c2ecbd1 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/BadStateException.java @@ -0,0 +1,60 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource; + +/** + * Exception thrown when a method is called while the object state is not ready + * for this call. + * + * @author cedric dumoulin + * + */ +public class BadStateException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + */ + public BadStateException() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param message + * @param cause + */ + public BadStateException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param message + */ + public BadStateException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param cause + */ + public BadStateException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/EditingDomainServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/EditingDomainServiceFactory.java new file mode 100644 index 00000000000..97eb39bdfd5 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/EditingDomainServiceFactory.java @@ -0,0 +1,59 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource; + +import org.eclipse.papyrus.infra.core.services.IServiceFactory; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * A service factory starting the EditingDomain service. + * + * @author cedric dumoulin + * + */ +public class EditingDomainServiceFactory implements IServiceFactory { + + /** + * The associated ModelSet. This service depends on the ModelSet service. + * So, we can get it in the init. + */ + private ModelSet modelSet; + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry) + * + * @param servicesRegistry + * @throws ServiceException + */ + public void init(ServicesRegistry servicesRegistry) throws ServiceException { + modelSet = servicesRegistry.getService(ModelSet.class); + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#startService() + * + * @throws ServiceException + */ + public void startService() throws ServiceException { + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IService#disposeService() + * + * @throws ServiceException + */ + public void disposeService() throws ServiceException { + } + + /** + * @see org.eclipse.papyrus.infra.core.services.IServiceFactory#createServiceInstance() + * + * @return + */ + public Object createServiceInstance() { + return modelSet.getTransactionalEditingDomain(); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IModel.java new file mode 100644 index 00000000000..2a95ec0903d --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IModel.java @@ -0,0 +1,94 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource; + +import java.io.IOException; + +import org.eclipse.core.runtime.IPath; + +/** + * A Model is a set of elements defined by a metamodel (preferably an EMF + * metamodel). A root of a model is an element which have no parent (i.e. is not + * contained by another element of the model). A model has usually only one + * root. Elements of a model can be contained in one or several resources. A + * model is identified by an id, usually the id from the metamodel package + * (ModelPackage.eCONTENT_TYPE). + * + * @author cedric dumoulin + * + */ +public interface IModel { + + /** + * Initialize the model and set its associated model manager. + * + * @param modelManager + * The associated model manager. + */ + public void init(ModelSet modelManager); + + /** + * Get the identifier identifying this model (aka: uml, notation, ...) + * + * @return + */ + public String getIdentifier(); + + /** + * Create the model repository. + * + * @param fullPath + * The full path, without extension where the model should be + * saved. + */ + public void createModel(IPath fullPath); + + /** + * Load the model from the specified path.. + * + * @param path + * The full path, without extension where the model should be + * saved. Should be used as a bases to guess the model IPath. + */ + public void loadModel(IPath path); + + /** + * Import the model from the specified path. + * + * @param path + * The full path, without extension. + */ + public void importModel(IPath path); + + /** + * Save the model in its repository. + * + * @throws IOException + * + */ + public void saveModel() throws IOException; + + /** + * Change the path under which the model should be save. Do not save it now + * ! + * + */ + public void changeModelPath(IPath fullPath); + + /** + * Dispose the model. + */ + public void unload(); + + /** + * Add a snippet to this model. The snippet is called just after model is + * initialized, and before it is disposed or unloaded. Snippet can be shared + * among models. + * + * @param snippet + * The snippet to add. + */ + public void addModelSnippet(IModelSnippet snippet); + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IModelSetSnippet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IModelSetSnippet.java new file mode 100644 index 00000000000..1fdbde2f0f0 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IModelSetSnippet.java @@ -0,0 +1,32 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource; + +/** + * A model snippet can be used to add code that should do some stuff on a + * modelsManager. A ModelSnippet is attached to a modelsManager, and is called + * after modelsManager is started and just before it is disposed. + * + * + * @author cedric dumoulin + * + */ +public interface IModelSetSnippet { + + /** + * Called right after the model is started. + * + * @param modelsManager + * The modelsManager that is starting + */ + public void start(ModelSet modelsManager); + + /** + * Called just before the model is disposed or unloaded. + * + * @param modelsManager + * The modelsManager that is starting + */ + public void dispose(ModelSet modelsManager); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IModelSnippet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IModelSnippet.java new file mode 100644 index 00000000000..496ce18ef75 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IModelSnippet.java @@ -0,0 +1,32 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource; + +/** + * A model snippet can be used to add code that should do some stuff on a model. + * A ModelSnippet is attached to a model, and is called after model starting and + * when model is disposed. + * + * + * @author cedric dumoulin + * + */ +public interface IModelSnippet { + + /** + * Called right after the model is started. + * + * @param startingModel + * The model that is starting + */ + public void start(IModel startingModel); + + /** + * Called just before the model is disposed or unloaded. + * + * @param stoppingModel + * The model that is starting + */ + public void dispose(IModel stoppingModel); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ITransactionalEditingDomainProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ITransactionalEditingDomainProvider.java new file mode 100644 index 00000000000..86eaa6c8be1 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ITransactionalEditingDomainProvider.java @@ -0,0 +1,8 @@ +package org.eclipse.papyrus.infra.core.resource; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.transaction.TransactionalEditingDomain; + +public interface ITransactionalEditingDomainProvider { + TransactionalEditingDomain createTransactionalEditingDomain(ResourceSet resourceSet); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelException.java new file mode 100644 index 00000000000..a2c4336f1ee --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelException.java @@ -0,0 +1,54 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource; + +/** + * Root exception for this package. + * + * @author cedric dumoulin + * + */ +public class ModelException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + */ + public ModelException() { + } + + /** + * Constructor. + * + * @param message + */ + public ModelException(String message) { + super(message); + } + + /** + * Constructor. + * + * @param cause + */ + public ModelException(Throwable cause) { + super(cause); + } + + /** + * Constructor. + * + * @param message + * @param cause + */ + public ModelException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelIdentifiers.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelIdentifiers.java new file mode 100644 index 00000000000..7a363c54a56 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelIdentifiers.java @@ -0,0 +1,28 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource; + +import java.util.ArrayList; + +/** + * A collection of Identifiers identifying Models. + * + * @author cedric dumoulin + * + */ +public class ModelIdentifiers extends ArrayList { + + public ModelIdentifiers(String... modelIdentifiers) { + + for(String identifier : modelIdentifiers) { + add(identifier); + } + } + + /** + * + */ + private static final long serialVersionUID = 1L; + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelMultiException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelMultiException.java new file mode 100644 index 00000000000..74edb6e3925 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelMultiException.java @@ -0,0 +1,137 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource; + +import java.util.ArrayList; +import java.util.List; + +/** + * An exception encapsulating multiple exceptions. This exception is thrown when + * an operation performed on several Models fails on one or more of these + * models. The exception contains all the exceptions encoutered while opertating + * on models. + * + * @author cedric dumoulin + * + */ +public class ModelMultiException extends ModelException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * List of encountered exceptions. + */ + List encounteredExceptions = new ArrayList(); + + /** + * List of identifiers corresponding to exceptions. + */ + List encounteredModels = new ArrayList(); + + /** + * @return the encounteredExceptions + */ + public List getExceptions() { + return encounteredExceptions; + } + + /** + * Constructor. + * + */ + public ModelMultiException() { + super("Multiple exceptions"); + } + + /** + * Constructor. + * + * @param message + */ + public ModelMultiException(String message) { + super(message); + } + + /** + * Return the first exception. + * + * @see java.lang.Throwable#getCause() + * + * @return + */ + @Override + public Throwable getCause() { + return (encounteredExceptions.size() > 0 ? encounteredExceptions.get(0) : null); + } + + /** + * Return the message if any, or the message of the first exception. + * + * @see java.lang.Throwable#getMessage() + * + * @return + */ + @Override + public String getMessage() { + + StringBuffer buffer = new StringBuffer(); + + String message = super.getMessage(); + if(message != null) + buffer.append(message).append('\n'); + + buffer.append("----- exceptions : ----------\n"); + for(int i = 0; i < encounteredExceptions.size(); i++) { + Throwable exception = encounteredExceptions.get(i); + Object identifierMsg = encounteredModels.get(i); + + if(identifierMsg != null) + buffer.append(identifierMsg.toString()).append(" : "); + String msg = exception.getMessage(); + if(msg != null) + buffer.append(msg).append('\n'); + } + buffer.append("----------------------------- \n"); + + return buffer.toString(); + // // Check for first exception + // if( encounteredExceptions.size() > 1) + // return encounteredExceptions.get(0).getMessage(); + // + // // default + // return null; + } + + /** + * Add an exception to the list of exceptions. + * + * @param exception + */ + public void addException(Throwable exception) { + addException("unknown", exception); + } + + /** + * Add an exception to the list of exceptions. Also record the corresponding + * model identifier if any. + * + * @param exception + */ + public void addException(Object identifier, Throwable exception) { + encounteredExceptions.add(exception); + encounteredModels.add(identifier); + } + + /** + * Return true if this MultiExceptions contains nested exceptions. + * + * @return + */ + public boolean isNotEmpty() { + return encounteredExceptions.size() != 0; + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java new file mode 100644 index 00000000000..646fb5df22e --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java @@ -0,0 +1,511 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * Emilien Perico emilien.perico@atosorigin.com - manage loading strategies + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.resource; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.impl.ResourceImpl; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory; +import org.eclipse.papyrus.infra.core.resource.additional.AdditionalResourcesModel; + +/** + * This class is used to manage a set of {@link IModel}. + * + *

>Usage

+ *
    + *
  • First, register associated model. A loader can be used.
  • + *
  • Second, call load() or create()
  • + *
  • Then, it is possible to get associated models
  • + *
  • Finally, call save()
  • + *
+ * + * Please note that indirectly referenced models are loaded on demand. If a + * model contains a cross reference towards another model (e.g. an import in + * case of UML) the referenced resource does not appear initially in the set. + * However, it is added once the referenced model is resolved. + * + * TODO Modify ModelSetSnippet in order to inform them of model addition. + * + * @author cedric dumoulin + * + */ +public class ModelSet extends ResourceSetImpl { + + /** The associated IModels. */ + private Map models = new HashMap(); + + /** The snippets. */ + private ModelSetSnippetList snippets = new ModelSetSnippetList(); + + private AdditionalResourcesModel additional = new AdditionalResourcesModel(); + + /** + * The associated EditingDomain. + */ + private TransactionalEditingDomain transactionalEditingDomain; + + /** + * The filename path, without extension, used for action on models. + */ + private IPath filenameWithoutExtension; + + /** + * + * Constructor. + * + */ + public ModelSet() { + registerModel(additional); + this.setURIResourceMap(new HashMap()); + getLoadOptions().put(XMLResource.OPTION_DEFER_ATTACHMENT, true); + getLoadOptions().put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, true); + } + + /** + * Register the specified model under its associated key. The key is defined + * in the model itself. It is usually the model type from + * (ModelPackage.eCONTENT_TYPE). + * + * @param model + * the model + */ + public void registerModel(IModel model) { + models.put(model.getIdentifier(), model); + model.init(this); + } + + /** + * Get a model by its key. TODO throw an exception if not found. + * + * @param key + * the key + * @return the model + */ + public IModel getModel(String key) { + return models.get(key); + } + + /** + * Get a model by its key. TODO throw an exception if not found. + * + * @param key + * the key + * @return the model + * @throws NotFoundException + * If no model is registered under the key. + */ + public IModel getModelChecked(String key) throws NotFoundException { + IModel model = models.get(key); + if(model == null) + throw new NotFoundException("Can't find model for identifier '" + key + "'."); + + return model; + } + + @Override + public Resource getResource(URI uri, boolean loadOnDemand) { + Resource r = super.getResource(uri, loadOnDemand); + if(r instanceof ResourceImpl) { + ResourceImpl impl = (ResourceImpl)r; + impl.setTrackingModification(true); + if(impl.getIntrinsicIDToEObjectMap() == null) { + impl.setIntrinsicIDToEObjectMap(new HashMap()); + } + } + return r; + } + + /** + * Create the transactional editing domain. + * + * @return the transactional editing domain + */ + public TransactionalEditingDomain getTransactionalEditingDomain() { + transactionalEditingDomain = WorkspaceEditingDomainFactory.INSTANCE.getEditingDomain(this); + + if(transactionalEditingDomain == null) { + transactionalEditingDomain = TransactionalEditingDomainManager.createTransactionalEditingDomain(this); + // What for? + transactionalEditingDomain.setID("SharedEditingDomain"); //$NON-NLS-1$ + } + return transactionalEditingDomain; + } + + /** + * @return the filenameWithoutExtension + */ + public IPath getFilenameWithoutExtension() { + return filenameWithoutExtension; + } + + /** + * @return the filenameWithoutExtension + * @throws BadStateException + */ + protected IPath getFilenameWithoutExtensionChecked() throws BadStateException { + if(filenameWithoutExtension == null) + throw new BadStateException("Path should be set prior calling any operations."); + + return filenameWithoutExtension; + } + + /** + * @param filenameWithoutExtension + * the filenameWithoutExtension to set + */ + protected void setFilenameWithoutExtension(IPath filenameWithoutExtension) { + this.filenameWithoutExtension = filenameWithoutExtension; + } + + /** + * Create all the associated models. This creates the models, regardless if + * they already exist. + * + * @param newFile + * The file from which path is extracted to create the new + * resources + */ + public void createsModels(IFile newFile) { + + // Get the file name, without extension. + filenameWithoutExtension = newFile.getFullPath().removeFileExtension(); + + // Walk all registered models + for(IModel model : models.values()) { + model.createModel(filenameWithoutExtension); + } + + // call snippets to allow them to do their stuff + snippets.performStart(this); + } + + /** + * Create the model specified by the identifiers. Other models are + * untouched, unless they are sharing something with specified models. + * + * This creates the models, regardless if they already exist. + * + * @param newFile + * The file from which path is extracted to create the new + * resources + */ + public void createsModels(ModelIdentifiers modelIdentifiers) { + + // Walk all registered models + for(String modelId : modelIdentifiers) { + IModel model = getModel(modelId); + + // Load models using the default path + model.createModel(filenameWithoutExtension); + } + + // call snippets to allow them to do their stuff + // snippets.modelsAdded(modelIdentifiers); + } + + /** + * Load only the specified model. ModelSetSnippets are not called. Model is + * loaded using the ModelSet Path. + * + * @param modelIdentifier + * the model identifier + * @param file + * the file + * @return the i model + * @throws BadStateException + * If the global path is not specified. + * @returns The loaded model. + */ + public IModel loadModel(String modelIdentifier) throws BadStateException { + + IModel model = getModel(modelIdentifier); + model.loadModel(getFilenameWithoutExtensionChecked()); + + return model; + } + + /** + * Import only the specified model. ModelSetSnippets are not called. + * + * @param modelIdentifier + * the model identifier + * @param file + * the file + * @return the i model + * @throws ModelException + * @returns The loaded model. + * @deprecated Use {@link #importModel(ModelIdentifier, IFile)} + */ + public IModel loadModel(String modelIdentifier, IFile file) throws ModelException { + + importModels(new ModelIdentifiers(modelIdentifier), file); + + return getModel(modelIdentifier); + } + + /** + * Load all the associated models from a handle on one of the associated + * file. + * + * @param file + * The file to load (no matter the extension) + */ + public void loadModels(IFile file) throws ModelMultiException { + + // Get the file name, without extension. + filenameWithoutExtension = file.getFullPath().removeFileExtension(); + + ModelMultiException exceptions = null; + + // Walk all registered models + for(IModel model : models.values()) { + // Try to load each model. Catch exceptions in order to load other + // models. + try { + model.loadModel(filenameWithoutExtension); + } catch (Exception e) { + // Record the exception + if(exceptions == null) { + + exceptions = new ModelMultiException("Problems encountered while loading one of the models."); + } + exceptions.addException(model.getIdentifier(), e); + } + } + + // call snippets to allow them to do their stuff + snippets.performStart(this); + + // Report exceptions if any + if(exceptions != null) + throw exceptions; + } + + /** + * Import specified models into the ModelSet. The models are imported using + * the specified IFile. After import, the models are associated with the + * ModelSet Path. + * + * @param modelIdentifiers + * The model to import from the specified IFile. + * @param file + * The IFile used to import the model. + * @throws ModelException + * If an error occur during import. + */ + public void importModels(ModelIdentifiers modelIdentifiers, IFile file) throws ModelException { + + IPath path = file.getFullPath().removeFileExtension(); + // Walk all registered models + for(String modelId : modelIdentifiers) { + IModel model = getModel(modelId); + + // Load models using the default path + model.importModel(path); + if(filenameWithoutExtension != null) + model.changeModelPath(filenameWithoutExtension); + } + } + + /** + * Import only the specified model. ModelSetSnippets are not called. An + * import can be performed after model are loaded. Normally, it should not + * be done before a model is loaded. + * + * @param modelIdentifier + * the model identifier + * @param file + * the file + * @throws ModelException + * @returns The loaded model. + */ + public IModel importModel(String modelIdentifier, IFile file) throws ModelException { + + importModels(new ModelIdentifiers(modelIdentifier), file); + + return getModel(modelIdentifier); + } + + /** + * Create models that are not already created or loaded. + */ + public void createMissingModels() throws ModelException { + throw new UnsupportedOperationException("Not yet implemented"); + + } + + /** + * Load models that are not already created or loaded. + */ + public void loadMissingModels() throws ModelException { + throw new UnsupportedOperationException("Not yet implemented"); + + } + + /** + * Save the resources. + * + * @param monitor + * The monitor. + * @throws IOException + * IO Error. + */ + public void save(IProgressMonitor monitor) throws IOException { + + // Initialize monitor with the number of models + Collection modelList = models.values(); + monitor.beginTask("Saving resources", modelList.size()); + + try { + // Walk all registered models + for(IModel model : modelList) { + if(!(model instanceof AdditionalResourcesModel)) { + model.saveModel(); + monitor.worked(1); + } + } + additional.saveModel(); + } finally { + monitor.done(); + } + } + + /** + * The resources are already loaded, but we want to save them under another + * name. + * + * @param path + * the path + * @throws IOException + * Signals that an I/O exception has occurred. + */ + public void saveAs(IPath path) throws IOException { + + // Get the file name, without extension. + filenameWithoutExtension = path.removeFileExtension(); + + // Walk all registered models + for(IModel model : models.values()) { + model.changeModelPath(filenameWithoutExtension); + } + + // Save with new paths + save(new NullProgressMonitor()); + } + + /** + * Unload all the resources. Do not disguard associated models. + */ + public void unload() { + + // call snippets to allow them to do their stuff + snippets.performDispose(this); + + // Walk all registered models + for(IModel model : models.values()) { + if(!(model instanceof AdditionalResourcesModel)) { + model.unload(); + } + } + additional.unload(); + + // Unload remaining resources + for(Iterator iter = getResources().iterator(); iter.hasNext();) { + iter.next().unload(); + iter.remove(); + } + } + + /** + * Add a {@link IModelSetSnippet}. A snippet allows to add code that will + * perform additional operations on the ModelSet. + * + * @param snippet + * The snippet to add. + */ + public void addModelSetSnippet(IModelSetSnippet snippet) { + snippets.add(snippet); + } + + /** + * A list of {@link IModelSetSnippet}. + * + * Used by Models to maintain their list of Snippets. + * + * @author cedric dumoulin + * + */ + public class ModelSetSnippetList extends ArrayList { + + /** The Constant serialVersionUID. */ + private static final long serialVersionUID = 1L; + + /** + * Call the start method on all registered snippets. + * + * @param modelsManager + * The model that is starting + */ + public void performStart(ModelSet modelsManager) { + for(IModelSetSnippet snippet : this) { + snippet.start(modelsManager); + } + } + + /** + * Call the start method on all registered snippets. + * + * @param modelsManager + * The model that is stopping + */ + public void performDispose(ModelSet modelsManager) { + for(IModelSetSnippet snippet : this) { + snippet.dispose(modelsManager); + } + + } + } + + /** + * Check is a resource is additional in the resource set + * + * @param uri + * the specified URI of the resource + * @return true if it is an additional resource + */ + public boolean isAdditionalResource(URI uri) { + if(uri != null) { + String platformString = uri.trimFileExtension().toPlatformString(false); + return ((platformString == null) || !getFilenameWithoutExtension().toString().equals(platformString.toString())); + } + return false; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSnippetList.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSnippetList.java new file mode 100644 index 00000000000..bd6aaa53f54 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSnippetList.java @@ -0,0 +1,47 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource; + +import java.util.ArrayList; + +/** + * A list of {@link IModelSnippet}. + * + * Used by Models to maintain their list of Snippets. + * + * @author cedric dumoulin + * + */ +public class ModelSnippetList extends ArrayList { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Call the start method on all registered snippets. + * + * @param model + * The model that is starting + */ + public void performStart(IModel model) { + for(IModelSnippet snippet : this) { + snippet.start(model); + } + } + + /** + * Call the start method on all registered snippets. + * + * @param model + * The model that is stopping + */ + public void performDispose(IModel model) { + for(IModelSnippet snippet : this) { + snippet.dispose(model); + } + + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelUtils.java new file mode 100644 index 00000000000..533e67e5717 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelUtils.java @@ -0,0 +1,85 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource; + +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers; + +/** + * Set of utility methods to get the current {@link ModelSet}. + * + * @author cedric dumoulin + * + */ +public class ModelUtils { + + /** + * Gets the {@link ModelSet} for the currently selected editor.
+ * Warning: This method is designed to be call from ui.handlers. It is not + * designed to be call from Editors. This method can return null. + * + * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() + * + * + * @return The {@link TraceModel} of the current editor, or null if not + * found. + * @deprecated Use ServiceUtilsForActionHandlers.getInstance().getModelSet() + */ + public static ModelSet getModelSet() { + + try { + return ServiceUtilsForActionHandlers.getInstance().getModelSet(); + } catch (ServiceException e) { + return null; + } + } + + /** + * Gets the {@link ModelSet} for the currently selected editor.
+ * Warning: This method is designed to be call from ui.handlers. It is not + * designed to be call from Editors. This method can return null if called + * during the MultiEditor initialization. + * + * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() Warning: + * + * + * @return The {@link TraceModel} of the current editor. + * @throws ServiceException + * If an error occurs while getting or starting the service. + * @deprecated Use ServiceUtilsForActionHandlers.getInstance().getModelSet() + */ + public static ModelSet getModelSetChecked() throws ServiceException { + + return ServiceUtilsForActionHandlers.getInstance().getModelSet(); + } + + /** + * Gets the ModelSet from the {@link ServicesRegistry}. + * + * @return ServicesRegistry The service registry under which the ModelSet is + * registered. + */ + public static ModelSet getModelSet(ServicesRegistry servicesRegistry) { + + try { + return servicesRegistry.getService(ModelSet.class); + } catch (ServiceException e) { + return null; + } + } + + /** + * Gets the ModelSet from the {@link ServicesRegistry}. + * + * @return ServicesRegistry The service registry under which the ModelSet is + * registered. + * @throws ServiceException + * If the service can't be returned. + */ + public static ModelSet getModelSetChecked(ServicesRegistry servicesRegistry) throws ServiceException { + return servicesRegistry.getService(ModelSet.class); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelsReader.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelsReader.java new file mode 100644 index 00000000000..18c3ee3bbf8 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelsReader.java @@ -0,0 +1,232 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource; + +import static org.eclipse.papyrus.infra.core.Activator.log; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.papyrus.infra.core.Activator; +import org.eclipse.papyrus.infra.core.extension.ExtensionException; +import org.eclipse.papyrus.infra.core.extension.ExtensionUtils; + +/** + * A reader to read model from Eclipse extension and register them to the + * specified ModelManager. + * + * @author cedric dumoulin + * + */ +public class ModelsReader extends ExtensionUtils { + + /** + * Name of the extension (as declared in 'plugin.xml->extension + * point->xxx->ID') + */ + public static final String EXTENSION_POINT_NAME = "model"; + + /** Name for the element "model" */ + public static final String MODEL_ELEMENT_NAME = "model"; + + /** Name for the element "modelSnippet" */ + public static final String MODEL_SNIPPET_ELEMENT_NAME = "modelSnippet"; + + /** Name for the element "modelSetSnippet" */ + public static final String MODEL_SET_SNIPPET_ELEMENT_NAME = "modelSetSnippet"; + + /** + * Name of attribute used to set class name. + */ + private static final String CLASSNAME_ATTRIBUTE = "classname"; + + /** Namespace where to look for the extension points. */ + protected String extensionPointNamespace; + + /** + * Create a ModelReader reading extension from the core namespace. + * + * @param extensionPointNamespace + */ + public ModelsReader() { + // Use this plugin namespace. + this(Activator.PLUGIN_ID); + } + + /** + * Create a ModelReader reading extension from the specified namespace. The + * namespace is usually the name of the plugin owning the {@link ModelSet}. + * + * @param extensionPointNamespace + */ + public ModelsReader(String extensionPointNamespace) { + super(); + this.extensionPointNamespace = extensionPointNamespace; + } + + /** + * Populate the manager with models found in Eclipse extensions. + * + * @param modelSet + */ + public void readModel(ModelSet modelSet) { + + // Actually, we register model manually. + // TODO: read from Eclipse extension. + // modelSet.registerModel( new SashModel() ); + // modelSet.registerModel( new NotationModel() ); + // // uml model + // UmlModel umlModel = new ExtendedUmlModel(); + // umlModel.addModelSnippet(new UmlSnippet()); + // modelSet.registerModel(umlModel); + // // global snippets + // modelSet.addModelSetSnippet(new TypeCacheInitializer()); + + // Reading data from plugins + IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointNamespace, EXTENSION_POINT_NAME); + addDeclaredModels(configElements, modelSet); + addDeclaredModelSetSnippets(configElements, modelSet); + } + + /** + * Read and instanciate declared models + * + * @param modelSet + */ + private void addDeclaredModels(IConfigurationElement[] configElements, ModelSet modelSet) { + + for(IConfigurationElement ele : configElements) { + + // Check if it is a Model + try { + if(MODEL_ELEMENT_NAME.equals(ele.getName())) { + IModel model = instanciateModel(ele); + modelSet.registerModel(model); + addDeclaredModelSnippet(ele, model); + + log.debug("model loaded: '" + model.getClass().getName() + "'"); + } + } catch (ExtensionException e) { + log.error("Problems occur while instanciating model", e); + } + } + } + + /** + * Add ModelSet snippet + * + * @param modelSet + */ + private void addDeclaredModelSetSnippets(IConfigurationElement[] configElements, ModelSet modelSet) { + for(IConfigurationElement ele : configElements) { + + // Check if it is a Model + try { + if(MODEL_SET_SNIPPET_ELEMENT_NAME.equals(ele.getName())) { + IModelSetSnippet snippet = instanciateModelSetSnippet(ele); + modelSet.addModelSetSnippet(snippet); + log.debug("modelSet snippet added: '" + modelSet.getClass().getName() + "().add(" + snippet.getClass().getName() + ")'"); + } + } catch (ExtensionException e) { + log.error("Problems occur while instanciating snippet", e); + } + } + } + + /** + * Instanciate model declared in the configuration element. + * + * @param ele + * @return + * @throws ExtensionException + */ + + private IModel instanciateModel(IConfigurationElement ele) throws ExtensionException { + + @SuppressWarnings("unchecked") + Class modelInstance = (Class)parseClass(ele, CLASSNAME_ATTRIBUTE, MODEL_ELEMENT_NAME); + + IModel model; + try { + model = modelInstance.newInstance(); + } catch (InstantiationException e) { + throw new ExtensionException(e); + } catch (IllegalAccessException e) { + throw new ExtensionException(e); + } + + return model; + } + + /** + * Instanciate model snippet declared in the configuration element. + * + * @param ele + * @return + * @throws ExtensionException + */ + private IModelSnippet instanciateModelSnippet(IConfigurationElement ele) throws ExtensionException { + + @SuppressWarnings("unchecked") + Class modelInstance = (Class)parseClass(ele, CLASSNAME_ATTRIBUTE, MODEL_SNIPPET_ELEMENT_NAME); + + IModelSnippet snippet; + try { + snippet = modelInstance.newInstance(); + } catch (InstantiationException e) { + throw new ExtensionException(e); + } catch (IllegalAccessException e) { + throw new ExtensionException(e); + } + + return snippet; + } + + /** + * Instanciate modelSet snippet declared in the configuration element. + * + * @param ele + * @return + * @throws ExtensionException + */ + private IModelSetSnippet instanciateModelSetSnippet(IConfigurationElement ele) throws ExtensionException { + + @SuppressWarnings("unchecked") + Class modelInstance = (Class)parseClass(ele, CLASSNAME_ATTRIBUTE, MODEL_SET_SNIPPET_ELEMENT_NAME); + + IModelSetSnippet snippet; + try { + snippet = modelInstance.newInstance(); + } catch (InstantiationException e) { + throw new ExtensionException(e); + } catch (IllegalAccessException e) { + throw new ExtensionException(e); + } + + return snippet; + } + + /** + * Add associated snippets to the model. + * + * @param parentElement + * @param model + */ + private void addDeclaredModelSnippet(IConfigurationElement parentElement, IModel model) { + + // Get children + IConfigurationElement[] configElements = parentElement.getChildren(MODEL_SNIPPET_ELEMENT_NAME); + + for(IConfigurationElement ele : configElements) { + try { + IModelSnippet snippet = instanciateModelSnippet(ele); + model.addModelSnippet(snippet); + log.debug("model snippet added: '" + model.getClass().getName() + "().add(" + snippet.getClass().getName() + ")'"); + } catch (ExtensionException e) { + log.error("Problems occur while instanciating model snippet", e); + } + } + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/NotFoundException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/NotFoundException.java new file mode 100644 index 00000000000..54bb3e62874 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/NotFoundException.java @@ -0,0 +1,54 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource; + +/** + * Exception indicating that something is not found. + * + * @author cedric dumoulin + * + */ +public class NotFoundException extends ModelException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + */ + public NotFoundException() { + } + + /** + * Constructor. + * + * @param message + */ + public NotFoundException(String message) { + super(message); + } + + /** + * Constructor. + * + * @param cause + */ + public NotFoundException(Throwable cause) { + super(cause); + } + + /** + * Constructor. + * + * @param message + * @param cause + */ + public NotFoundException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/TransactionalEditingDomainManager.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/TransactionalEditingDomainManager.java new file mode 100644 index 00000000000..93d2dba5ded --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/TransactionalEditingDomainManager.java @@ -0,0 +1,85 @@ +package org.eclipse.papyrus.infra.core.resource; + +import java.util.Collections; +import java.util.LinkedList; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; +import org.eclipse.emf.workspace.IResourceUndoContextPolicy; +import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory; +import org.eclipse.papyrus.commands.CheckedOperationHistory; +import org.eclipse.papyrus.commands.NotifyingWorkspaceCommandStack; + +public class TransactionalEditingDomainManager { + + protected static final ITransactionalEditingDomainProvider[] orderedProvidersArray; + + protected static class ProviderPriorityPair implements Comparable { + + public ITransactionalEditingDomainProvider provider; + public int priority; + + public int compareTo(ProviderPriorityPair o) { + if (o.priority > priority) { + return 1; + } else if (o.priority < priority) { + return -1; + } else { + return 0; + } + } + } + + static { + IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.papyrus.infra.core", "transactionalEditingDomainProvider"); + + LinkedList providerPriorityPairs = new LinkedList(); + + for(IConfigurationElement elem : configElements) { + if ("transactionalEditingDomainProvider".equals(elem.getName())) { + try { + ProviderPriorityPair providerPriorityPair = new ProviderPriorityPair(); + providerPriorityPair.provider = (ITransactionalEditingDomainProvider) elem.createExecutableExtension("class"); + providerPriorityPair.priority = Integer.parseInt(elem.getAttribute("priority")); + + providerPriorityPairs.add(providerPriorityPair); + } catch (Exception e) { + } + } + } + + Collections.sort(providerPriorityPairs); + + orderedProvidersArray = new ITransactionalEditingDomainProvider[providerPriorityPairs.size()]; + + for (int i = 0; i < orderedProvidersArray.length; i++) { + orderedProvidersArray[i] = providerPriorityPairs.get(i).provider; + } + } + + public static TransactionalEditingDomain createTransactionalEditingDomain(ResourceSet resourceSet) { + for (ITransactionalEditingDomainProvider provider : orderedProvidersArray) { + TransactionalEditingDomain ed = provider.createTransactionalEditingDomain(resourceSet); + if (ed != null) { + return ed; + } + } + return createDefaultTransactionalEditingDomain(resourceSet); + } + + public static TransactionalEditingDomain createDefaultTransactionalEditingDomain(ResourceSet resourceSet) { + NotifyingWorkspaceCommandStack stack = new NotifyingWorkspaceCommandStack(CheckedOperationHistory.getInstance()); + stack.setResourceUndoContextPolicy(IResourceUndoContextPolicy.DEFAULT); + + TransactionalEditingDomain result = new TransactionalEditingDomainImpl( + new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE), stack, resourceSet); + + WorkspaceEditingDomainFactory.INSTANCE.mapResourceSet(result); + + return result; + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/additional/AdditionalResourcesModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/additional/AdditionalResourcesModel.java new file mode 100644 index 00000000000..0e99c828a27 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/additional/AdditionalResourcesModel.java @@ -0,0 +1,114 @@ +/***************************************************************************** + * 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 emilien.perico@atosorigin.com - manage loading strategies + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.resource.additional; + +import java.io.IOException; +import java.util.Collections; +import java.util.Iterator; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.infra.core.resource.IModel; +import org.eclipse.papyrus.infra.core.resource.IModelSnippet; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.ModelSnippetList; + +public class AdditionalResourcesModel implements IModel { + + /** + * The associated ModelManager. + */ + private ModelSet modelSet; + + /** + * List of attached snippets. + */ + private ModelSnippetList snippets = new ModelSnippetList(); + + /** + * Model ID. + */ + public static String MODEL_ID = "org.eclipse.papyrus.infra.core.resource.additional"; + + public void init(ModelSet modelManager) { + this.modelSet = modelManager; + } + + public String getIdentifier() { + return MODEL_ID; + } + + /** + * useless for additional resources + */ + public void createModel(IPath fullPath) { + // do nothing + } + + public void loadModel(IPath path) { + // call registered snippets + snippets.performStart(this); + } + + public void importModel(IPath fullPathWithoutExtension) { + loadModel(fullPathWithoutExtension); + } + + public void saveModel() throws IOException { + for(Resource r : modelSet.getResources()) { + if(modelSet.isAdditionalResource(r.getURI())) { + EditingDomain editingDomain = modelSet.getTransactionalEditingDomain(); + // only save referenced models, if modified, not empty, not + // read-only and either platform or file + if(!r.getContents().isEmpty() && r.isModified() && (editingDomain != null) && !editingDomain.isReadOnly(r) && (r.getURI().isPlatform() || r.getURI().isFile())) { + r.save(Collections.EMPTY_MAP); + } + } + } + } + + /** + * useless for additional resources + */ + public void changeModelPath(IPath fullPath) { + // do nothing + } + + public void unload() { + // call registered snippets + snippets.performDispose(this); + + // Unload remaining resources + for(Iterator iter = modelSet.getResources().iterator(); iter.hasNext();) { + Resource next = iter.next(); + if(modelSet.isAdditionalResource(next.getURI())) { + next.unload(); + } + iter.remove(); + } + } + + public void addModelSnippet(IModelSnippet snippet) { + snippets.add(snippet); + } + + /** + * @return the modelManager + */ + protected ModelSet getModelManager() { + return modelSet; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/notation/NotationModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/notation/NotationModel.java new file mode 100644 index 00000000000..cb2925607bf --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/notation/NotationModel.java @@ -0,0 +1,80 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource.notation; + +import org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.papyrus.infra.core.resource.AbstractBaseModel; +import org.eclipse.papyrus.infra.core.resource.IModel; +import org.eclipse.papyrus.infra.core.resource.ModelSet; + +/** + * @author dumoulin + * + */ +public class NotationModel extends AbstractBaseModel implements IModel { + + /** + * File extension used for notation. + */ + public static final String NOTATION_FILE_EXTENSION = "notation"; //$NON-NLS-1$ + + /** + * Model ID. + */ + public static final String MODEL_ID = "org.eclipse.papyrus.infra.core.resource.notation.NotationModel"; //$NON-NLS-1$ + + /** + * + * Constructor. + * + */ + public NotationModel() { + + } + + // Initialize stuff in the model. + @Override + public void init(ModelSet modelManager) { + super.init(modelManager); + // Specify the factory to use to create the resource. + GMFResourceFactory gmfFactory = new GMFResourceFactory(); + getResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap().put(NOTATION_FILE_EXTENSION, gmfFactory); + + } + + /** + * Get the file extension used for this model. + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getModelFileExtension() + * + * @return + */ + @Override + protected String getModelFileExtension() { + return NOTATION_FILE_EXTENSION; + } + + /** + * Get the identifier used to register this model. + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getIdentifier() + * + * @return + */ + @Override + public String getIdentifier() { + return MODEL_ID; + } + + /** + * Add a new initialized {@link Diagram} to the model. + * + * @param newDiagram + * The diagram to add. + */ + public void addDiagram(Diagram newDiagram) { + getResource().getContents().add(newDiagram); + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/notation/NotationUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/notation/NotationUtils.java new file mode 100644 index 00000000000..2c8465944b7 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/notation/NotationUtils.java @@ -0,0 +1,176 @@ +/***************************************************************************** + * 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.infra.core.resource.notation; + +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers; + +/** + * Utilities method to manage notation models. Should be moved in a more + * suitable plugin + */ +public class NotationUtils { + + /** + * Get the notation Resource. + * + * @return + * + * @deprecated Usage of the internal Resource is discouraged. + */ + public static Resource getNotationResource() { + return getNotationModel().getResource(); + } + + /** + * Gets the NotationModel for the currently selected editor.
+ * Warning: This method is designed to be call from ui.handlers. It is not + * designed to be call from Editors. This method can return null if called + * during the MultiEditor initialization. + * + * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() + * + * @return The {@link NotationModel} of the current editor, or null if not + * found. + */ + public static NotationModel getNotationModel() { + + try { + return (NotationModel)ServiceUtilsForActionHandlers.getInstance().getModelSet().getModel(NotationModel.MODEL_ID); + } catch (ServiceException e) { + return null; + } + } + + /** + * Gets the NotationModel for the currently selected editor.
+ * Warning: This method is designed to be call from ui.handlers. It is not + * designed to be call from Editors. This method can return null if called + * during the MultiEditor initialization. + * + * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() + * + * @return The {@link NotationModel} of the current editor, or null if not + * found. + * @throws ServiceException + * If an error occurs while getting or starting the service. + */ + public static NotationModel getNotationModelChecked() throws ServiceException { + + return (NotationModel)ServiceUtilsForActionHandlers.getInstance().getModelSet().getModel(NotationModel.MODEL_ID); + } + + /** + * Gets the NotationModel from the {@link ModelSet}.
+ * + * @param modelsManager + * The modelManager containing the requested model. + * + * @return The {@link NotationModel} registered in modelManager, or null if + * not found. + */ + public static NotationModel getNotationModel(ModelSet modelsManager) { + + return (NotationModel)modelsManager.getModel(NotationModel.MODEL_ID); + } + + /** + * Gets the direct associated diagram of the specified eObject. + * + * @param eObject + * @param notationResource + * + * @return the associated diagram + */ + public static Diagram getAssociatedDiagram(Resource notationResource, EObject eObject) { + if(notationResource != null) { + for(EObject obj : notationResource.getContents()) { + if(obj instanceof Diagram) { + Diagram diagram = (Diagram)obj; + if(eObject != null && eObject.equals(diagram.getElement())) { + return diagram; + } + } + } + } + return null; + } + + /** + * Gets the direct associated diagram of the specified eObject. + * + * @param eObject + * @param notationResource + * @param resolve + * the resource if true + * + * @return the associated diagram + */ + public static Diagram getAssociatedDiagram(Resource notationResource, EObject eObject, boolean resolve) { + if(notationResource != null && resolve) { + EcoreUtil.resolveAll(notationResource); + } + return getAssociatedDiagram(notationResource, eObject); + } + + /** + * Gets the all the diagrams contained in the specified ancestor eObject + * + * @param notationResource + * @param eObject + * + * @return all the contained diagrams + * + */ + public static List getDiagrams(Resource notationResource, EObject eObject) { + List diagrams = new LinkedList(); + if(notationResource != null) { + for(EObject obj : notationResource.getContents()) { + if(obj instanceof Diagram) { + Diagram diagram = (Diagram)obj; + if(EcoreUtil.isAncestor(eObject, diagram.getElement())) { + diagrams.add(diagram); + } + } + } + } + return diagrams; + } + + /** + * Gets the all the diagrams contained in the specified ancestor eObject + * + * @param notationResource + * @param eObject + * @param resolve + * the resource if true + * + * @return all the contained diagrams + */ + public static List getDiagrams(Resource notationResource, EObject eObject, boolean resolve) { + if(notationResource != null && resolve) { + EcoreUtil.resolveAll(notationResource); + } + return getDiagrams(notationResource, eObject); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/DiModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/DiModel.java new file mode 100644 index 00000000000..572648401bf --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/DiModel.java @@ -0,0 +1,54 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource.sasheditor; + +import org.eclipse.papyrus.infra.core.resource.AbstractBaseModel; +import org.eclipse.papyrus.infra.core.resource.IModel; + +/** + * @author dumoulin + * + */ +public class DiModel extends AbstractBaseModel implements IModel { + + /** + * File extension used for notation. + */ + public static final String MODEL_FILE_EXTENSION = "di"; //$NON-NLS-1$ + + /** + * File extension used for notation. + */ + public static final String DI_FILE_EXTENSION = MODEL_FILE_EXTENSION; + + /** + * Model ID. + */ + public static final String MODEL_ID = "org.eclipse.papyrus.infra.core.resource.sasheditor.SashModel"; //$NON-NLS-1$ + + /** + * Get the file extension used for this model. + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getModelFileExtension() + * + * @return + */ + @Override + protected String getModelFileExtension() { + return MODEL_FILE_EXTENSION; + } + + /** + * Get the identifier used to register this model. + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getIdentifier() + * + * @return + */ + @Override + public String getIdentifier() { + return MODEL_FILE_EXTENSION; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/DiModelUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/DiModelUtils.java new file mode 100644 index 00000000000..a4e968c5307 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/DiModelUtils.java @@ -0,0 +1,41 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource.sasheditor; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IPath; + +/** + * Set of utility methods linked to Di resource. + * + * @author cedric dumoulin + * + */ +public class DiModelUtils { + + /** + * Returns the related di file. Warning : this method is here for historical + * reasons. It should be removed asap. + * + * @param file + * A file (di, model or notation). + * @return The associated DI file. + * @deprecated No replacement. + */ + public static IFile getRelatedDiFile(IFile file) { + if(file == null) { + return null; + } + IFile diFile; + if(DiModel.DI_FILE_EXTENSION.equalsIgnoreCase(file.getFileExtension())) { + diFile = file; + } else { + // Find the correct file + IPath diPath = file.getFullPath().removeFileExtension().addFileExtension(DiModel.DI_FILE_EXTENSION); + diFile = file.getParent().getFile(diPath.makeRelativeTo(file.getParent().getFullPath())); + } + return diFile; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModel.java new file mode 100644 index 00000000000..8a999d98f93 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModel.java @@ -0,0 +1,71 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource.sasheditor; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource; +import org.eclipse.papyrus.infra.core.resource.IModel; +import org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource.ModelKind; + +/** + * Model for the sash system.
+ * This model can share its resource with other model. This model is declared as {@link ModelKind#master}. Other model whishing to share the resource + * should + * subclass {@link AbstractModelWithSharedResource}, be declared as {@link ModelKind#slave} (which is the default.), and set {@link #getModelFileExtension()} to return the same file extension as this + * model ({@link #MODEL_FILE_EXTENSION}). + * + * @author cedric dumoulin + * + */ +public class SashModel extends AbstractModelWithSharedResource implements IModel { + + /** + * File extension used for notation. + */ + public static final String MODEL_FILE_EXTENSION = "di"; //$NON-NLS-1$ + + /** + * Model ID. + */ + public static final String MODEL_ID = "org.eclipse.papyrus.infra.core.resource.sasheditor.SashModel"; //$NON-NLS-1$ + + /** + * + * Constructor. + * + */ + public SashModel() { + super(ModelKind.master); + } + + /** + * Get the file extension used for this model. + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getModelFileExtension() + * + * @return + */ + @Override + protected String getModelFileExtension() { + return MODEL_FILE_EXTENSION; + } + + /** + * Get the identifier used to register this model. + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getIdentifier() + * + * @return + */ + @Override + public String getIdentifier() { + return MODEL_ID; + } + + @Override + protected boolean isModelRoot(EObject object) { + return object instanceof org.eclipse.papyrus.infra.core.sashwindows.di.SashModel; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModelUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModelUtils.java new file mode 100644 index 00000000000..47e8445b93c --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/SashModelUtils.java @@ -0,0 +1,118 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource.sasheditor; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.ModelUtils; +import org.eclipse.papyrus.infra.core.resource.uml.UmlUtils; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers; + +/** + * Set of utility methods linked to Trace for ControlMode + * + * @author cedric dumoulin + * + */ +public class SashModelUtils { + + /** + * Gets the SashModel for the currently selected editor.
+ * Warning: This method is designed to be call from ui.handlers. It is not + * designed to be call from Editors. This method can return null if called + * during the MultiEditor initialization. + * + * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() + * + * @return The {@link SashModel} of the current editor, or null if not + * found. + */ + public static SashModel getSashModel() { + + try { + return (SashModel)ServiceUtilsForActionHandlers.getInstance().getModelSet().getModel(SashModel.MODEL_ID); + } catch (ServiceException e) { + return null; + } + } + + /** + * Gets the SashModel for the currently selected editor.
+ * Warning: This method is designed to be call from ui.handlers. It is not + * designed to be call from Editors. This method can return null if called + * during the MultiEditor initialization. + * + * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() + * + * @return The {@link SashModel} of the current editor, or null if not + * found. + * @throws ServiceException + * If an error occurs while getting or starting the service. + */ + public static SashModel getSashModelChecked() throws ServiceException { + + return (SashModel)ServiceUtilsForActionHandlers.getInstance().getModelSet().getModel(SashModel.MODEL_ID); + } + + /** + * Gets the SashModel from the {@link ModelSet}.
+ * + * @param modelsManager + * The modelManager containing the requested model. + * + * @return The {@link SashModel} registered in modelManager, or null if not + * found. + */ + public static SashModel getSashModel(ModelSet modelsManager) { + + return (SashModel)modelsManager.getModel(SashModel.MODEL_ID); + } + + /** + * Gets the SashModel from the {@link ModelSet}.
+ * + * @param ServicesRegistry + * The servie registry under which the ModelSet is registered. + * + * @return The {@link SashModel} registered in modelManager, or null if not + * found. + */ + public static SashModel getSashModel(ServicesRegistry servicesRegistry) { + + try { + return (SashModel)ModelUtils.getModelSetChecked(servicesRegistry).getModel(SashModel.MODEL_ID); + } catch (ServiceException e) { + return null; + } + } + + /** + * Gets the SashModel from the {@link ModelSet}.
+ * + * @param ServicesRegistry + * The servie registry under which the ModelSet is registered. + * + * @return The {@link SashModel} registered in modelManager, or null if not + * found. + * @throws ServiceException + * If the service can't be returned. + */ + public static SashModel getSashModelChecked(ServicesRegistry servicesRegistry) throws ServiceException { + + return (SashModel)ModelUtils.getModelSetChecked(servicesRegistry).getModel(SashModel.MODEL_ID); + } + + /** + * Retrieve the uri of the initial di opened + * + * @param modelSet + * @return FIXME improve how to get the initial model opened + */ + public static URI getInitialURI(ModelSet modelSet) { + return UmlUtils.getUmlModel(modelSet).getResourceURI().trimFileExtension().appendFileExtension(SashModel.MODEL_FILE_EXTENSION); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/ExtendedUmlModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/ExtendedUmlModel.java new file mode 100644 index 00000000000..5385ea27085 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/ExtendedUmlModel.java @@ -0,0 +1,56 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource.uml; + +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.emf.ecore.resource.Resource; + +/** + * A UML model whose resource is either a uml file or a profile(?). + * + * @author cedric dumoulin + * + */ +public class ExtendedUmlModel extends UmlModel { + + /** + * Load the first resource with a supported extension TODO: (question from + * Cedric) fix what is a supported extension ? + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#loadModel(org.eclipse.core.runtime.IPath) + * + * @param fullPath + */ + @Override + public void loadModel(IFile file) { + + // Extract file name, without extension + IPath fullPath = file.getFullPath().removeFileExtension(); + + // Try to load resources that are not DI or Notation + // TODO : set the requested extension rather than taking anyone. + if(resource == null) { + IContainer folder = file.getParent(); + try { + IResource[] files = folder.members(); + for(IResource r : files) { + String extension = r.getFullPath().getFileExtension(); + if(r.getFullPath().removeFileExtension().lastSegment().equals(fullPath.lastSegment()) && !"di".equalsIgnoreCase(extension) && !"notation".equalsIgnoreCase(extension)) { + if(Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().get(extension) != null) { + resourceURI = getPlatformURI(r.getFullPath()); + resource = getResourceSet().getResource(resourceURI, true); + break; + } + } + } + } catch (CoreException e) { + // never happens. + } + } + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/UmlModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/UmlModel.java new file mode 100644 index 00000000000..32b2f763d82 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/UmlModel.java @@ -0,0 +1,93 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource.uml; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.core.resource.AbstractBaseModel; +import org.eclipse.papyrus.infra.core.resource.IModel; +import org.eclipse.papyrus.infra.core.resource.NotFoundException; + +/** + * A UML model. + * + * @author cedric dumoulin + * + */ +public class UmlModel extends AbstractBaseModel implements IModel { + + /** + * File extension used for DI. + */ + public static final String UML_FILE_EXTENSION = "uml"; //$NON-NLS-1$ + + /** + * Model ID. + */ + public static final String MODEL_ID = "org.eclipse.papyrus.infra.core.resource.uml.UmlModel"; //$NON-NLS-1$ + + /** + * @see org.eclipse.papyrus.infra.core.resource.IModel#createModel(org.eclipse.core.runtime.IPath) + * + * @param fullPath + */ + public void createModel(IPath fullPath) { + + // Compute model URI + resourceURI = getPlatformURI(fullPath.addFileExtension(UML_FILE_EXTENSION)); + + // Create Resource of appropriate type + resource = getResourceSet().createResource(resourceURI, getContentType()); + } + + /** + * + * @return + */ + protected String getContentType() { + // TODO: use the uml identifier + // return UMLPackage.eCONTENT_TYPE; + return "org.eclipse.uml2.uml"; + } + + /** + * Get the file extension used for this model. + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getModelFileExtension() + * + * @return + */ + @Override + protected String getModelFileExtension() { + return UML_FILE_EXTENSION; + } + + /** + * Get the identifier used to register this model. + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getIdentifier() + * + * @return + */ + @Override + public String getIdentifier() { + return MODEL_ID; + } + + /** + * Lookup the root of the model. Throw an exception if not found. + * + * @return + */ + public EObject lookupRoot() throws NotFoundException { + // TODO Auto-generated method stub + try { + return resource.getContents().get(0); + } catch (IndexOutOfBoundsException e) { + // The root doesn't exist. + throw new NotFoundException("No root defined in the model"); + } + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/UmlSnippet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/UmlSnippet.java new file mode 100644 index 00000000000..62a459f5dbf --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/UmlSnippet.java @@ -0,0 +1,51 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource.uml; + +import org.eclipse.papyrus.infra.core.listenerservice.ModelListenerManager; +import org.eclipse.papyrus.infra.core.resource.IModel; +import org.eclipse.papyrus.infra.core.resource.IModelSnippet; + +/** + * A snippet registering adapters to the UML model. + * + * @author cedric dumoulin + * + */ +public class UmlSnippet implements IModelSnippet { + + private ModelListenerManager modelListenerManager; + + /** + * Register the UML adapters + * + * @see org.eclipse.papyrus.infra.core.resource.IModelSnippet#start(org.eclipse.papyrus.infra.core.resource.IModel) + * + * @param startingModel + */ + public void start(IModel startingModel) { + + // Modl should be an uml one + UmlModel umlModel = (UmlModel)startingModel; + // add adapters + modelListenerManager = new ModelListenerManager(); + umlModel.getResource().eAdapters().add(modelListenerManager); + + } + + public void dispose(IModel stoppingModel) { + // Modl should be an uml one + UmlModel umlModel = (UmlModel)stoppingModel; + // add adapters + try { + if(umlModel.getResource() != null) { + umlModel.getResource().eAdapters().remove(modelListenerManager); + } + } catch (NullPointerException e) { + // resource is already disposed, or not loaded. Do nothing + } + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/UmlUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/UmlUtils.java new file mode 100644 index 00000000000..d413a9583fc --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/uml/UmlUtils.java @@ -0,0 +1,99 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.resource.uml; + +import javax.imageio.spi.ServiceRegistry; + +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.ModelUtils; +import org.eclipse.papyrus.infra.core.resource.sasheditor.SashModel; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers; + +/** + * Set of utility methods linked to Trace for ControlMode + * + * @author cedric dumoulin + * + */ +public class UmlUtils { + + /** + * Gets the UmlModel for the currently selected editor.
+ * Warning: This method is designed to be call from ui.handlers. It is not + * designed to be call from Editors. This method can return null if called + * during the MultiEditor initialization. + * + * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() + * + * + * @return The {@link UmlModel} of the current editor, or null if not found. + */ + public static UmlModel getUmlModel() { + + try { + return (UmlModel)ServiceUtilsForActionHandlers.getInstance().getModelSet().getModel(UmlModel.MODEL_ID); + } catch (ServiceException e) { + return null; + } + } + + /** + * Gets the UmlModel for the currently selected editor.
+ * Warning: this method can return null if called during the MultiEditor + * initialization. + * + * + * @return The {@link UmlModel} of the current editor, or null if not found. + * @throws ServiceException + * If an error occurs while getting or starting the service. + */ + public static UmlModel getUmlModelChecked() throws ServiceException { + + return (UmlModel)ServiceUtilsForActionHandlers.getInstance().getModelSet().getModel(UmlModel.MODEL_ID); + } + + /** + * Gets the UmlModel from the {@link ModelSet}.
+ * + * @param modelSet + * The modelManager containing the requested model. + * + * @return The {@link SashModel} registered in modelManager, or null if not + * found. + */ + public static UmlModel getUmlModel(ModelSet modelSet) { + + return (UmlModel)modelSet.getModel(UmlModel.MODEL_ID); + } + + /** + * Gets the UmlModel from the {@link ServiceRegistry}. + * + * @return ServicesRegistry The service registry under which the ModelSet is + * registered. + */ + public static UmlModel getUmlModel(ServicesRegistry servicesRegistry) { + + try { + return getUmlModelChecked(servicesRegistry); + } catch (ServiceException e) { + return null; + } + } + + /** + * Gets the UmlModel from the {@link ServiceRegistry}. + * + * @return ServicesRegistry The service registry under which the ModelSet is + * registered. + * @throws ServiceException + * If the service can't be returned. + */ + public static UmlModel getUmlModelChecked(ServicesRegistry servicesRegistry) throws ServiceException { + return (UmlModel)ModelUtils.getModelSetChecked(servicesRegistry).getModel(UmlModel.MODEL_ID); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/BadStateException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/BadStateException.java new file mode 100644 index 00000000000..d3bccad8c92 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/BadStateException.java @@ -0,0 +1,37 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services; + +/** + * @author cedric dumoulin + * + */ +public class BadStateException extends ServiceException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + */ + public BadStateException(ServiceState expectedState, ServiceState state, ServiceDescriptor descriptor) { + super("Bad state for service '" + descriptor.getKey() + "'. Expected '" + expectedState + "' found '" + state + "'."); + } + + /** + * + * Constructor. + * + * @param text + * @param state + * @param serviceDescriptor + */ + public BadStateException(String text, ServiceState state, ServiceDescriptor descriptor) { + super(text + " (Service= '" + descriptor.getKey() + ", state= " + state + ")"); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ComposedService.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ComposedService.java new file mode 100644 index 00000000000..22198fda810 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ComposedService.java @@ -0,0 +1,93 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services; + +import java.util.ArrayList; +import java.util.List; + +/** + * Base class to create a Service composed of other services called Parts. + * ServiceParts register themselves to the ComposedService. The ComposedService + * maintain a list of its part. + * + * @author cedric dumoulin + * + * @param T + * The type of sub-services that can register to this + * ComposedService. + */ +public abstract class ComposedService implements IService { + + /** + * The list of serviceParts composing this Service. + */ + protected List serviceParts = new ArrayList(); + + /** + * Constructor. Constructor. + * + */ + public ComposedService() { + + } + + /** + * Add the provided servicePart. + * + * @param servicePart + */ + public void addServicePart(T servicePart) { + serviceParts.add(servicePart); + } + + /** + * Remove the provided servicePart. + * + * @param servicePart + */ + public void removeServicePart(T servicePart) { + serviceParts.remove(servicePart); + } + + /** + * Do nothing here. + * + * @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry) + * + * @param servicesRegistry + * @throws ServiceException + */ + public void init(ServicesRegistry servicesRegistry) throws ServiceException { + } + + /** + * Do nothing here. + * + * @see org.eclipse.papyrus.infra.core.services.IService#startService() + * + * @throws ServiceException + */ + public void startService() throws ServiceException { + } + + /** + * Do nothing here. + * + * @see org.eclipse.papyrus.infra.core.services.IService#disposeService() + * + * @throws ServiceException + */ + public void disposeService() throws ServiceException { + } + + /** + * Get a list of registered sub service parts. + * + * @return List of registered services. + */ + public List getRegisteredServices() { + return serviceParts; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ComposedServicePart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ComposedServicePart.java new file mode 100644 index 00000000000..ad10f748ba7 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ComposedServicePart.java @@ -0,0 +1,75 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services; + +/** + * A service that register itself to its associated {@link ComposedService}. + * + * @param T + * The main ComposedService + * + * @author cedric dumoulin + * @param T + * The type of the ComposedService to which this part will be + * registered. + * + */ +@SuppressWarnings("rawtypes") +public abstract class ComposedServicePart implements IService { + + /** + * + */ + protected ServicesRegistry servicesRegistry; + + /** + * Class of the parent ComposedService + */ + private Class composedServiceKey; + + /** + * ComposedService that will own this part. + */ + T parentService; + + public ComposedServicePart(Class composedServiceKey) { + this.composedServiceKey = composedServiceKey; + } + + /** + * Initialize the service. Attach itself to the ComposedService + * + * @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry) + * + * @param servicesRegistry + * @throws ServiceException + */ + @SuppressWarnings("unchecked") + public void init(ServicesRegistry servicesRegistry) throws ServiceException { + this.servicesRegistry = servicesRegistry; + parentService = servicesRegistry.getService(composedServiceKey); + parentService.addServicePart(this); + } + + /** + * Start the service. + * + * @see org.eclipse.papyrus.infra.core.services.IService#startService() + * + */ + public void startService() throws ServiceException { + + } + + /** + * + * @see org.eclipse.papyrus.infra.core.services.IService#disposeService() + * + */ + @SuppressWarnings("unchecked") + public void disposeService() { + parentService.removeServicePart(this); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ExtensionServicesRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ExtensionServicesRegistry.java new file mode 100644 index 00000000000..28daa5bfe30 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ExtensionServicesRegistry.java @@ -0,0 +1,196 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.papyrus.infra.core.services.ServiceDescriptor.ServiceTypeKind; + +/** + * ServiceRegistry reading and registering services declared in Eclipse + * Extensions. + * + * @author dumoulin + * + */ +public class ExtensionServicesRegistry extends ServicesRegistry { + + /** ID of the extension (schema filename) */ + public static final String SERVICE_EXTENSION_ID = "service"; + + /** Namespace where to look for the extension points. */ + protected String extensionPointNamespace; + + /** Extension point name inside the extension description **/ + public final static String SERVICE_EXTENSIONPOINT = "service"; + + /** ServiceFactory Extension point **/ + public final static String SERVICE_FACTORY_ELEMENT_NAME = "serviceFactory"; + + /** constant for the attribute factoryClass **/ + public final static String CONTEXTCLASS_ATTRIBUTE = "contextClass"; + + /** extension point propertyname */ + private final static String STARTKIND_PROPERTY = "startKind"; + + /** name of the dependsOn element */ + private static final String DEPENDSON_ELEMENT_NAME = "dependsOn"; + + /** name of the key attribute inside the DEPENDSON element */ + private static final String DEPENDSON_KEY_ATTRIBUTE_NAME = "serviceKeyRef"; + + /** + * Constructor. + * + * @throws Exception + */ + public ExtensionServicesRegistry(String extensionPointNamespace) throws ServiceException { + this.extensionPointNamespace = extensionPointNamespace; + registerDeclaredExtensions(); + } + + /** + * Register the services declared in Eclipse Extension. + * + * @throws Exception + */ + private void registerDeclaredExtensions() throws ServiceException { + + List descriptors = new ArrayList(); + List exceptions = null; + + // Reading data from plugins + IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointNamespace, SERVICE_EXTENSION_ID); + + for(IConfigurationElement ele : configElements) { + ServiceDescriptor desc; + if(SERVICE_EXTENSIONPOINT.equals(ele.getName())) { + // Read a Service + try { + desc = readServiceDescriptor(ele); + desc.setServiceTypeKind(ServiceTypeKind.service); + // Add created desc + descriptors.add(desc); + } catch (ServiceException e) { + // record exceptions + if(exceptions == null) + exceptions = new ArrayList(); + exceptions.add(e); + } + } else if(SERVICE_FACTORY_ELEMENT_NAME.equals(ele.getName())) { + // Read a Service Factory + try { + desc = readServiceDescriptor(ele); + desc.setServiceTypeKind(ServiceTypeKind.serviceFactory); + // Add created desc + descriptors.add(desc); + } catch (ServiceException e) { + // record exceptions + if(exceptions == null) + exceptions = new ArrayList(); + exceptions.add(e); + } + } + } + + // Add found descriptors + for(ServiceDescriptor desc : descriptors) { + add(desc); + } + + // Throw exceptions if pb encountered + if(exceptions != null) { + if(exceptions.size() == 1) + throw exceptions.get(0); + else + throw new ServiceException("Somme services are not started (first is shown)", exceptions.get(0)); + + } + + } + + /** + * Read descriptor values from provided element. + * + * @param ele + * @return + * @throws ServiceException + */ + private ServiceDescriptor readServiceDescriptor(IConfigurationElement ele) throws ServiceException { + + // classname + String serviceClassname = ele.getAttribute("classname"); + + // key + String key = ele.getAttribute("id"); + if(key == null || key.length() == 0) { + key = serviceClassname; + } + + // Service start kind + ServiceStartKind serviceStartKind = ServiceStartKind.LAZY; + String serviceStartKindStr = ele.getAttribute(STARTKIND_PROPERTY); + if(serviceStartKindStr != null && serviceStartKindStr.length() > 0) { + try { + serviceStartKind = ServiceStartKind.valueOf(serviceStartKindStr.toUpperCase()); + } catch (IllegalArgumentException e) { + // Can't convert property + throw new ServiceException("Can't convert property " + STARTKIND_PROPERTY + "(plugin=" + ele.getContributor() + "declaringExtension=" + ele.getDeclaringExtension() + ")", e); + } + } + + // priority + int priority = 1; + String priorityStr = ele.getAttribute("priority"); + if(priorityStr != null && priorityStr.length() > 0) { + try { + priority = Integer.parseInt(priorityStr); + } catch (NumberFormatException e) { + } + } + + // Read dependsOn keys + List keys = getDependsOn(ele); + + // Create descriptor + ServiceDescriptor desc = new ServiceDescriptor(key, serviceClassname, serviceStartKind, priority); + desc.setClassBundleID(ele.getContributor().getName()); + + if(keys.size() > 0) + desc.setRequiredServiceKeys(keys); + + return desc; + } + + /** + * Add dependsOn keys. + * + * @param parentElement + * @param model + */ + private List getDependsOn(IConfigurationElement parentElement) { + + List keys = new ArrayList(); + + // Get children + IConfigurationElement[] configElements = parentElement.getChildren(DEPENDSON_ELEMENT_NAME); + + for(IConfigurationElement ele : configElements) { + String key = ele.getAttribute(DEPENDSON_KEY_ATTRIBUTE_NAME); + if(key != null && key.length() > 0) { + keys.add(key.trim()); + } + } + + if(keys.size() == 0) + return Collections.emptyList(); + + return keys; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/IService.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/IService.java new file mode 100644 index 00000000000..0e898476007 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/IService.java @@ -0,0 +1,42 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services; + +/** + * An Service that can be registered in the {@link ServicesRegistry}. A service + * is a singleton available throw the registry. A service can be shared across + * editors.
+ * The life cycle is as follow: + *
    + *
  • service creation
  • + *
  • {@link #init(ServicesRegistry)} - Other service can be retrieved from the registry, but are not started yet.
  • + *
  • {@link #startService()} - service is started.
  • + *
  • Service can be used
  • + *
  • {@link #disposeService()} - service is disposed and should not be used anymore.
  • + *
+ * + * @author cedric dumoulin + * + */ +public interface IService { + + /** + * Init the service and set its associated Registry. The registry can be + * used to retrieve other services. + * + * @param servicesRegistry + */ + public void init(ServicesRegistry servicesRegistry) throws ServiceException; + + /** + * Start the service. This method is called when the service is started. + */ + public void startService() throws ServiceException; + + /** + * Dispose the service. + */ + public void disposeService() throws ServiceException; + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/IServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/IServiceFactory.java new file mode 100644 index 00000000000..5688f928f7b --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/IServiceFactory.java @@ -0,0 +1,28 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services; + +/** + * A factory creating a Service that can be registered in the {@link ServicesRegistry}. + * + * A service is a singleton available throw the registry. A service can be + * shared across editors. The service lifecycle events (init, start and dispose) + * are sent to the factory. The factory is responsible to forward them to the + * real service. + * + * @author dumoulin + * + */ +public interface IServiceFactory extends IService { + + /** + * Create the instance of the service that will be returned by {@link ServicesRegistry#getService(Class)}. + * + * @return The instance of the service. + * @throws ServiceException + * If an error occurs during the operation. + */ + public Object createServiceInstance() throws ServiceException; + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceDescriptor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceDescriptor.java new file mode 100644 index 00000000000..31de15c216e --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceDescriptor.java @@ -0,0 +1,301 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services; + +import java.util.Collections; +import java.util.List; + +/** + * Descriptor of a service. This descriptor describe a service. + * + * @author cedirc dumoulin + * + */ +public class ServiceDescriptor { + + /** + * Possible kind for service types. + * + */ + public enum ServiceTypeKind { + service, serviceFactory, pojo + }; + + /** Classname of the service. USed to start the service */ + private String serviceClassname; + + /** Kind of start for this service */ + private ServiceStartKind serviceStartKind; + + /** Kind of service */ + private ServiceTypeKind serviceTypeKind = ServiceTypeKind.service; + + /** + * Service priority. If two service are registered under the same key, only + * the one with the higher priority is started. + */ + private int priority; + + /** + * Key used to register the service. + */ + private String key; + + /** + * Id of the bundle owning the .class that is referenced by + * serviceClassname. Requested when instanciating the class. + */ + private String classBundleID; + + /** + * If set to true, the service is anonymous : it is not registered and can't + * be retrieved with getService(). + */ + private boolean isAnonymous = false; + + /** + * List of keys of Services required by this service. + */ + private List requiredServices = Collections.emptyList(); + + /** + * Empty list. + */ + private static List EMPTY_LIST_STRING = Collections.emptyList(); + + /** + * Constructor. + * + * @param key + * @param serviceClassname + * @param serviceStartKind + * @param priority + * @param requiredServices + */ + public ServiceDescriptor(String key, String serviceClassname, ServiceStartKind serviceStartKind, int priority, List requiredServices) { + this.key = key; + this.serviceClassname = serviceClassname; + this.serviceStartKind = serviceStartKind; + this.priority = priority; + this.requiredServices = requiredServices; + } + + /** + * Constructor. + * + * @param key + * A class used as key. The classname is used as key. + * @param serviceClassname + * @param serviceStartKind + * @param priority + * @param requiredServices + */ + public ServiceDescriptor(Class key, String serviceClassname, ServiceStartKind serviceStartKind, int priority, List requiredServices) { + this(key.getName(), serviceClassname, serviceStartKind, priority, requiredServices); + } + + /** + * Constructor. + * + * @param key + * A class used as key. The classname is used as key. + * @param serviceClassname + * @param serviceStartKind + * @param priority + * @param isAnonymous + * @param requiredServices + */ + public ServiceDescriptor(String key, String serviceClassname, ServiceStartKind serviceStartKind, int priority, boolean isAnonymous, List requiredServices) { + this.key = key; + this.serviceClassname = serviceClassname; + this.serviceStartKind = serviceStartKind; + this.priority = priority; + this.isAnonymous = isAnonymous; + this.requiredServices = requiredServices; + } + + /** + * Constructor. + * + * @param key + * A class used as key. The classname is used as key. + * @param serviceClassname + * @param serviceStartKind + * @param priority + * @param isAnonymous + * @param requiredServices + */ + public ServiceDescriptor(Class key, String serviceClassname, ServiceStartKind serviceStartKind, int priority, boolean isAnonymous, List requiredServices) { + this(key.getName(), serviceClassname, serviceStartKind, priority, isAnonymous, requiredServices); + } + + /** + * Constructor. + * + * @param key + * @param serviceClassname + * @param serviceStartKind + * @param priority + */ + public ServiceDescriptor(String key, String serviceClassname, ServiceStartKind serviceStartKind, int priority) { + this(key, serviceClassname, serviceStartKind, priority, EMPTY_LIST_STRING); + } + + /** + * Constructor. + * + * @param key + * A class used as key. The classname is used as key. + * @param serviceClassname + * @param serviceStartKind + * @param priority + */ + public ServiceDescriptor(Class key, String serviceClassname, ServiceStartKind serviceStartKind, int priority) { + this(key.getName(), serviceClassname, serviceStartKind, priority, EMPTY_LIST_STRING); + } + + /** + * Constructor. + * + * @param serviceClassname + * @param serviceStartKind + * @param priority + * @param requiredServices + */ + public ServiceDescriptor(String serviceClassname, ServiceStartKind serviceStartKind, int priority, List requiredServices) { + this(serviceClassname, serviceClassname, serviceStartKind, priority, requiredServices); + } + + /** + * Constructor. + * + * @param serviceClassname + * @param serviceStartKind + * @param priority + */ + public ServiceDescriptor(String serviceClassname, ServiceStartKind serviceStartKind, int priority, boolean isAnonymous) { + this(serviceClassname, serviceClassname, serviceStartKind, priority, isAnonymous, EMPTY_LIST_STRING); + } + + /** + * Constructor. + * + * @param serviceClassname + * @param serviceStartKind + * @param priority + */ + public ServiceDescriptor(String serviceClassname, ServiceStartKind serviceStartKind, int priority) { + this(serviceClassname, serviceClassname, serviceStartKind, priority, EMPTY_LIST_STRING); + } + + /** + * @return the serviceStartKind + */ + public ServiceStartKind getServiceStartKind() { + return serviceStartKind; + } + + /** + * Return true if StartKind is 'always'. + * + * @return + */ + public boolean isStartAtStartup() { + return serviceStartKind == ServiceStartKind.STARTUP; + } + + /** + * @return the priority + */ + public int getPriority() { + return priority; + } + + /** + * @return the key + */ + public String getKey() { + return key; + } + + /** + * @return the serviceClassname + */ + public String getServiceClassname() { + return serviceClassname; + } + + /** + * @return the classBundleID + */ + public String getClassBundleID() { + return classBundleID; + } + + /** + * @param classBundleId + * the classBundleID to set + */ + public void setClassBundleID(String classBundleId) { + classBundleID = classBundleId; + } + + /** + * Get the keys of all the required services + * + * @return the requiredServices + */ + public List getRequiredServiceKeys() { + return requiredServices; + } + + /** + * @param requiredServices + * the requiredServices to set + */ + public void setRequiredServiceKeys(List requiredServices) { + this.requiredServices = requiredServices; + } + + /** + * @see java.lang.Object#toString() + * @return + * + */ + @Override + public String toString() { + return "ServiceDescriptor [key=" + key + ", serviceClassname=" + serviceClassname + ", serviceStartKind=" + serviceStartKind + ", priority=" + priority + "]"; + } + + /** + * @return the isAnonymous + */ + public boolean isAnonymous() { + return isAnonymous; + } + + /** + * @param isAnonymous + * the isAnonymous to set + */ + public void setAnonymous(boolean isAnonymous) { + this.isAnonymous = isAnonymous; + } + + /** + * @return the serviceTypeKind + */ + public ServiceTypeKind getServiceTypeKind() { + return serviceTypeKind; + } + + /** + * @param serviceTypeKind + * the serviceTypeKind to set + */ + public void setServiceTypeKind(ServiceTypeKind serviceTypeKind) { + this.serviceTypeKind = serviceTypeKind; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceException.java new file mode 100644 index 00000000000..0724c14467b --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceException.java @@ -0,0 +1,57 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services; + +/** + * Root Exception of Services Exception. + * + * @author dumoulin + * + */ +public class ServiceException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Constructor. + */ + public ServiceException() { + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param message + */ + public ServiceException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param cause + */ + public ServiceException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * + * @param message + * @param cause + */ + public ServiceException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceMultiException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceMultiException.java new file mode 100644 index 00000000000..e2d91609dbc --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceMultiException.java @@ -0,0 +1,139 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services; + +import java.util.ArrayList; +import java.util.List; + +/** + * An exception encapsulating multiple exceptions. This exception is thrown when + * an operation performed on several Services fails on one or more of these + * Service. The exception contains all the exceptions encoutered while + * opertating on Services. + * + * @author cedric dumoulin + * + */ +public class ServiceMultiException extends ServiceException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * List of encountered exceptions. + */ + List encounteredExceptions = new ArrayList(); + + /** + * List of identifiers corresponding to exceptions. + */ + List serviceIdentifiers = new ArrayList(); + + /** + * @return the encounteredExceptions + */ + public List getExceptions() { + return encounteredExceptions; + } + + /** + * Constructor. + * + */ + public ServiceMultiException() { + super("Multiple exceptions"); + } + + /** + * Constructor. + * + * @param message + */ + public ServiceMultiException(String message) { + super(message); + } + + /** + * Return the first exception. + * + * @see java.lang.Throwable#getCause() + * + * @return + */ + @Override + public Throwable getCause() { + return (encounteredExceptions.size() > 0 ? encounteredExceptions.get(0) : null); + } + + /** + * Return the message if any, or the message of the first exception. + * + * @see java.lang.Throwable#getMessage() + * + * @return + */ + @Override + public String getMessage() { + + StringBuffer buffer = new StringBuffer(); + + String message = super.getMessage(); + if(message != null) + buffer.append(message).append('\n'); + + buffer.append("----- exceptions : ----------\n"); + for(int i = 0; i < encounteredExceptions.size(); i++) { + Throwable exception = encounteredExceptions.get(i); + Object identifierMsg = serviceIdentifiers.get(i); + + if(identifierMsg != null) + buffer.append(identifierMsg.toString()).append(" : "); + String msg = exception.getMessage(); + if(msg != null) + buffer.append(msg).append('\n'); + } + buffer.append("----------------------------- \n"); + + return buffer.toString(); + // // Check for first exception + // if( encounteredExceptions.size() > 1) + // return encounteredExceptions.get(0).getMessage(); + // + // // default + // return null; + } + + /** + * Add an exception to the list of exceptions. + * + * @param exception + */ + public void addException(Throwable exception) { + addException("unknown", exception); + } + + /** + * Add an exception to the list of exceptions. Also record the corresponding + * model identifier if any. + * + * @param exception + */ + public void addException(Object identifier, Throwable exception) { + encounteredExceptions.add(exception); + serviceIdentifiers.add(identifier); + } + + /** + * Merge both exceptions + * + * @param e + */ + public void addAll(ServiceMultiException e) { + encounteredExceptions.addAll(e.encounteredExceptions); + serviceIdentifiers.addAll(serviceIdentifiers); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceNotFoundException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceNotFoundException.java new file mode 100644 index 00000000000..5c0c8c79664 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceNotFoundException.java @@ -0,0 +1,51 @@ +package org.eclipse.papyrus.infra.core.services; + +/** + * Service is not found. + * + * @author dumoulin + * + */ +public class ServiceNotFoundException extends ServiceException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Constructor. + */ + public ServiceNotFoundException() { + super(); + } + + /** + * Constructor. + * + * @param message + * @param cause + */ + public ServiceNotFoundException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructor. + * + * @param message + */ + public ServiceNotFoundException(String message) { + super(message); + } + + /** + * Constructor. + * + * @param cause + */ + public ServiceNotFoundException(Throwable cause) { + super(cause); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceStartKind.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceStartKind.java new file mode 100644 index 00000000000..daedcf0dcc8 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceStartKind.java @@ -0,0 +1,18 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services; + +/** + * Kind of possible start method for a service. LAZY - The service start when it + * is requested for the first time. STARTUP - The service start as soon as the + * registry is started, or when the service is added is the registry is already + * started. + * + * @author dumoulin + * + */ +public enum ServiceStartKind { + + LAZY, STARTUP; +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceState.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceState.java new file mode 100644 index 00000000000..dfe07d18757 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServiceState.java @@ -0,0 +1,14 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services; + +/** + * The different states that a service can have. + * + * @author dumoulin + * + */ +public enum ServiceState { + registered, created, initialized, starting, started, disposed, error +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java new file mode 100644 index 00000000000..c95c9c5fceb --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java @@ -0,0 +1,1042 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.eclipse.papyrus.infra.core.Activator; +import org.eclipse.papyrus.infra.core.services.ServiceDescriptor.ServiceTypeKind; +import org.eclipse.papyrus.infra.core.services.internal.LazyStartupEntry; +import org.eclipse.papyrus.infra.core.services.internal.PojoServiceEntry; +import org.eclipse.papyrus.infra.core.services.internal.ServiceEntry; +import org.eclipse.papyrus.infra.core.services.internal.ServiceFactoryEntry; +import org.eclipse.papyrus.infra.core.services.internal.ServiceStartupEntry; +import org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry; +import org.eclipse.papyrus.infra.core.services.internal.StartStartupEntry; + +/** + * A registry of services. This registry allows to get a service by its + * identifier. The identifier is generally the classname of the service. + * Services can be added using the Eclipse extension mechanism (if you use {@link ExtensionServicesRegistry}).
+ * A Service is a class providing operations. The ServiceRegistry is used to + * share objects (i.e. services) between nested editors and also the core main + * editor. + * + *
+ * In this implementation, services should be added to the registry before the + * call to createServices(). If a service is added after the call, it will not + * be started (except if it is a lazy service).
+ * A typical usage is: + * + *
+ * 
+ *   ServicesRegistry serviceRegistry = new ServiceRegistry();
+ *   // Add your services
+ *   serviceRegistry.add( ...);
+ *   serviceRegistry.add( ...);
+ *   
+ *   // start the services
+ *   serviceRegistry.startRegistry();
+ *   
+ *   // Retrieve a service
+ *   myService = serviceRegistry.getService( serviceKey );
+ * 
+ * 
+ * + * It is possible to register new services after the serviceRegistry has been + * started. In this case, you need to start them explicitly if they are of type + * ServiceStartKind.STARTUP. + * + *
+ * 
+ *   // Add your new services
+ *   serviceRegistry.add( key1, ...);
+ *   serviceRegistry.add( key2, ...);
+ *   
+ *   // start the new services
+ *   serviceRegistry.startRegistry(key1, key2);
+ * 
+ * 
+ * + *
    + *
  • + *
  • + *
+ * + * @author cedric dumoulin + * + * + */ +public class ServicesRegistry { + + /** Log object */ + protected Logger log = Logger.getLogger(getClass().getName()); + + /** + * Map of existing services. + */ + // private Map services; + + /** + * A Map of services added to the register (thow the addXxx() methods), but + * not yet registered. They will be registered after a call to startXxx(). + */ + private Map addedServices = new HashMap(); + + /** + * Map of services registered with a name. + */ + private Map namedServices = new HashMap(); + + /** + * Map of services registered without a name (anonymous). Such services + * can't be retrieved. + */ + private List anonymousServices = new ArrayList(); + + /** + * Constructor. + */ + public ServicesRegistry() { + } + + /** + * Add a service by its ServiceDescriptor. + * + * @param serviceDescriptor + * Descriptor describing the service. + * @throws ServiceException + * If an error occurs while initializing service. + */ + public void add(ServiceDescriptor serviceDescriptor) { + // Check if the service already exist. + ServiceStartupEntry service = addedServices.get(serviceDescriptor.getKey()); + if(service != null) { + if(service.getDescriptor().getPriority() > serviceDescriptor.getPriority()) + return; + else if(service.getDescriptor().getPriority() == serviceDescriptor.getPriority()) { + log.warning("Two services with same priority (" + serviceDescriptor.getPriority() + ") are declared under key '" + service.getDescriptor().getKey() + "'. Keep the first encountered only. (bundles: " + service.getDescriptor().getClassBundleID() + ", " + serviceDescriptor.getClassBundleID() + ")"); + } + } + + // Compute the service type entry + ServiceTypeEntry serviceTypeEntry; + ServiceTypeKind typeKind = serviceDescriptor.getServiceTypeKind(); + if(typeKind == ServiceTypeKind.service) + serviceTypeEntry = new ServiceEntry(serviceDescriptor); + else if(typeKind == ServiceTypeKind.serviceFactory) + serviceTypeEntry = new ServiceFactoryEntry(serviceDescriptor); + else + serviceTypeEntry = new PojoServiceEntry(serviceDescriptor); + + // Create the entry + ServiceStartupEntry serviceEntry; + if(serviceDescriptor.isStartAtStartup()) { + serviceEntry = new StartStartupEntry(serviceTypeEntry); + } else { + serviceEntry = new LazyStartupEntry(serviceTypeEntry, this); + } + // Add the entry + addedServices.put(serviceDescriptor.getKey(), serviceEntry); + } + + /** + * Add a service. The descriptor will be created. + * + * @param key + * Service key + * @param priority + * service priority + * @param serviceInstance + * The instance of the service + */ + public void add(String key, int priority, IService serviceInstance) { + add(key, priority, serviceInstance, ServiceStartKind.STARTUP); + } + + /** + * Add a service. The descriptor will be created. + * + * @param key + * Service key + * @param priority + * service priority + * @param serviceInstance + * The instance of the service + */ + public void add(Class key, int priority, IService serviceInstance) { + add(key.getName(), priority, serviceInstance, ServiceStartKind.STARTUP); + } + + /** + * Add a service. The descriptor will be created. + * + * @param key + * Service key + * @param priority + * service priority + * @param serviceInstance + * The instance of the service + */ + public void add(String key, int priority, IService serviceInstance, ServiceStartKind startKind) { + // Check if the service already exist. + ServiceStartupEntry service = addedServices.get(key); + if(service != null) { + if(service.getDescriptor().getPriority() > priority) + return; + else if(service.getDescriptor().getPriority() == priority) + log.warning("Two services with same priority (" + priority + ") are declared under key '" + service.getDescriptor().getKey() + "'. Keep the first encountered only."); + } + + // Create descriptor and add service. + ServiceDescriptor descriptor = new ServiceDescriptor(key, serviceInstance.getClass().getName(), startKind, priority); + + if(startKind == ServiceStartKind.STARTUP) + addedServices.put(key, new StartStartupEntry(new ServiceEntry(descriptor, serviceInstance))); + else + addedServices.put(key, new LazyStartupEntry(new ServiceEntry(descriptor, serviceInstance), this)); + } + + /** + * Add a service. The descriptor will be created. + * + * @param key + * Service key Class used as key. The classname is used as key. + * @param priority + * service priority + * @param serviceInstance + * The instance of the service + */ + public void add(Class key, int priority, IService serviceInstance, ServiceStartKind startKind) { + + add(key.getName(), priority, serviceInstance, startKind); + } + + /** + * Add an already instanciated pojo (Plain Old Java Object) as Service. The + * descriptor will be created. No life cycle methods are called on the + * service. + * + * @param key + * Service key + * @param priority + * service priority + * @param serviceInstance + * The instance of the service + */ + public void add(Class key, int priority, Object serviceInstance) { + add(key, priority, serviceInstance, ServiceStartKind.STARTUP); + } + + /** + * Add an already instanciated pojo (Plain Old Java Object) as Service. The + * descriptor will be created. No life cycle methods are called on the + * service. + * + * @param key + * Service key + * @param priority + * service priority + * @param serviceInstance + * The instance of the service + * @param startKind + * + */ + public void add(String key, int priority, Object serviceInstance, ServiceStartKind startKind) { + // Check if the service already exist. + ServiceStartupEntry service = addedServices.get(key); + if(service != null) { + if(service.getDescriptor().getPriority() > priority) + return; + else if(service.getDescriptor().getPriority() == priority) + log.warning("Two services with same priority (" + priority + ") are declared under key '" + service.getDescriptor().getKey() + "'. Keep the first encountered only."); + } + + // Create descriptor and add service. + ServiceDescriptor descriptor = new ServiceDescriptor(key, serviceInstance.getClass().getName(), startKind, priority); + + if(startKind == ServiceStartKind.STARTUP) + addedServices.put(key, new StartStartupEntry(new PojoServiceEntry(descriptor, serviceInstance))); + else + addedServices.put(key, new LazyStartupEntry(new PojoServiceEntry(descriptor, serviceInstance), this)); + + } + + /** + * Add an already instanciated pojo (Plain Old Java Object) as Service. The + * descriptor will be created. No life cycle methods are called on the + * service. + * + * @param key + * Service key Class used as key. The classname is used as key. + * @param priority + * service priority + * @param serviceInstance + * The instance of the service + * @param startKind + * + */ + public void add(Class key, int priority, Object serviceInstance, ServiceStartKind startKind) { + + add(key.getName(), priority, serviceInstance, startKind); + } + + /** + * Remove the specified service from the registry. + * + * @param key + */ + public void remove(ServiceDescriptor serviceDescriptor) throws ServiceException { + remove(serviceDescriptor.getKey()); + } + + /** + * Remove the specified service from the registry. + * + * @param key + */ + public void remove(Object key) throws ServiceException { + ServiceStartupEntry service = namedServices.remove(key); + if(service == null) { + return; + } + + // Stop the service + service.disposeService(); + } + + /** + * Get the requested service by its key. The key is usually the classname of + * the service. + * + * @param serviceClass + * @return + * @throws ServiceException + * If servive can't be started + */ + public Object getService(Object key) throws ServiceException { + ServiceStartupEntry service = namedServices.get(key); + if(service == null) { + // throw an exception. + // If added, say it. + service = addedServices.get(key); + if(service != null) + throw new BadStateException("Registry should be started before.", service.getState(), service.getDescriptor()); + else + throw new ServiceNotFoundException("No service registered under '" + key + "'"); + } + + return service.getServiceInstance(); + } + + /** + * Get the requested service by its class (the service has to be registered + * by its class object). + * + * @param key + * The service class. + * @return The service. + * @throws ServiceException + * If service can't be started + */ + @SuppressWarnings("unchecked") + public S getService(Class key) throws ServiceException { + + String realKey = key.getName(); + ServiceStartupEntry service = namedServices.get(realKey); + + if(service == null) { + // throw an exception. + // If added, say it. + service = addedServices.get(realKey); + if(service != null) + throw new BadStateException("Registry should be started before.", service.getState(), service.getDescriptor()); + else + throw new ServiceNotFoundException("No service registered under '" + key + "'"); + } + + return (S)service.getServiceInstance(); + } + + /** + * Return true if the service is instantiated. Return false otherwise. + * + * @return + */ + public boolean isStarted(Object key) throws ServiceNotFoundException { + ServiceStartupEntry service = namedServices.get(key); + if(service == null) { + throw new ServiceNotFoundException("No service registered under '" + key + "'"); + } + + return service.isStarted(); + } + + /** + * Return the state of the specified service. + * + * @return + */ + public ServiceState serviceState(Object key) throws ServiceNotFoundException { + ServiceStartupEntry service = namedServices.get(key); + if(service == null) { + throw new ServiceNotFoundException("No service registered under '" + key + "'"); + } + + return service.getState(); + } + + /** + * Start the registry. Start all services marked as start = STARTUP are + * started. All services are first created, then initialized and finally + * started. If an error occur on a service during one of this step, the + * service is removed from the registry and and the error is logged. + * + * @throws ServiceMultiException + * + * @throws ServiceException + * If a service can't be started. + */ + public void startRegistry() throws ServiceMultiException { + + // Build the lookup maps + LookupMap map = new LookupMap(addedServices, namedServices); + + // Check if all dependencies exist. + checkDependencies(addedServices.values(), map); + + // Get all roots : LAZY and START + Collection roots = getServiceRoots(addedServices.values(), map); + // showServices(" Roots:", roots); + // Detect cycles + checkCycle(roots, map); + // Retain only services with startupkind = START + roots = retainsToStartServices(roots); + // + List toStart = buildTopologicalListOfServicesToStart(roots, map); + + if(Activator.log.isDebugEnabled()) { + showServices(" Services to start:", toStart); + } + + // Create an object to collect errors if any. + ServiceMultiException errors = new ServiceMultiException(); + + createServices(toStart, errors); + // Register all new services : lazy and start + registerServices(addedServices.values()); + initServices(toStart, errors); + startServices(toStart, errors); + + // Report errors if any + if(errors.getExceptions().size() > 0) + throw errors; + + } + + /** + * Start the specified services, and their required services. The specifies + * services should be in the addServices or already registered. Start all + * services marked as start = STARTUP . All eligible services are first + * created, then initialized and finally started. If an error occur on a + * service during one of this step, the service is removed from the registry + * and and the error is logged. + * + * @param serviceKeys + * Keys of services to start. + * @throws ServiceMultiException + * @throws ServiceNotFoundException + * If a service can't be retrieved by its key. + * + * @throws ServiceException + * If a service can't be started. + */ + public void startServices(List serviceKeys) throws ServiceMultiException, ServiceNotFoundException { + + // Build the lookup maps + LookupMap map = new LookupMap(addedServices, namedServices); + + // Get the services + List services = keysToServices(serviceKeys, map); + + // Start them + startServices(services, map); + } + + /** + * Same as {@link #startServices(List)}, but with an array as input. + * + * @see #startServices(List) + * + * @param serviceKeys + * Keys of services to start. + * @throws ServiceMultiException + * @throws ServiceNotFoundException + * If a service can't be retrieved by its key. + * + * @throws ServiceException + * If a service can't be started. + */ + public void startServices(String... serviceKeys) throws ServiceMultiException, ServiceNotFoundException { + + List serviceKeysList = Arrays.asList(serviceKeys); + startServices(serviceKeysList); + } + + /** + * Start the specified services, and their required services. The specifies + * services should be in the addServices or already registered. Start all + * services marked as start = STARTUP . All eligible services are first + * created, then initialized and finally started. If an error occur on a + * service during one of this step, the service is removed from the registry + * and and the error is logged. + * + * @param serviceKeys + * Keys of services to start. Keys will be translated to the + * classname. + * @throws ServiceMultiException + * @throws ServiceNotFoundException + * If a service can't be retrieved by its key. + * + * @throws ServiceException + * If a service can't be started. + */ + public void startServicesByClassKeys(List> serviceKeys) throws ServiceMultiException, ServiceNotFoundException { + + // Build the lookup maps + LookupMap map = new LookupMap(addedServices, namedServices); + + // Get the services + List services = classKeysToServices(serviceKeys, map); + + // Start them + startServices(services, map); + } + + /** + * Same as {@link #startServicesByClassKeys(List)}, but with an array as + * input. + * + * @see #startServices(List) + * + * @param serviceKeys + * Keys of services to start. + * @throws ServiceMultiException + * @throws ServiceNotFoundException + * If a service can't be retrieved by its key. + * + * @throws ServiceException + * If a service can't be started. + */ + public void startServicesByClassKeys(Class... serviceKeys) throws ServiceMultiException, ServiceNotFoundException { + + List> serviceKeysList = Arrays.asList(serviceKeys); + startServicesByClassKeys(serviceKeysList); + } + + /** + * Start the specified services, and their required services. The specifies + * services should be in the specified map. The map is also used to resolves + * dependencies. Start all services marked as start = STARTUP . All eligible + * services are first created, then initialized and finally started. If an + * error occur on a service during one of this step, the service is removed + * from the registry and and the error is logged. + * + * @param services + * Services to start + * @param map + * a table of (key, service) used to get a service by its key. + * @throws ServiceMultiException + * If a service can't be started. + */ + private void startServices(List services, LookupMap map) throws ServiceMultiException { + // Check if all dependencies exist. + checkDependencies(services, map); + + // Get all roots : LAZY and START + Collection roots = getServiceRoots(services, map); + if(Activator.log.isDebugEnabled()) { + showServices(" Roots:", roots); + } + // Detect cycles + checkCycle(roots, map); + // Retain only services with startupkind == START and state == + // REGISTERED + roots = retainsToStartServices(roots); + // + List toStart = buildTopologicalListOfServicesToStart(roots, map); + + // Remove already started services + toStart = retainsToStartServices(toStart); + + // if( log.isLoggable(Level.FINE)) + // { + showServices(" Services to start:", toStart); + // } + + // Create an object to collect errors if any. + ServiceMultiException errors = new ServiceMultiException(); + + createServices(toStart, errors); + // Register all started services + registerServices(toStart); + initServices(toStart, errors); + startServices(toStart, errors); + + // Report errors if any + if(errors.getExceptions().size() > 0) + throw errors; + } + + /** + * Return a list of services from a list of services keys. + * + * @param serviceKeys + * @param map + * @return + * @throws ServiceNotFoundException + * If a service can't be retrieved by its key. + */ + private List keysToServices(List serviceKeys, LookupMap map) throws ServiceNotFoundException { + + List result = new ArrayList(serviceKeys.size()); + + for(String key : serviceKeys) { + result.add(map.getChecked(key)); + } + return result; + } + + /** + * Return a list of services from a list of services keys. + * + * @param serviceKeys + * @param map + * @return + * @throws ServiceNotFoundException + * If a service can't be retrieved by its key. + */ + private List classKeysToServices(List> serviceKeys, LookupMap map) throws ServiceNotFoundException { + + List result = new ArrayList(serviceKeys.size()); + + for(Class key : serviceKeys) { + result.add(map.getChecked(key.getName())); + } + return result; + } + + /** + * Print the services. For debug purpose + * + * @param roots + */ + private void showServices(String message, Collection roots) { + StringBuffer buffer = new StringBuffer(); + buffer.append("--------------------------\n"); + buffer.append(message); + buffer.append("\n"); + for(ServiceStartupEntry service : roots) { + buffer.append(" "); + buffer.append(service.getDescriptor().toString()); + buffer.append("\n"); + } + buffer.append("--------- done -----------\n"); + Activator.log.debug(buffer.toString()); + } + + /** + * Check if all dependencies exist. Throw an error if a declared dependency + * has no corresponding service. + * + * @param services + * Services to check + * @param map + * Map of services by keys. + * @throws ServiceMultiException + */ + private void checkDependencies(Collection services, LookupMap map) throws ServiceMultiException { + + ServiceMultiException errors = new ServiceMultiException(); + + // Walk each service and check if its required services exist. + for(ServiceStartupEntry service : services) { + ServiceDescriptor desc = service.getDescriptor(); + + // Check each required service + for(String key : desc.getRequiredServiceKeys()) { + + // Check if service can be found + try { + map.getChecked(key); + } catch (ServiceNotFoundException e) { + errors.addException(desc.getKey(), e); + } + } + } + + // Throw errors if any + if(errors.getExceptions().size() > 0) + throw errors; + } + + /** + * Retains only the services that should be started. Retains only services + * with startupkind = START and state == REGISTERED + * + * @param services + * Collection to filter + * @return a new Collection containing the services to start. + */ + private List retainsToStartServices(Collection services) { + + List result = new ArrayList(); + for(ServiceStartupEntry service : services) { + ServiceDescriptor desc = service.getDescriptor(); + if(service.getState() == ServiceState.registered && desc.isStartAtStartup()) { + result.add(service); + } + } + + return result; + } + + /** + * Check for cycles. Throws an exception if a cycle is discovered. Each root + * is checked to see if it contains a cycle. + * + * @param roots + * @param map + */ + private void checkCycle(Collection roots, LookupMap map) { + // TODO Auto-generated method stub + + } + + /** + * Build a list of services to start, in the topological order (right + * order). The required services are placed before the dependent services in + * the list. Services already started are disguarded. + * + * @param roots + * @param map + * Map used to resolve the entry by their key. + * @return + */ + private List buildTopologicalListOfServicesToStart(Collection roots, LookupMap map) { + + List result = new ArrayList(); + + // Each root represent a graph. Walk the root and its child in the list, + // in the right order. + for(ServiceStartupEntry root : roots) { + walkGraphDepthFirst(result, root, map); + } + + return result; + } + + /** + * Add recursively the provided node, and then its direct children. + * + * @param result + * The list where the node are added + * @param node + * The node to add + * @param map + */ + private void walkGraphDepthFirst(List result, ServiceStartupEntry node, LookupMap map) { + + // Do not add already added or started node. + if(result.contains(node) || node.isStarted()) + return; + + // add direct child + for(String serviceKey : node.getDescriptor().getRequiredServiceKeys()) { + try { + ServiceStartupEntry child = map.getChecked(serviceKey); + walkGraphDepthFirst(result, child, map); + } catch (ServiceNotFoundException e) { + // Do nothing, we have already reported the problems with + // checkServices; + } + } + + // Now add the node + result.add(node); + } + + /** + * Create a List of the root services. The roots are services that are not + * required by any service. + * + * @param addedServices + * A collection from which roots are required. The collection is + * unmodified. + * @param map + * @return + */ + private Collection getServiceRoots(Collection addedServices, LookupMap keyServiceMap) { + + // Create a copy of the list of services + Collection services = new ArrayList(addedServices); + + List allRequired = new ArrayList(); + + // The roots are services that are not required by any service. + // Build a list of the services required by all other services. + for(ServiceStartupEntry service : services) { + // Add each child to the list of required + for(String serviceKey : service.getDescriptor().getRequiredServiceKeys()) { + try { + + ServiceStartupEntry child = keyServiceMap.getChecked(serviceKey); + allRequired.add(child); + } catch (ServiceNotFoundException e) { + // Do nothing, we have already reported the problems with + // checkServices; + } + } + + } + + // Roots are those that are not required. + // So it is the original list minus the required. + services.removeAll(allRequired); + + return services; + } + + /** + * Dispose all services. + * + * @throws ServiceMultiException + */ + public void disposeRegistry() throws ServiceMultiException { + + // List of keys of service in error. + ServiceMultiException errors = new ServiceMultiException(); + disposeServices(namedServices.values(), errors); + disposeServices(anonymousServices, errors); + + // Report errors if any + if(errors.getExceptions().size() > 0) + throw errors; + } + + /** + * Create all services provided in the list + * + * @param toStart + * List of services to create. + * @param errors + * Exception to collect errors. + * + * @throws ServiceMultiException + * If an error occure during the creation + * + * @throws ServiceException + * If a service can't be started. + */ + private void createServices(List toStart, ServiceMultiException errors) throws ServiceMultiException { + + // Loop on all services + for(ServiceStartupEntry serviceEntry : toStart) { + try { + + serviceEntry.createService(); + } catch (ServiceException e) { + log.log(Level.SEVERE, "Can't create service '" + serviceEntry + "'", e); + + errors.addException(serviceEntry.getDescriptor().getKey(), e); + } + } + + } + + /** + * Register all services provided in the list. After this operation, + * services are available thru {@link #getService(Class)}. + * + * @param toStart + * List of services to register. + * + * @throws ServiceException + * If a service can't be started. + */ + private void registerServices(Collection toStart) { + + // Loop on all services + for(ServiceStartupEntry serviceEntry : toStart) { + ServiceDescriptor desc = serviceEntry.getDescriptor(); + if(desc.isAnonymous()) { + anonymousServices.add(serviceEntry); + } else { + namedServices.put(desc.getKey(), serviceEntry); + } + } + } + + /** + * Init all services provided in the list + * + * @param toStart + * List of services to init. + * @param errors + * + * @throws ServiceMultiException + * If an error occure during the process + * + * @throws ServiceException + * If a service can't be started. + */ + private void initServices(List toStart, ServiceMultiException errors) throws ServiceMultiException { + + // Loop on all services + for(ServiceStartupEntry serviceEntry : toStart) { + try { + + serviceEntry.initService(this); + } catch (ServiceException e) { + log.log(Level.SEVERE, "Can't initialize service '" + serviceEntry + "'", e); + errors.addException(serviceEntry.getDescriptor().getKey(), e); + } + } + + } + + /** + * Init all services provided in the list + * + * @param toStart + * List of services to init. + * @param errors + * + * @throws ServiceMultiException + * If an error occure during the process + * + * @throws ServiceException + * If a service can't be started. + */ + private void startServices(List toStart, ServiceMultiException errors) throws ServiceMultiException { + + // Loop on all services + for(ServiceStartupEntry serviceEntry : toStart) { + try { + + serviceEntry.startService(); + } catch (ServiceException e) { + log.log(Level.SEVERE, "Can't start service '" + serviceEntry + "'", e); + + errors.addException(serviceEntry.getDescriptor().getKey(), e); + } + } + + } + + /** + * Dispose all started services. + * + * @throws ServiceMultiException + * + * @throws ServiceException + * If a service can't be started. + */ + private void disposeServices(Collection services, ServiceMultiException errors) { + + // Dispose services + for(ServiceStartupEntry serviceEntry : services) { + try { + serviceEntry.disposeService(); + } catch (ServiceException e) { + log.log(Level.SEVERE, "Can't dispose service '" + serviceEntry.getDescriptor().getKey() + "'", e); + errors.addException(serviceEntry.getDescriptor(), e); + } + } + } + + /** + * This class represents a union of two maps of . It provide specific methods to retrieve a {@link ServiceStartupEntry} by its key. + * + * @author cedric dumoulin + * + */ + private class LookupMap { + + Map map1; + + Map map2; + + /** + * + * Constructor. Build a union of two maps. + * + * @param map1 + * @param map2 + */ + public LookupMap(Map map1, Map map2) { + this.map1 = map1; + this.map2 = map2; + } + + /** + * + * Constructor. Build a union of one map (sic). + * + * @param map + */ + @SuppressWarnings("unused") + public LookupMap(Map map) { + this(map, null); + } + + /** + * Get a service by its key. + * + * @param key + * @return the service or null if not found. + */ + @SuppressWarnings("unused") + public ServiceStartupEntry get(String key) { + + ServiceStartupEntry res = map1.get(key); + if(res != null) + return res; + if(map2 != null) + res = map2.get(key); + + return res; + } + + /** + * Get a service by its key. + * + * @param key + * @return The requested service. + * @throws ServiceNotFoundException + * if the service can't be found. + */ + public ServiceStartupEntry getChecked(String key) throws ServiceNotFoundException { + + ServiceStartupEntry res = map1.get(key); + if(res != null) + return res; + if(map2 != null) + res = map2.get(key); + if(res != null) + return res; + + throw new ServiceNotFoundException("No service found under key '" + key.toString() + "'"); + } + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ErrorServiceTypeEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ErrorServiceTypeEntry.java new file mode 100644 index 00000000000..6f94954eda0 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ErrorServiceTypeEntry.java @@ -0,0 +1,98 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services.internal; + +import org.eclipse.papyrus.infra.core.services.BadStateException; +import org.eclipse.papyrus.infra.core.services.ServiceDescriptor; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServiceState; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * A service entry used for faulty services. In this implementation, methods do + * nothings or throw an error. + * + * + * @author cedric dumoulin + * + */ +public class ErrorServiceTypeEntry extends ServiceTypeEntry { + + /** + * The original service descriptor. + */ + private ServiceDescriptor descriptor; + + /** + * + * Constructor. + * + * @param descriptor + */ + public ErrorServiceTypeEntry(ServiceDescriptor descriptor) { + super(descriptor); + } + + /** + * + * @see org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry#getServiceInstance() + * + * @return + * @throws ServiceException + */ + @Override + public Object getServiceInstance() throws ServiceException { + throw new BadStateException("Service has not started.", ServiceState.error, descriptor); + } + + /** + * + * @see org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry#createService() + * + * @throws ServiceException + */ + @Override + public void createService() throws ServiceException { + // do nothing + + } + + /** + * + * @see org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry#initService(ServicesRegistry) + * + * @param servicesRegistry + * @throws ServiceException + */ + @Override + public void initService(ServicesRegistry servicesRegistry) throws ServiceException { + // do nothing + + } + + /** + * + * @see org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry#startService() + * + * @throws ServiceException + */ + @Override + public void startService() throws ServiceException { + // do nothing + + } + + /** + * + * @see org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry#disposeService() + * + * @throws ServiceException + */ + @Override + public void disposeService() throws ServiceException { + // do nothing + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/LazyStartupEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/LazyStartupEntry.java new file mode 100644 index 00000000000..35fe0e641f2 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/LazyStartupEntry.java @@ -0,0 +1,96 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services.internal; + +import org.eclipse.papyrus.infra.core.services.IService; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServiceState; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * An ServiceEntry managing {@link IService} registered as lazy start. + * + * @author cedric dumoulin + * + */ +public class LazyStartupEntry extends ServiceStartupEntry { + + protected ServicesRegistry registry; + + /** + * Constructor. + * + * @param serviceDescriptor + * @param registry + */ + public LazyStartupEntry(ServiceTypeEntry serviceEntry, ServicesRegistry registry) { + + super(serviceEntry); + this.registry = registry; + } + + /** + * + * @see org.eclipse.papyrus.infra.core.services.internal.ServiceStartupEntry#getServiceInstance() + * + * @return + * @throws ServiceException + */ + @Override + public Object getServiceInstance() throws ServiceException { + if(serviceEntry.getState() == ServiceState.registered) { + // Start the service + try { + serviceEntry.createService(); + serviceEntry.initService(registry); + serviceEntry.startService(); + } catch (Exception e) { + // There was an error. The service is in error + serviceEntry = new ErrorServiceTypeEntry(serviceEntry.getDescriptor()); + } + } + + // Return the instance + return serviceEntry.getServiceInstance(); + } + + /** + * Do nothing + * + * @throws ServiceException + */ + @Override + public void createService() throws ServiceException { + } + + /** + * Do nothing + * + * @param servicesRegistry + * @throws ServiceException + */ + @Override + public void initService(ServicesRegistry servicesRegistry) throws ServiceException { + } + + /** + * Do nothing. + * + * @throws ServiceException + */ + @Override + public void startService() throws ServiceException { + } + + /** + * @see org.eclipse.papyrus.infra.core.services.AbstractServiceEntry#disposeService() + * + * @throws ServiceException + */ + @Override + public void disposeService() throws ServiceException { + serviceEntry.disposeService(); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/PojoServiceEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/PojoServiceEntry.java new file mode 100644 index 00000000000..d0723ca4977 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/PojoServiceEntry.java @@ -0,0 +1,118 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services.internal; + +import org.eclipse.papyrus.infra.core.services.BadStateException; +import org.eclipse.papyrus.infra.core.services.ServiceDescriptor; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServiceState; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * Entry for a service provided as POJO. + * + * + * @author cedric dumoulin + */ +public class PojoServiceEntry extends ServiceTypeEntry { + + /** Instance of the service, if started. */ + private Object serviceInstance; + + /** + * Constructor. + * + * @param serviceDescriptor + */ + public PojoServiceEntry(ServiceDescriptor serviceDescriptor) { + super(serviceDescriptor); + setState(ServiceState.registered); + } + + /** + * Create an entry for an already created service. Constructor. + * + * @param descriptor + * Descriptor of the service. Key and priority should be set. + * @param serviceInstance + * The service Instance + */ + public PojoServiceEntry(ServiceDescriptor descriptor, Object serviceInstance) { + super(descriptor); + this.serviceInstance = serviceInstance; + setState(ServiceState.registered); + } + + /** + * Get the service instance. + * + * @return + * @throws ServiceException + * If service can't be started. + */ + public Object getServiceInstance() throws ServiceException { + + if(serviceInstance == null) + throw new BadStateException("Service is not created.", state, serviceDescriptor); + + return serviceInstance; + } + + /** + * Already created : do nothing. + * + * @throws ServiceException + */ + public void createService() throws ServiceException { + checkState(ServiceState.registered); + // Exit if already created. + if(serviceInstance != null) { + setState(ServiceState.created); + return; + } + + // Create it + try { + // Create the instance + serviceInstance = instanciateService(); + } catch (Exception e) { + setState(ServiceState.error); + throw new ServiceException(e); + } + setState(ServiceState.created); + } + + /** + * Pojo : can't initialize the service. Do nothing. + * + * @param servicesRegistry + * The servicesRegistry containing this service. + * + * @throws ServiceException + */ + public void initService(ServicesRegistry servicesRegistry) throws ServiceException { + setState(ServiceState.initialized); + } + + /** + * Already started : do nothing. + * + * @throws ServiceException + */ + public void startService() throws ServiceException { + setState(ServiceState.started); + } + + /** + * Do nothing. + */ + public void disposeService() throws ServiceException { + if(serviceInstance == null) + return; + + serviceInstance = null; + setState(ServiceState.disposed); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceEntry.java new file mode 100644 index 00000000000..763915adf3b --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceEntry.java @@ -0,0 +1,160 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services.internal; + +import org.eclipse.papyrus.infra.core.services.BadStateException; +import org.eclipse.papyrus.infra.core.services.IService; +import org.eclipse.papyrus.infra.core.services.ServiceDescriptor; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServiceState; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * Entry of a Service implementing {@link IService}. This class provide methods + * to manage the Service life cycle. + * + * @author cedric dumoulin + * + */ +public class ServiceEntry extends ServiceTypeEntry { + + /** Instance of the service, if started. */ + private IService serviceInstance; + + /** + * Constructor. + * + * @param serviceDescriptor + * @param registry + */ + public ServiceEntry(ServiceDescriptor serviceDescriptor) { + super(serviceDescriptor); + setState(ServiceState.registered); + + } + + /** + * Create an entry for an already created service. Constructor. + * + * @param descriptor + * Descriptor of the service. Key and priority should be set. + * @param serviceInstance + * The service Instance + */ + public ServiceEntry(ServiceDescriptor descriptor, IService serviceInstance) { + super(descriptor); + this.serviceInstance = serviceInstance; + setState(ServiceState.registered); + } + + /** + * Get the service instance, even if it is not started. The service should + * be created. + * + * @return + * @throws ServiceException + * If service can't be started. + */ + public Object getServiceInstance() throws ServiceException { + + if(serviceInstance == null) + throw new BadStateException("Service is not created.", state, serviceDescriptor); + + return serviceInstance; + + } + + /** + * @see java.lang.Object#toString() + * @return + * + */ + @Override + public String toString() { + return "ServiceEntry [serviceDescriptor=" + serviceDescriptor.toString() + ", serviceInstance=" + serviceInstance + "]"; + } + + /** + * Create the associated service if not a Lazy Service. + * + * @throws ServiceException + */ + public void createService() throws ServiceException { + checkState(ServiceState.registered); + // Exit if already created. + if(serviceInstance != null) { + setState(ServiceState.created); + return; + } + + // Create it + try { + // Create the instance + serviceInstance = (IService)instanciateService(); + } catch (Exception e) { + setState(ServiceState.error); + throw new ServiceException(e); + } + setState(ServiceState.created); + } + + /** + * Start the associated service if not a Lazy Service. + * + * @param servicesRegistry + * The servicesRegistry containing this service. + * + * @throws ServiceException + */ + public void initService(ServicesRegistry servicesRegistry) throws ServiceException { + checkState(ServiceState.created); + try { + serviceInstance.init(servicesRegistry); + } catch (ServiceException e) { + setState(ServiceState.error); + throw e; + } catch (Exception e) { + setState(ServiceState.error); + throw new ServiceException(e); + } + + setState(ServiceState.initialized); + } + + /** + * Start the associated service if not a Lazy Service. + * + * @throws ServiceException + */ + public void startService() throws ServiceException { + + checkState(ServiceState.initialized); + setState(ServiceState.starting); + + try { + serviceInstance.startService(); + } catch (ServiceException e) { + setState(ServiceState.error); + throw e; + } catch (Exception e) { + setState(ServiceState.error); + throw new ServiceException(e); + } + + setState(ServiceState.started); + } + + /** + * Dispose the service. + */ + public void disposeService() throws ServiceException { + if(serviceInstance == null) + return; + + serviceInstance.disposeService(); + serviceInstance = null; + setState(ServiceState.disposed); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceFactoryEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceFactoryEntry.java new file mode 100644 index 00000000000..5ea5b53d73d --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceFactoryEntry.java @@ -0,0 +1,171 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services.internal; + +import org.eclipse.papyrus.infra.core.services.BadStateException; +import org.eclipse.papyrus.infra.core.services.IServiceFactory; +import org.eclipse.papyrus.infra.core.services.ServiceDescriptor; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServiceState; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * Entry of a Service implementing {@link IServiceFactory}. This class provide + * methods to manage the Service life cycle. + * + * @author cedric dumoulin + * + */ +public class ServiceFactoryEntry extends ServiceTypeEntry { + + /** Instance of the service, if started. */ + private Object serviceInstance; + + /** Instance of the factory, if created. */ + private IServiceFactory factoryInstance; + + /** + * Constructor. + * + * @param serviceDescriptor + * @param registry + */ + public ServiceFactoryEntry(ServiceDescriptor serviceDescriptor) { + super(serviceDescriptor); + setState(ServiceState.registered); + + } + + /** + * Create an entry for an already created service. Constructor. + * + * @param descriptor + * Descriptor of the service. Key and priority should be set. + * @param serviceInstance + * The service Instance + */ + public ServiceFactoryEntry(ServiceDescriptor descriptor, IServiceFactory factoryInstance) { + super(descriptor); + this.factoryInstance = factoryInstance; + setState(ServiceState.registered); + } + + /** + * Get the service instance, even if it is not started. The service should + * be created. + * + * @return + * @throws ServiceException + * If service can't be started. + */ + public Object getServiceInstance() throws ServiceException { + + if(factoryInstance == null) + throw new BadStateException("Service is not created.", state, serviceDescriptor); + + // Get the service instance if needed. + if(serviceInstance == null) { + serviceInstance = factoryInstance.createServiceInstance(); + if(serviceInstance == null) { + throw new ServiceException("Service Factory '" + getDescriptor().getKey() + " return a null service. It should return a valid service."); + } + } + + return serviceInstance; + + } + + /** + * @see java.lang.Object#toString() + * @return + * + */ + @Override + public String toString() { + return "ServiceEntry [serviceDescriptor=" + serviceDescriptor.toString() + ", serviceInstance=" + serviceInstance + "]"; + } + + /** + * Create the associated service if not a Lazy Service. + * + * @throws ServiceException + */ + public void createService() throws ServiceException { + checkState(ServiceState.registered); + // Exit if already created. + if(factoryInstance != null) { + setState(ServiceState.created); + return; + } + + // Create it + try { + // Create the instance + factoryInstance = (IServiceFactory)instanciateService(); + } catch (Exception e) { + setState(ServiceState.error); + throw new ServiceException(e); + } + setState(ServiceState.created); + } + + /** + * Start the associated service if not a Lazy Service. + * + * @param servicesRegistry + * The servicesRegistry containing this service. + * + * @throws ServiceException + */ + public void initService(ServicesRegistry servicesRegistry) throws ServiceException { + checkState(ServiceState.created); + try { + factoryInstance.init(servicesRegistry); + } catch (ServiceException e) { + setState(ServiceState.error); + throw e; + } catch (Exception e) { + setState(ServiceState.error); + throw new ServiceException(e); + } + + setState(ServiceState.initialized); + } + + /** + * Start the associated service if not a Lazy Service. + * + * @throws ServiceException + */ + public void startService() throws ServiceException { + + checkState(ServiceState.initialized); + setState(ServiceState.starting); + + try { + factoryInstance.startService(); + } catch (ServiceException e) { + setState(ServiceState.error); + throw e; + } catch (Exception e) { + setState(ServiceState.error); + throw new ServiceException(e); + } + + setState(ServiceState.started); + } + + /** + * Dispose the service. + */ + public void disposeService() throws ServiceException { + if(factoryInstance == null) + return; + + factoryInstance.disposeService(); + factoryInstance = null; + setState(ServiceState.disposed); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceStartupEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceStartupEntry.java new file mode 100644 index 00000000000..285a5d5ea4c --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceStartupEntry.java @@ -0,0 +1,127 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services.internal; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.papyrus.infra.core.services.ServiceDescriptor; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServiceState; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * Base class for the different types of service startups (lazy, synchronized). + * + * @author cedric dumoulin + * + */ +public abstract class ServiceStartupEntry { + + /** + * The ServiceEntry, according to its type. + */ + protected ServiceTypeEntry serviceEntry; + + /** + * Entries of Services required by this service. + */ + protected List requiredServices; + + /** + * + * Constructor. + * + * @param serviceDescriptor + */ + public ServiceStartupEntry(ServiceTypeEntry serviceEntry) { + this.serviceEntry = serviceEntry; + } + + /** + * Create the associated service if not a Lazy Service. + * + * @throws ServiceException + */ + abstract public void createService() throws ServiceException; + + /** + * Init the associated service if not a Lazy Service. + * + * @param servicesRegistry + * The servicesRegistry containing this service. + * + * @throws ServiceException + */ + abstract public void initService(ServicesRegistry servicesRegistry) throws ServiceException; + + /** + * Start the associated service if not a Lazy Service. + * + * @throws ServiceException + */ + abstract public void startService() throws ServiceException; + + /** + * Get the service instance. + * + * @return + * @throws ServiceException + */ + abstract public Object getServiceInstance() throws ServiceException; + + /** + * Dispose associated service. + */ + abstract public void disposeService() throws ServiceException; + + /** + * Return the list of the {@link ServiceStartupEntry} required by this + * service. + * + * @return + */ + public Collection getRequiredServices() { + + throw new UnsupportedOperationException("Not yet implemented"); + // return requiredServices; + } + + /** + * Get {@link ServiceDescriptor} associated to this entry. + * + * @return + */ + public ServiceDescriptor getDescriptor() { + return serviceEntry.getDescriptor(); + } + + /** + * @return the state of the service + */ + public ServiceState getState() { + return serviceEntry.getState(); + } + + /** + * Return true if the service is started. Return false otherwise. + * + * @return + */ + public boolean isStarted() { + return serviceEntry.isStarted(); + } + + /** + * + * @see java.lang.Object#toString() + * + * @return + */ + @Override + public String toString() { + return super.toString() + ": key=" + getDescriptor().getKey(); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceTypeEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceTypeEntry.java new file mode 100644 index 00000000000..a5dbc205147 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceTypeEntry.java @@ -0,0 +1,201 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services.internal; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.papyrus.infra.core.services.BadStateException; +import org.eclipse.papyrus.infra.core.services.ServiceDescriptor; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServiceState; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.osgi.framework.Bundle; + +/** + * Base class for the different types of service entries (PoJo, Service, + * ServiceFactory, ...). + * + * @author cedric dumoulin + */ +public abstract class ServiceTypeEntry { + + /** + * Current state of the service. + */ + protected ServiceState state = ServiceState.registered; + + /** + * Descriptor of the service associated to this entry. + */ + protected ServiceDescriptor serviceDescriptor; + + /** + * + * Constructor. + * + */ + public ServiceTypeEntry(ServiceDescriptor serviceDescriptor) { + this.serviceDescriptor = serviceDescriptor; + } + + /** + * Change the state of the service. + * + * @param newState + */ + protected void setState(ServiceState newState) { + state = newState; + } + + /** + * @return the state + */ + public ServiceState getState() { + return state; + } + + /** + * Check if the current state is the proposed state. Throws an exception if + * the state is different. + * + * @param expectedState + * @throws BadStateException + */ + protected void checkState(ServiceState expectedState) throws BadStateException { + if(expectedState != state) { + throw new BadStateException(expectedState, state, serviceDescriptor); + } + } + + /** + * Get the descriptor of the service associated to this entry. + * + * @return + */ + public ServiceDescriptor getDescriptor() { + return serviceDescriptor; + } + + /** + * Instanciate the service as specified in serviceClassname. + * + * @return the created service. + * @throws ServiceException + */ + protected Object instanciateService() throws ServiceException { + + // Load the Class of the service + String serviceClassname = serviceDescriptor.getServiceClassname(); + Class classname = loadClass(); + + // Try to get the one arg constructor. + // This require the ServiceRegistry. Old stuff, not more used. + // try { + // Constructor constructor = + // classname.getConstructor(ServicesRegistry.class); + // return constructor.newInstance(registry); + // } catch (SecurityException e) { + // // Do nothing, try next constructor + // } catch (NoSuchMethodException e) { + // // Do nothing, try next constructor + // } catch (IllegalArgumentException e) { + // throw new ServiceException("Can't instanciate '" + serviceClassname + + // "' with args ServicesRegistry.", e); + // } catch (InstantiationException e) { + // throw new ServiceException("Can't instanciate '" + serviceClassname + + // "' with args ServicesRegistry.", e); + // } catch (IllegalAccessException e) { + // throw new ServiceException("Can't instanciate '" + serviceClassname + + // "' with args ServicesRegistry.", e); + // } catch (InvocationTargetException e) { + // throw new ServiceException("Can't instanciate '" + serviceClassname + + // "' with args ServicesRegistry.", e); + // } + + // Try with zero arg constructor. + try { + return classname.newInstance(); + } catch (SecurityException e) { + throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e); + } catch (IllegalArgumentException e) { + throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e); + } catch (InstantiationException e) { + throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e); + } catch (IllegalAccessException e) { + throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e); + } + } + + /** + * Load the Class object. Try from current ClassLoader, then try using the + * plugin referenced in the serviceDescriptor.PluginId + * + * @return + * @throws ServiceException + */ + private Class loadClass() throws ServiceException { + String serviceClassname = serviceDescriptor.getServiceClassname(); + Class serviceClass; + try { + serviceClass = Class.forName(serviceClassname); + } catch (ClassNotFoundException e1) { + // Try using bundle + try { + String bundleID = serviceDescriptor.getClassBundleID(); + Bundle bundle = Platform.getBundle(bundleID); + serviceClass = bundle.loadClass(serviceClassname); + } catch (ClassNotFoundException e2) { + throw new ServiceException("Can't find class for the name '" + serviceClassname + "'.", e2); + } + } + + return serviceClass; + } + + /** + * Return true if the service is started. Return false otherwise. + * + * @return + */ + public boolean isStarted() { + return state == ServiceState.started; + } + + /** + * Get the service instance. + * + * @return + * @throws ServiceException + */ + abstract public Object getServiceInstance() throws ServiceException; + + /** + * Create the associated service if not a Lazy Service. + * + * @throws ServiceException + */ + abstract public void createService() throws ServiceException; + + /** + * Start the associated service if not a Lazy Service. + * + * @param servicesRegistry + * The servicesRegistry containing this service. + * + * @throws ServiceException + */ + abstract public void initService(ServicesRegistry servicesRegistry) throws ServiceException; + + /** + * Start the associated service if not a Lazy Service. + * + * @throws ServiceException + */ + abstract public void startService() throws ServiceException; + + /** + * Dispose associated service. + */ + abstract public void disposeService() throws ServiceException; + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/StartStartupEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/StartStartupEntry.java new file mode 100644 index 00000000000..be5f39451dd --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/StartStartupEntry.java @@ -0,0 +1,84 @@ +/** + * + */ +package org.eclipse.papyrus.infra.core.services.internal; + +import org.eclipse.papyrus.infra.core.services.IService; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * An ServiceEntry managing {@link IService} that should be started when the + * registry is started. + * + * @author cedric dumoulin + * + */ +public class StartStartupEntry extends ServiceStartupEntry { + + /** + * Constructor. + * + * @param serviceDescriptor + * @param registry + */ + public StartStartupEntry(ServiceTypeEntry serviceEntry) { + + super(serviceEntry); + } + + /** + * + * @see org.eclipse.papyrus.infra.core.services.internal.ServiceStartupEntry#getServiceInstance() + * + * @return + * @throws ServiceException + */ + @Override + public Object getServiceInstance() throws ServiceException { + // Return the instance + return serviceEntry.getServiceInstance(); + } + + /** + * Do nothing + * + * @throws ServiceException + */ + @Override + public void createService() throws ServiceException { + serviceEntry.createService(); + } + + /** + * Do nothing + * + * @param servicesRegistry + * @throws ServiceException + */ + @Override + public void initService(ServicesRegistry servicesRegistry) throws ServiceException { + serviceEntry.initService(servicesRegistry); + } + + /** + * Do nothing. + * + * @throws ServiceException + */ + @Override + public void startService() throws ServiceException { + serviceEntry.startService(); + } + + /** + * @see org.eclipse.papyrus.infra.core.services.AbstractServiceEntry#disposeService() + * + * @throws ServiceException + */ + @Override + public void disposeService() throws ServiceException { + serviceEntry.disposeService(); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/ui/IRevealSemanticElement.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/ui/IRevealSemanticElement.java new file mode 100644 index 00000000000..953abd73024 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/ui/IRevealSemanticElement.java @@ -0,0 +1,34 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + */ +package org.eclipse.papyrus.infra.core.ui; + +import java.util.List; + +/** + * this interface is used to reveal element that are given in parameter. Example + * of the use case: the class that implements this interface can be a diagram + * that select all editparts that are linked to the given list of semantic + * element + * + */ +public interface IRevealSemanticElement { + + /** + * reveal all elements that represent an element in the given list. + * + * @param elementList + * list of semantic element that we want to reveal, cannot be + * null + */ + public void revealSemanticElement(List elementList); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/AbstractServiceUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/AbstractServiceUtils.java new file mode 100644 index 00000000000..43cfbe47c22 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/AbstractServiceUtils.java @@ -0,0 +1,121 @@ +/***************************************************************************** + * Copyright (c) 2010 LIFL & CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.utils; + +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.infra.core.lifecycleevents.ILifeCycleEventsProvider; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.ui.IEditorPart; + +/** + * Set of utility methods for accessing core Services. This class provide + * methods to access the Papyrus well known services. + * + *
+ * This is the base class for concrete classes providing these utility methods. + * Concrete class need to provide method {@link #getServiceRegistry(Object)} implementing how the ServiceRegistry is retrieved from the provided + * object. + * Subclasses can also provide a Singleton pattern (getInstance()) in order to + * allow access to the utility methods in a static way.
+ * + * @author cedri dumoulin + * + */ +public abstract class AbstractServiceUtils { + + /** + * Get the service registry from the specified parameter. + * + * @param from + * @return + */ + abstract public ServicesRegistry getServiceRegistry(T from) throws ServiceException; + + /** + * Gets the {@link TransactionalEditingDomain} registered in the {@link ServicesRegistry}. + * + * @param from + * @return + * @throws ServiceException + * If an error occurs while getting the requested service. + */ + public TransactionalEditingDomain getTransactionalEditingDomain(T from) throws ServiceException { + return getServiceRegistry(from).getService(TransactionalEditingDomain.class); + } + + /** + * Gets the {@link IPageMngr} registered in the {@link ServicesRegistry}. + * + * @param from + * @return + * @throws ServiceException + * If an error occurs while getting the requested service. + */ + public IPageMngr getIPageMngr(T from) throws ServiceException { + return getServiceRegistry(from).getService(IPageMngr.class); + } + + /** + * Gets the {@link IPageMngr} registered in the {@link ServicesRegistry}. + * + * @param from + * @return + * @throws ServiceException + * If an error occurs while getting the requested service. + */ + public ModelSet getModelSet(T from) throws ServiceException { + return getServiceRegistry(from).getService(ModelSet.class); + } + + /** + * Gets the {@link ILifeCycleEventsProvider} registered in the {@link ServicesRegistry}. + * + * @param from + * @return + * @throws ServiceException + * If an error occurs while getting the requested service. + */ + public ILifeCycleEventsProvider getILifeCycleEventsProvider(T from) throws ServiceException { + return getServiceRegistry(from).getService(ILifeCycleEventsProvider.class); + } + + /** + * Gets the {@link ISashWindowsContainer} registered in the {@link ServicesRegistry}. + * + * @param from + * @return + * @throws ServiceException + * If an error occurs while getting the requested service. + */ + public ISashWindowsContainer getISashWindowsContainer(T from) throws ServiceException { + return getServiceRegistry(from).getService(ISashWindowsContainer.class); + } + + /** + * Gets the {@link IEditorPart} of the currently nested active editor. + * + * @param from + * @return + * @throws ServiceException + * If an error occurs while getting the requested service. + */ + public IEditorPart getNestedActiveIEditorPart(T from) throws ServiceException { + return getISashWindowsContainer(from).getActiveEditor(); + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/BusinessModelResolver.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/BusinessModelResolver.java new file mode 100644 index 00000000000..ffde6f1f31b --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/BusinessModelResolver.java @@ -0,0 +1,102 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.utils; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.notation.View; + +/** + * This class allows to retrieve the business object from an object representing + * a graphical artifact in a diagram. Each diagram can register its resolver + * which will be added to the list of resolvers. Some common resolvers are + * already registered : gef.EditPart TODO Use extensions to register additional + * resolvers. + */ +public class BusinessModelResolver { + + /** + * The unique instance + */ + public static BusinessModelResolver instance = new BusinessModelResolver(); + + public BusinessModelResolver() { + + } + + /** + * Get the business object associated to this object, if any. This method + * navigate throw the object if the object is an graphical artefact or a + * diagram artifact. + * + * @param object + * @return Object + */ + public Object getBusinessModel(Object object) { + if(object instanceof EditPart) { + // Check model. It can be a GraphNode. + Object model = ((EditPart)object).getModel(); + if(model instanceof View) { // Notation / GMF + return getBusinessElement((View)((EditPart)object).getModel()); + } else { + return model; + } + + } else if(object instanceof View) { + return ((View)object).getElement(); + + } else if(object instanceof IAdaptable) { + // Among others this is useful to retrieve the selected object from + // an explorer item. + return ((IAdaptable)object).getAdapter(EObject.class); + + } else { + return object; + } + } + + /** + * Get the business object from a GraphElement. + * + * @param object + * @return + */ + protected Object getBusinessElement(View object) { + try { + return object.getElement(); + } catch (NullPointerException e) { + // no business element + return null; + } + } + + /** + * Get the graphical object accessible from to this diagram object, if any. + * + * @param object + * @return Object + */ + public Object getGraphicalModel(Object object) { + throw new UnsupportedOperationException("Not yet implemented."); + } + + /** + * @return BusinessModelResolver + */ + public static BusinessModelResolver getInstance() { + return instance; + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/DiResourceSet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/DiResourceSet.java new file mode 100644 index 00000000000..e129e918505 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/DiResourceSet.java @@ -0,0 +1,339 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.utils; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IPath; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.infra.core.resource.ModelException; +import org.eclipse.papyrus.infra.core.resource.ModelMultiException; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.ModelsReader; +import org.eclipse.papyrus.infra.core.resource.notation.NotationModel; +import org.eclipse.papyrus.infra.core.resource.notation.NotationUtils; +import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModelUtils; +import org.eclipse.papyrus.infra.core.resource.sasheditor.SashModelUtils; +import org.eclipse.papyrus.infra.core.resource.uml.UmlModel; +import org.eclipse.papyrus.infra.core.resource.uml.UmlUtils; + +/** + * ResourceSet Manager for UML and DI files, and also other loaded models. + * + * @author Cedric dumoulin + * @author Jerome Benois + * @author Thomas Szadel + * + * @deprecated Use ModelSet instead. + */ +public class DiResourceSet extends ModelSet { + + /** + * + * Constructor. + * + */ + public DiResourceSet() { + super(); + // Register declared models + ModelsReader reader = new ModelsReader(); + reader.readModel(this); + } + + /** + * Just loads the model into the current resource set. + * + * @returns The loaded model or null if the model is not loaded. + * @deprecated load requested model and get its resource. See implementation + * for example. + */ + public Resource loadModelResource(IFile file) { + + UmlModel model = null; + try { + model = (UmlModel)loadModel(UmlModel.MODEL_ID, file); + } catch (ModelException e) { + return null; + } + return model.getResource(); + } + + /** + * Returns the extension of the model. Seem to be unused. + * + * @deprecated Use {@link UmlModel#UML_FILE_EXTENSION} + */ + public String getModelFileExtension() { + throw new UnsupportedOperationException("deprecated method."); + // if(modelFileExtension == null) { + // modelFileExtension = modelResource.getURI().fileExtension(); + // } + // return modelFileExtension; + } + + /** + * Load both files (DI and UML) from an handle on one of the two files. + * + * @param file + * The file to load (no matter the extension)Model + * @deprecated use {@link ModelSet#loadModels(IFile)} instead. + */ + public void loadResources(IFile file) { + try { + loadModels(file); + } catch (ModelMultiException e) { + e.printStackTrace(); + } + + // // Extract file name, without extension + // IPath fullPath = file.getFullPath().removeFileExtension(); + // + // // load DI2 + // URI diUri = + // getPlatformURI(fullPath.addFileExtension(DI_FILE_EXTENSION)); + // diResource = getResource(diUri, true); + // + // // load notation + // URI notationURI = + // getPlatformURI(fullPath.addFileExtension(NOTATION_FILE_EXTENSION)); + // notationResource = getResource(notationURI, true); + // + // if(notationResource != null) { + // // look for a model associated with a diagram in notation + // for(EObject eObject : notationResource.getContents()) { + // if(eObject instanceof Diagram) { + // Diagram diagram = (Diagram)eObject; + // if(diagram.getElement() != null) { + // modelResource = diagram.getElement().eResource(); + // break; + // } + // } + // } + // } + // + // + // // if modelResource is still null, we look for a file with the same + // name and a supported extension + // if(modelResource == null) { + // IContainer folder = file.getParent(); + // try { + // IResource[] files = folder.members(); + // for(IResource r : files) { + // String extension = r.getFullPath().getFileExtension(); + // if(r.getFullPath().removeFileExtension().lastSegment().equals(fullPath.lastSegment()) + // && !DI_FILE_EXTENSION.equalsIgnoreCase(extension) && + // !NOTATION_FILE_EXTENSION.equalsIgnoreCase(extension)) { + // if(Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().get(extension) + // != null) { + // modelResource = getResource(getPlatformURI(r.getFullPath()), true); + // break; + // } + // } + // } + // } catch (CoreException e) { + // // never happens. + // } + // } + // + // modelFileExtension = modelResource.getURI().fileExtension(); + // + // // TODO move next line away from DiResourceSet ? Define a place + // // where Resource initialization can take place. + // // move this line to centralize all the adapters + // modelResource.eAdapters().add(new ModelListenerManager()); + } + + /** + * Create both files (DI and UML) from a filename. + * + * @param newFile + * The file from which path is extracted to create the new files + * + * @deprecated Use {@link ModelSet#createsModels(IFile)} instead. + */ + public void createModelResources(IFile newFile, String eContentType, String modelExtension) { + + // Check if parameters are those expected. + // If not, throws an exception to inform the programmer. + if(!("org.eclipse.uml2.uml".equals(eContentType) && "uml".equals(modelExtension))) { + throw new UnsupportedOperationException(""); + } + // Create models + createsModels(newFile); + + // // create the di resource URI + // URI diUri = getPlatformURI(newFile.getFullPath()); + // // Create the di Resource for the sashcontainer + // // The model will be automatically initialized by the SashContainer + // if needed (if it is empty). + // // Normally the resource should contains models set by previous use + // from the SashContainer + // diResource = createResource(diUri); + // + // IPath filenameWithoutExtension = + // newFile.getFullPath().removeFileExtension(); + // // if the model is not loaded, create resource + // if(modelResource == null) { + // // create the model URI + // URI modelUri = + // getPlatformURI(filenameWithoutExtension.addFileExtension(modelExtension)); + // // create the model resource + // modelResource = createResource(modelUri, eContentType); + // this.modelFileExtension = modelExtension; + // } + // // create the notation URI + // URI notationURI = + // getPlatformURI(filenameWithoutExtension.addFileExtension(NOTATION_FILE_EXTENSION)); + // // create the notation resource + // notationResource = createResource(notationURI); + + } + + /** + * 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); + } + + /** + * Returns the notation resource. + * + * @return the notationResource + * @deprecated Use NotationUtils.getNotationModel(this).getResource(); + * instead. + */ + public Resource getNotationResource() { + return NotationUtils.getNotationModel(this).getResource(); + } + + /** + * + * + * @return the diResource + * @deprecated Use NotationUtils.getSashModel(this).getResource(); instead. + */ + public Resource getDiResource() { + return SashModelUtils.getSashModel(this).getResource(); + } + + /** + * Retrieve the di resource associated with a given model element. + * + * @param modelElement + * @return the di resource or null + * @deprecated a model should be modified/created to correctly handle + * controlled resources + */ + public Resource getAssociatedDiResource(EObject modelElement) { + // return the "base" di since we want the opened tabs in a unique di + return getDiResource(); + } + + /** + * Retrieve the notation resource associated with a given model element. + * + * @param modelElement + * @return the notation resource or null + * @deprecated a model should be modified/created to correctly handle + * controlled resources + */ + public Resource getAssociatedNotationResource(EObject modelElement) { + if(modelElement != null) { + Resource modelResource = modelElement.eResource(); + if(modelResource != null && !modelResource.equals(getModelResource())) { + // handle controlled resource + return getAssociatedResource(modelResource, NotationModel.NOTATION_FILE_EXTENSION); + } + } + return getNotationResource(); + } + + /** + * Retrieve the model resource associated with a given model element. Please + * refers to {@link ResourceSet#getResource(URI, boolean)} for the meaning + * of loadOnDemand. + * + * @param modelElement + * @return the model resource or null + * @deprecated a model should be modified/created to correctly handle + * controlled resources + */ + public Resource getAssociatedModelResource(EObject modelElement) { + if(modelElement != null && modelElement.eResource() != null) { + return modelElement.eResource(); + } + return getModelResource(); + } + + private Resource getAssociatedResource(Resource modelResource, String associatedResourceExtension) { + URI trimmedModelURI = modelResource.getURI().trimFileExtension(); + Resource r = null; + try { + r = getResource(trimmedModelURI.appendFileExtension(associatedResourceExtension), true); + } catch (Exception e) { + } + return r; + } + + /** + * Returns the model resource. + * + * @return the modelResource + * @deprecated Use NotationUtils.getUmlModel(this).getResource(); instead. + */ + public Resource getModelResource() { + return UmlUtils.getUmlModel(this).getResource(); + } + + /** + * Returns the additional resources. + * + * @return The additional resources. + */ + public List getAdditionalResources() { + List additionnalResources = new ArrayList(); + for(Resource resource : getResources()) { + // ignore di, notation and domain resources + + if(resource != getDiResource() && resource != getNotationResource() && resource != getModelResource()) { + additionnalResources.add(resource); + } + } + + return additionnalResources; + } + + /** + * Returns the related di file. + * + * @param file + * A file (di, model or notation). + * @return The associated DI file. + * @deprecated use {@link DiModelUtils#getRelatedDiFile(IFile)} + */ + public static IFile getRelatedDiFile(IFile file) { + return DiModelUtils.getRelatedDiFile(file); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/DisplayUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/DisplayUtils.java new file mode 100644 index 00000000000..44c43a293e4 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/DisplayUtils.java @@ -0,0 +1,44 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.utils; + +import static org.eclipse.papyrus.infra.core.Activator.log; + +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * Util class for display in Papyrus (label providers, etc...) + */ +public class DisplayUtils { + + /** + * Gets the shared label provider. + * + * @return Get the current {@link ILabelProvider} or null if + * not found + */ + public static ILabelProvider getLabelProvider() { + try { + ServicesRegistry registry = EditorUtils.getServiceRegistry(); + return registry == null ? null : registry.getService(ILabelProvider.class); + } catch (IllegalStateException e) { + // Registry can't be found, do nothing. + log.error(e); + } catch (ServiceException e) { + log.error(e); + } + return null; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/EditorUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/EditorUtils.java new file mode 100644 index 00000000000..e686abf8c54 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/EditorUtils.java @@ -0,0 +1,652 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * Thomas Szadel: Code simplification and NPE + * management. + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.utils; + +import static org.eclipse.papyrus.infra.core.Activator.log; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.papyrus.infra.core.editor.BackboneException; +import org.eclipse.papyrus.infra.core.editor.CoreMultiDiagramEditor; +import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; +import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModelUtils; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelMngr; +import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.TransactionalDiSashModelMngr; +import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage; +import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServiceNotFoundException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorReference; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * Set of utility methods for the CoreEditor.
+ * WARNING : Some of these methods rely on + * PlatformUI.getWorkbench().getActiveWorkbenchWindow()getActivePage() to lookup + * for shared objects owned by the main editor. This doesn't work during the + * initialization of the main editor because the main editor is not yet + * registered in the Eclipse workbench. This can lead to a null or an exception, + * and sometime this can lead to getting the shared object of another main + * editor ! + * + * @author cedric dumoulin + * @author Thomas Szadel + */ +// FIXME throws Exception (eg: NotFoundException) instead of null +public class EditorUtils { + + /** + * Gets the {@link IMultiDiagramEditor} interface of the a Eclipse active + * editor, if possible, or null if not possible.
+ * WARNING - This method doesn't work during the initialization of the main + * editor. See note in class doc.
+ * This method return null if there is no active editor, or if the editor is + * not instance of IMultiDiagramEditor.
+ * This method is designed to be used by ui actions that interact with the + * active editor.
+ * This method should not be used during the editor initialization phase.
+ * In any case, a check should be done on the returned value that can be + * null. Usage of this method is discouraged. Use {@link #getMultiDiagramEditorChecked()} instead. + * + * + * @return Get the current {@link IMultiDiagramEditor} or null if not found. + */ + public static IMultiDiagramEditor getMultiDiagramEditor() { + // Lookup ServiceRegistry + IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if(workbenchWindow == null) { + return null; + } + IWorkbenchPage page = workbenchWindow.getActivePage(); + if(page == null) { + return null; + } + IEditorPart editor = page.getActiveEditor(); + if(editor instanceof IMultiDiagramEditor) { + return (IMultiDiagramEditor)editor; + } else { + return null; + } + } + + /** + * Gets the {@link IMultiDiagramEditor} interface of the a Eclipse active + * editor, if possible, or throw an exception if not possible.
+ * WARNING - This method throw an exception during the initialization of the + * main editor. This method throws an exception if there is no active + * editor, or if the editor is not instance of IMultiDiagramEditor.
+ * This method is designed to be used by ui actions that interact with the + * active editor.
+ * + * + * @return Get the current {@link IMultiDiagramEditor} or null if not found. + * @throws BackboneException + * If it is not possible to get an instanceof {@link IMultiDiagramEditor} + */ + public static IMultiDiagramEditor getMultiDiagramEditorChecked() throws BackboneException { + IEditorPart editor; + try { + editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + } catch (NullPointerException e) { + // Can't get the active editor + throw new BackboneException("Can't get the current Eclipse Active Editor: There is no active editor at this time."); + } + + if(editor instanceof IMultiDiagramEditor) { + return (IMultiDiagramEditor)editor; + } else { + throw new BackboneException("Can't get an Active Editor instance of IMultiDiagramEditor. (actual type:" + editor.getClass().getName() + ")"); + } + } + + /** + * Gets the opened multi-diagram editors. + * + * @return The opened {@link IMultiDiagramEditor} or null if an error + * occured. + */ + public static IMultiDiagramEditor[] getMultiDiagramEditors() { + // Lookup ServiceRegistry + IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if(workbenchWindow == null) { + return null; + } + IWorkbenchPage page = workbenchWindow.getActivePage(); + if(page == null) { + return null; + } + List list = new ArrayList(); + for(IEditorReference editorRef : page.getEditorReferences()) { + IEditorPart editorPart = editorRef.getEditor(false); + if(editorPart instanceof IMultiDiagramEditor) { + list.add((IMultiDiagramEditor)editorPart); + } + } + return list.toArray(new IMultiDiagramEditor[list.size()]); + } + + /** + * Returns the editors that are related to to given file.
+ * + * @param file + * The file (model, di or notation). + * @return The associated editors. + */ + public static IMultiDiagramEditor[] getRelatedEditors(IFile file) { + // Get the DI file + IFile diFile = DiModelUtils.getRelatedDiFile(file); + if(diFile == null || !diFile.exists()) { + return new IMultiDiagramEditor[0]; + } + + IMultiDiagramEditor[] openedEditors = EditorUtils.getMultiDiagramEditors(); + if(openedEditors == null) { + return new IMultiDiagramEditor[0]; + } + List list = new ArrayList(openedEditors.length); + + for(IMultiDiagramEditor editorPart : openedEditors) { + if(editorPart.getEditorInput() instanceof IFileEditorInput && diFile.equals(((IFileEditorInput)editorPart.getEditorInput()).getFile())) { + list.add(editorPart); + } + } + return list.toArray(new IMultiDiagramEditor[list.size()]); + } + + /** + * Get the {@link ServicesRegistry}of the currently active eclipse editor.
+ * WARNING - This method doesn't work during the initialization of the main + * editor. See note in class doc.
+ * This method return null if the ServicesRegistry can not be found.
+ * This method is designed to be used by ui actions that interact with the + * active editor.
+ * This method should not be used during the editor initialization phase.
+ * In any case, a check should be done on the returned value that can be + * null. An alternative is to use {@link #getServiceRegistryChecked()} and + * to catch the exception.
+ * It is preferable to retrieve the ServiceRegistry from elsewhere whenever + * it is possible.
+ * In GMF EditParts or EditPolicies, the ServiceRegistry can be retrieved + * with methods from + * org.eclipse.papyrus.uml.diagram.common.util.ServiceUtilsForGMF + * + *
+ * WARNING: This method can return null if there is no Active Editor. This + * happen during the editor initialization, especially when there is no + * other editor opened. + * + * @return The {@link ServicesRegistry} or null if not found. + * @deprecated Check + * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments + * /cookbook/PapyrusCookBook.odt and use one of the replacement: + *
    + *
  • org.eclipse.papyrus.infra.core.utils.ServiceUtils
  • + *
  • + * org.eclipse.papyrus.uml.diagram.common.util.ServiceUtilsForGMF
  • + *
  • + * org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • + *
+ */ + static public ServicesRegistry getServiceRegistry() { + // Lookup ServiceRegistry + IMultiDiagramEditor editor = getMultiDiagramEditor(); + return editor == null ? null : (ServicesRegistry)editor.getAdapter(ServicesRegistry.class); + } + + /** + * Get the service registry of the currently active main editor.
+ * WARNING - This method doesn't work during the initialization of the main + * editor. See note in class doc. + * + * @return The {@link ServicesRegistry} or null if not found. + * @throws ServiceException + * If an error occurs. + * @deprecated Check + * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments + * /cookbook/PapyrusCookBook.odt and use one of the replacement: + *
    + *
  • org.eclipse.papyrus.infra.core.utils.ServiceUtils
  • + *
  • + * org.eclipse.papyrus.uml.diagram.common.util.ServiceUtilsForGMF
  • + *
  • + * org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • + *
+ */ + static public ServicesRegistry getServiceRegistryChecked() throws ServiceException { + // Lookup ServiceRegistry + IMultiDiagramEditor editor = getMultiDiagramEditor(); + if(editor == null) { + throw new ServiceException("Can't get ServiceRegistry"); + } + + return (ServicesRegistry)editor.getAdapter(ServicesRegistry.class); + } + + /** + * Get the ISashWindowsContentProvider of the active Eclipse Editor, if + * possible.
+ * This method return null if the ServiceRegistry can not be found or if an + * error occur.
+ * This method is designed to be used by ui actions that interact with the + * active editor.
+ * This method should not be used during the editor initialization phase.
+ * In any case, a check should be done on the returned value that can be + * null.
+ * + * @return the ISashWindowsContentProvider from the main editor or null if + * not found. + * @deprecated Check + * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments + * /cookbook/PapyrusCookBook.odt and use one of the replacement: + *
    + *
  • org.eclipse.papyrus.infra.core.utils.ServiceUtils
  • + *
  • + * org.eclipse.papyrus.uml.diagram.common.util.ServiceUtilsForGMF
  • + *
  • + * org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • + *
+ */ + static public ISashWindowsContentProvider getISashWindowsContentProvider() { + + try { + return getServiceRegistryChecked().getService(ISashWindowsContentProvider.class); + } catch (ServiceException e) { + // The contract says that we return null if not found + return null; + } + } + + /** + * Get the ISashWindowsContentProvider of the active Eclipse Editor, if + * possible.
+ * This method return null if the ServiceRegistry can not be found or if an + * error occur.
+ * This method is designed to be used by ui actions that interact with the + * active editor.
+ * This method should not be used during the editor initialization phase.
+ * In any case, a check should be done on the returned value that can be + * null. + * + * @return the ISashWindowsContentProvider from the main editor or null if + * not found. + * @deprecated Check + * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments + * /cookbook/PapyrusCookBook.odt and use one of the replacement: + *
    + *
  • org.eclipse.papyrus.infra.core.utils.ServiceUtils
  • + *
  • + * org.eclipse.papyrus.uml.diagram.common.util.ServiceUtilsForGMF
  • + *
  • + * org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • + *
+ */ + public static IPageMngr getIPageMngr() { + + try { + return getServiceRegistryChecked().getService(IPageMngr.class); + } catch (ServiceException e) { + // The contract says that we return null if not found + return null; + } + } + + /** + * Get the Eclipse ActiveEditor. + * + * @return The active {@link CoreMultiDiagramEditor} or null if not found. + * @deprecated Use {@link EditorUtils#getMultiDiagramEditor()} + */ + @Deprecated + protected static IEditorPart getWorkbenchActiveEditor() { + IMultiDiagramEditor editorPart = getMultiDiagramEditor(); + if(editorPart instanceof CoreMultiDiagramEditor) { + return editorPart; + } else { + return null; + } + } + + /** + * Create an instance of IPageMngr acting on the provided resource. This + * instance is suitable to add, remove, close or open diagrams. + * + * @param diResource + * @return The non transactional implementation of IPageMngr + */ + public static IPageMngr getIPageMngr(Resource diResource) { + return DiSashModelMngr.createIPageMngr(diResource); + } + + /** + * Create an instance of IPageMngr acting on the provided resource. This + * instance is suitable to add, remove, close or open diagrams. + * + * @param diResource + * @param editingDomain + * + * @return The transactional implementation of IPageMngr + */ + public static IPageMngr getTransactionalIPageMngr(Resource diResource, TransactionalEditingDomain editingDomain) { + return TransactionalDiSashModelMngr.createIPageMngr(diResource, editingDomain); + } + + /** + * Lookup the currently active Diagram from the Papyrus editor. Return the + * current Diagram or null if none is active.
+ * WARNING - This method doesn't work during the initialization of the main + * editor. See note in class doc.
+ * This method return null if the ServicesRegistry can not be found.
+ * TODO This method introduce dependency on GMF. It can be moved to a GMF + * plugin. + * + * @return The active diagram or null if not found. + * + * @deprecated The core do make suppositions about the type of nested + * Editors, GMF stuff should be moved in GMF projects. In many + * case, {@link #lookupActiveNestedIEditor()} can be used. + */ + public static Diagram lookupEditorActiveDiagram() { + DiagramEditor diagEditor = lookupActiveDiagramEditor(); + return diagEditor == null ? null : diagEditor.getDiagram(); + } + + /** + * Lookup the currently active Diagram from the Papyrus editor. Return the + * current Diagram or null if none is active.
+ * WARNING - This method doesn't work during the initialization of the main + * editor. See note in class doc.
+ * This method return null if the ServicesRegistry can not be found.
+ * TODO This method introduce dependency on GMF. It can be moved to a GMF + * plugin. + * + * @return the active diagram editor or null if not found. + * + * @deprecated The core do make suppositions about the type of nested + * Editors, GMF stuff should be moved in GMF projects. In many + * case, {@link #lookupActiveNestedIEditor()} can be used. + */ + public static DiagramEditor lookupActiveDiagramEditor() { + // Get the active page within the sashcontainer + IEditorPart activeEditor = lookupActiveNestedIEditor(); + // Check if it is a GMF DiagramEditor + if(activeEditor instanceof DiagramEditor) { + return ((DiagramEditor)activeEditor); + } else { + // Not found + return null; + } + + } + + /** + * Lookup the currently active {@link IEditorPart} from the Papyrus editor. + * Return the current nested editor part, or null if it can not be found.
+ * WARNING - This method doesn't work during the initialization of the main + * editor. See note in class doc.
+ * This method return null if the ServicesRegistry can not be found.
+ * This method is designed to be used by ui actions that interact with the + * active editor.
+ * This method should not be used during the editor initialization phase.
+ * In any case, a check should be done on the returned value that can be + * null. An alternative is to use + * serviceRegistry.getService(ISashWindowsContainer + * .class).getActiveEditor();
+ * It is preferable to retrieve the ServiceRegistry from elsewhere whenever + * it is possible.
+ * + * + * @return + * @deprecated Check + * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments + * /cookbook/PapyrusCookBook.odt and use one of the replacement: + *
    + *
  • org.eclipse.papyrus.infra.core.utils.ServiceUtils
  • + *
  • + * org.eclipse.papyrus.uml.diagram.common.util.ServiceUtilsForGMF
  • + *
  • + * org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • + *
+ */ + public static IEditorPart lookupActiveNestedIEditor() { + // Get the sashwindow container + ISashWindowsContainer container = getSashWindowContainer(); + // Get the active page within the sashcontainer + return container == null ? null : container.getActiveEditor(); + } + + /** + * Lookup the currently active IEditor in the SashSystem. If the currently + * eclipse active editor doesn't contains a {@link ISashWindowsContainer}, + * return null. If the current SashSystem page is not a IEditor, return + * null.
+ * WARNING - This method doesn't work during the initialization of the main + * editor. See note in class doc.
+ * This method return null if the ServicesRegistry can not be found.
+ * This method is designed to be used by ui actions that interact with the + * active editor.
+ * This method should not be used during the editor initialization phase.
+ * In any case, a check should be done on the returned value that can be + * null. An alternative is to use + * serviceRegistry.getService(ISashWindowsContainer + * .class).getActiveSashWindowsPage();
+ * It is preferable to retrieve the ServiceRegistry from elsewhere whenever + * it is possible. + * + * @return + * @deprecated Check + * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments + * /cookbook/PapyrusCookBook.odt and use one of the replacement: + *
    + *
  • org.eclipse.papyrus.infra.core.utils.ServiceUtils
  • + *
  • + * org.eclipse.papyrus.uml.diagram.common.util.ServiceUtilsForGMF
  • + *
  • + * org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • + *
+ */ + public static IPage lookupActiveNestedPage() { + + // Get the sashwindow container + ISashWindowsContainer container = getSashWindowContainer(); + // Get the active page within the sashcontainer + return container == null ? null : container.getActiveSashWindowsPage(); + } + + /** + * + * @return + */ + private static ISashWindowsContainer getSashWindowContainer() { + + try { + return getServiceRegistryChecked().getService(ISashWindowsContainer.class); + } catch (ServiceException e) { + // The contract says that we return null if not found + return null; + } + } + + /** + * Gets the di resource set. + * + * @return Get the current {@link DiResourceSet} or null if not found. + * @deprecated Check + * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments + * /cookbook/PapyrusCookBook.odt and use one of the replacement: + *
    + *
  • org.eclipse.papyrus.infra.core.utils.ServiceUtils
  • + *
  • + * org.eclipse.papyrus.uml.diagram.common.util.ServiceUtilsForGMF
  • + *
  • + * org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • + *
+ */ + public static DiResourceSet getDiResourceSet() { + try { + ServicesRegistry registry = getServiceRegistry(); + return registry == null ? null : registry.getService(DiResourceSet.class); + } catch (ServiceException e) { + log.error(e); + } + return null; + } + + /** + * Gets the {@link TransactionalEditingDomain} of the current active Eclipse + * Editor. This method should be used only when it is sure that the active + * editor exist, and that you want the EditingDomain of this editor.
+ * This method return null if the TransactionalEditingDomain can not be + * found.
+ * This method is designed to be used by ui actions that interact with the + * active editor.
+ * This method should not be used during the editor initialization phase.
+ * In any case, a check should be done on the returned value that can be + * null. An alternative is to use {@link #getTransactionalEditingDomainChecked()} and to catch the + * exception.
+ * It is preferable to use {@link #getTransactionalEditingDomain(ServicesRegistry)} whenever it is + * possible.
+ * In GMF EditParts or EditPolicies, the ServiceRegistry can be retrieved + * with methods from + * org.eclipse.papyrus.uml.diagram.common.util.DiagramCoreServiceUtils
+ * WARNING: This method can return null if there is no Active Editor. This + * happen during the editor initialization, especially when there is no + * other editor opened. + * + * @return Get the current {@link TransactionalEditingDomain} or null if not + * found + * @deprecated Check + * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments + * /cookbook/PapyrusCookBook.odt and use one of the replacement: + *
    + *
  • org.eclipse.papyrus.infra.core.utils.ServiceUtils
  • + *
  • + * org.eclipse.papyrus.uml.diagram.common.util.ServiceUtilsForGMF
  • + *
  • + * org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • + *
+ */ + public static TransactionalEditingDomain getTransactionalEditingDomain() { + try { + ServicesRegistry registry = getServiceRegistry(); + return registry == null ? null : registry.getService(TransactionalEditingDomain.class); + } catch (IllegalStateException e) { + // Registry can't be found, do nothing. + } catch (ServiceException e) { + log.error(e); + } + return null; + } + + /** + * Gets the {@link TransactionalEditingDomain} of the current active Eclipse + * Editor. This method should be used only when it is sure that the active + * editor exist, and that you want the EditingDomain of this editor.
+ * This method is designed to be used by ui actions that interact with the + * active editor.
+ * This method should not be used during the editor initialization phase.
+ * It is preferable to use {@link #getTransactionalEditingDomain(ServicesRegistry)} whenever it is + * possible.
+ * This method throw a {@link ServiceException} if the + * TransactionalEditingDomain can not be found.
+ * In GMF EditParts or EditPolicies, the ServiceRegistry can be retrieved + * with methods from + * org.eclipse.papyrus.uml.diagram.common.util.DiagramCoreServiceUtils + * + * + * WARNING: This method throws an exception when no Active Editor is found. + * This happen during the editor initialization, especially when there is no + * other editor opened. + * + * @return Get the current {@link TransactionalEditingDomain} + * @throws ServiceException + * @throws ServiceNotFoundException + * @deprecated Check + * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments + * /cookbook/PapyrusCookBook.odt and use one of the replacement: + *
    + *
  • org.eclipse.papyrus.infra.core.utils.ServiceUtils
  • + *
  • + * org.eclipse.papyrus.uml.diagram.common.util.ServiceUtilsForGMF
  • + *
  • + * org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers (to be used with care !)
  • + *
+ */ + public static TransactionalEditingDomain getTransactionalEditingDomainChecked() throws ServiceException { + try { + ServicesRegistry registry = getServiceRegistryChecked(); + return registry.getService(TransactionalEditingDomain.class); + } catch (IllegalStateException e) { + throw new ServiceException(e); + } catch (Exception e) { + throw new ServiceException(e); + } + } + + /** + * Gets the {@link TransactionalEditingDomain} registered in the {@link ServicesRegistry}. + * + * @param servicesRegistry + * @return + * @deprecated Check + * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments + * /cookbook/PapyrusCookBook.odt and use one of the replacement: + *
    + *
  • org.eclipse.papyrus.infra.core.utils.ServiceUtils
  • + *
+ */ + public static TransactionalEditingDomain getTransactionalEditingDomain(ServicesRegistry registry) { + try { + return registry.getService(TransactionalEditingDomain.class); + } catch (IllegalStateException e) { + // Registry can't be found, do nothing. + } catch (ServiceException e) { + log.error(e); + } + return null; + } + + /** + * Gets the {@link TransactionalEditingDomain} registered in the {@link ServicesRegistry}. + * + * @param servicesRegistry + * @return + * @throws ServiceException + * If the TransactionalEditingDomain can not be found. + * @deprecated Check + * modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments + * /cookbook/PapyrusCookBook.odt and use one of the replacement: + *
    + *
  • org.eclipse.papyrus.infra.core.utils.ServiceUtils
  • + *
+ */ + public static TransactionalEditingDomain getTransactionalEditingDomainChecked(ServicesRegistry registry) throws ServiceException { + return registry.getService(TransactionalEditingDomain.class); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/FilteredCollectionView.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/FilteredCollectionView.java new file mode 100644 index 00000000000..437d639c109 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/FilteredCollectionView.java @@ -0,0 +1,217 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.utils; + +import java.util.AbstractCollection; +import java.util.Collection; +import java.util.Iterator; +import java.util.NoSuchElementException; + +/** + * A unmodifiable view on a specified list. The view filters the original list + * according to the provided filter. + */ +public class FilteredCollectionView extends AbstractCollection implements Collection { + + /** The original collection */ + private Collection list; + + /** The filter for the view */ + private IFilter filter; + + /** + * The cached size. Compute only once, so change in the underlying + * collection is not reflected + */ + private int size = -1; + + /** + * Creates a new FilteredCollectionView. + * + * @param list + * the list to filter + * @param filter + * the filter for the view + */ + public FilteredCollectionView(Collection list, IFilter filter) { + this.list = list; + this.filter = filter; + } + + /** + * Sets the value of the list property. + * + * @param aList + * the new value of the list property + */ + public void setBackupCollection(Collection aList) { + list = aList; + } + + /** + * Sets the value of the filter property. + * + * @param aFilter + * the new value of the filter property + */ + public void setFilter(IFilter aFilter) { + filter = aFilter; + } + + /** + * Returns the value of the filter property. + * + * @return the new value of the filter property + */ + public IFilter getFilter() { + return filter; + } + + /** + * The size of the filtered list. + * + * @return the number of elements in the filtered list + */ + @Override + public int size() { + if(size == -1) { // compute the size + size = 0; + Iterator i = iterator(); + while(i.hasNext()) { + size++; + i.next(); + } + } + return size; + } + + /** + * Return true if the filteredCollection contains the object. + * + * @see java.util.AbstractCollection#contains(java.lang.Object) + * @param o + * @return + * + */ + @Override + public boolean contains(Object o) { + return list.contains(o); + } + + /** + * remove the object. Throw an UnsupportedOperationException, as the + * FilteredCollection is ReadOnly. + * + * @see java.util.AbstractCollection#remove(java.lang.Object) + * @param o + * @return + * + */ + @Override + public boolean remove(Object o) { + throw new UnsupportedOperationException(); + } + + /** + * Return the value to be returned by the iterator.next() method. This + * method can be overloaded by subclasses in order to return another value + * than the objects belonging to the underlying list. + * + * @param ele + * The iterated object. This is the object iterated inside the + * underlying list. + * @return + */ + protected T returnedValue(T ele) { + return ele; + } + + /** + * listIterator. + * + * @return ListIterator + */ + @Override + public Iterator iterator() { + return new FilteredIterator(); + } + + /** + * Iterator other the filtered collection + */ + private class FilteredIterator implements Iterator { + + /** the next object */ + T next; + + /** The original list iterator */ + Iterator listIterator; + + /** + * Creates a new FilteredIterator + */ + public FilteredIterator() { + listIterator = list.iterator(); + next = nextFilteredObject(); + } + + /** + * Unsupported operation, as this is just a view of a list. + */ + public void remove() { + throw new UnsupportedOperationException(); + } + + /** + * Returns the next object of the list, when filter is applied + * + * @return + */ + protected T nextFilteredObject() { + while(listIterator.hasNext()) { + T ele = listIterator.next(); + if(filter.isAllowed(ele)) { + return returnedValue(ele); + } + } // end loop + return null; + } + + /** + * hasNext. + * + * @return boolean + */ + public boolean hasNext() { + return next != null; + } + + /** + * Compute the next field (null or next value), and return the previous + * value of the next field. + * + * @return Object + */ + public T next() { + if(next == null) { + throw new NoSuchElementException(); + } + T ele = next; + next = nextFilteredObject(); + return ele; + } + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/FilteredCollectionViewFromIterator.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/FilteredCollectionViewFromIterator.java new file mode 100644 index 00000000000..4734b4e95bc --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/FilteredCollectionViewFromIterator.java @@ -0,0 +1,255 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +//Source file: H:\\temp\\generated\\modTransf\\util\\FilteredListView.java +package org.eclipse.papyrus.infra.core.utils; + +import java.util.AbstractCollection; +import java.util.Collection; +import java.util.Iterator; +import java.util.NoSuchElementException; + +/** + * A unmodifiable view on a specified list from its iterator. The view filters + * the original list according to the provided filter. + * + * @param + * the type of objects in the filtered collection + */ +public class FilteredCollectionViewFromIterator extends AbstractCollection implements Collection { + + /** + * The iterator provider linked to the backup list. + */ + private IteratorProvider iter; + + /** + * + */ + private IFilter filter; + + /** + * The cached size. Compute only once, so change in the underlying + * collection is not reflected + */ + private int size = -1; + + /** + * + * + * @param filter + * @param list + * * + * @param iter + */ + public FilteredCollectionViewFromIterator(IteratorProvider iter, IFilter filter) { + this.iter = iter; + this.filter = filter; + } + + /** + * Sets the value of the list property. + * + * @param iter + * the new value of the list property + */ + public void setBackupCollection(IteratorProvider iter) { + this.iter = iter; + } + + /** + * + * + * @return + */ + Iterator getBackupIterator() { + return iter.iterator(); + } + + /** + * Sets the value of the filter property. + * + * @param aFilter + * the new value of the filter property + */ + public void setFilter(IFilter aFilter) { + filter = aFilter; + } + + /** + * Sets the value of the filter property. + * + * @return the new value of the filter property + */ + public IFilter getFilter() { + return filter; + } + + /** + * size. + * + * @return int + */ + @Override + public int size() { + if(size == -1) { // compute the size + size = 0; + Iterator i = iterator(); + while(i.hasNext()) { + size++; + i.next(); + } + } + return size; + } + + /** + * Removes a single instance of the specified element from this collection, + * if it is present (optional operation). More formally, removes an element e such that (o==null ? e==null : + * o.equals(e)), if the collection contains one or more such elements. + * Returns true if the collection contained the specified element + * (or equivalently, if the collection changed as a result of the call). + *

+ * + * This implementation call the remove method on the underlying collection. + *

+ * + * @param o + * element to be removed from this collection, if present. + * + * @return true if the collection contained the specified element. + * + * @throws UnsupportedOperationException + * if the remove method is not supported by this + * collection. + */ + @Override + public boolean remove(Object o) { + // return list.remove(o); + throw new UnsupportedOperationException(); + } + + /** + * Return the value to be returned by the iterator.next() method. This + * method can be overloaded by subclasses in order to return another value + * than the objects belonging to the underlying list. + * + * @param ele + * The iterated object. This is the object iterated inside the + * underlying list. + * + * @return + */ + protected E returnedValue(E ele) { + return ele; + } + + /** + * listIterator. + * + * @param index + * int + * + * @return ListIterator + */ + @Override + public Iterator iterator() { + return new FilteredIterator(); + } + + /** + * + */ + private class FilteredIterator implements Iterator { + + /** + * + */ + E next; + + /** + * + */ + Iterator listIterator; + + /** + * + */ + public FilteredIterator() { + listIterator = getBackupIterator(); + next = nextFilteredObject(); + } + + /** + * remove. + */ + public void remove() { + throw new UnsupportedOperationException(); + } + + /** + * + * + * @return + */ + protected E nextFilteredObject() { + while(listIterator.hasNext()) { + E ele = listIterator.next(); + if(filter.isAllowed(ele)) { + return returnedValue(ele); + } + } // end loop + return null; + } + + /** + * hasNext. + * + * @return boolean + */ + public boolean hasNext() { + return next != null; + } + + /** + * Compute the next field (null or next value), and return the previous + * value of the next field. + * + * @return Object + */ + public E next() { + if(next == null) { + throw new NoSuchElementException(); + } + E ele = next; + next = nextFilteredObject(); + return ele; + } + + } + + /** + * Inner class. Provide an iterator used internally in the unmodifiable + * collection view.. + */ + public interface IteratorProvider { + + /** + * provide a new iterator over the list. + * + * @return + */ + Iterator iterator(); + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/FilteredListView.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/FilteredListView.java new file mode 100644 index 00000000000..92a42a3092a --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/FilteredListView.java @@ -0,0 +1,376 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.utils; + +import java.util.AbstractSequentialList; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +/** + * A unmodifiable view on a specified list. The view filters the original list + * according to the provided filter. + */ +public class FilteredListView extends AbstractSequentialList implements List { + + /** + * + */ + private List list; + + /** + * + */ + private IFilter filter; + + /** + * The cached size. Copute only once, so change in the underlying collection + * is not reflected + */ + private int size = -1; + + /** + * + * + * @param filter + * @param list + */ + public FilteredListView(List list, IFilter filter) { + this.list = list; + this.filter = filter; + } + + /** + * Sets the value of the list property. + * + * @param aList + * the new value of the list property + */ + public void setBackupList(List aList) { + list = aList; + } + + /** + * Sets the value of the filter property. + * + * @param aFilter + * the new value of the filter property + */ + public void setFilter(IFilter aFilter) { + filter = aFilter; + } + + /** + * size. + * + * @return int + */ + @Override + public int size() { + if(size == -1) { // compute the size + size = 0; + Iterator i = iterator(); + while(i.hasNext()) { + size++; + i.next(); + } + } + return size; + } + + /** + * Returns true if this collection contains the specified element. + * More formally, returns true if and only if this collection + * contains at least one element e such that (o==null ? e==null : o.equals(e)). + *

+ * + * @param o + * object to be checked for containment in this collection. + * + * @return true if this collection contains the specified element. + */ + @Override + public boolean contains(Object o) { + return list.contains(o); + } + + /** + * Removes a single instance of the specified element from this collection, + * if it is present (optional operation). More formally, removes an element e such that (o==null ? e==null : + * o.equals(e)), if the collection contains one or more such elements. + * Returns true if the collection contained the specified element + * (or equivalently, if the collection changed as a result of the call). + *

+ * + * This implementation call the remove method on the underlying collection. + *

+ * + * @param o + * element to be removed from this collection, if present. + * + * @return true if the collection contained the specified element. + * + * @throws UnsupportedOperationException + * if the remove method is not supported by this + * collection. + */ + @Override + public boolean remove(Object o) { + // return list.remove(o); + throw new UnsupportedOperationException(); + } + + /** + * listIterator. + * + * @param index + * int + * + * @return ListIterator + */ + @Override + public ListIterator listIterator(int index) { + return new FilteredListIterator(index); + } + + /** + * + */ + private class FilteredListIterator implements ListIterator { + + /** + * + */ + Object current; + + /** + * + */ + Object next; + + /** + * + */ + Object previous; + + /** + * Index of the current element (last returned) in the backup list. + */ + int currentIndex; + + /** + * + */ + int previousIndex; + + /** + * + */ + int nextIndex; + + /** + * Index of the last returned element. + */ + int eleIndex = -1; + + /** + * Index of the boundary. + */ + int index = 0; + + /** + * + */ + ListIterator listIterator; + + /** + * + * + * @param index + */ + FilteredListIterator(int index) { + listIterator = list.listIterator(0); + nextIndex = -1; + next = nextFilteredObject(); + + previous = null; + previousIndex = -1; + current = next; + currentIndex = 0; + + // Go to the specified index + while(hasNext() && (nextIndex() < index)) { + next(); + } + } + + /** + * + * + * @return + */ + protected Object nextFilteredObject() { + while(listIterator.hasNext()) { + + int curIndex = listIterator.nextIndex(); // This is the current + // index in the list + Object ele = listIterator.next(); + if(filter.isAllowed(ele) && (curIndex > nextIndex)) { + nextIndex = curIndex; + return ele; + } + } // end loop + return null; + } + + /** + * + * + * @return + */ + protected Object previousFilteredObject() { + while(listIterator.hasPrevious()) { + int curIndex = listIterator.previousIndex(); // This is the + // current index + // in the list + Object ele = listIterator.previous(); + if(filter.isAllowed(ele) && (curIndex < previousIndex)) { + previousIndex = curIndex; + return ele; + } + } // end loop + return null; + } + + /** + * /** nextIndex. + * + * @return int + */ + public int nextIndex() { + return index; + } + + /** + * previousIndex. + * + * @return int + */ + public int previousIndex() { + return index - 1; + } + + /** + * remove. + */ + public void remove() { + throw new UnsupportedOperationException(); + } + + /** + * hasNext. + * + * @return boolean + */ + public boolean hasNext() { + return next != null; + } + + /** + * hasPrevious. + * + * @return boolean + */ + public boolean hasPrevious() { + return previous != null; + } + + /** + * next. + * + * @return Object + */ + public Object next() { + if(next == null) { + throw new NoSuchElementException(); + } + + if(index > eleIndex) { // previous was up, continue + previous = current; + previousIndex = currentIndex; + current = next; + currentIndex = nextIndex; + next = nextFilteredObject(); + + index++; + eleIndex++; + return current; + } else { // previous was down, turn back + index++; + return current; + } + } + + /** + * previous. + * + * @return Object + */ + public Object previous() { + if(previous == null) { + throw new NoSuchElementException(); + } + + if(index > eleIndex) { // previous was up, turn back + index--; + return current; + } else { // previuos was done, continue + next = current; + nextIndex = currentIndex; + current = previous; + currentIndex = previousIndex; + previous = previousFilteredObject(); + + index--; + eleIndex--; + return current; + + } + + } + + /** + * add. + * + * @param o + * Object + */ + public void add(Object o) { + throw new UnsupportedOperationException(); + } + + /** + * set. + * + * @param o + * Object + */ + public void set(Object o) { + throw new UnsupportedOperationException(); + } + + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/GMFtoEMFCommandWrapper.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/GMFtoEMFCommandWrapper.java new file mode 100644 index 00000000000..54c953a34b2 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/GMFtoEMFCommandWrapper.java @@ -0,0 +1,32 @@ +/*************************************************************************** + * Copyright (c) 2007 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: Mario Cervera Ubeda (Prodevelop) + * + ******************************************************************************/ +package org.eclipse.papyrus.infra.core.utils; + +import org.eclipse.gmf.runtime.common.core.command.ICommand; + +/** + * A EMF Command that wraps a GMF command. Each method is redirected to the GMF + * one. + * + * @deprecated use {@link org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper} instead + */ +public class GMFtoEMFCommandWrapper extends org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper { + + /** + * Constructor. + * + * @param gmfCommand + * the gmf command + */ + public GMFtoEMFCommandWrapper(ICommand gmfCommand) { + super(gmfCommand); + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/IDebugChannel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/IDebugChannel.java new file mode 100644 index 00000000000..a73c14051d6 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/IDebugChannel.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2008 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.infra.core.utils; + +/** + * This interface contains all channels to trace papyrus + * + * @author Patrick Tessier + */ +public interface IDebugChannel { + + /** + * constant used to trace the core running + */ + public static final String PAPYRUS_CORE = "org.eclipse.papyrus.infra.core/debug/core"; + + /** + * constant used to trace the loading of extension point + */ + public static final String PAPYRUS_EXTENSIONPOINT_LOADING = "org.eclipse.papyrus.infra.core/debug/extensionpoint"; + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/IFilter.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/IFilter.java new file mode 100644 index 00000000000..a1f39f4ad7b --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/IFilter.java @@ -0,0 +1,30 @@ +/***************************************************************************** + * Copyright (c) 2008 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.utils; + +/** + * A filter. + */ +public interface IFilter { + + /** + * Is the specified object allowed ? Return true if the filter allow this + * object. Return false if the filter doesn't allows the object. + * + * @param object + * + * @return boolean + */ + public boolean isAllowed(Object object); +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/OpenDiagramCommand.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/OpenDiagramCommand.java new file mode 100644 index 00000000000..22e49fe6c09 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/OpenDiagramCommand.java @@ -0,0 +1,96 @@ +/***************************************************************************** + * 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: + * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.utils; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * The Class OpenDiagramCommand. + * + * @deprecated This method use GMF stuff. It should not be in the core package. + */ +public class OpenDiagramCommand extends AbstractTransactionalCommand { + + /** The diagram to open. */ + private EObject diagramToOpen = null; + + private ICommand previousCreateDiagramCommand = null; + + /** + * Instantiates a new open diagram command. + * + * @param domain + * the domain + * @param diagram + * the diagram + */ + public OpenDiagramCommand(TransactionalEditingDomain editingDomain, EObject diagram) { + super(editingDomain, "Open diagram", null); + diagramToOpen = diagram; + } + + public OpenDiagramCommand(TransactionalEditingDomain editingDomain, ICommand previousCreateDiagramCommand) { + super(editingDomain, "Open diagram", null); + this.previousCreateDiagramCommand = previousCreateDiagramCommand; + } + + /** + * {@inheritedDoc} + */ + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + try { + if(diagramToOpen == null && previousCreateDiagramCommand != null) { + Object possibleDiagramToOpen = previousCreateDiagramCommand.getCommandResult().getReturnValue(); + if(possibleDiagramToOpen instanceof EObject) { + diagramToOpen = (EObject)possibleDiagramToOpen; + } + } + + + + if(diagramToOpen != null) { + IPageMngr pageMngr; + final ServicesRegistry serviceRegistry = EditorUtils.getServiceRegistry(); + if(serviceRegistry != null) { + pageMngr =serviceRegistry.getService(IPageMngr.class); + } else if(getEditingDomain().getResourceSet() instanceof DiResourceSet){ + DiResourceSet diResourceSet = (DiResourceSet)getEditingDomain().getResourceSet(); + pageMngr = EditorUtils.getIPageMngr(diResourceSet.getDiResource()); + } else { + throw new IllegalStateException("Enable to get the page manager");////$NON-NLS-1$ + } + + + if(pageMngr.isOpen(diagramToOpen)) { + pageMngr.closePage(diagramToOpen); + } + pageMngr.openPage(diagramToOpen); + } + + return CommandResult.newOKCommandResult(); + } catch (Exception e) { + throw new ExecutionException("Can't open diagram", e); + } + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/PapyrusEcoreUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/PapyrusEcoreUtils.java new file mode 100644 index 00000000000..e50c13db005 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/PapyrusEcoreUtils.java @@ -0,0 +1,86 @@ +/***************************************************************************** + * 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: + * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.utils; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.EStructuralFeature.Setting; +import org.eclipse.emf.ecore.util.ECrossReferenceAdapter; +import org.eclipse.emf.ecore.util.EcoreUtil; + +public class PapyrusEcoreUtils { + + /** + * Gets the usages. + * + * @param source + * the source + * + * @return the usages or null if there is no usages + */ + public static Collection getUsages(EObject source) { + Collection collection = null; + ECrossReferenceAdapter crossReferenceAdapter = ECrossReferenceAdapter.getCrossReferenceAdapter(source); + if(crossReferenceAdapter != null) { + collection = crossReferenceAdapter.getNonNavigableInverseReferences(source); + } else { + collection = EcoreUtil.UsageCrossReferencer.find(source, source.eResource().getResourceSet()); + } + return collection; + } + + /** + *
+	 * Test if the used element is referenced by other elements than the known
+	 * referencer (except its container). It ignores references from an other meta-model.
+	 * 
+ * + * @param usedObject + * the used object + * @param knownReferencer + * the known referencer + * @return true if the known referencer is the only referencer. + */ + public static boolean isOnlyUsage(EObject usedObject, EObject knownReferencer) { + boolean isUsed = false; + EPackage mmPackage = usedObject.eClass().getEPackage(); + + // Retrieve the list of elements referencing the usedObject. + Set crossReferences = new HashSet(); + for(Setting setting : PapyrusEcoreUtils.getUsages(usedObject)) { + EObject eObj = setting.getEObject(); + if(eObj.eClass().getEPackage().equals(mmPackage)) { + crossReferences.add(eObj); + } + } + + // Remove the container of used object. + crossReferences.remove(usedObject.eContainer()); + // Remove the knownReferencer from the list of references. + crossReferences.remove(knownReferencer); + + // If no referencer remains in the list, the known element is the only + // usage. + if(crossReferences.isEmpty()) { + isUsed = true; + } + + return isUsed; + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/PapyrusImageUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/PapyrusImageUtils.java new file mode 100644 index 00000000000..1e5b0e6701c --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/PapyrusImageUtils.java @@ -0,0 +1,67 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tristan Faure (ATOS ORIGIN INTEGRATION) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.core.utils; + +import java.io.IOException; +import java.net.URL; + +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.papyrus.infra.core.Activator; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; + +/** + * Services to access to Papyrus images + * + * @author tristan faure + * + */ +public class PapyrusImageUtils { + + private static final String default_icon_32 = "/icons/papyrus/32x32/Papyrus_32x32_t.gif"; + + private static final String default_icon = "/icons/papyrus/Papyrus.gif"; + + /** + * get the default icon for Papyrus the image does not have to be disposed + * as it is registered in an ImageRegistry + * + * @return the Image + */ + public static Image getDefaultIcon() { + return getIcon(default_icon); + } + + /** + * get the default icon 32x32 for Papyrus the image does not have to be + * disposed as it is registered in an ImageRegistry + * + * @return the Image + */ + public static Image getDefaultIcon32() { + return getIcon(default_icon_32); + } + + private static Image getIcon(String path) { + String key = Activator.PLUGIN_ID + path; + Image result = JFaceResources.getImageRegistry().get(key); + if(result == null) { + URL url = Activator.getDefault().getBundle().getEntry(path); + try { + result = new Image(Display.getDefault(), url.openStream()); + JFaceResources.getImageRegistry().put(key, result); + } catch (IOException e) { + } + } + return result; + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/PapyrusTrace.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/PapyrusTrace.java new file mode 100644 index 00000000000..429dffc54bb --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/PapyrusTrace.java @@ -0,0 +1,107 @@ +/******************************************************************************* + * Copyright (c) 2008 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.infra.core.utils; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.papyrus.infra.core.Activator; +import org.eclipse.papyrus.infra.core.log.LogHelper; + +/** + * Utility class to log errors or debug information either in the plugin'log or + * in the console. + *

+ * A set of channels is used to separate different traces for different aspects. A short list is displayed at the end of the file to give an example of channels + * + * @deprecated Use {@link LogHelper} instead + **/ +@Deprecated +public class PapyrusTrace implements IDebugChannel { + + public static final String PAPYRUS_CORE = "org.eclipse.papyrus.infra.core/debug"; + + /** + * Display a debug trace. + * + * @param element + * that provides the trace + * @param text + * message to display + * @param traceOption + * channel of the trace (see {@link IDebugChannel}) + */ + public static void trace(String traceOption, Object element, String text) { + if(!Platform.inDebugMode()) { + return; + } + String globalTraceValue = Platform.getDebugOption(PAPYRUS_CORE); + String value = Platform.getDebugOption(traceOption); + if(null != globalTraceValue && globalTraceValue.equals("true") && null != value && value.equals("true")) { + if(element != null) { + log(IStatus.INFO, "[" + traceOption + "]: " + element.getClass() + " --> " + text); + } else { + log(IStatus.INFO, "[" + traceOption + "] --> " + text); + } + } + } + + /** + * display error. + * + * @param element + * that provides the trace + * @param text + * to display + * @param traceOption + * channel of the trace + */ + public static void error(String traceOption, Object element, String text) { + if(!Platform.inDebugMode()) { + return; + } + String globalTraceValue = Platform.getDebugOption(PAPYRUS_CORE); + String value = Platform.getDebugOption(traceOption); + if(null != globalTraceValue && globalTraceValue.equals("true") && null != value && value.equals("true")) { + if(element != null) { + log(IStatus.ERROR, "[" + traceOption + "]: " + element.getClass() + " --> " + text); + } else { + log(IStatus.ERROR, "[" + traceOption + "] --> " + text); + } + } + } + + /** + * Log an exception into the plugin log. + * + * @param exception + * the exception to log. + * @param e + * the message to log + */ + public static void log(Exception e) { + final IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.OK, e.getMessage(), e); + Activator.getDefault().getLog().log(status); + } + + /** + * Log a message into the plugin log. + * + * @param message + * the message to log + * @param severity + * the severity : one of OK, ERROR, INFO, WARNING, or CANCEL + */ + public static void log(int severity, String message) { + final IStatus status = new Status(severity, Activator.PLUGIN_ID, IStatus.OK, message, null); + Activator.getDefault().getLog().log(status); + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtils.java new file mode 100644 index 00000000000..c88d6d3a43c --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtils.java @@ -0,0 +1,49 @@ +/***************************************************************************** + * Copyright (c) 2010 LIFL & CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.utils; + +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; + +/** + * @author cedric dumoulin + * + */ +public class ServiceUtils extends AbstractServiceUtils { + + private final static ServiceUtils instance = new ServiceUtils(); + + /** + * Get the singleton instance of the class. + * + * @return + */ + public static final ServiceUtils getInstance() { + return instance; + } + + /** + * @see org.eclipse.papyrus.infra.core.utils.AbstractServiceUtils#getServiceRegistry(java.lang.Object) + * + * @param from + * @return + * @throws ServiceException + */ + @Override + public ServicesRegistry getServiceRegistry(ServicesRegistry from) throws ServiceException { + return from; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtilsForActionHandlers.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtilsForActionHandlers.java new file mode 100644 index 00000000000..75632a82237 --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtilsForActionHandlers.java @@ -0,0 +1,148 @@ +/***************************************************************************** + * Copyright (c) 2010 LIFL & CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.utils; + +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; +import org.eclipse.papyrus.infra.core.lifecycleevents.ILifeCycleEventsProvider; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr; +import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServiceNotFoundException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PlatformUI; + +/** + * Set of utility methods for accessing core Services. This class provide + * methods to access the Papyrus well known services. This class is designed to + * be used from ui Action Handlers or from any code relying on the Eclipse + * Active Editor.
+ * All methods from this class rely on the Eclipse Active Editor, which should + * be an instance of {@link IMultiDiagramEditor}. If this is not the case, + * methods throw an exception {@link ServiceException}. + * + * @author cedric dumoulin + * + */ +public class ServiceUtilsForActionHandlers { + + private final static ServiceUtilsForActionHandlers instance = new ServiceUtilsForActionHandlers(); + + /** + * Get the singleton instance of the class. + * + * @return + */ + public static final ServiceUtilsForActionHandlers getInstance() { + return instance; + } + + /** + * Get the service registry from the specified parameter. + * + * @param from + * @return + */ + public ServicesRegistry getServiceRegistry() throws ServiceException { + + IEditorPart editor; + try { + editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + } catch (NullPointerException e) { + // Can't get the active editor + throw new ServiceNotFoundException("Can't get the current Eclipse Active Editor. No ServiceRegistry found."); + } + + ServicesRegistry serviceRegistry = (ServicesRegistry)editor.getAdapter(ServicesRegistry.class); + if(serviceRegistry != null) { + return serviceRegistry; + } + + // Not found + throw new ServiceNotFoundException("Can't get the ServiceRegistry from current Eclipse Active Editor"); + + } + + /** + * Gets the {@link TransactionalEditingDomain} registered in the {@link ServicesRegistry}. + * + * @return + * @throws ServiceException + * If an error occurs while getting the requested service. + */ + public TransactionalEditingDomain getTransactionalEditingDomain() throws ServiceException { + return getServiceRegistry().getService(TransactionalEditingDomain.class); + } + + /** + * Gets the {@link IPageMngr} registered in the {@link ServicesRegistry}. + * + * @return + * @throws ServiceException + * If an error occurs while getting the requested service. + */ + public IPageMngr getIPageMngr() throws ServiceException { + return getServiceRegistry().getService(IPageMngr.class); + } + + /** + * Gets the {@link IPageMngr} registered in the {@link ServicesRegistry}. + * + * @return + * @throws ServiceException + * If an error occurs while getting the requested service. + */ + public ModelSet getModelSet() throws ServiceException { + return getServiceRegistry().getService(ModelSet.class); + } + + /** + * Gets the {@link ILifeCycleEventsProvider} registered in the {@link ServicesRegistry}. + * + * @param from + * @return + * @throws ServiceException + * If an error occurs while getting the requested service. + */ + public ILifeCycleEventsProvider getILifeCycleEventsProvider() throws ServiceException { + return getServiceRegistry().getService(ILifeCycleEventsProvider.class); + } + + /** + * Gets the {@link ISashWindowsContainer} registered in the {@link ServicesRegistry}. + * + * @param from + * @return + * @throws ServiceException + * If an error occurs while getting the requested service. + */ + public ISashWindowsContainer getISashWindowsContainer() throws ServiceException { + return getServiceRegistry().getService(ISashWindowsContainer.class); + } + + /** + * Gets the {@link IEditorPart} of the currently nested active editor. + * + * @param from + * @return + * @throws ServiceException + * If an error occurs while getting the requested service. + */ + public IEditorPart getNestedActiveIEditorPart() throws ServiceException { + return getISashWindowsContainer().getActiveEditor(); + } +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/AbstractBaseModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/AbstractBaseModel.java deleted file mode 100644 index 84a694e9c0c..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/AbstractBaseModel.java +++ /dev/null @@ -1,221 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource; - -import java.io.IOException; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; - -/** - * An abstract implmeentation of model. This class should be subclassed to fit - * the required model. - * - * @author cedric dumoulin - * - */ -public abstract class AbstractBaseModel implements IModel { - - /** - * The associated ModelManager. - */ - private ModelSet modelSet; - - /** - * List of attached snippets. - */ - private ModelSnippetList snippets = new ModelSnippetList(); - - /** - * The associated resource. - */ - protected Resource resource; - - /** - * The resource URI. - */ - protected URI resourceURI; - - /** - * @see org.eclipse.papyrus.resource.IModel#init(org.eclipse.papyrus.resource.ModelSet) - * - * @param modelManager - */ - public void init(ModelSet modelManager) { - this.modelSet = modelManager; - - } - - /** - * @return the modelManager - */ - protected ModelSet getModelManager() { - return modelSet; - } - - /** - * Get the associated ResourceSet containing the resources of this model. - * - * @return - */ - protected ResourceSet getResourceSet() { - return modelSet; - } - - /** - * @return the resource - */ - public Resource getResource() { - return resource; - } - - /** - * @return the resourceURI - */ - public URI getResourceURI() { - return resourceURI; - } - - /** - * Get the model identifier. - * - * @return - */ - abstract public String getIdentifier(); - - /** - * Get the file extension used by the resource. - * - * @return - */ - abstract protected String getModelFileExtension(); - - /** - * Return true if the resource is set, false otherwise. When the resource is - * set, this mean that the model is loaded or created. - * - * @return - */ - protected boolean resourceIsSet() { - return resource != null; - } - - /** - * @see org.eclipse.papyrus.resource.IModel#createModel(org.eclipse.core.runtime.IPath) - * - * @param fullPath - */ - public void createModel(IPath fullPath) { - - // Compute model URI - resourceURI = getPlatformURI(fullPath.addFileExtension(getModelFileExtension())); - - // Create Resource of appropriate type - resource = getModelManager().createResource(resourceURI); - } - - /** - * Get a platform resource URI of the given path - * - * @param path - * the path - * @return the uri - */ - protected URI getPlatformURI(IPath path) { - return URI.createPlatformResourceURI(path.toString(), true); - } - - /** - * Load the model repository. The URI is calculated by removing the - * extension and replacing it by the model extension. - * - * @param file - * The file selected by user requesting load. Should be used as a - * bases to guess the model IPath. - */ - public void loadModel(IFile file) { - // Get the full path and call the load method with it. - loadModel(file.getFullPath().removeFileExtension()); - } - - /** - * Load the model by using the provided fullpath as a hint for the resource - * URI. In this implementation, simply add the model extension. - * - * @param fullPathWithoutExtension - */ - public void loadModel(IPath fullPathWithoutExtension) { - - // Compute model URI - resourceURI = getPlatformURI(fullPathWithoutExtension.addFileExtension(getModelFileExtension())); - - // Create Resource of appropriate type - resource = modelSet.getResource(resourceURI, true); - // call registered snippets - snippets.performStart(this); - } - - /** - * Import the model by using the provided fullpath as a hint for the - * resource URI. In this implementation, simply call {@link #loadModel(IPath)} - * - * @param fullPathWithoutExtension - */ - public void importModel(IPath fullPathWithoutExtension) { - - loadModel(fullPathWithoutExtension); - } - - /** - * @throws IOException - * @see org.eclipse.papyrus.resource.IModel#saveModel() - * - */ - public void saveModel() throws IOException { - resource.save(null); - } - - /** - * @see org.eclipse.papyrus.resource.IModel#changeModelPath(org.eclipse.core.runtime.IPath) - * - * @param nameWithoutExt - */ - public void changeModelPath(IPath fullPath) { - // Compute model URI - resourceURI = getPlatformURI(fullPath.addFileExtension(getModelFileExtension())); - - resource.setURI(resourceURI); - } - - /** - * @see org.eclipse.papyrus.resource.IModel#dispose() - * - */ - public void unload() { - // call registered snippets - snippets.performDispose(this); - - // Do unloading - if(resource != null) { - resource.unload(); - resource = null; - } - } - - /** - * Add a snippet to this model. The snippet is called just after model is - * initialized, and before it is disposed or unloaded. Snippet can be shared - * among models. - * - * @param snippet - * The snippet to add. - */ - public void addModelSnippet(IModelSnippet snippet) { - snippets.add(snippet); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/AbstractModelWithSharedResource.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/AbstractModelWithSharedResource.java deleted file mode 100644 index 984adb22a84..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/AbstractModelWithSharedResource.java +++ /dev/null @@ -1,184 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; - -/** - * Base class for models sharing a common {@link Resource}. To share a common {@link Resource}, one of the model should be Master, while the other are - * slaves. The Master is the one performing the save operation. All the model - * should use the same file extension. So, {@link #getModelFileExtension()} should return the same value for all models. - * - * @author cedric dumoulin - * - * @param T - * Type of the roots of the model. - */ -public abstract class AbstractModelWithSharedResource extends AbstractBaseModel { - - /** - * Possible type for this model: master or slave - */ - public enum ModelKind { - master, slave - } - - /** - * Model kind. - */ - private ModelKind modelKind;; - - /** - * - * Constructor. - * - * @param modelKind - */ - public AbstractModelWithSharedResource(ModelKind modelKind) { - this.modelKind = modelKind; - } - - /** - * By default, we are a slave. Constructor. - * - * @param modelKind - */ - public AbstractModelWithSharedResource() { - this.modelKind = ModelKind.slave; - } - - /** - * Attach the model to its resource if this is not already done. - * - * @see org.eclipse.papyrus.resource.AbstractBaseModel#loadModel(org.eclipse.core.runtime.IPath) - * - * @param fullPathWithoutExtension - */ - @Override - public void loadModel(IPath fullPathWithoutExtension) { - - // Look for the resource - lookupResource(fullPathWithoutExtension); - // Check if model is loaded. - if(resourceIsSet()) - return; - // model is not loaded, do it. - super.loadModel(fullPathWithoutExtension); - } - - /** - * Create the model if this is not already done. - * - * @see org.eclipse.papyrus.resource.AbstractBaseModel#createModel(org.eclipse.core.runtime.IPath) - * - * @param fullPath - */ - @Override - public void createModel(IPath fullPath) { - - // Look for the resource - lookupResource(fullPath); - // Check if model is loaded. - if(resourceIsSet()) - return; - // model is not loaded, do it. - super.createModel(fullPath); - } - - /** - * Lookup for the resource in the resourceSet. Return the resource or null - * if not found. - * - * @param fullPath - */ - private void lookupResource(IPath fullPath) { - - // Compute model URI - resourceURI = getPlatformURI(fullPath.addFileExtension(getModelFileExtension())); - - resource = getResourceSet().getResource(resourceURI, false); - - } - - /** - * Do nothing as we are slave. The Resource is save by the master model. - * - * @see org.eclipse.papyrus.resource.AbstractBaseModel#saveModel() - * - * @throws IOException - */ - @Override - public void saveModel() throws IOException { - - // Do nothing if we are a slave - if(modelKind == ModelKind.slave) - return; - - // Do the save - super.saveModel(); - } - - /** - * Get the root of this model. Lookup in the associated {@link Resource} for - * the root. - * - * @return The root of the model, or null if no root exist. - */ - @SuppressWarnings("unchecked") - public T getModelRoot() { - - for(EObject object : getResource().getContents()) { - - if(isModelRoot(object)) { - return (T)object; - } - } - - // Not found - return null; - } - - /** - * Get the roots of this model. Lookup in the associated {@link Resource} for the roots. - * - * @return A list containing the roots of the model. The list is empty if - * there is no root. - */ - @SuppressWarnings("unchecked") - public List getModelRoots() { - - List roots = new ArrayList(); - - for(EObject object : getResource().getContents()) { - if(isModelRoot(object)) - roots.add((T)object); - } - - return roots; - } - - /** - * Return true if the provided object is a root of the model, false - * otherwise. This method should be implemented by subclasses. - * - * @param object - * @return - */ - protected abstract boolean isModelRoot(EObject object); - - /** - * Add a root to this model. - * - * @param root - */ - public void addModelRoot(T root) { - getResource().getContents().add(root); - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/BadStateException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/BadStateException.java deleted file mode 100644 index 6f921e10950..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/BadStateException.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource; - -/** - * Exception thrown when a method is called while the object state is not ready - * for this call. - * - * @author cedric dumoulin - * - */ -public class BadStateException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Constructor. - * - */ - public BadStateException() { - super(); - // TODO Auto-generated constructor stub - } - - /** - * Constructor. - * - * @param message - * @param cause - */ - public BadStateException(String message, Throwable cause) { - super(message, cause); - // TODO Auto-generated constructor stub - } - - /** - * Constructor. - * - * @param message - */ - public BadStateException(String message) { - super(message); - // TODO Auto-generated constructor stub - } - - /** - * Constructor. - * - * @param cause - */ - public BadStateException(Throwable cause) { - super(cause); - // TODO Auto-generated constructor stub - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/EditingDomainServiceFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/EditingDomainServiceFactory.java deleted file mode 100644 index eff67437600..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/EditingDomainServiceFactory.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource; - -import org.eclipse.papyrus.core.services.IServiceFactory; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; - -/** - * A service factory starting the EditingDomain service. - * - * @author cedric dumoulin - * - */ -public class EditingDomainServiceFactory implements IServiceFactory { - - /** - * The associated ModelSet. This service depends on the ModelSet service. - * So, we can get it in the init. - */ - private ModelSet modelSet; - - /** - * @see org.eclipse.papyrus.core.services.IService#init(org.eclipse.papyrus.core.services.ServicesRegistry) - * - * @param servicesRegistry - * @throws ServiceException - */ - public void init(ServicesRegistry servicesRegistry) throws ServiceException { - modelSet = servicesRegistry.getService(ModelSet.class); - } - - /** - * @see org.eclipse.papyrus.core.services.IService#startService() - * - * @throws ServiceException - */ - public void startService() throws ServiceException { - } - - /** - * @see org.eclipse.papyrus.core.services.IService#disposeService() - * - * @throws ServiceException - */ - public void disposeService() throws ServiceException { - } - - /** - * @see org.eclipse.papyrus.core.services.IServiceFactory#createServiceInstance() - * - * @return - */ - public Object createServiceInstance() { - return modelSet.getTransactionalEditingDomain(); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/IModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/IModel.java deleted file mode 100644 index a4b37b8b633..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/IModel.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource; - -import java.io.IOException; - -import org.eclipse.core.runtime.IPath; - -/** - * A Model is a set of elements defined by a metamodel (preferably an EMF - * metamodel). A root of a model is an element which have no parent (i.e. is not - * contained by another element of the model). A model has usually only one - * root. Elements of a model can be contained in one or several resources. A - * model is identified by an id, usually the id from the metamodel package - * (ModelPackage.eCONTENT_TYPE). - * - * @author cedric dumoulin - * - */ -public interface IModel { - - /** - * Initialize the model and set its associated model manager. - * - * @param modelManager - * The associated model manager. - */ - public void init(ModelSet modelManager); - - /** - * Get the identifier identifying this model (aka: uml, notation, ...) - * - * @return - */ - public String getIdentifier(); - - /** - * Create the model repository. - * - * @param fullPath - * The full path, without extension where the model should be - * saved. - */ - public void createModel(IPath fullPath); - - /** - * Load the model from the specified path.. - * - * @param path - * The full path, without extension where the model should be - * saved. Should be used as a bases to guess the model IPath. - */ - public void loadModel(IPath path); - - /** - * Import the model from the specified path. - * - * @param path - * The full path, without extension. - */ - public void importModel(IPath path); - - /** - * Save the model in its repository. - * - * @throws IOException - * - */ - public void saveModel() throws IOException; - - /** - * Change the path under which the model should be save. Do not save it now - * ! - * - */ - public void changeModelPath(IPath fullPath); - - /** - * Dispose the model. - */ - public void unload(); - - /** - * Add a snippet to this model. The snippet is called just after model is - * initialized, and before it is disposed or unloaded. Snippet can be shared - * among models. - * - * @param snippet - * The snippet to add. - */ - public void addModelSnippet(IModelSnippet snippet); - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/IModelSetSnippet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/IModelSetSnippet.java deleted file mode 100644 index f805063e2da..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/IModelSetSnippet.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource; - -/** - * A model snippet can be used to add code that should do some stuff on a - * modelsManager. A ModelSnippet is attached to a modelsManager, and is called - * after modelsManager is started and just before it is disposed. - * - * - * @author cedric dumoulin - * - */ -public interface IModelSetSnippet { - - /** - * Called right after the model is started. - * - * @param modelsManager - * The modelsManager that is starting - */ - public void start(ModelSet modelsManager); - - /** - * Called just before the model is disposed or unloaded. - * - * @param modelsManager - * The modelsManager that is starting - */ - public void dispose(ModelSet modelsManager); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/IModelSnippet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/IModelSnippet.java deleted file mode 100644 index 1a445db2387..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/IModelSnippet.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource; - -/** - * A model snippet can be used to add code that should do some stuff on a model. - * A ModelSnippet is attached to a model, and is called after model starting and - * when model is disposed. - * - * - * @author cedric dumoulin - * - */ -public interface IModelSnippet { - - /** - * Called right after the model is started. - * - * @param startingModel - * The model that is starting - */ - public void start(IModel startingModel); - - /** - * Called just before the model is disposed or unloaded. - * - * @param stoppingModel - * The model that is starting - */ - public void dispose(IModel stoppingModel); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ITransactionalEditingDomainProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ITransactionalEditingDomainProvider.java deleted file mode 100644 index a5a0df6f45e..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ITransactionalEditingDomainProvider.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.eclipse.papyrus.resource; - -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.transaction.TransactionalEditingDomain; - -public interface ITransactionalEditingDomainProvider { - TransactionalEditingDomain createTransactionalEditingDomain(ResourceSet resourceSet); -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelException.java deleted file mode 100644 index 4180d8ee00d..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelException.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource; - -/** - * Root exception for this package. - * - * @author cedric dumoulin - * - */ -public class ModelException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Constructor. - * - */ - public ModelException() { - } - - /** - * Constructor. - * - * @param message - */ - public ModelException(String message) { - super(message); - } - - /** - * Constructor. - * - * @param cause - */ - public ModelException(Throwable cause) { - super(cause); - } - - /** - * Constructor. - * - * @param message - * @param cause - */ - public ModelException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelIdentifiers.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelIdentifiers.java deleted file mode 100644 index 5670facbf0c..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelIdentifiers.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource; - -import java.util.ArrayList; - -/** - * A collection of Identifiers identifying Models. - * - * @author cedric dumoulin - * - */ -public class ModelIdentifiers extends ArrayList { - - public ModelIdentifiers(String... modelIdentifiers) { - - for(String identifier : modelIdentifiers) { - add(identifier); - } - } - - /** - * - */ - private static final long serialVersionUID = 1L; - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelMultiException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelMultiException.java deleted file mode 100644 index 1e4b0ca0ee5..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelMultiException.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource; - -import java.util.ArrayList; -import java.util.List; - -/** - * An exception encapsulating multiple exceptions. This exception is thrown when - * an operation performed on several Models fails on one or more of these - * models. The exception contains all the exceptions encoutered while opertating - * on models. - * - * @author cedric dumoulin - * - */ -public class ModelMultiException extends ModelException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * List of encountered exceptions. - */ - List encounteredExceptions = new ArrayList(); - - /** - * List of identifiers corresponding to exceptions. - */ - List encounteredModels = new ArrayList(); - - /** - * @return the encounteredExceptions - */ - public List getExceptions() { - return encounteredExceptions; - } - - /** - * Constructor. - * - */ - public ModelMultiException() { - super("Multiple exceptions"); - } - - /** - * Constructor. - * - * @param message - */ - public ModelMultiException(String message) { - super(message); - } - - /** - * Return the first exception. - * - * @see java.lang.Throwable#getCause() - * - * @return - */ - @Override - public Throwable getCause() { - return (encounteredExceptions.size() > 0 ? encounteredExceptions.get(0) : null); - } - - /** - * Return the message if any, or the message of the first exception. - * - * @see java.lang.Throwable#getMessage() - * - * @return - */ - @Override - public String getMessage() { - - StringBuffer buffer = new StringBuffer(); - - String message = super.getMessage(); - if(message != null) - buffer.append(message).append('\n'); - - buffer.append("----- exceptions : ----------\n"); - for(int i = 0; i < encounteredExceptions.size(); i++) { - Throwable exception = encounteredExceptions.get(i); - Object identifierMsg = encounteredModels.get(i); - - if(identifierMsg != null) - buffer.append(identifierMsg.toString()).append(" : "); - String msg = exception.getMessage(); - if(msg != null) - buffer.append(msg).append('\n'); - } - buffer.append("----------------------------- \n"); - - return buffer.toString(); - // // Check for first exception - // if( encounteredExceptions.size() > 1) - // return encounteredExceptions.get(0).getMessage(); - // - // // default - // return null; - } - - /** - * Add an exception to the list of exceptions. - * - * @param exception - */ - public void addException(Throwable exception) { - addException("unknown", exception); - } - - /** - * Add an exception to the list of exceptions. Also record the corresponding - * model identifier if any. - * - * @param exception - */ - public void addException(Object identifier, Throwable exception) { - encounteredExceptions.add(exception); - encounteredModels.add(identifier); - } - - /** - * Return true if this MultiExceptions contains nested exceptions. - * - * @return - */ - public boolean isNotEmpty() { - return encounteredExceptions.size() != 0; - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelSet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelSet.java deleted file mode 100644 index 0c9cfc4befc..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelSet.java +++ /dev/null @@ -1,511 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * Emilien Perico emilien.perico@atosorigin.com - manage loading strategies - * - *****************************************************************************/ -package org.eclipse.papyrus.resource; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.impl.ResourceImpl; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.xmi.XMLResource; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory; -import org.eclipse.papyrus.resource.additional.AdditionalResourcesModel; - -/** - * This class is used to manage a set of {@link IModel}. - * - *

>Usage

- *
    - *
  • First, register associated model. A loader can be used.
  • - *
  • Second, call load() or create()
  • - *
  • Then, it is possible to get associated models
  • - *
  • Finally, call save()
  • - *
- * - * Please note that indirectly referenced models are loaded on demand. If a - * model contains a cross reference towards another model (e.g. an import in - * case of UML) the referenced resource does not appear initially in the set. - * However, it is added once the referenced model is resolved. - * - * TODO Modify ModelSetSnippet in order to inform them of model addition. - * - * @author cedric dumoulin - * - */ -public class ModelSet extends ResourceSetImpl { - - /** The associated IModels. */ - private Map models = new HashMap(); - - /** The snippets. */ - private ModelSetSnippetList snippets = new ModelSetSnippetList(); - - private AdditionalResourcesModel additional = new AdditionalResourcesModel(); - - /** - * The associated EditingDomain. - */ - private TransactionalEditingDomain transactionalEditingDomain; - - /** - * The filename path, without extension, used for action on models. - */ - private IPath filenameWithoutExtension; - - /** - * - * Constructor. - * - */ - public ModelSet() { - registerModel(additional); - this.setURIResourceMap(new HashMap()); - getLoadOptions().put(XMLResource.OPTION_DEFER_ATTACHMENT, true); - getLoadOptions().put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, true); - } - - /** - * Register the specified model under its associated key. The key is defined - * in the model itself. It is usually the model type from - * (ModelPackage.eCONTENT_TYPE). - * - * @param model - * the model - */ - public void registerModel(IModel model) { - models.put(model.getIdentifier(), model); - model.init(this); - } - - /** - * Get a model by its key. TODO throw an exception if not found. - * - * @param key - * the key - * @return the model - */ - public IModel getModel(String key) { - return models.get(key); - } - - /** - * Get a model by its key. TODO throw an exception if not found. - * - * @param key - * the key - * @return the model - * @throws NotFoundException - * If no model is registered under the key. - */ - public IModel getModelChecked(String key) throws NotFoundException { - IModel model = models.get(key); - if(model == null) - throw new NotFoundException("Can't find model for identifier '" + key + "'."); - - return model; - } - - @Override - public Resource getResource(URI uri, boolean loadOnDemand) { - Resource r = super.getResource(uri, loadOnDemand); - if(r instanceof ResourceImpl) { - ResourceImpl impl = (ResourceImpl)r; - impl.setTrackingModification(true); - if(impl.getIntrinsicIDToEObjectMap() == null) { - impl.setIntrinsicIDToEObjectMap(new HashMap()); - } - } - return r; - } - - /** - * Create the transactional editing domain. - * - * @return the transactional editing domain - */ - public TransactionalEditingDomain getTransactionalEditingDomain() { - transactionalEditingDomain = WorkspaceEditingDomainFactory.INSTANCE.getEditingDomain(this); - - if(transactionalEditingDomain == null) { - transactionalEditingDomain = TransactionalEditingDomainManager.createTransactionalEditingDomain(this); - // What for? - transactionalEditingDomain.setID("SharedEditingDomain"); //$NON-NLS-1$ - } - return transactionalEditingDomain; - } - - /** - * @return the filenameWithoutExtension - */ - public IPath getFilenameWithoutExtension() { - return filenameWithoutExtension; - } - - /** - * @return the filenameWithoutExtension - * @throws BadStateException - */ - protected IPath getFilenameWithoutExtensionChecked() throws BadStateException { - if(filenameWithoutExtension == null) - throw new BadStateException("Path should be set prior calling any operations."); - - return filenameWithoutExtension; - } - - /** - * @param filenameWithoutExtension - * the filenameWithoutExtension to set - */ - protected void setFilenameWithoutExtension(IPath filenameWithoutExtension) { - this.filenameWithoutExtension = filenameWithoutExtension; - } - - /** - * Create all the associated models. This creates the models, regardless if - * they already exist. - * - * @param newFile - * The file from which path is extracted to create the new - * resources - */ - public void createsModels(IFile newFile) { - - // Get the file name, without extension. - filenameWithoutExtension = newFile.getFullPath().removeFileExtension(); - - // Walk all registered models - for(IModel model : models.values()) { - model.createModel(filenameWithoutExtension); - } - - // call snippets to allow them to do their stuff - snippets.performStart(this); - } - - /** - * Create the model specified by the identifiers. Other models are - * untouched, unless they are sharing something with specified models. - * - * This creates the models, regardless if they already exist. - * - * @param newFile - * The file from which path is extracted to create the new - * resources - */ - public void createsModels(ModelIdentifiers modelIdentifiers) { - - // Walk all registered models - for(String modelId : modelIdentifiers) { - IModel model = getModel(modelId); - - // Load models using the default path - model.createModel(filenameWithoutExtension); - } - - // call snippets to allow them to do their stuff - // snippets.modelsAdded(modelIdentifiers); - } - - /** - * Load only the specified model. ModelSetSnippets are not called. Model is - * loaded using the ModelSet Path. - * - * @param modelIdentifier - * the model identifier - * @param file - * the file - * @return the i model - * @throws BadStateException - * If the global path is not specified. - * @returns The loaded model. - */ - public IModel loadModel(String modelIdentifier) throws BadStateException { - - IModel model = getModel(modelIdentifier); - model.loadModel(getFilenameWithoutExtensionChecked()); - - return model; - } - - /** - * Import only the specified model. ModelSetSnippets are not called. - * - * @param modelIdentifier - * the model identifier - * @param file - * the file - * @return the i model - * @throws ModelException - * @returns The loaded model. - * @deprecated Use {@link #importModel(ModelIdentifier, IFile)} - */ - public IModel loadModel(String modelIdentifier, IFile file) throws ModelException { - - importModels(new ModelIdentifiers(modelIdentifier), file); - - return getModel(modelIdentifier); - } - - /** - * Load all the associated models from a handle on one of the associated - * file. - * - * @param file - * The file to load (no matter the extension) - */ - public void loadModels(IFile file) throws ModelMultiException { - - // Get the file name, without extension. - filenameWithoutExtension = file.getFullPath().removeFileExtension(); - - ModelMultiException exceptions = null; - - // Walk all registered models - for(IModel model : models.values()) { - // Try to load each model. Catch exceptions in order to load other - // models. - try { - model.loadModel(filenameWithoutExtension); - } catch (Exception e) { - // Record the exception - if(exceptions == null) { - - exceptions = new ModelMultiException("Problems encountered while loading one of the models."); - } - exceptions.addException(model.getIdentifier(), e); - } - } - - // call snippets to allow them to do their stuff - snippets.performStart(this); - - // Report exceptions if any - if(exceptions != null) - throw exceptions; - } - - /** - * Import specified models into the ModelSet. The models are imported using - * the specified IFile. After import, the models are associated with the - * ModelSet Path. - * - * @param modelIdentifiers - * The model to import from the specified IFile. - * @param file - * The IFile used to import the model. - * @throws ModelException - * If an error occur during import. - */ - public void importModels(ModelIdentifiers modelIdentifiers, IFile file) throws ModelException { - - IPath path = file.getFullPath().removeFileExtension(); - // Walk all registered models - for(String modelId : modelIdentifiers) { - IModel model = getModel(modelId); - - // Load models using the default path - model.importModel(path); - if(filenameWithoutExtension != null) - model.changeModelPath(filenameWithoutExtension); - } - } - - /** - * Import only the specified model. ModelSetSnippets are not called. An - * import can be performed after model are loaded. Normally, it should not - * be done before a model is loaded. - * - * @param modelIdentifier - * the model identifier - * @param file - * the file - * @throws ModelException - * @returns The loaded model. - */ - public IModel importModel(String modelIdentifier, IFile file) throws ModelException { - - importModels(new ModelIdentifiers(modelIdentifier), file); - - return getModel(modelIdentifier); - } - - /** - * Create models that are not already created or loaded. - */ - public void createMissingModels() throws ModelException { - throw new UnsupportedOperationException("Not yet implemented"); - - } - - /** - * Load models that are not already created or loaded. - */ - public void loadMissingModels() throws ModelException { - throw new UnsupportedOperationException("Not yet implemented"); - - } - - /** - * Save the resources. - * - * @param monitor - * The monitor. - * @throws IOException - * IO Error. - */ - public void save(IProgressMonitor monitor) throws IOException { - - // Initialize monitor with the number of models - Collection modelList = models.values(); - monitor.beginTask("Saving resources", modelList.size()); - - try { - // Walk all registered models - for(IModel model : modelList) { - if(!(model instanceof AdditionalResourcesModel)) { - model.saveModel(); - monitor.worked(1); - } - } - additional.saveModel(); - } finally { - monitor.done(); - } - } - - /** - * The resources are already loaded, but we want to save them under another - * name. - * - * @param path - * the path - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public void saveAs(IPath path) throws IOException { - - // Get the file name, without extension. - filenameWithoutExtension = path.removeFileExtension(); - - // Walk all registered models - for(IModel model : models.values()) { - model.changeModelPath(filenameWithoutExtension); - } - - // Save with new paths - save(new NullProgressMonitor()); - } - - /** - * Unload all the resources. Do not disguard associated models. - */ - public void unload() { - - // call snippets to allow them to do their stuff - snippets.performDispose(this); - - // Walk all registered models - for(IModel model : models.values()) { - if(!(model instanceof AdditionalResourcesModel)) { - model.unload(); - } - } - additional.unload(); - - // Unload remaining resources - for(Iterator iter = getResources().iterator(); iter.hasNext();) { - iter.next().unload(); - iter.remove(); - } - } - - /** - * Add a {@link IModelSetSnippet}. A snippet allows to add code that will - * perform additional operations on the ModelSet. - * - * @param snippet - * The snippet to add. - */ - public void addModelSetSnippet(IModelSetSnippet snippet) { - snippets.add(snippet); - } - - /** - * A list of {@link IModelSetSnippet}. - * - * Used by Models to maintain their list of Snippets. - * - * @author cedric dumoulin - * - */ - public class ModelSetSnippetList extends ArrayList { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 1L; - - /** - * Call the start method on all registered snippets. - * - * @param modelsManager - * The model that is starting - */ - public void performStart(ModelSet modelsManager) { - for(IModelSetSnippet snippet : this) { - snippet.start(modelsManager); - } - } - - /** - * Call the start method on all registered snippets. - * - * @param modelsManager - * The model that is stopping - */ - public void performDispose(ModelSet modelsManager) { - for(IModelSetSnippet snippet : this) { - snippet.dispose(modelsManager); - } - - } - } - - /** - * Check is a resource is additional in the resource set - * - * @param uri - * the specified URI of the resource - * @return true if it is an additional resource - */ - public boolean isAdditionalResource(URI uri) { - if(uri != null) { - String platformString = uri.trimFileExtension().toPlatformString(false); - return ((platformString == null) || !getFilenameWithoutExtension().toString().equals(platformString.toString())); - } - return false; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelSnippetList.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelSnippetList.java deleted file mode 100644 index 794a11457c9..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelSnippetList.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource; - -import java.util.ArrayList; - -/** - * A list of {@link IModelSnippet}. - * - * Used by Models to maintain their list of Snippets. - * - * @author cedric dumoulin - * - */ -public class ModelSnippetList extends ArrayList { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Call the start method on all registered snippets. - * - * @param model - * The model that is starting - */ - public void performStart(IModel model) { - for(IModelSnippet snippet : this) { - snippet.start(model); - } - } - - /** - * Call the start method on all registered snippets. - * - * @param model - * The model that is stopping - */ - public void performDispose(IModel model) { - for(IModelSnippet snippet : this) { - snippet.dispose(model); - } - - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelUtils.java deleted file mode 100644 index 8d93a8e4a08..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelUtils.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource; - -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers; - -/** - * Set of utility methods to get the current {@link ModelSet}. - * - * @author cedric dumoulin - * - */ -public class ModelUtils { - - /** - * Gets the {@link ModelSet} for the currently selected editor.
- * Warning: This method is designed to be call from ui.handlers. It is not - * designed to be call from Editors. This method can return null. - * - * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() - * - * - * @return The {@link TraceModel} of the current editor, or null if not - * found. - * @deprecated Use ServiceUtilsForActionHandlers.getInstance().getModelSet() - */ - public static ModelSet getModelSet() { - - try { - return ServiceUtilsForActionHandlers.getInstance().getModelSet(); - } catch (ServiceException e) { - return null; - } - } - - /** - * Gets the {@link ModelSet} for the currently selected editor.
- * Warning: This method is designed to be call from ui.handlers. It is not - * designed to be call from Editors. This method can return null if called - * during the MultiEditor initialization. - * - * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() Warning: - * - * - * @return The {@link TraceModel} of the current editor. - * @throws ServiceException - * If an error occurs while getting or starting the service. - * @deprecated Use ServiceUtilsForActionHandlers.getInstance().getModelSet() - */ - public static ModelSet getModelSetChecked() throws ServiceException { - - return ServiceUtilsForActionHandlers.getInstance().getModelSet(); - } - - /** - * Gets the ModelSet from the {@link ServicesRegistry}. - * - * @return ServicesRegistry The service registry under which the ModelSet is - * registered. - */ - public static ModelSet getModelSet(ServicesRegistry servicesRegistry) { - - try { - return servicesRegistry.getService(ModelSet.class); - } catch (ServiceException e) { - return null; - } - } - - /** - * Gets the ModelSet from the {@link ServicesRegistry}. - * - * @return ServicesRegistry The service registry under which the ModelSet is - * registered. - * @throws ServiceException - * If the service can't be returned. - */ - public static ModelSet getModelSetChecked(ServicesRegistry servicesRegistry) throws ServiceException { - return servicesRegistry.getService(ModelSet.class); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelsReader.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelsReader.java deleted file mode 100644 index 719523df90b..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/ModelsReader.java +++ /dev/null @@ -1,232 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource; - -import static org.eclipse.papyrus.core.Activator.log; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; -import org.eclipse.papyrus.core.Activator; -import org.eclipse.papyrus.core.extension.ExtensionException; -import org.eclipse.papyrus.core.extension.ExtensionUtils; - -/** - * A reader to read model from Eclipse extension and register them to the - * specified ModelManager. - * - * @author cedric dumoulin - * - */ -public class ModelsReader extends ExtensionUtils { - - /** - * Name of the extension (as declared in 'plugin.xml->extension - * point->xxx->ID') - */ - public static final String EXTENSION_POINT_NAME = "model"; - - /** Name for the element "model" */ - public static final String MODEL_ELEMENT_NAME = "model"; - - /** Name for the element "modelSnippet" */ - public static final String MODEL_SNIPPET_ELEMENT_NAME = "modelSnippet"; - - /** Name for the element "modelSetSnippet" */ - public static final String MODEL_SET_SNIPPET_ELEMENT_NAME = "modelSetSnippet"; - - /** - * Name of attribute used to set class name. - */ - private static final String CLASSNAME_ATTRIBUTE = "classname"; - - /** Namespace where to look for the extension points. */ - protected String extensionPointNamespace; - - /** - * Create a ModelReader reading extension from the core namespace. - * - * @param extensionPointNamespace - */ - public ModelsReader() { - // Use this plugin namespace. - this(Activator.PLUGIN_ID); - } - - /** - * Create a ModelReader reading extension from the specified namespace. The - * namespace is usually the name of the plugin owning the {@link ModelSet}. - * - * @param extensionPointNamespace - */ - public ModelsReader(String extensionPointNamespace) { - super(); - this.extensionPointNamespace = extensionPointNamespace; - } - - /** - * Populate the manager with models found in Eclipse extensions. - * - * @param modelSet - */ - public void readModel(ModelSet modelSet) { - - // Actually, we register model manually. - // TODO: read from Eclipse extension. - // modelSet.registerModel( new SashModel() ); - // modelSet.registerModel( new NotationModel() ); - // // uml model - // UmlModel umlModel = new ExtendedUmlModel(); - // umlModel.addModelSnippet(new UmlSnippet()); - // modelSet.registerModel(umlModel); - // // global snippets - // modelSet.addModelSetSnippet(new TypeCacheInitializer()); - - // Reading data from plugins - IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointNamespace, EXTENSION_POINT_NAME); - addDeclaredModels(configElements, modelSet); - addDeclaredModelSetSnippets(configElements, modelSet); - } - - /** - * Read and instanciate declared models - * - * @param modelSet - */ - private void addDeclaredModels(IConfigurationElement[] configElements, ModelSet modelSet) { - - for(IConfigurationElement ele : configElements) { - - // Check if it is a Model - try { - if(MODEL_ELEMENT_NAME.equals(ele.getName())) { - IModel model = instanciateModel(ele); - modelSet.registerModel(model); - addDeclaredModelSnippet(ele, model); - - log.debug("model loaded: '" + model.getClass().getName() + "'"); - } - } catch (ExtensionException e) { - log.error("Problems occur while instanciating model", e); - } - } - } - - /** - * Add ModelSet snippet - * - * @param modelSet - */ - private void addDeclaredModelSetSnippets(IConfigurationElement[] configElements, ModelSet modelSet) { - for(IConfigurationElement ele : configElements) { - - // Check if it is a Model - try { - if(MODEL_SET_SNIPPET_ELEMENT_NAME.equals(ele.getName())) { - IModelSetSnippet snippet = instanciateModelSetSnippet(ele); - modelSet.addModelSetSnippet(snippet); - log.debug("modelSet snippet added: '" + modelSet.getClass().getName() + "().add(" + snippet.getClass().getName() + ")'"); - } - } catch (ExtensionException e) { - log.error("Problems occur while instanciating snippet", e); - } - } - } - - /** - * Instanciate model declared in the configuration element. - * - * @param ele - * @return - * @throws ExtensionException - */ - - private IModel instanciateModel(IConfigurationElement ele) throws ExtensionException { - - @SuppressWarnings("unchecked") - Class modelInstance = (Class)parseClass(ele, CLASSNAME_ATTRIBUTE, MODEL_ELEMENT_NAME); - - IModel model; - try { - model = modelInstance.newInstance(); - } catch (InstantiationException e) { - throw new ExtensionException(e); - } catch (IllegalAccessException e) { - throw new ExtensionException(e); - } - - return model; - } - - /** - * Instanciate model snippet declared in the configuration element. - * - * @param ele - * @return - * @throws ExtensionException - */ - private IModelSnippet instanciateModelSnippet(IConfigurationElement ele) throws ExtensionException { - - @SuppressWarnings("unchecked") - Class modelInstance = (Class)parseClass(ele, CLASSNAME_ATTRIBUTE, MODEL_SNIPPET_ELEMENT_NAME); - - IModelSnippet snippet; - try { - snippet = modelInstance.newInstance(); - } catch (InstantiationException e) { - throw new ExtensionException(e); - } catch (IllegalAccessException e) { - throw new ExtensionException(e); - } - - return snippet; - } - - /** - * Instanciate modelSet snippet declared in the configuration element. - * - * @param ele - * @return - * @throws ExtensionException - */ - private IModelSetSnippet instanciateModelSetSnippet(IConfigurationElement ele) throws ExtensionException { - - @SuppressWarnings("unchecked") - Class modelInstance = (Class)parseClass(ele, CLASSNAME_ATTRIBUTE, MODEL_SET_SNIPPET_ELEMENT_NAME); - - IModelSetSnippet snippet; - try { - snippet = modelInstance.newInstance(); - } catch (InstantiationException e) { - throw new ExtensionException(e); - } catch (IllegalAccessException e) { - throw new ExtensionException(e); - } - - return snippet; - } - - /** - * Add associated snippets to the model. - * - * @param parentElement - * @param model - */ - private void addDeclaredModelSnippet(IConfigurationElement parentElement, IModel model) { - - // Get children - IConfigurationElement[] configElements = parentElement.getChildren(MODEL_SNIPPET_ELEMENT_NAME); - - for(IConfigurationElement ele : configElements) { - try { - IModelSnippet snippet = instanciateModelSnippet(ele); - model.addModelSnippet(snippet); - log.debug("model snippet added: '" + model.getClass().getName() + "().add(" + snippet.getClass().getName() + ")'"); - } catch (ExtensionException e) { - log.error("Problems occur while instanciating model snippet", e); - } - } - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/NotFoundException.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/NotFoundException.java deleted file mode 100644 index 24033a65f18..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/NotFoundException.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource; - -/** - * Exception indicating that something is not found. - * - * @author cedric dumoulin - * - */ -public class NotFoundException extends ModelException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Constructor. - * - */ - public NotFoundException() { - } - - /** - * Constructor. - * - * @param message - */ - public NotFoundException(String message) { - super(message); - } - - /** - * Constructor. - * - * @param cause - */ - public NotFoundException(Throwable cause) { - super(cause); - } - - /** - * Constructor. - * - * @param message - * @param cause - */ - public NotFoundException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/TransactionalEditingDomainManager.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/TransactionalEditingDomainManager.java deleted file mode 100644 index 0fc48fd0899..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/TransactionalEditingDomainManager.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.eclipse.papyrus.resource; - -import java.util.Collections; -import java.util.LinkedList; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.edit.provider.ComposedAdapterFactory; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; -import org.eclipse.emf.workspace.IResourceUndoContextPolicy; -import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory; -import org.eclipse.papyrus.commands.CheckedOperationHistory; -import org.eclipse.papyrus.commands.NotifyingWorkspaceCommandStack; - -public class TransactionalEditingDomainManager { - - protected static final ITransactionalEditingDomainProvider[] orderedProvidersArray; - - protected static class ProviderPriorityPair implements Comparable { - - public ITransactionalEditingDomainProvider provider; - public int priority; - - public int compareTo(ProviderPriorityPair o) { - if (o.priority > priority) { - return 1; - } else if (o.priority < priority) { - return -1; - } else { - return 0; - } - } - } - - static { - IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.papyrus.core", "transactionalEditingDomainProvider"); - - LinkedList providerPriorityPairs = new LinkedList(); - - for(IConfigurationElement elem : configElements) { - if ("transactionalEditingDomainProvider".equals(elem.getName())) { - try { - ProviderPriorityPair providerPriorityPair = new ProviderPriorityPair(); - providerPriorityPair.provider = (ITransactionalEditingDomainProvider) elem.createExecutableExtension("class"); - providerPriorityPair.priority = Integer.parseInt(elem.getAttribute("priority")); - - providerPriorityPairs.add(providerPriorityPair); - } catch (Exception e) { - } - } - } - - Collections.sort(providerPriorityPairs); - - orderedProvidersArray = new ITransactionalEditingDomainProvider[providerPriorityPairs.size()]; - - for (int i = 0; i < orderedProvidersArray.length; i++) { - orderedProvidersArray[i] = providerPriorityPairs.get(i).provider; - } - } - - public static TransactionalEditingDomain createTransactionalEditingDomain(ResourceSet resourceSet) { - for (ITransactionalEditingDomainProvider provider : orderedProvidersArray) { - TransactionalEditingDomain ed = provider.createTransactionalEditingDomain(resourceSet); - if (ed != null) { - return ed; - } - } - return createDefaultTransactionalEditingDomain(resourceSet); - } - - public static TransactionalEditingDomain createDefaultTransactionalEditingDomain(ResourceSet resourceSet) { - NotifyingWorkspaceCommandStack stack = new NotifyingWorkspaceCommandStack(CheckedOperationHistory.getInstance()); - stack.setResourceUndoContextPolicy(IResourceUndoContextPolicy.DEFAULT); - - TransactionalEditingDomain result = new TransactionalEditingDomainImpl( - new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE), stack, resourceSet); - - WorkspaceEditingDomainFactory.INSTANCE.mapResourceSet(result); - - return result; - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/additional/AdditionalResourcesModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/additional/AdditionalResourcesModel.java deleted file mode 100644 index 754cce1a079..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/additional/AdditionalResourcesModel.java +++ /dev/null @@ -1,114 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Emilien Perico emilien.perico@atosorigin.com - manage loading strategies - * - *****************************************************************************/ -package org.eclipse.papyrus.resource.additional; - -import java.io.IOException; -import java.util.Collections; -import java.util.Iterator; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.papyrus.resource.IModel; -import org.eclipse.papyrus.resource.IModelSnippet; -import org.eclipse.papyrus.resource.ModelSet; -import org.eclipse.papyrus.resource.ModelSnippetList; - -public class AdditionalResourcesModel implements IModel { - - /** - * The associated ModelManager. - */ - private ModelSet modelSet; - - /** - * List of attached snippets. - */ - private ModelSnippetList snippets = new ModelSnippetList(); - - /** - * Model ID. - */ - public static String MODEL_ID = "org.eclipse.papyrus.resource.additional"; - - public void init(ModelSet modelManager) { - this.modelSet = modelManager; - } - - public String getIdentifier() { - return MODEL_ID; - } - - /** - * useless for additional resources - */ - public void createModel(IPath fullPath) { - // do nothing - } - - public void loadModel(IPath path) { - // call registered snippets - snippets.performStart(this); - } - - public void importModel(IPath fullPathWithoutExtension) { - loadModel(fullPathWithoutExtension); - } - - public void saveModel() throws IOException { - for(Resource r : modelSet.getResources()) { - if(modelSet.isAdditionalResource(r.getURI())) { - EditingDomain editingDomain = modelSet.getTransactionalEditingDomain(); - // only save referenced models, if modified, not empty, not - // read-only and either platform or file - if(!r.getContents().isEmpty() && r.isModified() && (editingDomain != null) && !editingDomain.isReadOnly(r) && (r.getURI().isPlatform() || r.getURI().isFile())) { - r.save(Collections.EMPTY_MAP); - } - } - } - } - - /** - * useless for additional resources - */ - public void changeModelPath(IPath fullPath) { - // do nothing - } - - public void unload() { - // call registered snippets - snippets.performDispose(this); - - // Unload remaining resources - for(Iterator iter = modelSet.getResources().iterator(); iter.hasNext();) { - Resource next = iter.next(); - if(modelSet.isAdditionalResource(next.getURI())) { - next.unload(); - } - iter.remove(); - } - } - - public void addModelSnippet(IModelSnippet snippet) { - snippets.add(snippet); - } - - /** - * @return the modelManager - */ - protected ModelSet getModelManager() { - return modelSet; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/notation/NotationModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/notation/NotationModel.java deleted file mode 100644 index cddc86f598d..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/notation/NotationModel.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource.notation; - -import org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.papyrus.resource.AbstractBaseModel; -import org.eclipse.papyrus.resource.IModel; -import org.eclipse.papyrus.resource.ModelSet; - -/** - * @author dumoulin - * - */ -public class NotationModel extends AbstractBaseModel implements IModel { - - /** - * File extension used for notation. - */ - public static final String NOTATION_FILE_EXTENSION = "notation"; //$NON-NLS-1$ - - /** - * Model ID. - */ - public static final String MODEL_ID = "org.eclipse.papyrus.resource.notation.NotationModel"; //$NON-NLS-1$ - - /** - * - * Constructor. - * - */ - public NotationModel() { - - } - - // Initialize stuff in the model. - @Override - public void init(ModelSet modelManager) { - super.init(modelManager); - // Specify the factory to use to create the resource. - GMFResourceFactory gmfFactory = new GMFResourceFactory(); - getResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap().put(NOTATION_FILE_EXTENSION, gmfFactory); - - } - - /** - * Get the file extension used for this model. - * - * @see org.eclipse.papyrus.resource.AbstractBaseModel#getModelFileExtension() - * - * @return - */ - @Override - protected String getModelFileExtension() { - return NOTATION_FILE_EXTENSION; - } - - /** - * Get the identifier used to register this model. - * - * @see org.eclipse.papyrus.resource.AbstractBaseModel#getIdentifier() - * - * @return - */ - @Override - public String getIdentifier() { - return MODEL_ID; - } - - /** - * Add a new initialized {@link Diagram} to the model. - * - * @param newDiagram - * The diagram to add. - */ - public void addDiagram(Diagram newDiagram) { - getResource().getContents().add(newDiagram); - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/notation/NotationUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/notation/NotationUtils.java deleted file mode 100644 index 9cb46002479..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/notation/NotationUtils.java +++ /dev/null @@ -1,176 +0,0 @@ -/***************************************************************************** - * 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.resource.notation; - -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers; -import org.eclipse.papyrus.resource.ModelSet; - -/** - * Utilities method to manage notation models. Should be moved in a more - * suitable plugin - */ -public class NotationUtils { - - /** - * Get the notation Resource. - * - * @return - * - * @deprecated Usage of the internal Resource is discouraged. - */ - public static Resource getNotationResource() { - return getNotationModel().getResource(); - } - - /** - * Gets the NotationModel for the currently selected editor.
- * Warning: This method is designed to be call from ui.handlers. It is not - * designed to be call from Editors. This method can return null if called - * during the MultiEditor initialization. - * - * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() - * - * @return The {@link NotationModel} of the current editor, or null if not - * found. - */ - public static NotationModel getNotationModel() { - - try { - return (NotationModel)ServiceUtilsForActionHandlers.getInstance().getModelSet().getModel(NotationModel.MODEL_ID); - } catch (ServiceException e) { - return null; - } - } - - /** - * Gets the NotationModel for the currently selected editor.
- * Warning: This method is designed to be call from ui.handlers. It is not - * designed to be call from Editors. This method can return null if called - * during the MultiEditor initialization. - * - * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() - * - * @return The {@link NotationModel} of the current editor, or null if not - * found. - * @throws ServiceException - * If an error occurs while getting or starting the service. - */ - public static NotationModel getNotationModelChecked() throws ServiceException { - - return (NotationModel)ServiceUtilsForActionHandlers.getInstance().getModelSet().getModel(NotationModel.MODEL_ID); - } - - /** - * Gets the NotationModel from the {@link ModelSet}.
- * - * @param modelsManager - * The modelManager containing the requested model. - * - * @return The {@link NotationModel} registered in modelManager, or null if - * not found. - */ - public static NotationModel getNotationModel(ModelSet modelsManager) { - - return (NotationModel)modelsManager.getModel(NotationModel.MODEL_ID); - } - - /** - * Gets the direct associated diagram of the specified eObject. - * - * @param eObject - * @param notationResource - * - * @return the associated diagram - */ - public static Diagram getAssociatedDiagram(Resource notationResource, EObject eObject) { - if(notationResource != null) { - for(EObject obj : notationResource.getContents()) { - if(obj instanceof Diagram) { - Diagram diagram = (Diagram)obj; - if(eObject != null && eObject.equals(diagram.getElement())) { - return diagram; - } - } - } - } - return null; - } - - /** - * Gets the direct associated diagram of the specified eObject. - * - * @param eObject - * @param notationResource - * @param resolve - * the resource if true - * - * @return the associated diagram - */ - public static Diagram getAssociatedDiagram(Resource notationResource, EObject eObject, boolean resolve) { - if(notationResource != null && resolve) { - EcoreUtil.resolveAll(notationResource); - } - return getAssociatedDiagram(notationResource, eObject); - } - - /** - * Gets the all the diagrams contained in the specified ancestor eObject - * - * @param notationResource - * @param eObject - * - * @return all the contained diagrams - * - */ - public static List getDiagrams(Resource notationResource, EObject eObject) { - List diagrams = new LinkedList(); - if(notationResource != null) { - for(EObject obj : notationResource.getContents()) { - if(obj instanceof Diagram) { - Diagram diagram = (Diagram)obj; - if(EcoreUtil.isAncestor(eObject, diagram.getElement())) { - diagrams.add(diagram); - } - } - } - } - return diagrams; - } - - /** - * Gets the all the diagrams contained in the specified ancestor eObject - * - * @param notationResource - * @param eObject - * @param resolve - * the resource if true - * - * @return all the contained diagrams - */ - public static List getDiagrams(Resource notationResource, EObject eObject, boolean resolve) { - if(notationResource != null && resolve) { - EcoreUtil.resolveAll(notationResource); - } - return getDiagrams(notationResource, eObject); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/DiModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/DiModel.java deleted file mode 100644 index 4ddd5c73837..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/DiModel.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource.sasheditor; - -import org.eclipse.papyrus.resource.AbstractBaseModel; -import org.eclipse.papyrus.resource.IModel; - -/** - * @author dumoulin - * - */ -public class DiModel extends AbstractBaseModel implements IModel { - - /** - * File extension used for notation. - */ - public static final String MODEL_FILE_EXTENSION = "di"; //$NON-NLS-1$ - - /** - * File extension used for notation. - */ - public static final String DI_FILE_EXTENSION = MODEL_FILE_EXTENSION; - - /** - * Model ID. - */ - public static final String MODEL_ID = "org.eclipse.papyrus.resource.sasheditor.SashModel"; //$NON-NLS-1$ - - /** - * Get the file extension used for this model. - * - * @see org.eclipse.papyrus.resource.AbstractBaseModel#getModelFileExtension() - * - * @return - */ - @Override - protected String getModelFileExtension() { - return MODEL_FILE_EXTENSION; - } - - /** - * Get the identifier used to register this model. - * - * @see org.eclipse.papyrus.resource.AbstractBaseModel#getIdentifier() - * - * @return - */ - @Override - public String getIdentifier() { - return MODEL_FILE_EXTENSION; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/DiModelUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/DiModelUtils.java deleted file mode 100644 index dd20a104e14..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/DiModelUtils.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource.sasheditor; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IPath; - -/** - * Set of utility methods linked to Di resource. - * - * @author cedric dumoulin - * - */ -public class DiModelUtils { - - /** - * Returns the related di file. Warning : this method is here for historical - * reasons. It should be removed asap. - * - * @param file - * A file (di, model or notation). - * @return The associated DI file. - * @deprecated No replacement. - */ - public static IFile getRelatedDiFile(IFile file) { - if(file == null) { - return null; - } - IFile diFile; - if(DiModel.DI_FILE_EXTENSION.equalsIgnoreCase(file.getFileExtension())) { - diFile = file; - } else { - // Find the correct file - IPath diPath = file.getFullPath().removeFileExtension().addFileExtension(DiModel.DI_FILE_EXTENSION); - diFile = file.getParent().getFile(diPath.makeRelativeTo(file.getParent().getFullPath())); - } - return diFile; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/SashModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/SashModel.java deleted file mode 100644 index b828ed37f61..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/SashModel.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource.sasheditor; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.papyrus.resource.AbstractModelWithSharedResource; -import org.eclipse.papyrus.resource.AbstractModelWithSharedResource.ModelKind; -import org.eclipse.papyrus.resource.IModel; - -/** - * Model for the sash system.
- * This model can share its resource with other model. This model is declared as {@link ModelKind#master}. Other model whishing to share the resource - * should - * subclass {@link AbstractModelWithSharedResource}, be declared as {@link ModelKind#slave} (which is the default.), and set {@link #getModelFileExtension()} to return the same file extension as this - * model ({@link #MODEL_FILE_EXTENSION}). - * - * @author cedric dumoulin - * - */ -public class SashModel extends AbstractModelWithSharedResource implements IModel { - - /** - * File extension used for notation. - */ - public static final String MODEL_FILE_EXTENSION = "di"; //$NON-NLS-1$ - - /** - * Model ID. - */ - public static final String MODEL_ID = "org.eclipse.papyrus.resource.sasheditor.SashModel"; //$NON-NLS-1$ - - /** - * - * Constructor. - * - */ - public SashModel() { - super(ModelKind.master); - } - - /** - * Get the file extension used for this model. - * - * @see org.eclipse.papyrus.resource.AbstractBaseModel#getModelFileExtension() - * - * @return - */ - @Override - protected String getModelFileExtension() { - return MODEL_FILE_EXTENSION; - } - - /** - * Get the identifier used to register this model. - * - * @see org.eclipse.papyrus.resource.AbstractBaseModel#getIdentifier() - * - * @return - */ - @Override - public String getIdentifier() { - return MODEL_ID; - } - - @Override - protected boolean isModelRoot(EObject object) { - return object instanceof org.eclipse.papyrus.sashwindows.di.SashModel; - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/SashModelUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/SashModelUtils.java deleted file mode 100644 index 77961f82751..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/sasheditor/SashModelUtils.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource.sasheditor; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers; -import org.eclipse.papyrus.resource.ModelSet; -import org.eclipse.papyrus.resource.ModelUtils; -import org.eclipse.papyrus.resource.uml.UmlUtils; - -/** - * Set of utility methods linked to Trace for ControlMode - * - * @author cedric dumoulin - * - */ -public class SashModelUtils { - - /** - * Gets the SashModel for the currently selected editor.
- * Warning: This method is designed to be call from ui.handlers. It is not - * designed to be call from Editors. This method can return null if called - * during the MultiEditor initialization. - * - * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() - * - * @return The {@link SashModel} of the current editor, or null if not - * found. - */ - public static SashModel getSashModel() { - - try { - return (SashModel)ServiceUtilsForActionHandlers.getInstance().getModelSet().getModel(SashModel.MODEL_ID); - } catch (ServiceException e) { - return null; - } - } - - /** - * Gets the SashModel for the currently selected editor.
- * Warning: This method is designed to be call from ui.handlers. It is not - * designed to be call from Editors. This method can return null if called - * during the MultiEditor initialization. - * - * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() - * - * @return The {@link SashModel} of the current editor, or null if not - * found. - * @throws ServiceException - * If an error occurs while getting or starting the service. - */ - public static SashModel getSashModelChecked() throws ServiceException { - - return (SashModel)ServiceUtilsForActionHandlers.getInstance().getModelSet().getModel(SashModel.MODEL_ID); - } - - /** - * Gets the SashModel from the {@link ModelSet}.
- * - * @param modelsManager - * The modelManager containing the requested model. - * - * @return The {@link SashModel} registered in modelManager, or null if not - * found. - */ - public static SashModel getSashModel(ModelSet modelsManager) { - - return (SashModel)modelsManager.getModel(SashModel.MODEL_ID); - } - - /** - * Gets the SashModel from the {@link ModelSet}.
- * - * @param ServicesRegistry - * The servie registry under which the ModelSet is registered. - * - * @return The {@link SashModel} registered in modelManager, or null if not - * found. - */ - public static SashModel getSashModel(ServicesRegistry servicesRegistry) { - - try { - return (SashModel)ModelUtils.getModelSetChecked(servicesRegistry).getModel(SashModel.MODEL_ID); - } catch (ServiceException e) { - return null; - } - } - - /** - * Gets the SashModel from the {@link ModelSet}.
- * - * @param ServicesRegistry - * The servie registry under which the ModelSet is registered. - * - * @return The {@link SashModel} registered in modelManager, or null if not - * found. - * @throws ServiceException - * If the service can't be returned. - */ - public static SashModel getSashModelChecked(ServicesRegistry servicesRegistry) throws ServiceException { - - return (SashModel)ModelUtils.getModelSetChecked(servicesRegistry).getModel(SashModel.MODEL_ID); - } - - /** - * Retrieve the uri of the initial di opened - * - * @param modelSet - * @return FIXME improve how to get the initial model opened - */ - public static URI getInitialURI(ModelSet modelSet) { - return UmlUtils.getUmlModel(modelSet).getResourceURI().trimFileExtension().appendFileExtension(SashModel.MODEL_FILE_EXTENSION); - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/ExtendedUmlModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/ExtendedUmlModel.java deleted file mode 100644 index f9fd72bdac2..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/ExtendedUmlModel.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource.uml; - -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.emf.ecore.resource.Resource; - -/** - * A UML model whose resource is either a uml file or a profile(?). - * - * @author cedric dumoulin - * - */ -public class ExtendedUmlModel extends UmlModel { - - /** - * Load the first resource with a supported extension TODO: (question from - * Cedric) fix what is a supported extension ? - * - * @see org.eclipse.papyrus.resource.AbstractBaseModel#loadModel(org.eclipse.core.runtime.IPath) - * - * @param fullPath - */ - @Override - public void loadModel(IFile file) { - - // Extract file name, without extension - IPath fullPath = file.getFullPath().removeFileExtension(); - - // Try to load resources that are not DI or Notation - // TODO : set the requested extension rather than taking anyone. - if(resource == null) { - IContainer folder = file.getParent(); - try { - IResource[] files = folder.members(); - for(IResource r : files) { - String extension = r.getFullPath().getFileExtension(); - if(r.getFullPath().removeFileExtension().lastSegment().equals(fullPath.lastSegment()) && !"di".equalsIgnoreCase(extension) && !"notation".equalsIgnoreCase(extension)) { - if(Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().get(extension) != null) { - resourceURI = getPlatformURI(r.getFullPath()); - resource = getResourceSet().getResource(resourceURI, true); - break; - } - } - } - } catch (CoreException e) { - // never happens. - } - } - } -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/UmlModel.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/UmlModel.java deleted file mode 100644 index a6767c83df0..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/UmlModel.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource.uml; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.papyrus.resource.AbstractBaseModel; -import org.eclipse.papyrus.resource.IModel; -import org.eclipse.papyrus.resource.NotFoundException; - -/** - * A UML model. - * - * @author cedric dumoulin - * - */ -public class UmlModel extends AbstractBaseModel implements IModel { - - /** - * File extension used for DI. - */ - public static final String UML_FILE_EXTENSION = "uml"; //$NON-NLS-1$ - - /** - * Model ID. - */ - public static final String MODEL_ID = "org.eclipse.papyrus.resource.uml.UmlModel"; //$NON-NLS-1$ - - /** - * @see org.eclipse.papyrus.resource.IModel#createModel(org.eclipse.core.runtime.IPath) - * - * @param fullPath - */ - public void createModel(IPath fullPath) { - - // Compute model URI - resourceURI = getPlatformURI(fullPath.addFileExtension(UML_FILE_EXTENSION)); - - // Create Resource of appropriate type - resource = getResourceSet().createResource(resourceURI, getContentType()); - } - - /** - * - * @return - */ - protected String getContentType() { - // TODO: use the uml identifier - // return UMLPackage.eCONTENT_TYPE; - return "org.eclipse.uml2.uml"; - } - - /** - * Get the file extension used for this model. - * - * @see org.eclipse.papyrus.resource.AbstractBaseModel#getModelFileExtension() - * - * @return - */ - @Override - protected String getModelFileExtension() { - return UML_FILE_EXTENSION; - } - - /** - * Get the identifier used to register this model. - * - * @see org.eclipse.papyrus.resource.AbstractBaseModel#getIdentifier() - * - * @return - */ - @Override - public String getIdentifier() { - return MODEL_ID; - } - - /** - * Lookup the root of the model. Throw an exception if not found. - * - * @return - */ - public EObject lookupRoot() throws NotFoundException { - // TODO Auto-generated method stub - try { - return resource.getContents().get(0); - } catch (IndexOutOfBoundsException e) { - // The root doesn't exist. - throw new NotFoundException("No root defined in the model"); - } - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/UmlSnippet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/UmlSnippet.java deleted file mode 100644 index 0eec8a19d9c..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/UmlSnippet.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource.uml; - -import org.eclipse.papyrus.core.listenerservice.ModelListenerManager; -import org.eclipse.papyrus.resource.IModel; -import org.eclipse.papyrus.resource.IModelSnippet; - -/** - * A snippet registering adapters to the UML model. - * - * @author cedric dumoulin - * - */ -public class UmlSnippet implements IModelSnippet { - - private ModelListenerManager modelListenerManager; - - /** - * Register the UML adapters - * - * @see org.eclipse.papyrus.resource.IModelSnippet#start(org.eclipse.papyrus.resource.IModel) - * - * @param startingModel - */ - public void start(IModel startingModel) { - - // Modl should be an uml one - UmlModel umlModel = (UmlModel)startingModel; - // add adapters - modelListenerManager = new ModelListenerManager(); - umlModel.getResource().eAdapters().add(modelListenerManager); - - } - - public void dispose(IModel stoppingModel) { - // Modl should be an uml one - UmlModel umlModel = (UmlModel)stoppingModel; - // add adapters - try { - if(umlModel.getResource() != null) { - umlModel.getResource().eAdapters().remove(modelListenerManager); - } - } catch (NullPointerException e) { - // resource is already disposed, or not loaded. Do nothing - } - - } - -} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/UmlUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/UmlUtils.java deleted file mode 100644 index d8a18560300..00000000000 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/resource/uml/UmlUtils.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.resource.uml; - -import javax.imageio.spi.ServiceRegistry; - -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.core.utils.ServiceUtilsForActionHandlers; -import org.eclipse.papyrus.resource.ModelUtils; -import org.eclipse.papyrus.resource.ModelSet; -import org.eclipse.papyrus.resource.sasheditor.SashModel; - -/** - * Set of utility methods linked to Trace for ControlMode - * - * @author cedric dumoulin - * - */ -public class UmlUtils { - - /** - * Gets the UmlModel for the currently selected editor.
- * Warning: This method is designed to be call from ui.handlers. It is not - * designed to be call from Editors. This method can return null if called - * during the MultiEditor initialization. - * - * @see ServiceUtilsForActionHandlers.getInstance().getModelSet() - * - * - * @return The {@link UmlModel} of the current editor, or null if not found. - */ - public static UmlModel getUmlModel() { - - try { - return (UmlModel)ServiceUtilsForActionHandlers.getInstance().getModelSet().getModel(UmlModel.MODEL_ID); - } catch (ServiceException e) { - return null; - } - } - - /** - * Gets the UmlModel for the currently selected editor.
- * Warning: this method can return null if called during the MultiEditor - * initialization. - * - * - * @return The {@link UmlModel} of the current editor, or null if not found. - * @throws ServiceException - * If an error occurs while getting or starting the service. - */ - public static UmlModel getUmlModelChecked() throws ServiceException { - - return (UmlModel)ServiceUtilsForActionHandlers.getInstance().getModelSet().getModel(UmlModel.MODEL_ID); - } - - /** - * Gets the UmlModel from the {@link ModelSet}.
- * - * @param modelSet - * The modelManager containing the requested model. - * - * @return The {@link SashModel} registered in modelManager, or null if not - * found. - */ - public static UmlModel getUmlModel(ModelSet modelSet) { - - return (UmlModel)modelSet.getModel(UmlModel.MODEL_ID); - } - - /** - * Gets the UmlModel from the {@link ServiceRegistry}. - * - * @return ServicesRegistry The service registry under which the ModelSet is - * registered. - */ - public static UmlModel getUmlModel(ServicesRegistry servicesRegistry) { - - try { - return getUmlModelChecked(servicesRegistry); - } catch (ServiceException e) { - return null; - } - } - - /** - * Gets the UmlModel from the {@link ServiceRegistry}. - * - * @return ServicesRegistry The service registry under which the ModelSet is - * registered. - * @throws ServiceException - * If the service can't be returned. - */ - public static UmlModel getUmlModelChecked(ServicesRegistry servicesRegistry) throws ServiceException { - return (UmlModel)ModelUtils.getModelSetChecked(servicesRegistry).getModel(UmlModel.MODEL_ID); - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/META-INF/MANIFEST.MF b/plugins/infra/org.eclipse.papyrus.infra.export/META-INF/MANIFEST.MF index d9570b0f97d..82986f783d8 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.export/META-INF/MANIFEST.MF +++ b/plugins/infra/org.eclipse.papyrus.infra.export/META-INF/MANIFEST.MF @@ -7,13 +7,13 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="3.7.0", org.eclipse.emf.common.ui;bundle-version="2.7.0", org.eclipse.papyrus.views.modelexplorer;bundle-version="0.9.0", org.eclipse.papyrus.infra.onefile;bundle-version="0.9.0" -Export-Package: org.eclipse.papyrus.export +Export-Package: org.eclipse.papyrus.infra.export Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-Version: 0.9.0.qualifier Bundle-Name: %pluginName Bundle-ManifestVersion: 2 -Bundle-Activator: org.eclipse.papyrus.export.internal.Activator +Bundle-Activator: org.eclipse.papyrus.infra.export.internal.Activator Bundle-SymbolicName: org.eclipse.papyrus.infra.export;singleton:=true Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/plugin.xml b/plugins/infra/org.eclipse.papyrus.infra.export/plugin.xml index b770d529512..47929f46cbb 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.export/plugin.xml +++ b/plugins/infra/org.eclipse.papyrus.infra.export/plugin.xml @@ -49,21 +49,21 @@ @@ -83,7 +83,7 @@ name="*.di"> + class="org.eclipse.papyrus.infra.onefile.model.IPapyrusFile"> diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/ExportAllDiagrams.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/ExportAllDiagrams.java deleted file mode 100644 index 0190432bf7f..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/ExportAllDiagrams.java +++ /dev/null @@ -1,417 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Anyware Technologies. 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: Jacques Lescot (Anyware Technologies) - initial API and - * implementation - * Thibault Landre (Atos Origin) - refactor to extract the exportAllDiagram from ExportAllDiagramsAction - * Alexia Allanic (Atos Origin) - Add margin to not truncate images - * Anass Radouani (AtoS) - add use GMF exporting tool and remove manual extraction - * - ******************************************************************************/ -package org.eclipse.papyrus.export; - -import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.emf.common.command.CommandStack; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.util.BasicDiagnostic; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.emf.common.util.URI; -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.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.ecore.xmi.XMLResource; -import org.eclipse.emf.edit.provider.ComposedAdapterFactory; -import org.eclipse.emf.edit.provider.IItemLabelProvider; -import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; -import org.eclipse.emf.transaction.RollbackException; -import org.eclipse.emf.transaction.Transaction; -import org.eclipse.emf.transaction.TransactionalCommandStack; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.emf.transaction.TransactionalEditingDomain.Factory; -import org.eclipse.emf.transaction.util.TransactionUtil; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; -import org.eclipse.gmf.runtime.diagram.ui.image.ImageFileFormat; -import org.eclipse.gmf.runtime.diagram.ui.render.util.CopyToImageUtil; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.emf.common.ui.dialogs.DiagnosticDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; -import org.eclipse.papyrus.export.internal.Activator; -import org.eclipse.swt.SWTError; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.WorkspaceModifyOperation; - -public class ExportAllDiagrams { - - private IFile file; - - private String extension; - - private String outputDirectoryPath; - - private IWorkbenchWindow workbenchWindow; - - private boolean displayRenamingInformation; - - private static boolean useDisplayRunnable = true; - - private boolean qualifiedName; - - private BasicDiagnostic diagnostic = new BasicDiagnostic(Diagnostic.OK, "", 0, Messages.ExportAllDiagrams_18, null); //$NON-NLS-1$ - - /** - * Constructor - * - * @param file - * the *.*di file where the diagrams are stored, can be null if - * you use export method with diagrams in parameter - * @param outputDirectoryPath - * the directory in which the images will be saved - * @param extension - * the image extension - * @param imageExporter - * the image exporter used. The image exporter should be coherent - * with the file extension - */ - public ExportAllDiagrams(IFile file, String outputDirectoryPath, String extension, boolean qualifiedName) { - this.file = file; - this.extension = extension; - this.outputDirectoryPath = outputDirectoryPath; - try { - this.workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - } catch (IllegalStateException e) { - this.workbenchWindow = null; - // is normal in batch mode - } - this.displayRenamingInformation = true; - this.qualifiedName = qualifiedName; - } - - /** - * Run the export of all diagrams of a *.*di file into images in the given - * format. - */ - public void exportDiagramsToImages() { - final IRunnableWithProgress op = new WorkspaceModifyOperation() { - - @Override - protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - if(monitor == null) { - monitor = new NullProgressMonitor(); - } - final IProgressMonitor newMonitor = monitor; - export(newMonitor); - } - - }; - Job job = new Job(Messages.ExportAllDiagrams_0) { - - @Override - public IStatus run(IProgressMonitor monitor) { - try { - op.run(monitor); - } catch (InvocationTargetException e) { - } catch (InterruptedException e) { - } - return Status.OK_STATUS; - } - }; - job.setUser(true); - job.schedule(); - - } - - /** - * Export all diagrams of the IFile - * - * @param newMonitor - */ - private void export(IProgressMonitor newMonitor) { - // Then iterates on all the diagrams and export them one by one - newMonitor.beginTask(Messages.ExportAllDiagrams_1, 10); - newMonitor.subTask(Messages.ExportAllDiagrams_2); - if(file != null) { - final ResourceSetImpl resourceSet = new ResourceSetImpl(); - resourceSet.getLoadOptions().put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, true); - resourceSet.getLoadOptions().put(XMLResource.OPTION_DEFER_ATTACHMENT, true); - resourceSet.getResource(URI.createPlatformResourceURI(file.getFullPath().toString(), true), true); - - // create transactional editing domain - - TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(resourceSet); - if(editingDomain == null) { - Factory factory = TransactionalEditingDomain.Factory.INSTANCE; - editingDomain = factory.createEditingDomain(resourceSet); - } - - AbstractTransactionalCommand com = new AbstractTransactionalCommand(editingDomain, "Resolve", Collections.emptyList()) { - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - EcoreUtil.resolveAll(resourceSet); - return null; - } - }; - - // bypass all the transaction/validate/notification mechanisms, it is a lot faster and it has no impact - // since we do not modify the model - CommandStack commandStack = editingDomain.getCommandStack(); - if(commandStack instanceof TransactionalCommandStack) { - TransactionalCommandStack stack = (TransactionalCommandStack)commandStack; - Map options = new HashMap(); - options.put(Transaction.OPTION_NO_NOTIFICATIONS, Boolean.TRUE); - options.put(Transaction.OPTION_NO_UNDO, Boolean.TRUE); - options.put(Transaction.OPTION_UNPROTECTED, Boolean.TRUE); - options.put(Transaction.OPTION_IS_UNDO_REDO_TRANSACTION, Boolean.FALSE); - options.put(Transaction.OPTION_NO_TRIGGERS, Boolean.TRUE); - options.put(Transaction.OPTION_VALIDATE_EDIT, Boolean.FALSE); - options.put(Transaction.OPTION_VALIDATE_EDIT_CONTEXT, Boolean.FALSE); - try { - stack.execute(new GMFtoEMFCommandWrapper(com), options); - } catch (InterruptedException e) { - } catch (RollbackException e) { - } - } else { - Activator.log("no transactional editing domain found", Status.WARNING); - } - - List diagrams = new ArrayList(); - if(newMonitor.isCanceled()) { - return; - } - for(Iterator i = resourceSet.getAllContents(); i.hasNext();) { - Notifier n = i.next(); - if(n instanceof Diagram) { - diagrams.add((Diagram)n); - } - } - if(newMonitor.isCanceled()) { - return; - } - newMonitor.worked(1); - export(new SubProgressMonitor(newMonitor, 9), diagrams); - } else { - Activator.log(new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.ExportAllDiagrams_3)); - } - - } - - /** - * export all the diagrams in image - * - * @param newMonitor - * , the monitor - * @param diagrams - * , the emf element diagrams - */ - public void export(IProgressMonitor newMonitor, List diagrams) { - boolean duplicates; - newMonitor.beginTask(Messages.ExportAllDiagrams_4, 10); - duplicates = createDiagramFiles(new SubProgressMonitor(newMonitor, 9), diagrams); - unloadResources(new SubProgressMonitor(newMonitor, 1), diagrams); - - // Alert the user that file names have been changed to avoid duplicates - if(duplicates && displayRenamingInformation) { - - final String message = Messages.ExportAllDiagrams_5; - if(workbenchWindow != null && workbenchWindow.getShell() != null) { - - BasicDiagnostic newDiagnostic = new BasicDiagnostic(Diagnostic.WARNING, "", 0, message, null); //$NON-NLS-1$ - diagnostic.add(newDiagnostic); - - } else { - Activator.log(new Status(Status.INFO, Activator.PLUGIN_ID, message)); - } - - } - int severity = diagnostic.recomputeSeverity(); - if(severity == Diagnostic.ERROR) { - BasicDiagnostic oldDiagnostic = diagnostic; - diagnostic = new BasicDiagnostic(Diagnostic.ERROR, "", 0, Messages.ExportAllDiagrams_22, null); //$NON-NLS-1$ - diagnostic.addAll(oldDiagnostic); - } else if(severity == Diagnostic.WARNING) { - BasicDiagnostic oldDiagnostic = diagnostic; - diagnostic = new BasicDiagnostic(Diagnostic.WARNING, "", 0, Messages.ExportAllDiagrams_24, null); //$NON-NLS-1$ - diagnostic.addAll(oldDiagnostic); - } else if(severity == Diagnostic.OK) { - if(workbenchWindow != null && workbenchWindow.getShell() != null) { - Display.getDefault().syncExec(new Runnable() { - - public void run() { - MessageDialog.openInformation(Activator.getActiveWorkbenchShell(), Messages.ExportAllDiagrams_25, Messages.ExportAllDiagrams_26 + outputDirectoryPath); - } - }); - } - } - - Display.getDefault().syncExec(new Runnable() { - - public void run() { - DiagnosticDialog.open(Activator.getActiveWorkbenchShell(), Messages.ExportAllDiagrams_27, "", diagnostic); //$NON-NLS-2$ - } - }); - - } - - /** - * Browse all the diagrams and export them - * - * @param newMonitor - * @param findAllDiagrams - * @return - */ - private boolean createDiagramFiles(final IProgressMonitor newMonitor, List diagrams) { - boolean duplicates = false; - boolean nameCut = false; - try { - List diagramNames = new ArrayList(); - try { - newMonitor.beginTask(Messages.ExportAllDiagrams_7, diagrams.size()); - for(final Diagram diagram : diagrams) { - if(newMonitor.isCanceled()) { - break; - } - String label = ""; //$NON-NLS-1$ - if(qualifiedName) { - ComposedAdapterFactory composedAdapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); - composedAdapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory()); - IItemLabelProvider itemLabelFactory = (IItemLabelProvider)composedAdapterFactory.adapt(diagram.getElement(), IItemLabelProvider.class); - label = itemLabelFactory.getText(diagram.getElement()).replace(Messages.ExportAllDiagrams_16, "") + "_"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ - } - String uniqueFileName = encodeFileName(label + diagram.getName()); - if(uniqueFileName.length() > 150) { - nameCut = true; - uniqueFileName = uniqueFileName.substring(0, 150); - } - if(diagramNames.contains(uniqueFileName)) { - duplicates = true; - uniqueFileName = getFirstAvailableName(uniqueFileName, diagramNames, 1); - } - - if(nameCut) { - - BasicDiagnostic newDiagnostic = new BasicDiagnostic(Diagnostic.WARNING, "", 0, Messages.ExportAllDiagrams_10 + uniqueFileName, null); //$NON-NLS-1$ - diagnostic.add(newDiagnostic); - - nameCut = false; - } - - final String finalUniqueFileName = uniqueFileName; - diagramNames.add(uniqueFileName); - newMonitor.subTask(Messages.ExportAllDiagrams_8 + uniqueFileName); - if(useDisplayRunnable) { - Display.getDefault().syncExec(new Runnable() { - - public void run() { - exportDiagram(finalUniqueFileName, diagram, newMonitor); - } - }); - } else { - exportDiagram(uniqueFileName, diagram, newMonitor); - } - newMonitor.worked(1); - } - } catch (SWTError e) { - String message = Messages.ExportAllDiagrams_9; - Activator.log(new Exception(message, e)); - } - } catch (Exception e) { - e.printStackTrace(); - } - return duplicates; - } - - private void exportDiagram(String uniqueFileName, Diagram diagram, IProgressMonitor newMonitor) { - CopyToImageUtil copyImageUtil = new CopyToImageUtil(); - try { - copyImageUtil.copyToImage(diagram, new Path(outputDirectoryPath + File.separator + uniqueFileName + "." //$NON-NLS-1$ - + ImageFileFormat.resolveImageFormat(extension)), ImageFileFormat.resolveImageFormat(extension), new SubProgressMonitor(newMonitor, 1), PreferencesHint.USE_DEFAULTS); - } catch (Throwable e) { - BasicDiagnostic newDiagnostic = new BasicDiagnostic(Diagnostic.ERROR, "", 0, String.format(Messages.ExportAllDiagrams_11, uniqueFileName, diagram.eResource().getURI().toString()), null); //$NON-NLS-1$ - diagnostic.add(newDiagnostic); - Activator.log(String.format(Messages.ExportAllDiagrams_11, uniqueFileName, diagram.eResource().getURI().toString()), IStatus.ERROR, e); - } - } - - public void unloadResources(IProgressMonitor newMonitor, List diagrams) { - if(newMonitor == null) { - newMonitor = new NullProgressMonitor(); - } - newMonitor.subTask(Messages.ExportAllDiagrams_12); - if(diagrams != null && !diagrams.isEmpty()) { - ResourceSet resourceSet2 = diagrams.get(0).eResource().getResourceSet(); - newMonitor.beginTask(Messages.ExportAllDiagrams_13, resourceSet2.getResources().size()); - for(int i = resourceSet2.getResources().size() - 1; i >= 0; i--) { - try { - Resource r = resourceSet2.getResources().get(i); - if(r.isLoaded()) { - r.unload(); - } - } catch (Exception e) { - // not very clean but it sometimes occurs - } - newMonitor.worked(1); - } - } - - } - - /** - * Escape all characters that may result in a wrong file name - * - * @param pathName - * a file name to encode - * @return The encoded file name - */ - private String encodeFileName(String pathName) { - pathName = pathName.trim(); - pathName = pathName.replaceAll(Messages.ExportAllDiagrams_14, Messages.ExportAllDiagrams_15); - pathName = pathName.replaceAll("_-_", "-"); //$NON-NLS-1$ //$NON-NLS-2$ - while(pathName.contains("__")) { //$NON-NLS-1$ - pathName = pathName.replaceAll("__", "_"); //$NON-NLS-1$ //$NON-NLS-2$ - } - if(pathName.startsWith("_")) { //$NON-NLS-1$ - pathName = pathName.replaceFirst("_", ""); //$NON-NLS-1$ //$NON-NLS-2$ - } - if(pathName.endsWith("_")) { //$NON-NLS-1$ - pathName = pathName.substring(0, pathName.length() - 1); - } - - return pathName; - // return URLEncoder.encode(pathName, "UTF-8").replaceAll("[*]", "_"); - } - - private String getFirstAvailableName(String commonBasis, List existingNames, int cpt) { - if(existingNames.contains(commonBasis + cpt)) { - return getFirstAvailableName(commonBasis, existingNames, cpt + 1); - } - return commonBasis + cpt; - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/ExportException.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/ExportException.java deleted file mode 100644 index d679c96a831..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/ExportException.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Anyware Technologies - * 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: - * David Sciamma (Anyware Technologies) - initial API and implementation - *******************************************************************************/ - -package org.eclipse.papyrus.export; - -/** - * Exception raised during an image export - * - * @author David Sciamma - */ -public class ExportException extends Exception { - - /** - * serialVersionUID - */ - private static final long serialVersionUID = 5787608979737224951L; - - /** - * Constructor - */ - public ExportException() { - super(); - } - - /** - * Constructor - * - * @param message - */ - public ExportException(String message) { - super(message); - } - - /** - * Constructor - * - * @param cause - */ - public ExportException(Throwable cause) { - super(cause); - } - - /** - * Constructor - * - * @param message - * @param cause - */ - public ExportException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/Messages.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/Messages.java deleted file mode 100644 index 4206fb1f613..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/Messages.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 AtoS - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Anass RADOUANI (AtoS) - *******************************************************************************/ -package org.eclipse.papyrus.export; - -import org.eclipse.osgi.util.NLS; - -public class Messages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.papyrus.export.messages"; //$NON-NLS-1$ - - public static String ExportAllDiagrams_0; - - public static String ExportAllDiagrams_1; - - public static String ExportAllDiagrams_10; - - public static String ExportAllDiagrams_11; - - public static String ExportAllDiagrams_12; - - public static String ExportAllDiagrams_13; - - public static String ExportAllDiagrams_14; - - public static String ExportAllDiagrams_15; - - public static String ExportAllDiagrams_16; - - public static String ExportAllDiagrams_18; - - public static String ExportAllDiagrams_2; - - public static String ExportAllDiagrams_20; - - public static String ExportAllDiagrams_22; - - public static String ExportAllDiagrams_24; - - public static String ExportAllDiagrams_25; - - public static String ExportAllDiagrams_26; - - public static String ExportAllDiagrams_27; - - public static String ExportAllDiagrams_3; - - public static String ExportAllDiagrams_4; - - public static String ExportAllDiagrams_5; - - public static String ExportAllDiagrams_6; - - public static String ExportAllDiagrams_7; - - public static String ExportAllDiagrams_8; - - public static String ExportAllDiagrams_9; - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/PropertyTester.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/PropertyTester.java deleted file mode 100644 index 5cbe271fc26..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/PropertyTester.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 AtoS - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Anass RADOUANI (AtoS) - test property to enable or disable Export All menu item - *******************************************************************************/ - -package org.eclipse.papyrus.export; - -import org.eclipse.papyrus.export.actions.ExportAllDiagramsAction; - -public class PropertyTester extends org.eclipse.core.expressions.PropertyTester { - - public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if("isFileExportable".equals(property) || "isCollectionExportable".equals(property)) { - return ExportAllDiagramsAction.getIFile(receiver) != null; - } - return false; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/ExportAllDiagramsAction.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/ExportAllDiagramsAction.java deleted file mode 100644 index 8b256223386..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/ExportAllDiagramsAction.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Anyware Technologies. 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: Jacques Lescot (Anyware Technologies) - initial API and - * implementation - * Anass RADOUANI (AtoS) - add verification of the selection if it is - * a papyrus file or not - ******************************************************************************/ -package org.eclipse.papyrus.export.actions; - -import java.util.Collection; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.export.ExportAllDiagrams; -import org.eclipse.papyrus.export.internal.Activator; -import org.eclipse.ui.handlers.HandlerUtil; - -public class ExportAllDiagramsAction extends AbstractHandler { - - /** - * Try to retrieve the selected file from the given selection - * - * @param sel - * the selection - * @return the selected file - */ - private IFile convertSelection2File(ISelection sel) { - // get the selected diagrams file - if(sel instanceof IStructuredSelection) { - IStructuredSelection ssel = (IStructuredSelection)sel; - // Only one file should be selected - if(!ssel.isEmpty() && ssel.size() == 1) { - Object selectedObj = ssel.getFirstElement(); - return getIFile(selectedObj); - } - } - return null; - } - - public static IFile getIFile(Object selectedObj) { - IFile result = null; - if(selectedObj instanceof IFile) { - result = (IFile)selectedObj; - } - // Try to adapt - if(result == null && selectedObj instanceof IAdaptable) { - result = (IFile)((IAdaptable)selectedObj).getAdapter(IFile.class); - } - // adapt in ifile - if(result == null) { - result = (IFile)Platform.getAdapterManager().getAdapter(selectedObj, IFile.class); - } - if(result == null) { - // try to check if it is a collection - Collection collec = (Collection)Platform.getAdapterManager().getAdapter(selectedObj, Collection.class); - if(collec != null) { - for(Object o : collec) { - if(o instanceof IFile) { - IFile f = (IFile)o; - if("di".equals(f.getFileExtension())) { - result = f; - break; - } - } - } - } - } - return result != null && "di".equals(result.getFileExtension()) ? result : null; - } - - - public Object execute(ExecutionEvent event) throws ExecutionException { - ISelection selection = HandlerUtil.getActiveMenuSelection(event); - ExportAllDiagramsDialog exportPopup = new ExportAllDiagramsDialog(Activator.getActiveWorkbenchShell(), convertSelection2File(selection)); - if(exportPopup.open() == Window.OK) { - final IFile file = convertSelection2File(selection); - ExportAllDiagrams exportAllDiagrams; - exportAllDiagrams = new ExportAllDiagrams(file, exportPopup.getOutputDirectory().getLocation().toString(), exportPopup.getExporter(), exportPopup.getQualifiedName()); - exportAllDiagrams.exportDiagramsToImages(); - } - return null; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/ExportAllDiagramsDialog.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/ExportAllDiagramsDialog.java deleted file mode 100644 index b3785fffec4..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/ExportAllDiagramsDialog.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Anyware Technologies. 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: Jacques Lescot (Anyware Technologies) - initial API and - * implementation - * Anass Radouani (AtoS) - use of ExporterManager removed - ******************************************************************************/ -package org.eclipse.papyrus.export.actions; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -/** - * - * Creation 24 sept. 07 - * - * @author Jacques LESCOT - */ -public class ExportAllDiagramsDialog extends Dialog { - - private ExportComposite dialogComposite; - - private IFile selectedDiagramFile; - - - /** - * @param parentShell - * @param selectedFile - */ - public ExportAllDiagramsDialog(Shell parentShell, IFile selectedFile) { - super(parentShell); - selectedDiagramFile = selectedFile; - setBlockOnOpen(true); - setShellStyle(getShellStyle() | SWT.RESIZE); - } - - @Override - protected Control createDialogArea(Composite parent) { - Composite composite = (Composite)super.createDialogArea(parent); - dialogComposite = new ExportComposite(composite, SWT.NONE); - dialogComposite.setSelectedDiagramFile(selectedDiagramFile); - return composite; - } - - public IResource getOutputDirectory() { - return dialogComposite.getOutputDirectory(); - } - - public String getExporter() { - return dialogComposite.getExporter(); - } - - public boolean getQualifiedName() { - return dialogComposite.getQualifiedName(); - } - - - - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/ExportComposite.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/ExportComposite.java deleted file mode 100644 index 104ab1f4abb..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/ExportComposite.java +++ /dev/null @@ -1,199 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 AtoS - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Anass RADOUANI (AtoS) - *******************************************************************************/ - -package org.eclipse.papyrus.export.actions; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.util.URI; -import org.eclipse.gmf.runtime.diagram.ui.image.ImageFileFormat; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.export.internal.Activator; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.dialogs.ContainerSelectionDialog; - -/** - * ExportAll configuration windows - */ -public class ExportComposite extends Composite { - - // SWT Objects - private Text outputPathTxt; - - private Button outputDirectoryBtn; - - private Combo outputFormatCb; - - private Button btnCheckButton; - - // Configured items - protected IResource outputDirectory; - - protected String exporter; - - protected boolean qualifiedName; - - private IFile selectedDiagramFile; - - /** - * Constructor - * - * @param parent - * @param style - */ - public ExportComposite(Composite parent, int style) { - super(parent, style); - createDialogComposite(); - createDialogContents(); - hookListeners(); - } - - /** - * Create the view of the list of interaction operators - * - * @param parent - * the parent composite to contain this group - */ - protected void createDialogContents() { - Composite composite = new Composite(this, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - composite.setLayout(layout); - composite.setFont(this.getFont()); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label editorConfLbl = new Label(composite, SWT.NONE); - editorConfLbl.setText(Messages.ExportAllDiagramsDialog_0); - outputPathTxt = new Text(composite, SWT.BORDER); - outputPathTxt.setEnabled(false); - outputPathTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - outputDirectoryBtn = new Button(composite, SWT.NONE); - outputDirectoryBtn.setText(Messages.ExportAllDiagramsDialog_1); - - Label outputFormatLbl = new Label(composite, SWT.NONE); - outputFormatLbl.setText(Messages.ExportAllDiagramsDialog_2); - - outputFormatCb = new Combo(composite, SWT.NONE); - GridData gridData2 = new GridData(GridData.FILL_HORIZONTAL); - gridData2.horizontalSpan = 2; - outputFormatCb.setLayoutData(gridData2); - - btnCheckButton = new Button(this, SWT.CHECK); - btnCheckButton.setText(Messages.ExportAllDiagramsDialog_btnCheckButton_text); - - } - - /** - * Create the Dialog Contents - */ - private void createDialogComposite() { - GridLayout dialogLayout = new GridLayout(); - GridData dialogLayoutData = new GridData(GridData.FILL_BOTH); - this.setLayout(dialogLayout); - this.setLayoutData(dialogLayoutData); - } - - private void hookListeners() { - btnCheckButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - qualifiedName = btnCheckButton.getSelection(); - } - }); - - outputDirectoryBtn.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - ContainerSelectionDialog csDialog = new ContainerSelectionDialog(Activator.getActiveWorkbenchShell(), ResourcesPlugin.getWorkspace().getRoot(), true, Messages.ExportAllDiagramsDialog_3); - - - if(csDialog.open() == Window.OK) { - Object[] results = csDialog.getResult(); - if(results.length == 1 && results[0] instanceof IPath) { - URI uri = URI.createPlatformResourceURI(((IPath)results[0]).toString(), true); - outputDirectory = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(uri.toPlatformString(true))); - outputPathTxt.setText(outputDirectory.getLocation().toString()); - } - } - } - }); - - outputFormatCb.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - exporter = outputFormatCb.getText(); - } - }); - } - - /** - * set the file from which diagrams will be exported - * - * @param file - */ - public void setSelectedDiagramFile(IFile file) { - selectedDiagramFile = file; - loadData(); - } - - private void loadData() { - outputDirectory = selectedDiagramFile.getParent(); - outputPathTxt.setText(outputDirectory.getLocation().toString()); - for(ImageFileFormat imageFileFormat : ImageFileFormat.VALUES) { - outputFormatCb.add(imageFileFormat.toString()); - } - - outputFormatCb.setText(ImageFileFormat.getDefaultImageFormat().toString()); - - exporter = outputFormatCb.getText(); - } - - /** - * return the output directory where exported diagrams will be saved - * - * @return - */ - public IResource getOutputDirectory() { - return outputDirectory; - } - - /** - * return the path to the output directory - * - * @return - */ - public String getExporter() { - return exporter; - } - - /** - * return the qualified name of the diagram - * - * @return - */ - public boolean getQualifiedName() { - return qualifiedName; - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/Messages.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/Messages.java deleted file mode 100644 index 084baec31b4..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/Messages.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 AtoS - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Anass RADOUANI (AtoS) - *******************************************************************************/ -package org.eclipse.papyrus.export.actions; - -import org.eclipse.osgi.util.NLS; - -public class Messages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.papyrus.export.actions.messages"; //$NON-NLS-1$ - - public static String ExportAllDiagramsDialog_0; - - public static String ExportAllDiagramsDialog_1; - - public static String ExportAllDiagramsDialog_2; - - public static String ExportAllDiagramsDialog_3; - - public static String ExportAllDiagramsDialog_btnCheckButton_text; - - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/messages.properties b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/messages.properties deleted file mode 100644 index f289fe21a82..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/actions/messages.properties +++ /dev/null @@ -1,5 +0,0 @@ -ExportAllDiagramsDialog_0=Select the output directory : -ExportAllDiagramsDialog_1=Browse... -ExportAllDiagramsDialog_2=Select the output format : -ExportAllDiagramsDialog_3=Please select the output directory -ExportAllDiagramsDialog_btnCheckButton_text=Prefix with qualified name\u00A0 diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/internal/Activator.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/internal/Activator.java deleted file mode 100644 index babf17faf19..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/internal/Activator.java +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Anyware Technologies - * 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: - * David Sciamma (Anyware Technologies) - initial API and implementation - *******************************************************************************/ - -package org.eclipse.papyrus.export.internal; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.papyrus.export"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - plugin = this; - } - - /** - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - } - - /** - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - - /** - * Log an IStatus - * - * @param status - * Status of an operation - */ - public static void log(IStatus status) { - getDefault().getLog().log(status); - } - - /** - * Log a message with given level into the Eclipse log file - * - * @param message - * the message to log - * @param level - * the message priority - */ - public static void log(String message, int level) { - IStatus status = null; - status = new Status(level, PLUGIN_ID, IStatus.OK, message, null); - log(status); - } - - /** - * Log a message with given level into the Eclipse log file - * - * @param message - * the message to log - * @param level - * the message priority - */ - public static void log(String message, int level, Throwable t) { - IStatus status = null; - status = new Status(level, PLUGIN_ID, IStatus.OK, message, t); - log(status); - } - - /** - * Log an exception into the Eclipse log file - * - * @param e - * the exception to log - */ - public static void log(Throwable e) { - Throwable loggedThrowable = e; - if(loggedThrowable instanceof InvocationTargetException) { - loggedThrowable = ((InvocationTargetException)loggedThrowable).getTargetException(); - } - - IStatus status = null; - if(loggedThrowable instanceof CoreException) { - status = ((CoreException)loggedThrowable).getStatus(); - } else { - status = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, "Error", loggedThrowable); - } - log(status); - } - - /** - * Returns the active workbench shell - * - * @return the active workbench shell - */ - public static Shell getActiveWorkbenchShell() { - IWorkbenchWindow workBenchWindow = getActiveWorkbenchWindow(); - if(workBenchWindow == null) { - return null; - } - return workBenchWindow.getShell(); - } - - /** - * Returns the active workbench page or null if none. - * - * @return the active workbench page - */ - public static IWorkbenchPage getActivePage() { - IWorkbenchWindow window = getActiveWorkbenchWindow(); - if(window != null) { - return window.getActivePage(); - } - return null; - } - - /** - * Returns the active workbench window - * - * @return the active workbench window - */ - public static IWorkbenchWindow getActiveWorkbenchWindow() { - if(getDefault() == null) { - return null; - } - IWorkbench workBench = getDefault().getWorkbench(); - if(workBench == null) { - return null; - } - return workBench.getActiveWorkbenchWindow(); - } - - /** - * Display a dialog box with the specified level - * - * @param title - * title dialog box - * @param message - * message displayed - * @param level - * message level - */ - public static void displayDialog(final String title, final String message, final int level) { - if(level == IStatus.INFO) { - Display.getDefault().asyncExec(new Runnable() { - - public void run() { - MessageDialog.openInformation(getActiveWorkbenchShell(), (title == null) ? "Information" : title, (message == null) ? "" : message); - } - }); - } else if(level == IStatus.WARNING) { - Display.getDefault().asyncExec(new Runnable() { - - public void run() { - MessageDialog.openWarning(getActiveWorkbenchShell(), (title == null) ? "Warning" : title, (message == null) ? "" : message); - } - }); - } else if(level == IStatus.ERROR) { - Display.getDefault().asyncExec(new Runnable() { - - public void run() { - MessageDialog.openError(getActiveWorkbenchShell(), (title == null) ? "Error" : title, (message == null) ? "" : message); - } - }); - } - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/messages.properties b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/messages.properties deleted file mode 100644 index 814adafda6f..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/messages.properties +++ /dev/null @@ -1,24 +0,0 @@ -ExportAllDiagrams_0=Generate -ExportAllDiagrams_1=Diagram generation -ExportAllDiagrams_10=Too long file name has been reduced to : -ExportAllDiagrams_11=error during generation of diagram %s in resource %s -ExportAllDiagrams_12=\ : unload resources -ExportAllDiagrams_13=unload -ExportAllDiagrams_14=[^a-zA-Z0-9ùéèêà&ô_\\-ï] -ExportAllDiagrams_15=_ -ExportAllDiagrams_16=[<].*[>] -ExportAllDiagrams_18=Generation successful \! -ExportAllDiagrams_2=Load ... -ExportAllDiagrams_20=Name cut performed -ExportAllDiagrams_22=Generation failed for some tests -ExportAllDiagrams_24=Generation successful with some warnings -ExportAllDiagrams_25=Generation successful \! -ExportAllDiagrams_26=Generation successful at : -ExportAllDiagrams_27=ExportAll report -ExportAllDiagrams_3=please provide a file in constructor -ExportAllDiagrams_4=Diagram generation -ExportAllDiagrams_5=During export, at least two diagrams had the same name, created files have been renamed to avoid confusion. -ExportAllDiagrams_6=Renaming Issue -ExportAllDiagrams_7=Diagram Generation -ExportAllDiagrams_8=\ : -ExportAllDiagrams_9=An error occurred while trying to create the output file for diagram diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/ExportAllWizard.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/ExportAllWizard.java deleted file mode 100644 index 07233ddc719..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/ExportAllWizard.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 AtoS - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Anass RADOUANI (AtoS) - *******************************************************************************/ - -package org.eclipse.papyrus.export.wizard; - -import java.util.Collection; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.papyrus.export.ExportAllDiagrams; -import org.eclipse.ui.IExportWizard; -import org.eclipse.ui.IWorkbench; - -public class ExportAllWizard extends Wizard implements IExportWizard { - - /** wizard page to export all diagram from a Papyrus model */ - private ExportDiagramsPage page; - - /** error wizard page shown when the selected file is incorrect */ - private ExportDiagramsErrorPage pageError; - - /** Selected file */ - private IFile file; - - public void init(IWorkbench workbench, IStructuredSelection selection) { - file = convertSelection2File(selection); - if(file != null) { - page = new ExportDiagramsPage(file); - addPage(page); - } else { - pageError = new ExportDiagramsErrorPage(); - addPage(pageError); - } - - } - - @Override - public boolean canFinish() { - if(file == null) { - return false; - } - return super.canFinish(); - } - - @Override - public boolean performFinish() { - if(file == null) { - return false; - } else { - if(!page.getExport().getOutputDirectory().isAccessible()) { - page.setErrorMessage(Messages.ExportAllWizard_0); - return false; - } - page.setErrorMessage(null); - new ExportAllDiagrams(file, page.getExport().getOutputDirectory().getLocation().toString(), page.getExport().getExporter(), page.getExport().getQualifiedName()).exportDiagramsToImages(); - return true; - } - } - - /** - * Try to retrieve the selected file from the given selection - * - * @param sel - * the selection - * @return the selected file - */ - private IFile convertSelection2File(ISelection sel) { - // get the selected diagrams file - if(sel instanceof IStructuredSelection) { - IStructuredSelection ssel = (IStructuredSelection)sel; - // Only one file should be selected - if(!ssel.isEmpty() && ssel.size() == 1) { - Object selectedObj = ssel.getFirstElement(); - return getIFile(selectedObj); - } - } - return null; - } - - /** - * return the IFile corresponding to the selection - * - * @param selectedObj - * selected file - * @return - */ - public static IFile getIFile(Object selectedObj) { - IFile result = null; - if(selectedObj instanceof IFile) { - result = (IFile)selectedObj; - } - // Try to adapt - if(result == null && selectedObj instanceof IAdaptable) { - result = (IFile)((IAdaptable)selectedObj).getAdapter(IFile.class); - } - // adapt in ifile - if(result == null) { - result = (IFile)Platform.getAdapterManager().getAdapter(selectedObj, IFile.class); - } - if(result == null) { - // try to check if it is a collection - Collection collec = (Collection)Platform.getAdapterManager().getAdapter(selectedObj, Collection.class); - if(collec != null) { - for(Object o : collec) { - if(o instanceof IFile) { - IFile f = (IFile)o; - if("di".equals(f.getFileExtension())) { //$NON-NLS-1$ - result = f; - break; - } - } - } - } - } - return result != null && "di".equals(result.getFileExtension()) ? result //$NON-NLS-1$ - : null; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/ExportDiagramsErrorPage.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/ExportDiagramsErrorPage.java deleted file mode 100644 index 5d46fa56f1a..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/ExportDiagramsErrorPage.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 AtoS - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Anass RADOUANI (AtoS) - *******************************************************************************/ - -package org.eclipse.papyrus.export.wizard; - -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; - -/** - * error wizard page shown when the selected file is incorrect - */ -public class ExportDiagramsErrorPage extends WizardPage { - - /** - * Create the wizard. - */ - public ExportDiagramsErrorPage() { - super(Messages.ExportDiagramsErrorPage_0); - setTitle(Messages.ExportDiagramsErrorPage_0); - setDescription(Messages.ExportDiagramsErrorPage_2); - } - - /** - * Create contents of the wizard. - * - * @param parent - */ - public void createControl(Composite parent) { - Label label = new Label(parent, SWT.NONE); - label.setText(Messages.ExportDiagramsErrorPage_3); - setControl(label); - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/ExportDiagramsPage.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/ExportDiagramsPage.java deleted file mode 100644 index e96e397e947..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/ExportDiagramsPage.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 AtoS - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Anass RADOUANI (AtoS) - *******************************************************************************/ - -package org.eclipse.papyrus.export.wizard; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.papyrus.export.actions.ExportComposite; - -/** - * wizard page to export all diagram from a Papyrus model - */ -public class ExportDiagramsPage extends WizardPage { - - private ExportComposite export; - - public ExportComposite getExport() { - return export; - } - - private final IFile file; - - /** - * Create the wizard. - */ - public ExportDiagramsPage(IFile file) { - super(Messages.ExportDiagramsPage_0); - this.file = file; - setTitle(Messages.ExportDiagramsPage_0); - setDescription(Messages.ExportDiagramsPage_2); - } - - /** - * Create contents of the wizard. - * - * @param parent - */ - public void createControl(Composite parent) { - export = new ExportComposite(parent, SWT.NONE); - export.setSelectedDiagramFile(file); - setControl(export); - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/Messages.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/Messages.java deleted file mode 100644 index a5f4a6326ba..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/Messages.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 AtoS - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Anass RADOUANI (AtoS) - *******************************************************************************/ - -package org.eclipse.papyrus.export.wizard; - -import org.eclipse.osgi.util.NLS; - -public class Messages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.papyrus.export.wizard.messages"; //$NON-NLS-1$ - - public static String ExportAllWizard_0; - - public static String ExportDiagramsErrorPage_0; - - public static String ExportDiagramsErrorPage_2; - - public static String ExportDiagramsErrorPage_3; - - public static String ExportDiagramsPage_0; - - public static String ExportDiagramsPage_2; - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/messages.properties b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/messages.properties deleted file mode 100644 index 67798f4c499..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/export/wizard/messages.properties +++ /dev/null @@ -1,6 +0,0 @@ -ExportAllWizard_0=Please fixe output directory -ExportDiagramsErrorPage_0=Export all diagrams -ExportDiagramsErrorPage_2=Export all diagrams of a model created with papyrus -ExportDiagramsErrorPage_3=Please select a Papyrus model before trying to export all diagrams -ExportDiagramsPage_0=Export All diagrams -ExportDiagramsPage_2=Export all diagrams of a model created with papyrus diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/ExportAllDiagrams.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/ExportAllDiagrams.java new file mode 100644 index 00000000000..ccd8fcddb60 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/ExportAllDiagrams.java @@ -0,0 +1,417 @@ +/******************************************************************************* + * Copyright (c) 2007 Anyware Technologies. 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: Jacques Lescot (Anyware Technologies) - initial API and + * implementation + * Thibault Landre (Atos Origin) - refactor to extract the exportAllDiagram from ExportAllDiagramsAction + * Alexia Allanic (Atos Origin) - Add margin to not truncate images + * Anass Radouani (AtoS) - add use GMF exporting tool and remove manual extraction + * + ******************************************************************************/ +package org.eclipse.papyrus.infra.export; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.emf.common.command.CommandStack; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.BasicDiagnostic; +import org.eclipse.emf.common.util.Diagnostic; +import org.eclipse.emf.common.util.URI; +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.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; +import org.eclipse.emf.transaction.RollbackException; +import org.eclipse.emf.transaction.Transaction; +import org.eclipse.emf.transaction.TransactionalCommandStack; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.TransactionalEditingDomain.Factory; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; +import org.eclipse.gmf.runtime.diagram.ui.image.ImageFileFormat; +import org.eclipse.gmf.runtime.diagram.ui.render.util.CopyToImageUtil; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.emf.common.ui.dialogs.DiagnosticDialog; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.export.internal.Activator; +import org.eclipse.swt.SWTError; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.WorkspaceModifyOperation; + +public class ExportAllDiagrams { + + private IFile file; + + private String extension; + + private String outputDirectoryPath; + + private IWorkbenchWindow workbenchWindow; + + private boolean displayRenamingInformation; + + private static boolean useDisplayRunnable = true; + + private boolean qualifiedName; + + private BasicDiagnostic diagnostic = new BasicDiagnostic(Diagnostic.OK, "", 0, Messages.ExportAllDiagrams_18, null); //$NON-NLS-1$ + + /** + * Constructor + * + * @param file + * the *.*di file where the diagrams are stored, can be null if + * you use export method with diagrams in parameter + * @param outputDirectoryPath + * the directory in which the images will be saved + * @param extension + * the image extension + * @param imageExporter + * the image exporter used. The image exporter should be coherent + * with the file extension + */ + public ExportAllDiagrams(IFile file, String outputDirectoryPath, String extension, boolean qualifiedName) { + this.file = file; + this.extension = extension; + this.outputDirectoryPath = outputDirectoryPath; + try { + this.workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + } catch (IllegalStateException e) { + this.workbenchWindow = null; + // is normal in batch mode + } + this.displayRenamingInformation = true; + this.qualifiedName = qualifiedName; + } + + /** + * Run the export of all diagrams of a *.*di file into images in the given + * format. + */ + public void exportDiagramsToImages() { + final IRunnableWithProgress op = new WorkspaceModifyOperation() { + + @Override + protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { + if(monitor == null) { + monitor = new NullProgressMonitor(); + } + final IProgressMonitor newMonitor = monitor; + export(newMonitor); + } + + }; + Job job = new Job(Messages.ExportAllDiagrams_0) { + + @Override + public IStatus run(IProgressMonitor monitor) { + try { + op.run(monitor); + } catch (InvocationTargetException e) { + } catch (InterruptedException e) { + } + return Status.OK_STATUS; + } + }; + job.setUser(true); + job.schedule(); + + } + + /** + * Export all diagrams of the IFile + * + * @param newMonitor + */ + private void export(IProgressMonitor newMonitor) { + // Then iterates on all the diagrams and export them one by one + newMonitor.beginTask(Messages.ExportAllDiagrams_1, 10); + newMonitor.subTask(Messages.ExportAllDiagrams_2); + if(file != null) { + final ResourceSetImpl resourceSet = new ResourceSetImpl(); + resourceSet.getLoadOptions().put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, true); + resourceSet.getLoadOptions().put(XMLResource.OPTION_DEFER_ATTACHMENT, true); + resourceSet.getResource(URI.createPlatformResourceURI(file.getFullPath().toString(), true), true); + + // create transactional editing domain + + TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(resourceSet); + if(editingDomain == null) { + Factory factory = TransactionalEditingDomain.Factory.INSTANCE; + editingDomain = factory.createEditingDomain(resourceSet); + } + + AbstractTransactionalCommand com = new AbstractTransactionalCommand(editingDomain, "Resolve", Collections.emptyList()) { + + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + EcoreUtil.resolveAll(resourceSet); + return null; + } + }; + + // bypass all the transaction/validate/notification mechanisms, it is a lot faster and it has no impact + // since we do not modify the model + CommandStack commandStack = editingDomain.getCommandStack(); + if(commandStack instanceof TransactionalCommandStack) { + TransactionalCommandStack stack = (TransactionalCommandStack)commandStack; + Map options = new HashMap(); + options.put(Transaction.OPTION_NO_NOTIFICATIONS, Boolean.TRUE); + options.put(Transaction.OPTION_NO_UNDO, Boolean.TRUE); + options.put(Transaction.OPTION_UNPROTECTED, Boolean.TRUE); + options.put(Transaction.OPTION_IS_UNDO_REDO_TRANSACTION, Boolean.FALSE); + options.put(Transaction.OPTION_NO_TRIGGERS, Boolean.TRUE); + options.put(Transaction.OPTION_VALIDATE_EDIT, Boolean.FALSE); + options.put(Transaction.OPTION_VALIDATE_EDIT_CONTEXT, Boolean.FALSE); + try { + stack.execute(new GMFtoEMFCommandWrapper(com), options); + } catch (InterruptedException e) { + } catch (RollbackException e) { + } + } else { + Activator.log("no transactional editing domain found", Status.WARNING); + } + + List diagrams = new ArrayList(); + if(newMonitor.isCanceled()) { + return; + } + for(Iterator i = resourceSet.getAllContents(); i.hasNext();) { + Notifier n = i.next(); + if(n instanceof Diagram) { + diagrams.add((Diagram)n); + } + } + if(newMonitor.isCanceled()) { + return; + } + newMonitor.worked(1); + export(new SubProgressMonitor(newMonitor, 9), diagrams); + } else { + Activator.log(new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.ExportAllDiagrams_3)); + } + + } + + /** + * export all the diagrams in image + * + * @param newMonitor + * , the monitor + * @param diagrams + * , the emf element diagrams + */ + public void export(IProgressMonitor newMonitor, List diagrams) { + boolean duplicates; + newMonitor.beginTask(Messages.ExportAllDiagrams_4, 10); + duplicates = createDiagramFiles(new SubProgressMonitor(newMonitor, 9), diagrams); + unloadResources(new SubProgressMonitor(newMonitor, 1), diagrams); + + // Alert the user that file names have been changed to avoid duplicates + if(duplicates && displayRenamingInformation) { + + final String message = Messages.ExportAllDiagrams_5; + if(workbenchWindow != null && workbenchWindow.getShell() != null) { + + BasicDiagnostic newDiagnostic = new BasicDiagnostic(Diagnostic.WARNING, "", 0, message, null); //$NON-NLS-1$ + diagnostic.add(newDiagnostic); + + } else { + Activator.log(new Status(Status.INFO, Activator.PLUGIN_ID, message)); + } + + } + int severity = diagnostic.recomputeSeverity(); + if(severity == Diagnostic.ERROR) { + BasicDiagnostic oldDiagnostic = diagnostic; + diagnostic = new BasicDiagnostic(Diagnostic.ERROR, "", 0, Messages.ExportAllDiagrams_22, null); //$NON-NLS-1$ + diagnostic.addAll(oldDiagnostic); + } else if(severity == Diagnostic.WARNING) { + BasicDiagnostic oldDiagnostic = diagnostic; + diagnostic = new BasicDiagnostic(Diagnostic.WARNING, "", 0, Messages.ExportAllDiagrams_24, null); //$NON-NLS-1$ + diagnostic.addAll(oldDiagnostic); + } else if(severity == Diagnostic.OK) { + if(workbenchWindow != null && workbenchWindow.getShell() != null) { + Display.getDefault().syncExec(new Runnable() { + + public void run() { + MessageDialog.openInformation(Activator.getActiveWorkbenchShell(), Messages.ExportAllDiagrams_25, Messages.ExportAllDiagrams_26 + outputDirectoryPath); + } + }); + } + } + + Display.getDefault().syncExec(new Runnable() { + + public void run() { + DiagnosticDialog.open(Activator.getActiveWorkbenchShell(), Messages.ExportAllDiagrams_27, "", diagnostic); //$NON-NLS-2$ + } + }); + + } + + /** + * Browse all the diagrams and export them + * + * @param newMonitor + * @param findAllDiagrams + * @return + */ + private boolean createDiagramFiles(final IProgressMonitor newMonitor, List diagrams) { + boolean duplicates = false; + boolean nameCut = false; + try { + List diagramNames = new ArrayList(); + try { + newMonitor.beginTask(Messages.ExportAllDiagrams_7, diagrams.size()); + for(final Diagram diagram : diagrams) { + if(newMonitor.isCanceled()) { + break; + } + String label = ""; //$NON-NLS-1$ + if(qualifiedName) { + ComposedAdapterFactory composedAdapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); + composedAdapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory()); + IItemLabelProvider itemLabelFactory = (IItemLabelProvider)composedAdapterFactory.adapt(diagram.getElement(), IItemLabelProvider.class); + label = itemLabelFactory.getText(diagram.getElement()).replace(Messages.ExportAllDiagrams_16, "") + "_"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ + } + String uniqueFileName = encodeFileName(label + diagram.getName()); + if(uniqueFileName.length() > 150) { + nameCut = true; + uniqueFileName = uniqueFileName.substring(0, 150); + } + if(diagramNames.contains(uniqueFileName)) { + duplicates = true; + uniqueFileName = getFirstAvailableName(uniqueFileName, diagramNames, 1); + } + + if(nameCut) { + + BasicDiagnostic newDiagnostic = new BasicDiagnostic(Diagnostic.WARNING, "", 0, Messages.ExportAllDiagrams_10 + uniqueFileName, null); //$NON-NLS-1$ + diagnostic.add(newDiagnostic); + + nameCut = false; + } + + final String finalUniqueFileName = uniqueFileName; + diagramNames.add(uniqueFileName); + newMonitor.subTask(Messages.ExportAllDiagrams_8 + uniqueFileName); + if(useDisplayRunnable) { + Display.getDefault().syncExec(new Runnable() { + + public void run() { + exportDiagram(finalUniqueFileName, diagram, newMonitor); + } + }); + } else { + exportDiagram(uniqueFileName, diagram, newMonitor); + } + newMonitor.worked(1); + } + } catch (SWTError e) { + String message = Messages.ExportAllDiagrams_9; + Activator.log(new Exception(message, e)); + } + } catch (Exception e) { + e.printStackTrace(); + } + return duplicates; + } + + private void exportDiagram(String uniqueFileName, Diagram diagram, IProgressMonitor newMonitor) { + CopyToImageUtil copyImageUtil = new CopyToImageUtil(); + try { + copyImageUtil.copyToImage(diagram, new Path(outputDirectoryPath + File.separator + uniqueFileName + "." //$NON-NLS-1$ + + ImageFileFormat.resolveImageFormat(extension)), ImageFileFormat.resolveImageFormat(extension), new SubProgressMonitor(newMonitor, 1), PreferencesHint.USE_DEFAULTS); + } catch (Throwable e) { + BasicDiagnostic newDiagnostic = new BasicDiagnostic(Diagnostic.ERROR, "", 0, String.format(Messages.ExportAllDiagrams_11, uniqueFileName, diagram.eResource().getURI().toString()), null); //$NON-NLS-1$ + diagnostic.add(newDiagnostic); + Activator.log(String.format(Messages.ExportAllDiagrams_11, uniqueFileName, diagram.eResource().getURI().toString()), IStatus.ERROR, e); + } + } + + public void unloadResources(IProgressMonitor newMonitor, List diagrams) { + if(newMonitor == null) { + newMonitor = new NullProgressMonitor(); + } + newMonitor.subTask(Messages.ExportAllDiagrams_12); + if(diagrams != null && !diagrams.isEmpty()) { + ResourceSet resourceSet2 = diagrams.get(0).eResource().getResourceSet(); + newMonitor.beginTask(Messages.ExportAllDiagrams_13, resourceSet2.getResources().size()); + for(int i = resourceSet2.getResources().size() - 1; i >= 0; i--) { + try { + Resource r = resourceSet2.getResources().get(i); + if(r.isLoaded()) { + r.unload(); + } + } catch (Exception e) { + // not very clean but it sometimes occurs + } + newMonitor.worked(1); + } + } + + } + + /** + * Escape all characters that may result in a wrong file name + * + * @param pathName + * a file name to encode + * @return The encoded file name + */ + private String encodeFileName(String pathName) { + pathName = pathName.trim(); + pathName = pathName.replaceAll(Messages.ExportAllDiagrams_14, Messages.ExportAllDiagrams_15); + pathName = pathName.replaceAll("_-_", "-"); //$NON-NLS-1$ //$NON-NLS-2$ + while(pathName.contains("__")) { //$NON-NLS-1$ + pathName = pathName.replaceAll("__", "_"); //$NON-NLS-1$ //$NON-NLS-2$ + } + if(pathName.startsWith("_")) { //$NON-NLS-1$ + pathName = pathName.replaceFirst("_", ""); //$NON-NLS-1$ //$NON-NLS-2$ + } + if(pathName.endsWith("_")) { //$NON-NLS-1$ + pathName = pathName.substring(0, pathName.length() - 1); + } + + return pathName; + // return URLEncoder.encode(pathName, "UTF-8").replaceAll("[*]", "_"); + } + + private String getFirstAvailableName(String commonBasis, List existingNames, int cpt) { + if(existingNames.contains(commonBasis + cpt)) { + return getFirstAvailableName(commonBasis, existingNames, cpt + 1); + } + return commonBasis + cpt; + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/ExportException.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/ExportException.java new file mode 100644 index 00000000000..d61d51ef6f7 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/ExportException.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2005 Anyware Technologies + * 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: + * David Sciamma (Anyware Technologies) - initial API and implementation + *******************************************************************************/ + +package org.eclipse.papyrus.infra.export; + +/** + * Exception raised during an image export + * + * @author David Sciamma + */ +public class ExportException extends Exception { + + /** + * serialVersionUID + */ + private static final long serialVersionUID = 5787608979737224951L; + + /** + * Constructor + */ + public ExportException() { + super(); + } + + /** + * Constructor + * + * @param message + */ + public ExportException(String message) { + super(message); + } + + /** + * Constructor + * + * @param cause + */ + public ExportException(Throwable cause) { + super(cause); + } + + /** + * Constructor + * + * @param message + * @param cause + */ + public ExportException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/Messages.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/Messages.java new file mode 100644 index 00000000000..b6d0f1eeb8a --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/Messages.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2011 AtoS + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Anass RADOUANI (AtoS) + *******************************************************************************/ +package org.eclipse.papyrus.infra.export; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + + private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.export.messages"; //$NON-NLS-1$ + + public static String ExportAllDiagrams_0; + + public static String ExportAllDiagrams_1; + + public static String ExportAllDiagrams_10; + + public static String ExportAllDiagrams_11; + + public static String ExportAllDiagrams_12; + + public static String ExportAllDiagrams_13; + + public static String ExportAllDiagrams_14; + + public static String ExportAllDiagrams_15; + + public static String ExportAllDiagrams_16; + + public static String ExportAllDiagrams_18; + + public static String ExportAllDiagrams_2; + + public static String ExportAllDiagrams_20; + + public static String ExportAllDiagrams_22; + + public static String ExportAllDiagrams_24; + + public static String ExportAllDiagrams_25; + + public static String ExportAllDiagrams_26; + + public static String ExportAllDiagrams_27; + + public static String ExportAllDiagrams_3; + + public static String ExportAllDiagrams_4; + + public static String ExportAllDiagrams_5; + + public static String ExportAllDiagrams_6; + + public static String ExportAllDiagrams_7; + + public static String ExportAllDiagrams_8; + + public static String ExportAllDiagrams_9; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/PropertyTester.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/PropertyTester.java new file mode 100644 index 00000000000..da6e700a53b --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/PropertyTester.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2011 AtoS + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Anass RADOUANI (AtoS) - test property to enable or disable Export All menu item + *******************************************************************************/ + +package org.eclipse.papyrus.infra.export; + +import org.eclipse.papyrus.infra.export.actions.ExportAllDiagramsAction; + +public class PropertyTester extends org.eclipse.core.expressions.PropertyTester { + + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { + if("isFileExportable".equals(property) || "isCollectionExportable".equals(property)) { + return ExportAllDiagramsAction.getIFile(receiver) != null; + } + return false; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/ExportAllDiagramsAction.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/ExportAllDiagramsAction.java new file mode 100644 index 00000000000..5b864bb6795 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/ExportAllDiagramsAction.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2007 Anyware Technologies. 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: Jacques Lescot (Anyware Technologies) - initial API and + * implementation + * Anass RADOUANI (AtoS) - add verification of the selection if it is + * a papyrus file or not + ******************************************************************************/ +package org.eclipse.papyrus.infra.export.actions; + +import java.util.Collection; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.infra.export.ExportAllDiagrams; +import org.eclipse.papyrus.infra.export.internal.Activator; +import org.eclipse.ui.handlers.HandlerUtil; + +public class ExportAllDiagramsAction extends AbstractHandler { + + /** + * Try to retrieve the selected file from the given selection + * + * @param sel + * the selection + * @return the selected file + */ + private IFile convertSelection2File(ISelection sel) { + // get the selected diagrams file + if(sel instanceof IStructuredSelection) { + IStructuredSelection ssel = (IStructuredSelection)sel; + // Only one file should be selected + if(!ssel.isEmpty() && ssel.size() == 1) { + Object selectedObj = ssel.getFirstElement(); + return getIFile(selectedObj); + } + } + return null; + } + + public static IFile getIFile(Object selectedObj) { + IFile result = null; + if(selectedObj instanceof IFile) { + result = (IFile)selectedObj; + } + // Try to adapt + if(result == null && selectedObj instanceof IAdaptable) { + result = (IFile)((IAdaptable)selectedObj).getAdapter(IFile.class); + } + // adapt in ifile + if(result == null) { + result = (IFile)Platform.getAdapterManager().getAdapter(selectedObj, IFile.class); + } + if(result == null) { + // try to check if it is a collection + Collection collec = (Collection)Platform.getAdapterManager().getAdapter(selectedObj, Collection.class); + if(collec != null) { + for(Object o : collec) { + if(o instanceof IFile) { + IFile f = (IFile)o; + if("di".equals(f.getFileExtension())) { + result = f; + break; + } + } + } + } + } + return result != null && "di".equals(result.getFileExtension()) ? result : null; + } + + + public Object execute(ExecutionEvent event) throws ExecutionException { + ISelection selection = HandlerUtil.getActiveMenuSelection(event); + ExportAllDiagramsDialog exportPopup = new ExportAllDiagramsDialog(Activator.getActiveWorkbenchShell(), convertSelection2File(selection)); + if(exportPopup.open() == Window.OK) { + final IFile file = convertSelection2File(selection); + ExportAllDiagrams exportAllDiagrams; + exportAllDiagrams = new ExportAllDiagrams(file, exportPopup.getOutputDirectory().getLocation().toString(), exportPopup.getExporter(), exportPopup.getQualifiedName()); + exportAllDiagrams.exportDiagramsToImages(); + } + return null; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/ExportAllDiagramsDialog.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/ExportAllDiagramsDialog.java new file mode 100644 index 00000000000..20c8960f7a0 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/ExportAllDiagramsDialog.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2007 Anyware Technologies. 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: Jacques Lescot (Anyware Technologies) - initial API and + * implementation + * Anass Radouani (AtoS) - use of ExporterManager removed + ******************************************************************************/ +package org.eclipse.papyrus.infra.export.actions; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +/** + * + * Creation 24 sept. 07 + * + * @author Jacques LESCOT + */ +public class ExportAllDiagramsDialog extends Dialog { + + private ExportComposite dialogComposite; + + private IFile selectedDiagramFile; + + + /** + * @param parentShell + * @param selectedFile + */ + public ExportAllDiagramsDialog(Shell parentShell, IFile selectedFile) { + super(parentShell); + selectedDiagramFile = selectedFile; + setBlockOnOpen(true); + setShellStyle(getShellStyle() | SWT.RESIZE); + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite)super.createDialogArea(parent); + dialogComposite = new ExportComposite(composite, SWT.NONE); + dialogComposite.setSelectedDiagramFile(selectedDiagramFile); + return composite; + } + + public IResource getOutputDirectory() { + return dialogComposite.getOutputDirectory(); + } + + public String getExporter() { + return dialogComposite.getExporter(); + } + + public boolean getQualifiedName() { + return dialogComposite.getQualifiedName(); + } + + + + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/ExportComposite.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/ExportComposite.java new file mode 100644 index 00000000000..ee3eafb5d29 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/ExportComposite.java @@ -0,0 +1,199 @@ +/******************************************************************************* + * Copyright (c) 2011 AtoS + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Anass RADOUANI (AtoS) + *******************************************************************************/ + +package org.eclipse.papyrus.infra.export.actions; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.emf.common.util.URI; +import org.eclipse.gmf.runtime.diagram.ui.image.ImageFileFormat; +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.infra.export.internal.Activator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.ContainerSelectionDialog; + +/** + * ExportAll configuration windows + */ +public class ExportComposite extends Composite { + + // SWT Objects + private Text outputPathTxt; + + private Button outputDirectoryBtn; + + private Combo outputFormatCb; + + private Button btnCheckButton; + + // Configured items + protected IResource outputDirectory; + + protected String exporter; + + protected boolean qualifiedName; + + private IFile selectedDiagramFile; + + /** + * Constructor + * + * @param parent + * @param style + */ + public ExportComposite(Composite parent, int style) { + super(parent, style); + createDialogComposite(); + createDialogContents(); + hookListeners(); + } + + /** + * Create the view of the list of interaction operators + * + * @param parent + * the parent composite to contain this group + */ + protected void createDialogContents() { + Composite composite = new Composite(this, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 3; + composite.setLayout(layout); + composite.setFont(this.getFont()); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + Label editorConfLbl = new Label(composite, SWT.NONE); + editorConfLbl.setText(Messages.ExportAllDiagramsDialog_0); + outputPathTxt = new Text(composite, SWT.BORDER); + outputPathTxt.setEnabled(false); + outputPathTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + outputDirectoryBtn = new Button(composite, SWT.NONE); + outputDirectoryBtn.setText(Messages.ExportAllDiagramsDialog_1); + + Label outputFormatLbl = new Label(composite, SWT.NONE); + outputFormatLbl.setText(Messages.ExportAllDiagramsDialog_2); + + outputFormatCb = new Combo(composite, SWT.NONE); + GridData gridData2 = new GridData(GridData.FILL_HORIZONTAL); + gridData2.horizontalSpan = 2; + outputFormatCb.setLayoutData(gridData2); + + btnCheckButton = new Button(this, SWT.CHECK); + btnCheckButton.setText(Messages.ExportAllDiagramsDialog_btnCheckButton_text); + + } + + /** + * Create the Dialog Contents + */ + private void createDialogComposite() { + GridLayout dialogLayout = new GridLayout(); + GridData dialogLayoutData = new GridData(GridData.FILL_BOTH); + this.setLayout(dialogLayout); + this.setLayoutData(dialogLayoutData); + } + + private void hookListeners() { + btnCheckButton.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + qualifiedName = btnCheckButton.getSelection(); + } + }); + + outputDirectoryBtn.addSelectionListener(new SelectionAdapter() { + + public void widgetSelected(SelectionEvent e) { + ContainerSelectionDialog csDialog = new ContainerSelectionDialog(Activator.getActiveWorkbenchShell(), ResourcesPlugin.getWorkspace().getRoot(), true, Messages.ExportAllDiagramsDialog_3); + + + if(csDialog.open() == Window.OK) { + Object[] results = csDialog.getResult(); + if(results.length == 1 && results[0] instanceof IPath) { + URI uri = URI.createPlatformResourceURI(((IPath)results[0]).toString(), true); + outputDirectory = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(uri.toPlatformString(true))); + outputPathTxt.setText(outputDirectory.getLocation().toString()); + } + } + } + }); + + outputFormatCb.addSelectionListener(new SelectionAdapter() { + + public void widgetSelected(SelectionEvent e) { + exporter = outputFormatCb.getText(); + } + }); + } + + /** + * set the file from which diagrams will be exported + * + * @param file + */ + public void setSelectedDiagramFile(IFile file) { + selectedDiagramFile = file; + loadData(); + } + + private void loadData() { + outputDirectory = selectedDiagramFile.getParent(); + outputPathTxt.setText(outputDirectory.getLocation().toString()); + for(ImageFileFormat imageFileFormat : ImageFileFormat.VALUES) { + outputFormatCb.add(imageFileFormat.toString()); + } + + outputFormatCb.setText(ImageFileFormat.getDefaultImageFormat().toString()); + + exporter = outputFormatCb.getText(); + } + + /** + * return the output directory where exported diagrams will be saved + * + * @return + */ + public IResource getOutputDirectory() { + return outputDirectory; + } + + /** + * return the path to the output directory + * + * @return + */ + public String getExporter() { + return exporter; + } + + /** + * return the qualified name of the diagram + * + * @return + */ + public boolean getQualifiedName() { + return qualifiedName; + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/Messages.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/Messages.java new file mode 100644 index 00000000000..5f143b02aa6 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/Messages.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2011 AtoS + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Anass RADOUANI (AtoS) + *******************************************************************************/ +package org.eclipse.papyrus.infra.export.actions; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + + private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.export.actions.messages"; //$NON-NLS-1$ + + public static String ExportAllDiagramsDialog_0; + + public static String ExportAllDiagramsDialog_1; + + public static String ExportAllDiagramsDialog_2; + + public static String ExportAllDiagramsDialog_3; + + public static String ExportAllDiagramsDialog_btnCheckButton_text; + + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/messages.properties b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/messages.properties new file mode 100644 index 00000000000..f289fe21a82 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/actions/messages.properties @@ -0,0 +1,5 @@ +ExportAllDiagramsDialog_0=Select the output directory : +ExportAllDiagramsDialog_1=Browse... +ExportAllDiagramsDialog_2=Select the output format : +ExportAllDiagramsDialog_3=Please select the output directory +ExportAllDiagramsDialog_btnCheckButton_text=Prefix with qualified name\u00A0 diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/internal/Activator.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/internal/Activator.java new file mode 100644 index 00000000000..0931cbbf080 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/internal/Activator.java @@ -0,0 +1,205 @@ +/******************************************************************************* + * Copyright (c) 2005 Anyware Technologies + * 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: + * David Sciamma (Anyware Technologies) - initial API and implementation + *******************************************************************************/ + +package org.eclipse.papyrus.infra.export.internal; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.export"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + plugin = this; + } + + /** + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + } + + /** + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Log an IStatus + * + * @param status + * Status of an operation + */ + public static void log(IStatus status) { + getDefault().getLog().log(status); + } + + /** + * Log a message with given level into the Eclipse log file + * + * @param message + * the message to log + * @param level + * the message priority + */ + public static void log(String message, int level) { + IStatus status = null; + status = new Status(level, PLUGIN_ID, IStatus.OK, message, null); + log(status); + } + + /** + * Log a message with given level into the Eclipse log file + * + * @param message + * the message to log + * @param level + * the message priority + */ + public static void log(String message, int level, Throwable t) { + IStatus status = null; + status = new Status(level, PLUGIN_ID, IStatus.OK, message, t); + log(status); + } + + /** + * Log an exception into the Eclipse log file + * + * @param e + * the exception to log + */ + public static void log(Throwable e) { + Throwable loggedThrowable = e; + if(loggedThrowable instanceof InvocationTargetException) { + loggedThrowable = ((InvocationTargetException)loggedThrowable).getTargetException(); + } + + IStatus status = null; + if(loggedThrowable instanceof CoreException) { + status = ((CoreException)loggedThrowable).getStatus(); + } else { + status = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, "Error", loggedThrowable); + } + log(status); + } + + /** + * Returns the active workbench shell + * + * @return the active workbench shell + */ + public static Shell getActiveWorkbenchShell() { + IWorkbenchWindow workBenchWindow = getActiveWorkbenchWindow(); + if(workBenchWindow == null) { + return null; + } + return workBenchWindow.getShell(); + } + + /** + * Returns the active workbench page or null if none. + * + * @return the active workbench page + */ + public static IWorkbenchPage getActivePage() { + IWorkbenchWindow window = getActiveWorkbenchWindow(); + if(window != null) { + return window.getActivePage(); + } + return null; + } + + /** + * Returns the active workbench window + * + * @return the active workbench window + */ + public static IWorkbenchWindow getActiveWorkbenchWindow() { + if(getDefault() == null) { + return null; + } + IWorkbench workBench = getDefault().getWorkbench(); + if(workBench == null) { + return null; + } + return workBench.getActiveWorkbenchWindow(); + } + + /** + * Display a dialog box with the specified level + * + * @param title + * title dialog box + * @param message + * message displayed + * @param level + * message level + */ + public static void displayDialog(final String title, final String message, final int level) { + if(level == IStatus.INFO) { + Display.getDefault().asyncExec(new Runnable() { + + public void run() { + MessageDialog.openInformation(getActiveWorkbenchShell(), (title == null) ? "Information" : title, (message == null) ? "" : message); + } + }); + } else if(level == IStatus.WARNING) { + Display.getDefault().asyncExec(new Runnable() { + + public void run() { + MessageDialog.openWarning(getActiveWorkbenchShell(), (title == null) ? "Warning" : title, (message == null) ? "" : message); + } + }); + } else if(level == IStatus.ERROR) { + Display.getDefault().asyncExec(new Runnable() { + + public void run() { + MessageDialog.openError(getActiveWorkbenchShell(), (title == null) ? "Error" : title, (message == null) ? "" : message); + } + }); + } + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/messages.properties b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/messages.properties new file mode 100644 index 00000000000..814adafda6f --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/messages.properties @@ -0,0 +1,24 @@ +ExportAllDiagrams_0=Generate +ExportAllDiagrams_1=Diagram generation +ExportAllDiagrams_10=Too long file name has been reduced to : +ExportAllDiagrams_11=error during generation of diagram %s in resource %s +ExportAllDiagrams_12=\ : unload resources +ExportAllDiagrams_13=unload +ExportAllDiagrams_14=[^a-zA-Z0-9ùéèêà&ô_\\-ï] +ExportAllDiagrams_15=_ +ExportAllDiagrams_16=[<].*[>] +ExportAllDiagrams_18=Generation successful \! +ExportAllDiagrams_2=Load ... +ExportAllDiagrams_20=Name cut performed +ExportAllDiagrams_22=Generation failed for some tests +ExportAllDiagrams_24=Generation successful with some warnings +ExportAllDiagrams_25=Generation successful \! +ExportAllDiagrams_26=Generation successful at : +ExportAllDiagrams_27=ExportAll report +ExportAllDiagrams_3=please provide a file in constructor +ExportAllDiagrams_4=Diagram generation +ExportAllDiagrams_5=During export, at least two diagrams had the same name, created files have been renamed to avoid confusion. +ExportAllDiagrams_6=Renaming Issue +ExportAllDiagrams_7=Diagram Generation +ExportAllDiagrams_8=\ : +ExportAllDiagrams_9=An error occurred while trying to create the output file for diagram diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/ExportAllWizard.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/ExportAllWizard.java new file mode 100644 index 00000000000..72e0e46060b --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/ExportAllWizard.java @@ -0,0 +1,131 @@ +/******************************************************************************* + * Copyright (c) 2011 AtoS + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Anass RADOUANI (AtoS) + *******************************************************************************/ + +package org.eclipse.papyrus.infra.export.wizard; + +import java.util.Collection; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.papyrus.infra.export.ExportAllDiagrams; +import org.eclipse.ui.IExportWizard; +import org.eclipse.ui.IWorkbench; + +public class ExportAllWizard extends Wizard implements IExportWizard { + + /** wizard page to export all diagram from a Papyrus model */ + private ExportDiagramsPage page; + + /** error wizard page shown when the selected file is incorrect */ + private ExportDiagramsErrorPage pageError; + + /** Selected file */ + private IFile file; + + public void init(IWorkbench workbench, IStructuredSelection selection) { + file = convertSelection2File(selection); + if(file != null) { + page = new ExportDiagramsPage(file); + addPage(page); + } else { + pageError = new ExportDiagramsErrorPage(); + addPage(pageError); + } + + } + + @Override + public boolean canFinish() { + if(file == null) { + return false; + } + return super.canFinish(); + } + + @Override + public boolean performFinish() { + if(file == null) { + return false; + } else { + if(!page.getExport().getOutputDirectory().isAccessible()) { + page.setErrorMessage(Messages.ExportAllWizard_0); + return false; + } + page.setErrorMessage(null); + new ExportAllDiagrams(file, page.getExport().getOutputDirectory().getLocation().toString(), page.getExport().getExporter(), page.getExport().getQualifiedName()).exportDiagramsToImages(); + return true; + } + } + + /** + * Try to retrieve the selected file from the given selection + * + * @param sel + * the selection + * @return the selected file + */ + private IFile convertSelection2File(ISelection sel) { + // get the selected diagrams file + if(sel instanceof IStructuredSelection) { + IStructuredSelection ssel = (IStructuredSelection)sel; + // Only one file should be selected + if(!ssel.isEmpty() && ssel.size() == 1) { + Object selectedObj = ssel.getFirstElement(); + return getIFile(selectedObj); + } + } + return null; + } + + /** + * return the IFile corresponding to the selection + * + * @param selectedObj + * selected file + * @return + */ + public static IFile getIFile(Object selectedObj) { + IFile result = null; + if(selectedObj instanceof IFile) { + result = (IFile)selectedObj; + } + // Try to adapt + if(result == null && selectedObj instanceof IAdaptable) { + result = (IFile)((IAdaptable)selectedObj).getAdapter(IFile.class); + } + // adapt in ifile + if(result == null) { + result = (IFile)Platform.getAdapterManager().getAdapter(selectedObj, IFile.class); + } + if(result == null) { + // try to check if it is a collection + Collection collec = (Collection)Platform.getAdapterManager().getAdapter(selectedObj, Collection.class); + if(collec != null) { + for(Object o : collec) { + if(o instanceof IFile) { + IFile f = (IFile)o; + if("di".equals(f.getFileExtension())) { //$NON-NLS-1$ + result = f; + break; + } + } + } + } + } + return result != null && "di".equals(result.getFileExtension()) ? result //$NON-NLS-1$ + : null; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/ExportDiagramsErrorPage.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/ExportDiagramsErrorPage.java new file mode 100644 index 00000000000..65e8096edab --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/ExportDiagramsErrorPage.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2011 AtoS + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Anass RADOUANI (AtoS) + *******************************************************************************/ + +package org.eclipse.papyrus.infra.export.wizard; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +/** + * error wizard page shown when the selected file is incorrect + */ +public class ExportDiagramsErrorPage extends WizardPage { + + /** + * Create the wizard. + */ + public ExportDiagramsErrorPage() { + super(Messages.ExportDiagramsErrorPage_0); + setTitle(Messages.ExportDiagramsErrorPage_0); + setDescription(Messages.ExportDiagramsErrorPage_2); + } + + /** + * Create contents of the wizard. + * + * @param parent + */ + public void createControl(Composite parent) { + Label label = new Label(parent, SWT.NONE); + label.setText(Messages.ExportDiagramsErrorPage_3); + setControl(label); + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/ExportDiagramsPage.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/ExportDiagramsPage.java new file mode 100644 index 00000000000..42b7fbeca5b --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/ExportDiagramsPage.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2011 AtoS + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Anass RADOUANI (AtoS) + *******************************************************************************/ + +package org.eclipse.papyrus.infra.export.wizard; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.papyrus.infra.export.actions.ExportComposite; + +/** + * wizard page to export all diagram from a Papyrus model + */ +public class ExportDiagramsPage extends WizardPage { + + private ExportComposite export; + + public ExportComposite getExport() { + return export; + } + + private final IFile file; + + /** + * Create the wizard. + */ + public ExportDiagramsPage(IFile file) { + super(Messages.ExportDiagramsPage_0); + this.file = file; + setTitle(Messages.ExportDiagramsPage_0); + setDescription(Messages.ExportDiagramsPage_2); + } + + /** + * Create contents of the wizard. + * + * @param parent + */ + public void createControl(Composite parent) { + export = new ExportComposite(parent, SWT.NONE); + export.setSelectedDiagramFile(file); + setControl(export); + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/Messages.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/Messages.java new file mode 100644 index 00000000000..058f14a2e38 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/Messages.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2011 AtoS + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Anass RADOUANI (AtoS) + *******************************************************************************/ + +package org.eclipse.papyrus.infra.export.wizard; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + + private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.export.wizard.messages"; //$NON-NLS-1$ + + public static String ExportAllWizard_0; + + public static String ExportDiagramsErrorPage_0; + + public static String ExportDiagramsErrorPage_2; + + public static String ExportDiagramsErrorPage_3; + + public static String ExportDiagramsPage_0; + + public static String ExportDiagramsPage_2; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/messages.properties b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/messages.properties new file mode 100644 index 00000000000..67798f4c499 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/wizard/messages.properties @@ -0,0 +1,6 @@ +ExportAllWizard_0=Please fixe output directory +ExportDiagramsErrorPage_0=Export all diagrams +ExportDiagramsErrorPage_2=Export all diagrams of a model created with papyrus +ExportDiagramsErrorPage_3=Please select a Papyrus model before trying to export all diagrams +ExportDiagramsPage_0=Export All diagrams +ExportDiagramsPage_2=Export all diagrams of a model created with papyrus diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/META-INF/MANIFEST.MF b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/META-INF/MANIFEST.MF index 648610eb39f..431ee881724 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/META-INF/MANIFEST.MF +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/META-INF/MANIFEST.MF @@ -1,9 +1,9 @@ Manifest-Version: 1.0 -Export-Package: org.eclipse.papyrus.extendedtypes.emf, - org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration, - org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl, - org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util, - org.eclipse.papyrus.extendedtypes.emf.providers +Export-Package: org.eclipse.papyrus.infra.extendedtypes.emf, + org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration, + org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl, + org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util, + org.eclipse.papyrus.infra.extendedtypes.emf.providers Bundle-ActivationPolicy: lazy Bundle-ClassPath: . Bundle-Name: %pluginName @@ -23,6 +23,6 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0", Bundle-Vendor: %providerName Bundle-Version: 0.9.0.qualifier Bundle-ManifestVersion: 2 -Bundle-Activator: org.eclipse.papyrus.extendedtypes.emf.Activator +Bundle-Activator: org.eclipse.papyrus.infra.extendedtypes.emf.Activator Bundle-SymbolicName: org.eclipse.papyrus.infra.extendedtypes.emf;singleton:=true diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/model/ModifySemanticValuesActionConfiguration.ecore b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/model/ModifySemanticValuesActionConfiguration.ecore index 2b897e91347..4333d095e5d 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/model/ModifySemanticValuesActionConfiguration.ecore +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/model/ModifySemanticValuesActionConfiguration.ecore @@ -5,7 +5,7 @@ nsURI="http://www.eclipse.org/papyrus/diagram/types/modifysemanticvaluesactionconfiguration/0.8" nsPrefix="modifysemanticvaluesactionconfiguration"> + eSuperTypes="platform:/plugin/org.eclipse.papyrus.infra.extendedtypes/model/ExtendedTypes.ecore#//PostActionConfiguration"> @@ -26,6 +26,6 @@ eType="#//FeatureValue"/> - + diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/model/ModifySemanticValuesActionConfiguration.ecorediag b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/model/ModifySemanticValuesActionConfiguration.ecorediag index 3b0060d96d1..52c54db4738 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/model/ModifySemanticValuesActionConfiguration.ecorediag +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/model/ModifySemanticValuesActionConfiguration.ecorediag @@ -16,7 +16,7 @@ - + @@ -151,7 +151,7 @@ - + diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/model/ModifySemanticValuesActionConfiguration.genmodel b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/model/ModifySemanticValuesActionConfiguration.genmodel index 75b2475d2e7..53f0c6613a7 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/model/ModifySemanticValuesActionConfiguration.genmodel +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/model/ModifySemanticValuesActionConfiguration.genmodel @@ -1,14 +1,14 @@ + usedGenPackages="platform:/plugin/org.eclipse.papyrus.infra.queries.core.configuration/model/Configuration.genmodel#//configuration platform:/plugin/org.eclipse.emf.ecore/model/Ecore.genmodel#//ecore platform:/plugin/org.eclipse.papyrus.infra.extendedtypes/model/ExtendedTypes.genmodel#//extendedtypes platform:/plugin/org.eclipse.emf.facet.infra.query/model/query.genmodel#//query platform:/plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml"> ModifySemanticValuesActionConfiguration.ecore - diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/plugin.xml b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/plugin.xml index f5f358abc11..9d8c9c3ff06 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/plugin.xml +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/plugin.xml @@ -13,24 +13,24 @@ + class="org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util.ModifySemanticValuesActionConfigurationResourceFactoryImpl"/> + point="org.eclipse.papyrus.infra.extendedtypes.extendedElementTypeActionProvider"> diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ConstantValue.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ConstantValue.java deleted file mode 100644 index 11decf35ab8..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ConstantValue.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration; - -import org.eclipse.uml2.uml.ValueSpecification; - -/** - * - * A representation of the model object 'Constant Value'. - * - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue#getValueInstance Value Instance}
  • - *
- *

- * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getConstantValue() - * @model - * @generated - */ -public interface ConstantValue extends FeatureValue { - /** - * Returns the value of the 'Value Instance' containment reference. - * - *

- * If the meaning of the 'Value Instance' containment reference isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Value Instance' containment reference. - * @see #setValueInstance(ValueSpecification) - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getConstantValue_ValueInstance() - * @model containment="true" - * @generated - */ - ValueSpecification getValueInstance(); - - /** - * Sets the value of the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue#getValueInstance Value Instance}' containment reference. - * - * - * @param value the new value of the 'Value Instance' containment reference. - * @see #getValueInstance() - * @generated - */ - void setValueInstance(ValueSpecification value); - -} // ConstantValue diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/DynamicValue.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/DynamicValue.java deleted file mode 100644 index ffa2bde7d1f..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/DynamicValue.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration; - - -/** - * - * A representation of the model object 'Dynamic Value'. - * - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getDynamicValue() - * @model - * @generated - */ -public interface DynamicValue extends FeatureValue { -} // DynamicValue diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureToSet.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureToSet.java deleted file mode 100644 index 16a179c8bf8..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureToSet.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration; - -import org.eclipse.emf.ecore.EObject; - -/** - * - * A representation of the model object 'Feature To Set'. - * - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getFeatureName Feature Name}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getValue Value}
  • - *
- *

- * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getFeatureToSet() - * @model - * @generated - */ -public interface FeatureToSet extends EObject { - /** - * Returns the value of the 'Feature Name' attribute. - * - *

- * If the meaning of the 'Feature Name' attribute isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Feature Name' attribute. - * @see #setFeatureName(String) - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getFeatureToSet_FeatureName() - * @model required="true" - * @generated - */ - String getFeatureName(); - - /** - * Sets the value of the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getFeatureName Feature Name}' attribute. - * - * - * @param value the new value of the 'Feature Name' attribute. - * @see #getFeatureName() - * @generated - */ - void setFeatureName(String value); - - /** - * Returns the value of the 'Value' containment reference. - * - *

- * If the meaning of the 'Value' containment reference isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Value' containment reference. - * @see #setValue(FeatureValue) - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getFeatureToSet_Value() - * @model containment="true" required="true" - * @generated - */ - FeatureValue getValue(); - - /** - * Sets the value of the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getValue Value}' containment reference. - * - * - * @param value the new value of the 'Value' containment reference. - * @see #getValue() - * @generated - */ - void setValue(FeatureValue value); - -} // FeatureToSet diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureValue.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureValue.java deleted file mode 100644 index 115b6621243..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureValue.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration; - -import org.eclipse.emf.ecore.EObject; - -/** - * - * A representation of the model object 'Feature Value'. - * - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getFeatureValue() - * @model abstract="true" - * @generated - */ -public interface FeatureValue extends EObject { -} // FeatureValue diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ListValue.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ListValue.java deleted file mode 100644 index b505d6f544d..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ListValue.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration; - -import org.eclipse.emf.common.util.EList; - -/** - * - * A representation of the model object 'List Value'. - * - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue#getValues Values}
  • - *
- *

- * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getListValue() - * @model - * @generated - */ -public interface ListValue extends FeatureValue { - /** - * Returns the value of the 'Values' reference list. - * The list contents are of type {@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue}. - * - *

- * If the meaning of the 'Values' reference list isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Values' reference list. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getListValue_Values() - * @model - * @generated - */ - EList getValues(); - -} // ListValue diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfiguration.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfiguration.java deleted file mode 100644 index 6297f184cb8..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfiguration.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration; - -import org.eclipse.emf.common.util.EList; - -import org.eclipse.papyrus.extendedtypes.PostActionConfiguration; - -/** - * - * A representation of the model object 'Modify Semantic Values Action Configuration'. - * - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration#getFeaturesToSet Features To Set}
  • - *
- *

- * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getModifySemanticValuesActionConfiguration() - * @model - * @generated - */ -public interface ModifySemanticValuesActionConfiguration extends PostActionConfiguration { - /** - * Returns the value of the 'Features To Set' containment reference list. - * The list contents are of type {@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet}. - * - *

- * If the meaning of the 'Features To Set' containment reference list isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Features To Set' containment reference list. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getModifySemanticValuesActionConfiguration_FeaturesToSet() - * @model containment="true" - * @generated - */ - EList getFeaturesToSet(); - -} // ModifySemanticValuesActionConfiguration diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationFactory.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationFactory.java deleted file mode 100644 index beacaa6d3ef..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationFactory.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration; - -import org.eclipse.emf.ecore.EFactory; - -/** - * - * The Factory for the model. - * It provides a create method for each non-abstract class of the model. - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage - * @generated - */ -public interface ModifySemanticValuesActionConfigurationFactory extends EFactory { - /** - * The singleton instance of the factory. - * - * - * @generated - */ - ModifySemanticValuesActionConfigurationFactory eINSTANCE = org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationFactoryImpl.init(); - - /** - * Returns a new object of class 'Modify Semantic Values Action Configuration'. - * - * - * @return a new object of class 'Modify Semantic Values Action Configuration'. - * @generated - */ - ModifySemanticValuesActionConfiguration createModifySemanticValuesActionConfiguration(); - - /** - * Returns a new object of class 'Feature To Set'. - * - * - * @return a new object of class 'Feature To Set'. - * @generated - */ - FeatureToSet createFeatureToSet(); - - /** - * Returns a new object of class 'Dynamic Value'. - * - * - * @return a new object of class 'Dynamic Value'. - * @generated - */ - DynamicValue createDynamicValue(); - - /** - * Returns a new object of class 'Constant Value'. - * - * - * @return a new object of class 'Constant Value'. - * @generated - */ - ConstantValue createConstantValue(); - - /** - * Returns a new object of class 'List Value'. - * - * - * @return a new object of class 'List Value'. - * @generated - */ - ListValue createListValue(); - - /** - * Returns a new object of class 'Query Execution Value'. - * - * - * @return a new object of class 'Query Execution Value'. - * @generated - */ - QueryExecutionValue createQueryExecutionValue(); - - /** - * Returns the package supported by this factory. - * - * - * @return the package supported by this factory. - * @generated - */ - ModifySemanticValuesActionConfigurationPackage getModifySemanticValuesActionConfigurationPackage(); - -} //ModifySemanticValuesActionConfigurationFactory diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationPackage.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationPackage.java deleted file mode 100644 index e8e13811079..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationPackage.java +++ /dev/null @@ -1,548 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; - -import org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage; - -/** - * - * The Package for the model. - * It contains accessors for the meta objects to represent - *
    - *
  • each class,
  • - *
  • each feature of each class,
  • - *
  • each enum,
  • - *
  • and each data type
  • - *
- * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationFactory - * @model kind="package" - * @generated - */ -public interface ModifySemanticValuesActionConfigurationPackage extends EPackage { - /** - * The package name. - * - * - * @generated - */ - String eNAME = "modifysemanticvaluesactionconfiguration"; - - /** - * The package namespace URI. - * - * - * @generated - */ - String eNS_URI = "http://www.eclipse.org/papyrus/diagram/types/modifysemanticvaluesactionconfiguration/0.8"; - - /** - * The package namespace name. - * - * - * @generated - */ - String eNS_PREFIX = "modifysemanticvaluesactionconfiguration"; - - /** - * The singleton instance of the package. - * - * - * @generated - */ - ModifySemanticValuesActionConfigurationPackage eINSTANCE = org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl.init(); - - /** - * The meta object id for the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationImpl Modify Semantic Values Action Configuration}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationImpl - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getModifySemanticValuesActionConfiguration() - * @generated - */ - int MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION = 0; - - /** - * The feature id for the 'Label' attribute. - * - * - * @generated - * @ordered - */ - int MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__LABEL = ExtendedtypesPackage.POST_ACTION_CONFIGURATION__LABEL; - - /** - * The feature id for the 'Id' attribute. - * - * - * @generated - * @ordered - */ - int MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__ID = ExtendedtypesPackage.POST_ACTION_CONFIGURATION__ID; - - /** - * The feature id for the 'Features To Set' containment reference list. - * - * - * @generated - * @ordered - */ - int MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET = ExtendedtypesPackage.POST_ACTION_CONFIGURATION_FEATURE_COUNT + 0; - - /** - * The number of structural features of the 'Modify Semantic Values Action Configuration' class. - * - * - * @generated - * @ordered - */ - int MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION_FEATURE_COUNT = ExtendedtypesPackage.POST_ACTION_CONFIGURATION_FEATURE_COUNT + 1; - - /** - * The meta object id for the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureToSetImpl Feature To Set}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureToSetImpl - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getFeatureToSet() - * @generated - */ - int FEATURE_TO_SET = 1; - - /** - * The feature id for the 'Feature Name' attribute. - * - * - * @generated - * @ordered - */ - int FEATURE_TO_SET__FEATURE_NAME = 0; - - /** - * The feature id for the 'Value' containment reference. - * - * - * @generated - * @ordered - */ - int FEATURE_TO_SET__VALUE = 1; - - /** - * The number of structural features of the 'Feature To Set' class. - * - * - * @generated - * @ordered - */ - int FEATURE_TO_SET_FEATURE_COUNT = 2; - - /** - * The meta object id for the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureValueImpl Feature Value}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureValueImpl - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getFeatureValue() - * @generated - */ - int FEATURE_VALUE = 2; - - /** - * The number of structural features of the 'Feature Value' class. - * - * - * @generated - * @ordered - */ - int FEATURE_VALUE_FEATURE_COUNT = 0; - - /** - * The meta object id for the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.DynamicValueImpl Dynamic Value}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.DynamicValueImpl - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getDynamicValue() - * @generated - */ - int DYNAMIC_VALUE = 3; - - /** - * The number of structural features of the 'Dynamic Value' class. - * - * - * @generated - * @ordered - */ - int DYNAMIC_VALUE_FEATURE_COUNT = FEATURE_VALUE_FEATURE_COUNT + 0; - - /** - * The meta object id for the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ConstantValueImpl Constant Value}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ConstantValueImpl - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getConstantValue() - * @generated - */ - int CONSTANT_VALUE = 4; - - /** - * The feature id for the 'Value Instance' containment reference. - * - * - * @generated - * @ordered - */ - int CONSTANT_VALUE__VALUE_INSTANCE = FEATURE_VALUE_FEATURE_COUNT + 0; - - /** - * The number of structural features of the 'Constant Value' class. - * - * - * @generated - * @ordered - */ - int CONSTANT_VALUE_FEATURE_COUNT = FEATURE_VALUE_FEATURE_COUNT + 1; - - /** - * The meta object id for the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ListValueImpl List Value}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ListValueImpl - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getListValue() - * @generated - */ - int LIST_VALUE = 5; - - /** - * The feature id for the 'Values' reference list. - * - * - * @generated - * @ordered - */ - int LIST_VALUE__VALUES = FEATURE_VALUE_FEATURE_COUNT + 0; - - /** - * The number of structural features of the 'List Value' class. - * - * - * @generated - * @ordered - */ - int LIST_VALUE_FEATURE_COUNT = FEATURE_VALUE_FEATURE_COUNT + 1; - - /** - * The meta object id for the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.QueryExecutionValueImpl Query Execution Value}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.QueryExecutionValueImpl - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getQueryExecutionValue() - * @generated - */ - int QUERY_EXECUTION_VALUE = 6; - - /** - * The feature id for the 'Configuration' reference. - * - * - * @generated - * @ordered - */ - int QUERY_EXECUTION_VALUE__CONFIGURATION = FEATURE_VALUE_FEATURE_COUNT + 0; - - /** - * The number of structural features of the 'Query Execution Value' class. - * - * - * @generated - * @ordered - */ - int QUERY_EXECUTION_VALUE_FEATURE_COUNT = FEATURE_VALUE_FEATURE_COUNT + 1; - - - /** - * Returns the meta object for class '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration Modify Semantic Values Action Configuration}'. - * - * - * @return the meta object for class 'Modify Semantic Values Action Configuration'. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration - * @generated - */ - EClass getModifySemanticValuesActionConfiguration(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration#getFeaturesToSet Features To Set}'. - * - * - * @return the meta object for the containment reference list 'Features To Set'. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration#getFeaturesToSet() - * @see #getModifySemanticValuesActionConfiguration() - * @generated - */ - EReference getModifySemanticValuesActionConfiguration_FeaturesToSet(); - - /** - * Returns the meta object for class '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet Feature To Set}'. - * - * - * @return the meta object for class 'Feature To Set'. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet - * @generated - */ - EClass getFeatureToSet(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getFeatureName Feature Name}'. - * - * - * @return the meta object for the attribute 'Feature Name'. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getFeatureName() - * @see #getFeatureToSet() - * @generated - */ - EAttribute getFeatureToSet_FeatureName(); - - /** - * Returns the meta object for the containment reference '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getValue Value}'. - * - * - * @return the meta object for the containment reference 'Value'. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getValue() - * @see #getFeatureToSet() - * @generated - */ - EReference getFeatureToSet_Value(); - - /** - * Returns the meta object for class '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue Feature Value}'. - * - * - * @return the meta object for class 'Feature Value'. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue - * @generated - */ - EClass getFeatureValue(); - - /** - * Returns the meta object for class '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.DynamicValue Dynamic Value}'. - * - * - * @return the meta object for class 'Dynamic Value'. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.DynamicValue - * @generated - */ - EClass getDynamicValue(); - - /** - * Returns the meta object for class '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue Constant Value}'. - * - * - * @return the meta object for class 'Constant Value'. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue - * @generated - */ - EClass getConstantValue(); - - /** - * Returns the meta object for the containment reference '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue#getValueInstance Value Instance}'. - * - * - * @return the meta object for the containment reference 'Value Instance'. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue#getValueInstance() - * @see #getConstantValue() - * @generated - */ - EReference getConstantValue_ValueInstance(); - - /** - * Returns the meta object for class '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue List Value}'. - * - * - * @return the meta object for class 'List Value'. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue - * @generated - */ - EClass getListValue(); - - /** - * Returns the meta object for the reference list '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue#getValues Values}'. - * - * - * @return the meta object for the reference list 'Values'. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue#getValues() - * @see #getListValue() - * @generated - */ - EReference getListValue_Values(); - - /** - * Returns the meta object for class '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue Query Execution Value}'. - * - * - * @return the meta object for class 'Query Execution Value'. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue - * @generated - */ - EClass getQueryExecutionValue(); - - /** - * Returns the meta object for the reference '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue#getConfiguration Configuration}'. - * - * - * @return the meta object for the reference 'Configuration'. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue#getConfiguration() - * @see #getQueryExecutionValue() - * @generated - */ - EReference getQueryExecutionValue_Configuration(); - - /** - * Returns the factory that creates the instances of the model. - * - * - * @return the factory that creates the instances of the model. - * @generated - */ - ModifySemanticValuesActionConfigurationFactory getModifySemanticValuesActionConfigurationFactory(); - - /** - * - * Defines literals for the meta objects that represent - *
    - *
  • each class,
  • - *
  • each feature of each class,
  • - *
  • each enum,
  • - *
  • and each data type
  • - *
- * - * @generated - */ - interface Literals { - /** - * The meta object literal for the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationImpl Modify Semantic Values Action Configuration}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationImpl - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getModifySemanticValuesActionConfiguration() - * @generated - */ - EClass MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION = eINSTANCE.getModifySemanticValuesActionConfiguration(); - - /** - * The meta object literal for the 'Features To Set' containment reference list feature. - * - * - * @generated - */ - EReference MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET = eINSTANCE.getModifySemanticValuesActionConfiguration_FeaturesToSet(); - - /** - * The meta object literal for the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureToSetImpl Feature To Set}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureToSetImpl - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getFeatureToSet() - * @generated - */ - EClass FEATURE_TO_SET = eINSTANCE.getFeatureToSet(); - - /** - * The meta object literal for the 'Feature Name' attribute feature. - * - * - * @generated - */ - EAttribute FEATURE_TO_SET__FEATURE_NAME = eINSTANCE.getFeatureToSet_FeatureName(); - - /** - * The meta object literal for the 'Value' containment reference feature. - * - * - * @generated - */ - EReference FEATURE_TO_SET__VALUE = eINSTANCE.getFeatureToSet_Value(); - - /** - * The meta object literal for the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureValueImpl Feature Value}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureValueImpl - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getFeatureValue() - * @generated - */ - EClass FEATURE_VALUE = eINSTANCE.getFeatureValue(); - - /** - * The meta object literal for the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.DynamicValueImpl Dynamic Value}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.DynamicValueImpl - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getDynamicValue() - * @generated - */ - EClass DYNAMIC_VALUE = eINSTANCE.getDynamicValue(); - - /** - * The meta object literal for the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ConstantValueImpl Constant Value}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ConstantValueImpl - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getConstantValue() - * @generated - */ - EClass CONSTANT_VALUE = eINSTANCE.getConstantValue(); - - /** - * The meta object literal for the 'Value Instance' containment reference feature. - * - * - * @generated - */ - EReference CONSTANT_VALUE__VALUE_INSTANCE = eINSTANCE.getConstantValue_ValueInstance(); - - /** - * The meta object literal for the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ListValueImpl List Value}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ListValueImpl - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getListValue() - * @generated - */ - EClass LIST_VALUE = eINSTANCE.getListValue(); - - /** - * The meta object literal for the 'Values' reference list feature. - * - * - * @generated - */ - EReference LIST_VALUE__VALUES = eINSTANCE.getListValue_Values(); - - /** - * The meta object literal for the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.QueryExecutionValueImpl Query Execution Value}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.QueryExecutionValueImpl - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getQueryExecutionValue() - * @generated - */ - EClass QUERY_EXECUTION_VALUE = eINSTANCE.getQueryExecutionValue(); - - /** - * The meta object literal for the 'Configuration' reference feature. - * - * - * @generated - */ - EReference QUERY_EXECUTION_VALUE__CONFIGURATION = eINSTANCE.getQueryExecutionValue_Configuration(); - - } - -} //ModifySemanticValuesActionConfigurationPackage diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/QueryExecutionValue.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/QueryExecutionValue.java deleted file mode 100644 index e6932cd3bde..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/QueryExecutionValue.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration; - -import org.eclipse.papyrus.core.queries.configuration.QueryConfiguration; - -/** - * - * A representation of the model object 'Query Execution Value'. - * - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue#getConfiguration Configuration}
  • - *
- *

- * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getQueryExecutionValue() - * @model - * @generated - */ -public interface QueryExecutionValue extends FeatureValue { - /** - * Returns the value of the 'Configuration' reference. - * - *

- * If the meaning of the 'Configuration' reference isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Configuration' reference. - * @see #setConfiguration(QueryConfiguration) - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getQueryExecutionValue_Configuration() - * @model - * @generated - */ - QueryConfiguration getConfiguration(); - - /** - * Sets the value of the '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue#getConfiguration Configuration}' reference. - * - * - * @param value the new value of the 'Configuration' reference. - * @see #getConfiguration() - * @generated - */ - void setConfiguration(QueryConfiguration value); - -} // QueryExecutionValue diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ConstantValueImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ConstantValueImpl.java deleted file mode 100644 index f2e1fab1bc2..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ConstantValueImpl.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; - -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; - -import org.eclipse.uml2.uml.ValueSpecification; - -/** - * - * An implementation of the model object 'Constant Value'. - * - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ConstantValueImpl#getValueInstance Value Instance}
  • - *
- *

- * - * @generated - */ -public class ConstantValueImpl extends FeatureValueImpl implements ConstantValue { - /** - * The cached value of the '{@link #getValueInstance() Value Instance}' containment reference. - * - * - * @see #getValueInstance() - * @generated - * @ordered - */ - protected ValueSpecification valueInstance; - - /** - * - * - * @generated - */ - protected ConstantValueImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return ModifySemanticValuesActionConfigurationPackage.Literals.CONSTANT_VALUE; - } - - /** - * - * - * @generated - */ - public ValueSpecification getValueInstance() { - return valueInstance; - } - - /** - * - * - * @generated - */ - public NotificationChain basicSetValueInstance(ValueSpecification newValueInstance, NotificationChain msgs) { - ValueSpecification oldValueInstance = valueInstance; - valueInstance = newValueInstance; - if (eNotificationRequired()) { - ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE, oldValueInstance, newValueInstance); - if (msgs == null) msgs = notification; else msgs.add(notification); - } - return msgs; - } - - /** - * - * - * @generated - */ - public void setValueInstance(ValueSpecification newValueInstance) { - if (newValueInstance != valueInstance) { - NotificationChain msgs = null; - if (valueInstance != null) - msgs = ((InternalEObject)valueInstance).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE, null, msgs); - if (newValueInstance != null) - msgs = ((InternalEObject)newValueInstance).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE, null, msgs); - msgs = basicSetValueInstance(newValueInstance, msgs); - if (msgs != null) msgs.dispatch(); - } - else if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE, newValueInstance, newValueInstance)); - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE: - return basicSetValueInstance(null, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE: - return getValueInstance(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE: - setValueInstance((ValueSpecification)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE: - setValueInstance((ValueSpecification)null); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE: - return valueInstance != null; - } - return super.eIsSet(featureID); - } - -} //ConstantValueImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/DynamicValueImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/DynamicValueImpl.java deleted file mode 100644 index e6f23f25d7f..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/DynamicValueImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; - -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.DynamicValue; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; - -/** - * - * An implementation of the model object 'Dynamic Value'. - * - *

- *

- * - * @generated - */ -public class DynamicValueImpl extends FeatureValueImpl implements DynamicValue { - /** - * - * - * @generated - */ - protected DynamicValueImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return ModifySemanticValuesActionConfigurationPackage.Literals.DYNAMIC_VALUE; - } - -} //DynamicValueImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureToSetImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureToSetImpl.java deleted file mode 100644 index 54382a784c9..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureToSetImpl.java +++ /dev/null @@ -1,248 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; - -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; - -/** - * - * An implementation of the model object 'Feature To Set'. - * - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureToSetImpl#getFeatureName Feature Name}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureToSetImpl#getValue Value}
  • - *
- *

- * - * @generated - */ -public class FeatureToSetImpl extends EObjectImpl implements FeatureToSet { - /** - * The default value of the '{@link #getFeatureName() Feature Name}' attribute. - * - * - * @see #getFeatureName() - * @generated - * @ordered - */ - protected static final String FEATURE_NAME_EDEFAULT = null; - - /** - * The cached value of the '{@link #getFeatureName() Feature Name}' attribute. - * - * - * @see #getFeatureName() - * @generated - * @ordered - */ - protected String featureName = FEATURE_NAME_EDEFAULT; - - /** - * The cached value of the '{@link #getValue() Value}' containment reference. - * - * - * @see #getValue() - * @generated - * @ordered - */ - protected FeatureValue value; - - /** - * - * - * @generated - */ - protected FeatureToSetImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return ModifySemanticValuesActionConfigurationPackage.Literals.FEATURE_TO_SET; - } - - /** - * - * - * @generated - */ - public String getFeatureName() { - return featureName; - } - - /** - * - * - * @generated - */ - public void setFeatureName(String newFeatureName) { - String oldFeatureName = featureName; - featureName = newFeatureName; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__FEATURE_NAME, oldFeatureName, featureName)); - } - - /** - * - * - * @generated - */ - public FeatureValue getValue() { - return value; - } - - /** - * - * - * @generated - */ - public NotificationChain basicSetValue(FeatureValue newValue, NotificationChain msgs) { - FeatureValue oldValue = value; - value = newValue; - if (eNotificationRequired()) { - ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE, oldValue, newValue); - if (msgs == null) msgs = notification; else msgs.add(notification); - } - return msgs; - } - - /** - * - * - * @generated - */ - public void setValue(FeatureValue newValue) { - if (newValue != value) { - NotificationChain msgs = null; - if (value != null) - msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE, null, msgs); - if (newValue != null) - msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE, null, msgs); - msgs = basicSetValue(newValue, msgs); - if (msgs != null) msgs.dispatch(); - } - else if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE, newValue, newValue)); - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE: - return basicSetValue(null, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__FEATURE_NAME: - return getFeatureName(); - case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE: - return getValue(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__FEATURE_NAME: - setFeatureName((String)newValue); - return; - case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE: - setValue((FeatureValue)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__FEATURE_NAME: - setFeatureName(FEATURE_NAME_EDEFAULT); - return; - case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE: - setValue((FeatureValue)null); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__FEATURE_NAME: - return FEATURE_NAME_EDEFAULT == null ? featureName != null : !FEATURE_NAME_EDEFAULT.equals(featureName); - case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE: - return value != null; - } - return super.eIsSet(featureID); - } - - /** - * - * - * @generated - */ - @Override - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (featureName: "); - result.append(featureName); - result.append(')'); - return result.toString(); - } - -} //FeatureToSetImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureValueImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureValueImpl.java deleted file mode 100644 index 759fabeffea..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureValueImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; - -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.emf.ecore.impl.EObjectImpl; - -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; - -/** - * - * An implementation of the model object 'Feature Value'. - * - *

- *

- * - * @generated - */ -public abstract class FeatureValueImpl extends EObjectImpl implements FeatureValue { - /** - * - * - * @generated - */ - protected FeatureValueImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return ModifySemanticValuesActionConfigurationPackage.Literals.FEATURE_VALUE; - } - -} //FeatureValueImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ListValueImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ListValueImpl.java deleted file mode 100644 index 4700b924396..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ListValueImpl.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; - -import java.util.Collection; - -import org.eclipse.emf.common.util.EList; - -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.emf.ecore.util.EObjectResolvingEList; - -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; - -/** - * - * An implementation of the model object 'List Value'. - * - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ListValueImpl#getValues Values}
  • - *
- *

- * - * @generated - */ -public class ListValueImpl extends FeatureValueImpl implements ListValue { - /** - * The cached value of the '{@link #getValues() Values}' reference list. - * - * - * @see #getValues() - * @generated - * @ordered - */ - protected EList values; - - /** - * - * - * @generated - */ - protected ListValueImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return ModifySemanticValuesActionConfigurationPackage.Literals.LIST_VALUE; - } - - /** - * - * - * @generated - */ - public EList getValues() { - if (values == null) { - values = new EObjectResolvingEList(FeatureValue.class, this, ModifySemanticValuesActionConfigurationPackage.LIST_VALUE__VALUES); - } - return values; - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.LIST_VALUE__VALUES: - return getValues(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.LIST_VALUE__VALUES: - getValues().clear(); - getValues().addAll((Collection)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.LIST_VALUE__VALUES: - getValues().clear(); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.LIST_VALUE__VALUES: - return values != null && !values.isEmpty(); - } - return super.eIsSet(featureID); - } - -} //ListValueImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationFactoryImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationFactoryImpl.java deleted file mode 100644 index 995fa344da8..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationFactoryImpl.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; - -import org.eclipse.emf.ecore.impl.EFactoryImpl; - -import org.eclipse.emf.ecore.plugin.EcorePlugin; - -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.*; - -/** - * - * An implementation of the model Factory. - * - * @generated - */ -public class ModifySemanticValuesActionConfigurationFactoryImpl extends EFactoryImpl implements ModifySemanticValuesActionConfigurationFactory { - /** - * Creates the default factory implementation. - * - * - * @generated - */ - public static ModifySemanticValuesActionConfigurationFactory init() { - try { - ModifySemanticValuesActionConfigurationFactory theModifySemanticValuesActionConfigurationFactory = (ModifySemanticValuesActionConfigurationFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.eclipse.org/papyrus/diagram/types/modifysemanticvaluesactionconfiguration/0.8"); - if (theModifySemanticValuesActionConfigurationFactory != null) { - return theModifySemanticValuesActionConfigurationFactory; - } - } - catch (Exception exception) { - EcorePlugin.INSTANCE.log(exception); - } - return new ModifySemanticValuesActionConfigurationFactoryImpl(); - } - - /** - * Creates an instance of the factory. - * - * - * @generated - */ - public ModifySemanticValuesActionConfigurationFactoryImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - public EObject create(EClass eClass) { - switch (eClass.getClassifierID()) { - case ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION: return createModifySemanticValuesActionConfiguration(); - case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET: return createFeatureToSet(); - case ModifySemanticValuesActionConfigurationPackage.DYNAMIC_VALUE: return createDynamicValue(); - case ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE: return createConstantValue(); - case ModifySemanticValuesActionConfigurationPackage.LIST_VALUE: return createListValue(); - case ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE: return createQueryExecutionValue(); - default: - throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); - } - } - - /** - * - * - * @generated - */ - public ModifySemanticValuesActionConfiguration createModifySemanticValuesActionConfiguration() { - ModifySemanticValuesActionConfigurationImpl modifySemanticValuesActionConfiguration = new ModifySemanticValuesActionConfigurationImpl(); - return modifySemanticValuesActionConfiguration; - } - - /** - * - * - * @generated - */ - public FeatureToSet createFeatureToSet() { - FeatureToSetImpl featureToSet = new FeatureToSetImpl(); - return featureToSet; - } - - /** - * - * - * @generated - */ - public DynamicValue createDynamicValue() { - DynamicValueImpl dynamicValue = new DynamicValueImpl(); - return dynamicValue; - } - - /** - * - * - * @generated - */ - public ConstantValue createConstantValue() { - ConstantValueImpl constantValue = new ConstantValueImpl(); - return constantValue; - } - - /** - * - * - * @generated - */ - public ListValue createListValue() { - ListValueImpl listValue = new ListValueImpl(); - return listValue; - } - - /** - * - * - * @generated - */ - public QueryExecutionValue createQueryExecutionValue() { - QueryExecutionValueImpl queryExecutionValue = new QueryExecutionValueImpl(); - return queryExecutionValue; - } - - /** - * - * - * @generated - */ - public ModifySemanticValuesActionConfigurationPackage getModifySemanticValuesActionConfigurationPackage() { - return (ModifySemanticValuesActionConfigurationPackage)getEPackage(); - } - - /** - * - * - * @deprecated - * @generated - */ - @Deprecated - public static ModifySemanticValuesActionConfigurationPackage getPackage() { - return ModifySemanticValuesActionConfigurationPackage.eINSTANCE; - } - -} //ModifySemanticValuesActionConfigurationFactoryImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationImpl.java deleted file mode 100644 index 57a1504de91..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationImpl.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; - -import java.util.Collection; - -import org.eclipse.emf.common.notify.NotificationChain; - -import org.eclipse.emf.common.util.EList; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; - -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.InternalEList; - -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; - -import org.eclipse.papyrus.extendedtypes.impl.PostActionConfigurationImpl; - -/** - * - * An implementation of the model object 'Modify Semantic Values Action Configuration'. - * - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationImpl#getFeaturesToSet Features To Set}
  • - *
- *

- * - * @generated - */ -public class ModifySemanticValuesActionConfigurationImpl extends PostActionConfigurationImpl implements ModifySemanticValuesActionConfiguration { - /** - * The cached value of the '{@link #getFeaturesToSet() Features To Set}' containment reference list. - * - * - * @see #getFeaturesToSet() - * @generated - * @ordered - */ - protected EList featuresToSet; - - /** - * - * - * @generated - */ - protected ModifySemanticValuesActionConfigurationImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return ModifySemanticValuesActionConfigurationPackage.Literals.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION; - } - - /** - * - * - * @generated - */ - public EList getFeaturesToSet() { - if (featuresToSet == null) { - featuresToSet = new EObjectContainmentEList(FeatureToSet.class, this, ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET); - } - return featuresToSet; - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET: - return ((InternalEList)getFeaturesToSet()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET: - return getFeaturesToSet(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET: - getFeaturesToSet().clear(); - getFeaturesToSet().addAll((Collection)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET: - getFeaturesToSet().clear(); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET: - return featuresToSet != null && !featuresToSet.isEmpty(); - } - return super.eIsSet(featureID); - } - -} //ModifySemanticValuesActionConfigurationImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationPackageImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationPackageImpl.java deleted file mode 100644 index 7b19a41c6ab..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationPackageImpl.java +++ /dev/null @@ -1,384 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.EcorePackage; - -import org.eclipse.emf.ecore.impl.EPackageImpl; - -import org.eclipse.papyrus.core.queries.configuration.ConfigurationPackage; - -import org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage; - -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.DynamicValue; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationFactory; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue; - -import org.eclipse.uml2.uml.UMLPackage; - -/** - * - * An implementation of the model Package. - * - * @generated - */ -public class ModifySemanticValuesActionConfigurationPackageImpl extends EPackageImpl implements ModifySemanticValuesActionConfigurationPackage { - /** - * - * - * @generated - */ - private EClass modifySemanticValuesActionConfigurationEClass = null; - - /** - * - * - * @generated - */ - private EClass featureToSetEClass = null; - - /** - * - * - * @generated - */ - private EClass featureValueEClass = null; - - /** - * - * - * @generated - */ - private EClass dynamicValueEClass = null; - - /** - * - * - * @generated - */ - private EClass constantValueEClass = null; - - /** - * - * - * @generated - */ - private EClass listValueEClass = null; - - /** - * - * - * @generated - */ - private EClass queryExecutionValueEClass = null; - - /** - * Creates an instance of the model Package, registered with - * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package - * package URI value. - *

Note: the correct way to create the package is via the static - * factory method {@link #init init()}, which also performs - * initialization of the package, or returns the registered package, - * if one already exists. - * - * - * @see org.eclipse.emf.ecore.EPackage.Registry - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#eNS_URI - * @see #init() - * @generated - */ - private ModifySemanticValuesActionConfigurationPackageImpl() { - super(eNS_URI, ModifySemanticValuesActionConfigurationFactory.eINSTANCE); - } - - /** - * - * - * @generated - */ - private static boolean isInited = false; - - /** - * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. - * - *

This method is used to initialize {@link ModifySemanticValuesActionConfigurationPackage#eINSTANCE} when that field is accessed. - * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. - * - * - * @see #eNS_URI - * @see #createPackageContents() - * @see #initializePackageContents() - * @generated - */ - public static ModifySemanticValuesActionConfigurationPackage init() { - if (isInited) return (ModifySemanticValuesActionConfigurationPackage)EPackage.Registry.INSTANCE.getEPackage(ModifySemanticValuesActionConfigurationPackage.eNS_URI); - - // Obtain or create and register package - ModifySemanticValuesActionConfigurationPackageImpl theModifySemanticValuesActionConfigurationPackage = (ModifySemanticValuesActionConfigurationPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof ModifySemanticValuesActionConfigurationPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new ModifySemanticValuesActionConfigurationPackageImpl()); - - isInited = true; - - // Initialize simple dependencies - ExtendedtypesPackage.eINSTANCE.eClass(); - - // Create package meta-data objects - theModifySemanticValuesActionConfigurationPackage.createPackageContents(); - - // Initialize created meta-data - theModifySemanticValuesActionConfigurationPackage.initializePackageContents(); - - // Mark meta-data to indicate it can't be changed - theModifySemanticValuesActionConfigurationPackage.freeze(); - - - // Update the registry and return the package - EPackage.Registry.INSTANCE.put(ModifySemanticValuesActionConfigurationPackage.eNS_URI, theModifySemanticValuesActionConfigurationPackage); - return theModifySemanticValuesActionConfigurationPackage; - } - - /** - * - * - * @generated - */ - public EClass getModifySemanticValuesActionConfiguration() { - return modifySemanticValuesActionConfigurationEClass; - } - - /** - * - * - * @generated - */ - public EReference getModifySemanticValuesActionConfiguration_FeaturesToSet() { - return (EReference)modifySemanticValuesActionConfigurationEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EClass getFeatureToSet() { - return featureToSetEClass; - } - - /** - * - * - * @generated - */ - public EAttribute getFeatureToSet_FeatureName() { - return (EAttribute)featureToSetEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EReference getFeatureToSet_Value() { - return (EReference)featureToSetEClass.getEStructuralFeatures().get(1); - } - - /** - * - * - * @generated - */ - public EClass getFeatureValue() { - return featureValueEClass; - } - - /** - * - * - * @generated - */ - public EClass getDynamicValue() { - return dynamicValueEClass; - } - - /** - * - * - * @generated - */ - public EClass getConstantValue() { - return constantValueEClass; - } - - /** - * - * - * @generated - */ - public EReference getConstantValue_ValueInstance() { - return (EReference)constantValueEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EClass getListValue() { - return listValueEClass; - } - - /** - * - * - * @generated - */ - public EReference getListValue_Values() { - return (EReference)listValueEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EClass getQueryExecutionValue() { - return queryExecutionValueEClass; - } - - /** - * - * - * @generated - */ - public EReference getQueryExecutionValue_Configuration() { - return (EReference)queryExecutionValueEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public ModifySemanticValuesActionConfigurationFactory getModifySemanticValuesActionConfigurationFactory() { - return (ModifySemanticValuesActionConfigurationFactory)getEFactoryInstance(); - } - - /** - * - * - * @generated - */ - private boolean isCreated = false; - - /** - * Creates the meta-model objects for the package. This method is - * guarded to have no affect on any invocation but its first. - * - * - * @generated - */ - public void createPackageContents() { - if (isCreated) return; - isCreated = true; - - // Create classes and their features - modifySemanticValuesActionConfigurationEClass = createEClass(MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION); - createEReference(modifySemanticValuesActionConfigurationEClass, MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET); - - featureToSetEClass = createEClass(FEATURE_TO_SET); - createEAttribute(featureToSetEClass, FEATURE_TO_SET__FEATURE_NAME); - createEReference(featureToSetEClass, FEATURE_TO_SET__VALUE); - - featureValueEClass = createEClass(FEATURE_VALUE); - - dynamicValueEClass = createEClass(DYNAMIC_VALUE); - - constantValueEClass = createEClass(CONSTANT_VALUE); - createEReference(constantValueEClass, CONSTANT_VALUE__VALUE_INSTANCE); - - listValueEClass = createEClass(LIST_VALUE); - createEReference(listValueEClass, LIST_VALUE__VALUES); - - queryExecutionValueEClass = createEClass(QUERY_EXECUTION_VALUE); - createEReference(queryExecutionValueEClass, QUERY_EXECUTION_VALUE__CONFIGURATION); - } - - /** - * - * - * @generated - */ - private boolean isInitialized = false; - - /** - * Complete the initialization of the package and its meta-model. This - * method is guarded to have no affect on any invocation but its first. - * - * - * @generated - */ - public void initializePackageContents() { - if (isInitialized) return; - isInitialized = true; - - // Initialize package - setName(eNAME); - setNsPrefix(eNS_PREFIX); - setNsURI(eNS_URI); - - // Obtain other dependent packages - ExtendedtypesPackage theExtendedtypesPackage = (ExtendedtypesPackage)EPackage.Registry.INSTANCE.getEPackage(ExtendedtypesPackage.eNS_URI); - EcorePackage theEcorePackage = (EcorePackage)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI); - UMLPackage theUMLPackage = (UMLPackage)EPackage.Registry.INSTANCE.getEPackage(UMLPackage.eNS_URI); - ConfigurationPackage theConfigurationPackage = (ConfigurationPackage)EPackage.Registry.INSTANCE.getEPackage(ConfigurationPackage.eNS_URI); - - // Create type parameters - - // Set bounds for type parameters - - // Add supertypes to classes - modifySemanticValuesActionConfigurationEClass.getESuperTypes().add(theExtendedtypesPackage.getPostActionConfiguration()); - dynamicValueEClass.getESuperTypes().add(this.getFeatureValue()); - constantValueEClass.getESuperTypes().add(this.getFeatureValue()); - listValueEClass.getESuperTypes().add(this.getFeatureValue()); - queryExecutionValueEClass.getESuperTypes().add(this.getFeatureValue()); - - // Initialize classes and features; add operations and parameters - initEClass(modifySemanticValuesActionConfigurationEClass, ModifySemanticValuesActionConfiguration.class, "ModifySemanticValuesActionConfiguration", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getModifySemanticValuesActionConfiguration_FeaturesToSet(), this.getFeatureToSet(), null, "featuresToSet", null, 0, -1, ModifySemanticValuesActionConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(featureToSetEClass, FeatureToSet.class, "FeatureToSet", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getFeatureToSet_FeatureName(), theEcorePackage.getEString(), "featureName", null, 1, 1, FeatureToSet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getFeatureToSet_Value(), this.getFeatureValue(), null, "value", null, 1, 1, FeatureToSet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(featureValueEClass, FeatureValue.class, "FeatureValue", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - - initEClass(dynamicValueEClass, DynamicValue.class, "DynamicValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - - initEClass(constantValueEClass, ConstantValue.class, "ConstantValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getConstantValue_ValueInstance(), theUMLPackage.getValueSpecification(), null, "valueInstance", null, 0, 1, ConstantValue.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(listValueEClass, ListValue.class, "ListValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getListValue_Values(), this.getFeatureValue(), null, "values", null, 0, -1, ListValue.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(queryExecutionValueEClass, QueryExecutionValue.class, "QueryExecutionValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getQueryExecutionValue_Configuration(), theConfigurationPackage.getQueryConfiguration(), null, "configuration", null, 0, 1, QueryExecutionValue.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - // Create resource - createResource(eNS_URI); - } - -} //ModifySemanticValuesActionConfigurationPackageImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/QueryExecutionValueImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/QueryExecutionValueImpl.java deleted file mode 100644 index 5002629cd9e..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/QueryExecutionValueImpl.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; - -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; - -import org.eclipse.papyrus.core.queries.configuration.QueryConfiguration; - -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue; - -/** - * - * An implementation of the model object 'Query Execution Value'. - * - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.QueryExecutionValueImpl#getConfiguration Configuration}
  • - *
- *

- * - * @generated - */ -public class QueryExecutionValueImpl extends FeatureValueImpl implements QueryExecutionValue { - /** - * The cached value of the '{@link #getConfiguration() Configuration}' reference. - * - * - * @see #getConfiguration() - * @generated - * @ordered - */ - protected QueryConfiguration configuration; - - /** - * - * - * @generated - */ - protected QueryExecutionValueImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return ModifySemanticValuesActionConfigurationPackage.Literals.QUERY_EXECUTION_VALUE; - } - - /** - * - * - * @generated - */ - public QueryConfiguration getConfiguration() { - if (configuration != null && configuration.eIsProxy()) { - InternalEObject oldConfiguration = (InternalEObject)configuration; - configuration = (QueryConfiguration)eResolveProxy(oldConfiguration); - if (configuration != oldConfiguration) { - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.RESOLVE, ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE__CONFIGURATION, oldConfiguration, configuration)); - } - } - return configuration; - } - - /** - * - * - * @generated - */ - public QueryConfiguration basicGetConfiguration() { - return configuration; - } - - /** - * - * - * @generated - */ - public void setConfiguration(QueryConfiguration newConfiguration) { - QueryConfiguration oldConfiguration = configuration; - configuration = newConfiguration; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE__CONFIGURATION, oldConfiguration, configuration)); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE__CONFIGURATION: - if (resolve) return getConfiguration(); - return basicGetConfiguration(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE__CONFIGURATION: - setConfiguration((QueryConfiguration)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE__CONFIGURATION: - setConfiguration((QueryConfiguration)null); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE__CONFIGURATION: - return configuration != null; - } - return super.eIsSet(featureID); - } - -} //QueryExecutionValueImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationAdapterFactory.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationAdapterFactory.java deleted file mode 100644 index 0a0ef68c1a9..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationAdapterFactory.java +++ /dev/null @@ -1,271 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notifier; - -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; - -import org.eclipse.emf.ecore.EObject; - -import org.eclipse.papyrus.extendedtypes.ActionConfiguration; -import org.eclipse.papyrus.extendedtypes.PostActionConfiguration; - -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.*; - -/** - * - * The Adapter Factory for the model. - * It provides an adapter createXXX method for each class of the model. - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage - * @generated - */ -public class ModifySemanticValuesActionConfigurationAdapterFactory extends AdapterFactoryImpl { - /** - * The cached model package. - * - * - * @generated - */ - protected static ModifySemanticValuesActionConfigurationPackage modelPackage; - - /** - * Creates an instance of the adapter factory. - * - * - * @generated - */ - public ModifySemanticValuesActionConfigurationAdapterFactory() { - if (modelPackage == null) { - modelPackage = ModifySemanticValuesActionConfigurationPackage.eINSTANCE; - } - } - - /** - * Returns whether this factory is applicable for the type of the object. - * - * This implementation returns true if the object is either the model's package or is an instance object of the model. - * - * @return whether this factory is applicable for the type of the object. - * @generated - */ - @Override - public boolean isFactoryForType(Object object) { - if (object == modelPackage) { - return true; - } - if (object instanceof EObject) { - return ((EObject)object).eClass().getEPackage() == modelPackage; - } - return false; - } - - /** - * The switch that delegates to the createXXX methods. - * - * - * @generated - */ - protected ModifySemanticValuesActionConfigurationSwitch modelSwitch = - new ModifySemanticValuesActionConfigurationSwitch() { - @Override - public Adapter caseModifySemanticValuesActionConfiguration(ModifySemanticValuesActionConfiguration object) { - return createModifySemanticValuesActionConfigurationAdapter(); - } - @Override - public Adapter caseFeatureToSet(FeatureToSet object) { - return createFeatureToSetAdapter(); - } - @Override - public Adapter caseFeatureValue(FeatureValue object) { - return createFeatureValueAdapter(); - } - @Override - public Adapter caseDynamicValue(DynamicValue object) { - return createDynamicValueAdapter(); - } - @Override - public Adapter caseConstantValue(ConstantValue object) { - return createConstantValueAdapter(); - } - @Override - public Adapter caseListValue(ListValue object) { - return createListValueAdapter(); - } - @Override - public Adapter caseQueryExecutionValue(QueryExecutionValue object) { - return createQueryExecutionValueAdapter(); - } - @Override - public Adapter caseActionConfiguration(ActionConfiguration object) { - return createActionConfigurationAdapter(); - } - @Override - public Adapter casePostActionConfiguration(PostActionConfiguration object) { - return createPostActionConfigurationAdapter(); - } - @Override - public Adapter defaultCase(EObject object) { - return createEObjectAdapter(); - } - }; - - /** - * Creates an adapter for the target. - * - * - * @param target the object to adapt. - * @return the adapter for the target. - * @generated - */ - @Override - public Adapter createAdapter(Notifier target) { - return modelSwitch.doSwitch((EObject)target); - } - - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration Modify Semantic Values Action Configuration}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration - * @generated - */ - public Adapter createModifySemanticValuesActionConfigurationAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet Feature To Set}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet - * @generated - */ - public Adapter createFeatureToSetAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue Feature Value}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue - * @generated - */ - public Adapter createFeatureValueAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.DynamicValue Dynamic Value}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.DynamicValue - * @generated - */ - public Adapter createDynamicValueAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue Constant Value}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue - * @generated - */ - public Adapter createConstantValueAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue List Value}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue - * @generated - */ - public Adapter createListValueAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue Query Execution Value}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue - * @generated - */ - public Adapter createQueryExecutionValueAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.extendedtypes.ActionConfiguration Action Configuration}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.extendedtypes.ActionConfiguration - * @generated - */ - public Adapter createActionConfigurationAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.extendedtypes.PostActionConfiguration Post Action Configuration}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.extendedtypes.PostActionConfiguration - * @generated - */ - public Adapter createPostActionConfigurationAdapter() { - return null; - } - - /** - * Creates a new adapter for the default case. - * - * This default implementation returns null. - * - * @return the new adapter. - * @generated - */ - public Adapter createEObjectAdapter() { - return null; - } - -} //ModifySemanticValuesActionConfigurationAdapterFactory diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceFactoryImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceFactoryImpl.java deleted file mode 100644 index 1d00406f1b0..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceFactoryImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.resource.Resource; - -import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; - -import org.eclipse.emf.ecore.xmi.XMLResource; - -/** - * - * The Resource Factory associated with the package. - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util.ModifySemanticValuesActionConfigurationResourceImpl - * @generated - */ -public class ModifySemanticValuesActionConfigurationResourceFactoryImpl extends ResourceFactoryImpl { - /** - * Creates an instance of the resource factory. - * - * - * @generated - */ - public ModifySemanticValuesActionConfigurationResourceFactoryImpl() { - super(); - } - - /** - * Creates an instance of the resource. - * - * - * @generated - */ - @Override - public Resource createResource(URI uri) { - XMLResource result = new ModifySemanticValuesActionConfigurationResourceImpl(uri); - result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - - result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); - result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE); - return result; - } - -} //ModifySemanticValuesActionConfigurationResourceFactoryImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceImpl.java deleted file mode 100644 index 184e297c8ed..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; - -/** - * - * The Resource associated with the package. - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util.ModifySemanticValuesActionConfigurationResourceFactoryImpl - * @generated - */ -public class ModifySemanticValuesActionConfigurationResourceImpl extends XMLResourceImpl { - /** - * Creates an instance of the resource. - * - * - * @param uri the URI of the new resource. - * @generated - */ - public ModifySemanticValuesActionConfigurationResourceImpl(URI uri) { - super(uri); - } - -} //ModifySemanticValuesActionConfigurationResourceImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationSwitch.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationSwitch.java deleted file mode 100644 index eab57c7a53c..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationSwitch.java +++ /dev/null @@ -1,279 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; - -import org.eclipse.emf.ecore.util.Switch; - -import org.eclipse.papyrus.extendedtypes.ActionConfiguration; -import org.eclipse.papyrus.extendedtypes.PostActionConfiguration; - -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.*; - -/** - * - * The Switch for the model's inheritance hierarchy. - * It supports the call {@link #doSwitch(EObject) doSwitch(object)} - * to invoke the caseXXX method for each class of the model, - * starting with the actual class of the object - * and proceeding up the inheritance hierarchy - * until a non-null result is returned, - * which is the result of the switch. - * - * @see org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage - * @generated - */ -public class ModifySemanticValuesActionConfigurationSwitch extends Switch { - /** - * The cached model package - * - * - * @generated - */ - protected static ModifySemanticValuesActionConfigurationPackage modelPackage; - - /** - * Creates an instance of the switch. - * - * - * @generated - */ - public ModifySemanticValuesActionConfigurationSwitch() { - if (modelPackage == null) { - modelPackage = ModifySemanticValuesActionConfigurationPackage.eINSTANCE; - } - } - - /** - * Checks whether this is a switch for the given package. - * - * - * @parameter ePackage the package in question. - * @return whether this is a switch for the given package. - * @generated - */ - @Override - protected boolean isSwitchFor(EPackage ePackage) { - return ePackage == modelPackage; - } - - /** - * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. - * - * - * @return the first non-null result returned by a caseXXX call. - * @generated - */ - @Override - protected T doSwitch(int classifierID, EObject theEObject) { - switch (classifierID) { - case ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION: { - ModifySemanticValuesActionConfiguration modifySemanticValuesActionConfiguration = (ModifySemanticValuesActionConfiguration)theEObject; - T result = caseModifySemanticValuesActionConfiguration(modifySemanticValuesActionConfiguration); - if (result == null) result = casePostActionConfiguration(modifySemanticValuesActionConfiguration); - if (result == null) result = caseActionConfiguration(modifySemanticValuesActionConfiguration); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET: { - FeatureToSet featureToSet = (FeatureToSet)theEObject; - T result = caseFeatureToSet(featureToSet); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ModifySemanticValuesActionConfigurationPackage.FEATURE_VALUE: { - FeatureValue featureValue = (FeatureValue)theEObject; - T result = caseFeatureValue(featureValue); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ModifySemanticValuesActionConfigurationPackage.DYNAMIC_VALUE: { - DynamicValue dynamicValue = (DynamicValue)theEObject; - T result = caseDynamicValue(dynamicValue); - if (result == null) result = caseFeatureValue(dynamicValue); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE: { - ConstantValue constantValue = (ConstantValue)theEObject; - T result = caseConstantValue(constantValue); - if (result == null) result = caseFeatureValue(constantValue); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ModifySemanticValuesActionConfigurationPackage.LIST_VALUE: { - ListValue listValue = (ListValue)theEObject; - T result = caseListValue(listValue); - if (result == null) result = caseFeatureValue(listValue); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE: { - QueryExecutionValue queryExecutionValue = (QueryExecutionValue)theEObject; - T result = caseQueryExecutionValue(queryExecutionValue); - if (result == null) result = caseFeatureValue(queryExecutionValue); - if (result == null) result = defaultCase(theEObject); - return result; - } - default: return defaultCase(theEObject); - } - } - - /** - * Returns the result of interpreting the object as an instance of 'Modify Semantic Values Action Configuration'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Modify Semantic Values Action Configuration'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseModifySemanticValuesActionConfiguration(ModifySemanticValuesActionConfiguration object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'Feature To Set'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Feature To Set'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseFeatureToSet(FeatureToSet object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'Feature Value'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Feature Value'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseFeatureValue(FeatureValue object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'Dynamic Value'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Dynamic Value'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseDynamicValue(DynamicValue object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'Constant Value'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Constant Value'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseConstantValue(ConstantValue object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'List Value'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'List Value'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseListValue(ListValue object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'Query Execution Value'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Query Execution Value'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseQueryExecutionValue(QueryExecutionValue object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'Action Configuration'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Action Configuration'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseActionConfiguration(ActionConfiguration object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'Post Action Configuration'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Post Action Configuration'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T casePostActionConfiguration(PostActionConfiguration object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'EObject'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch, but this is the last case anyway. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'EObject'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) - * @generated - */ - @Override - public T defaultCase(EObject object) { - return null; - } - -} //ModifySemanticValuesActionConfigurationSwitch diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationXMLProcessor.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationXMLProcessor.java deleted file mode 100644 index 75f9ec3549e..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationXMLProcessor.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util; - -import java.util.Map; - -import org.eclipse.emf.ecore.EPackage; - -import org.eclipse.emf.ecore.resource.Resource; - -import org.eclipse.emf.ecore.xmi.util.XMLProcessor; - -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; - -/** - * This class contains helper methods to serialize and deserialize XML documents - * - * - * @generated - */ -public class ModifySemanticValuesActionConfigurationXMLProcessor extends XMLProcessor { - - /** - * Public constructor to instantiate the helper. - * - * - * @generated - */ - public ModifySemanticValuesActionConfigurationXMLProcessor() { - super((EPackage.Registry.INSTANCE)); - ModifySemanticValuesActionConfigurationPackage.eINSTANCE.eClass(); - } - - /** - * Register for "*" and "xml" file extensions the ModifySemanticValuesActionConfigurationResourceFactoryImpl factory. - * - * - * @generated - */ - @Override - protected Map getRegistrations() { - if (registrations == null) { - super.getRegistrations(); - registrations.put(XML_EXTENSION, new ModifySemanticValuesActionConfigurationResourceFactoryImpl()); - registrations.put(STAR_EXTENSION, new ModifySemanticValuesActionConfigurationResourceFactoryImpl()); - } - return registrations; - } - -} //ModifySemanticValuesActionConfigurationXMLProcessor diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ConstantValue.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ConstantValue.java new file mode 100644 index 00000000000..fd3845d569d --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ConstantValue.java @@ -0,0 +1,54 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration; + +import org.eclipse.uml2.uml.ValueSpecification; + +/** + * + * A representation of the model object 'Constant Value'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue#getValueInstance Value Instance}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getConstantValue() + * @model + * @generated + */ +public interface ConstantValue extends FeatureValue { + /** + * Returns the value of the 'Value Instance' containment reference. + * + *

+ * If the meaning of the 'Value Instance' containment reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Value Instance' containment reference. + * @see #setValueInstance(ValueSpecification) + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getConstantValue_ValueInstance() + * @model containment="true" + * @generated + */ + ValueSpecification getValueInstance(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue#getValueInstance Value Instance}' containment reference. + * + * + * @param value the new value of the 'Value Instance' containment reference. + * @see #getValueInstance() + * @generated + */ + void setValueInstance(ValueSpecification value); + +} // ConstantValue diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/DynamicValue.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/DynamicValue.java new file mode 100644 index 00000000000..ab1de224cf8 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/DynamicValue.java @@ -0,0 +1,21 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration; + + +/** + * + * A representation of the model object 'Dynamic Value'. + * + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getDynamicValue() + * @model + * @generated + */ +public interface DynamicValue extends FeatureValue { +} // DynamicValue diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureToSet.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureToSet.java new file mode 100644 index 00000000000..1beda453abd --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureToSet.java @@ -0,0 +1,81 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Feature To Set'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getFeatureName Feature Name}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getValue Value}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getFeatureToSet() + * @model + * @generated + */ +public interface FeatureToSet extends EObject { + /** + * Returns the value of the 'Feature Name' attribute. + * + *

+ * If the meaning of the 'Feature Name' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Feature Name' attribute. + * @see #setFeatureName(String) + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getFeatureToSet_FeatureName() + * @model required="true" + * @generated + */ + String getFeatureName(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getFeatureName Feature Name}' attribute. + * + * + * @param value the new value of the 'Feature Name' attribute. + * @see #getFeatureName() + * @generated + */ + void setFeatureName(String value); + + /** + * Returns the value of the 'Value' containment reference. + * + *

+ * If the meaning of the 'Value' containment reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Value' containment reference. + * @see #setValue(FeatureValue) + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getFeatureToSet_Value() + * @model containment="true" required="true" + * @generated + */ + FeatureValue getValue(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getValue Value}' containment reference. + * + * + * @param value the new value of the 'Value' containment reference. + * @see #getValue() + * @generated + */ + void setValue(FeatureValue value); + +} // FeatureToSet diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureValue.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureValue.java new file mode 100644 index 00000000000..f48176278bc --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/FeatureValue.java @@ -0,0 +1,22 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Feature Value'. + * + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getFeatureValue() + * @model abstract="true" + * @generated + */ +public interface FeatureValue extends EObject { +} // FeatureValue diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ListValue.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ListValue.java new file mode 100644 index 00000000000..fb889826620 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ListValue.java @@ -0,0 +1,44 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration; + +import org.eclipse.emf.common.util.EList; + +/** + * + * A representation of the model object 'List Value'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue#getValues Values}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getListValue() + * @model + * @generated + */ +public interface ListValue extends FeatureValue { + /** + * Returns the value of the 'Values' reference list. + * The list contents are of type {@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue}. + * + *

+ * If the meaning of the 'Values' reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Values' reference list. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getListValue_Values() + * @model + * @generated + */ + EList getValues(); + +} // ListValue diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfiguration.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfiguration.java new file mode 100644 index 00000000000..f87a0fa77fc --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfiguration.java @@ -0,0 +1,46 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration; + +/** + * + * A representation of the model object 'Modify Semantic Values Action Configuration'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration#getFeaturesToSet Features To Set}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getModifySemanticValuesActionConfiguration() + * @model + * @generated + */ +public interface ModifySemanticValuesActionConfiguration extends PostActionConfiguration { + /** + * Returns the value of the 'Features To Set' containment reference list. + * The list contents are of type {@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet}. + * + *

+ * If the meaning of the 'Features To Set' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Features To Set' containment reference list. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getModifySemanticValuesActionConfiguration_FeaturesToSet() + * @model containment="true" + * @generated + */ + EList getFeaturesToSet(); + +} // ModifySemanticValuesActionConfiguration diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationFactory.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationFactory.java new file mode 100644 index 00000000000..e38f1f1692f --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationFactory.java @@ -0,0 +1,91 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage + * @generated + */ +public interface ModifySemanticValuesActionConfigurationFactory extends EFactory { + /** + * The singleton instance of the factory. + * + * + * @generated + */ + ModifySemanticValuesActionConfigurationFactory eINSTANCE = org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationFactoryImpl.init(); + + /** + * Returns a new object of class 'Modify Semantic Values Action Configuration'. + * + * + * @return a new object of class 'Modify Semantic Values Action Configuration'. + * @generated + */ + ModifySemanticValuesActionConfiguration createModifySemanticValuesActionConfiguration(); + + /** + * Returns a new object of class 'Feature To Set'. + * + * + * @return a new object of class 'Feature To Set'. + * @generated + */ + FeatureToSet createFeatureToSet(); + + /** + * Returns a new object of class 'Dynamic Value'. + * + * + * @return a new object of class 'Dynamic Value'. + * @generated + */ + DynamicValue createDynamicValue(); + + /** + * Returns a new object of class 'Constant Value'. + * + * + * @return a new object of class 'Constant Value'. + * @generated + */ + ConstantValue createConstantValue(); + + /** + * Returns a new object of class 'List Value'. + * + * + * @return a new object of class 'List Value'. + * @generated + */ + ListValue createListValue(); + + /** + * Returns a new object of class 'Query Execution Value'. + * + * + * @return a new object of class 'Query Execution Value'. + * @generated + */ + QueryExecutionValue createQueryExecutionValue(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + ModifySemanticValuesActionConfigurationPackage getModifySemanticValuesActionConfigurationPackage(); + +} //ModifySemanticValuesActionConfigurationFactory diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationPackage.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationPackage.java new file mode 100644 index 00000000000..e69f4a020b0 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/ModifySemanticValuesActionConfigurationPackage.java @@ -0,0 +1,548 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationFactory + * @model kind="package" + * @generated + */ +public interface ModifySemanticValuesActionConfigurationPackage extends EPackage { + /** + * The package name. + * + * + * @generated + */ + String eNAME = "modifysemanticvaluesactionconfiguration"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://www.eclipse.org/papyrus/diagram/types/modifysemanticvaluesactionconfiguration/0.8"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "modifysemanticvaluesactionconfiguration"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + ModifySemanticValuesActionConfigurationPackage eINSTANCE = org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl.init(); + + /** + * The meta object id for the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationImpl Modify Semantic Values Action Configuration}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationImpl + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getModifySemanticValuesActionConfiguration() + * @generated + */ + int MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION = 0; + + /** + * The feature id for the 'Label' attribute. + * + * + * @generated + * @ordered + */ + int MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__LABEL = ExtendedtypesPackage.POST_ACTION_CONFIGURATION__LABEL; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__ID = ExtendedtypesPackage.POST_ACTION_CONFIGURATION__ID; + + /** + * The feature id for the 'Features To Set' containment reference list. + * + * + * @generated + * @ordered + */ + int MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET = ExtendedtypesPackage.POST_ACTION_CONFIGURATION_FEATURE_COUNT + 0; + + /** + * The number of structural features of the 'Modify Semantic Values Action Configuration' class. + * + * + * @generated + * @ordered + */ + int MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION_FEATURE_COUNT = ExtendedtypesPackage.POST_ACTION_CONFIGURATION_FEATURE_COUNT + 1; + + /** + * The meta object id for the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureToSetImpl Feature To Set}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureToSetImpl + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getFeatureToSet() + * @generated + */ + int FEATURE_TO_SET = 1; + + /** + * The feature id for the 'Feature Name' attribute. + * + * + * @generated + * @ordered + */ + int FEATURE_TO_SET__FEATURE_NAME = 0; + + /** + * The feature id for the 'Value' containment reference. + * + * + * @generated + * @ordered + */ + int FEATURE_TO_SET__VALUE = 1; + + /** + * The number of structural features of the 'Feature To Set' class. + * + * + * @generated + * @ordered + */ + int FEATURE_TO_SET_FEATURE_COUNT = 2; + + /** + * The meta object id for the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureValueImpl Feature Value}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureValueImpl + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getFeatureValue() + * @generated + */ + int FEATURE_VALUE = 2; + + /** + * The number of structural features of the 'Feature Value' class. + * + * + * @generated + * @ordered + */ + int FEATURE_VALUE_FEATURE_COUNT = 0; + + /** + * The meta object id for the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.DynamicValueImpl Dynamic Value}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.DynamicValueImpl + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getDynamicValue() + * @generated + */ + int DYNAMIC_VALUE = 3; + + /** + * The number of structural features of the 'Dynamic Value' class. + * + * + * @generated + * @ordered + */ + int DYNAMIC_VALUE_FEATURE_COUNT = FEATURE_VALUE_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ConstantValueImpl Constant Value}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ConstantValueImpl + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getConstantValue() + * @generated + */ + int CONSTANT_VALUE = 4; + + /** + * The feature id for the 'Value Instance' containment reference. + * + * + * @generated + * @ordered + */ + int CONSTANT_VALUE__VALUE_INSTANCE = FEATURE_VALUE_FEATURE_COUNT + 0; + + /** + * The number of structural features of the 'Constant Value' class. + * + * + * @generated + * @ordered + */ + int CONSTANT_VALUE_FEATURE_COUNT = FEATURE_VALUE_FEATURE_COUNT + 1; + + /** + * The meta object id for the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ListValueImpl List Value}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ListValueImpl + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getListValue() + * @generated + */ + int LIST_VALUE = 5; + + /** + * The feature id for the 'Values' reference list. + * + * + * @generated + * @ordered + */ + int LIST_VALUE__VALUES = FEATURE_VALUE_FEATURE_COUNT + 0; + + /** + * The number of structural features of the 'List Value' class. + * + * + * @generated + * @ordered + */ + int LIST_VALUE_FEATURE_COUNT = FEATURE_VALUE_FEATURE_COUNT + 1; + + /** + * The meta object id for the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.QueryExecutionValueImpl Query Execution Value}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.QueryExecutionValueImpl + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getQueryExecutionValue() + * @generated + */ + int QUERY_EXECUTION_VALUE = 6; + + /** + * The feature id for the 'Configuration' reference. + * + * + * @generated + * @ordered + */ + int QUERY_EXECUTION_VALUE__CONFIGURATION = FEATURE_VALUE_FEATURE_COUNT + 0; + + /** + * The number of structural features of the 'Query Execution Value' class. + * + * + * @generated + * @ordered + */ + int QUERY_EXECUTION_VALUE_FEATURE_COUNT = FEATURE_VALUE_FEATURE_COUNT + 1; + + + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration Modify Semantic Values Action Configuration}'. + * + * + * @return the meta object for class 'Modify Semantic Values Action Configuration'. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration + * @generated + */ + EClass getModifySemanticValuesActionConfiguration(); + + /** + * Returns the meta object for the containment reference list '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration#getFeaturesToSet Features To Set}'. + * + * + * @return the meta object for the containment reference list 'Features To Set'. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration#getFeaturesToSet() + * @see #getModifySemanticValuesActionConfiguration() + * @generated + */ + EReference getModifySemanticValuesActionConfiguration_FeaturesToSet(); + + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet Feature To Set}'. + * + * + * @return the meta object for class 'Feature To Set'. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet + * @generated + */ + EClass getFeatureToSet(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getFeatureName Feature Name}'. + * + * + * @return the meta object for the attribute 'Feature Name'. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getFeatureName() + * @see #getFeatureToSet() + * @generated + */ + EAttribute getFeatureToSet_FeatureName(); + + /** + * Returns the meta object for the containment reference '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getValue Value}'. + * + * + * @return the meta object for the containment reference 'Value'. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet#getValue() + * @see #getFeatureToSet() + * @generated + */ + EReference getFeatureToSet_Value(); + + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue Feature Value}'. + * + * + * @return the meta object for class 'Feature Value'. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue + * @generated + */ + EClass getFeatureValue(); + + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.DynamicValue Dynamic Value}'. + * + * + * @return the meta object for class 'Dynamic Value'. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.DynamicValue + * @generated + */ + EClass getDynamicValue(); + + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue Constant Value}'. + * + * + * @return the meta object for class 'Constant Value'. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue + * @generated + */ + EClass getConstantValue(); + + /** + * Returns the meta object for the containment reference '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue#getValueInstance Value Instance}'. + * + * + * @return the meta object for the containment reference 'Value Instance'. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue#getValueInstance() + * @see #getConstantValue() + * @generated + */ + EReference getConstantValue_ValueInstance(); + + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue List Value}'. + * + * + * @return the meta object for class 'List Value'. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue + * @generated + */ + EClass getListValue(); + + /** + * Returns the meta object for the reference list '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue#getValues Values}'. + * + * + * @return the meta object for the reference list 'Values'. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue#getValues() + * @see #getListValue() + * @generated + */ + EReference getListValue_Values(); + + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue Query Execution Value}'. + * + * + * @return the meta object for class 'Query Execution Value'. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue + * @generated + */ + EClass getQueryExecutionValue(); + + /** + * Returns the meta object for the reference '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue#getConfiguration Configuration}'. + * + * + * @return the meta object for the reference 'Configuration'. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue#getConfiguration() + * @see #getQueryExecutionValue() + * @generated + */ + EReference getQueryExecutionValue_Configuration(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + ModifySemanticValuesActionConfigurationFactory getModifySemanticValuesActionConfigurationFactory(); + + /** + * + * Defines literals for the meta objects that represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationImpl Modify Semantic Values Action Configuration}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationImpl + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getModifySemanticValuesActionConfiguration() + * @generated + */ + EClass MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION = eINSTANCE.getModifySemanticValuesActionConfiguration(); + + /** + * The meta object literal for the 'Features To Set' containment reference list feature. + * + * + * @generated + */ + EReference MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET = eINSTANCE.getModifySemanticValuesActionConfiguration_FeaturesToSet(); + + /** + * The meta object literal for the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureToSetImpl Feature To Set}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureToSetImpl + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getFeatureToSet() + * @generated + */ + EClass FEATURE_TO_SET = eINSTANCE.getFeatureToSet(); + + /** + * The meta object literal for the 'Feature Name' attribute feature. + * + * + * @generated + */ + EAttribute FEATURE_TO_SET__FEATURE_NAME = eINSTANCE.getFeatureToSet_FeatureName(); + + /** + * The meta object literal for the 'Value' containment reference feature. + * + * + * @generated + */ + EReference FEATURE_TO_SET__VALUE = eINSTANCE.getFeatureToSet_Value(); + + /** + * The meta object literal for the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureValueImpl Feature Value}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureValueImpl + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getFeatureValue() + * @generated + */ + EClass FEATURE_VALUE = eINSTANCE.getFeatureValue(); + + /** + * The meta object literal for the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.DynamicValueImpl Dynamic Value}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.DynamicValueImpl + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getDynamicValue() + * @generated + */ + EClass DYNAMIC_VALUE = eINSTANCE.getDynamicValue(); + + /** + * The meta object literal for the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ConstantValueImpl Constant Value}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ConstantValueImpl + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getConstantValue() + * @generated + */ + EClass CONSTANT_VALUE = eINSTANCE.getConstantValue(); + + /** + * The meta object literal for the 'Value Instance' containment reference feature. + * + * + * @generated + */ + EReference CONSTANT_VALUE__VALUE_INSTANCE = eINSTANCE.getConstantValue_ValueInstance(); + + /** + * The meta object literal for the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ListValueImpl List Value}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ListValueImpl + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getListValue() + * @generated + */ + EClass LIST_VALUE = eINSTANCE.getListValue(); + + /** + * The meta object literal for the 'Values' reference list feature. + * + * + * @generated + */ + EReference LIST_VALUE__VALUES = eINSTANCE.getListValue_Values(); + + /** + * The meta object literal for the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.QueryExecutionValueImpl Query Execution Value}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.QueryExecutionValueImpl + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationPackageImpl#getQueryExecutionValue() + * @generated + */ + EClass QUERY_EXECUTION_VALUE = eINSTANCE.getQueryExecutionValue(); + + /** + * The meta object literal for the 'Configuration' reference feature. + * + * + * @generated + */ + EReference QUERY_EXECUTION_VALUE__CONFIGURATION = eINSTANCE.getQueryExecutionValue_Configuration(); + + } + +} //ModifySemanticValuesActionConfigurationPackage diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/QueryExecutionValue.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/QueryExecutionValue.java new file mode 100644 index 00000000000..60c3ee93a61 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/QueryExecutionValue.java @@ -0,0 +1,54 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration; + +import org.eclipse.papyrus.infra.queries.core.configuration.QueryConfiguration; + +/** + * + * A representation of the model object 'Query Execution Value'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue#getConfiguration Configuration}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getQueryExecutionValue() + * @model + * @generated + */ +public interface QueryExecutionValue extends FeatureValue { + /** + * Returns the value of the 'Configuration' reference. + * + *

+ * If the meaning of the 'Configuration' reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Configuration' reference. + * @see #setConfiguration(QueryConfiguration) + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#getQueryExecutionValue_Configuration() + * @model + * @generated + */ + QueryConfiguration getConfiguration(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue#getConfiguration Configuration}' reference. + * + * + * @param value the new value of the 'Configuration' reference. + * @see #getConfiguration() + * @generated + */ + void setConfiguration(QueryConfiguration value); + +} // QueryExecutionValue diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ConstantValueImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ConstantValueImpl.java new file mode 100644 index 00000000000..b6c6683c8fc --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ConstantValueImpl.java @@ -0,0 +1,180 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; + +import org.eclipse.uml2.uml.ValueSpecification; + +/** + * + * An implementation of the model object 'Constant Value'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ConstantValueImpl#getValueInstance Value Instance}
  • + *
+ *

+ * + * @generated + */ +public class ConstantValueImpl extends FeatureValueImpl implements ConstantValue { + /** + * The cached value of the '{@link #getValueInstance() Value Instance}' containment reference. + * + * + * @see #getValueInstance() + * @generated + * @ordered + */ + protected ValueSpecification valueInstance; + + /** + * + * + * @generated + */ + protected ConstantValueImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ModifySemanticValuesActionConfigurationPackage.Literals.CONSTANT_VALUE; + } + + /** + * + * + * @generated + */ + public ValueSpecification getValueInstance() { + return valueInstance; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetValueInstance(ValueSpecification newValueInstance, NotificationChain msgs) { + ValueSpecification oldValueInstance = valueInstance; + valueInstance = newValueInstance; + if (eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE, oldValueInstance, newValueInstance); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setValueInstance(ValueSpecification newValueInstance) { + if (newValueInstance != valueInstance) { + NotificationChain msgs = null; + if (valueInstance != null) + msgs = ((InternalEObject)valueInstance).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE, null, msgs); + if (newValueInstance != null) + msgs = ((InternalEObject)newValueInstance).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE, null, msgs); + msgs = basicSetValueInstance(newValueInstance, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE, newValueInstance, newValueInstance)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE: + return basicSetValueInstance(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE: + return getValueInstance(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE: + setValueInstance((ValueSpecification)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE: + setValueInstance((ValueSpecification)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE__VALUE_INSTANCE: + return valueInstance != null; + } + return super.eIsSet(featureID); + } + +} //ConstantValueImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/DynamicValueImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/DynamicValueImpl.java new file mode 100644 index 00000000000..947f33547e8 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/DynamicValueImpl.java @@ -0,0 +1,43 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.DynamicValue; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; + +/** + * + * An implementation of the model object 'Dynamic Value'. + * + *

+ *

+ * + * @generated + */ +public class DynamicValueImpl extends FeatureValueImpl implements DynamicValue { + /** + * + * + * @generated + */ + protected DynamicValueImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ModifySemanticValuesActionConfigurationPackage.Literals.DYNAMIC_VALUE; + } + +} //DynamicValueImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureToSetImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureToSetImpl.java new file mode 100644 index 00000000000..5a91323c5b6 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureToSetImpl.java @@ -0,0 +1,248 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; + +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; + +/** + * + * An implementation of the model object 'Feature To Set'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureToSetImpl#getFeatureName Feature Name}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.FeatureToSetImpl#getValue Value}
  • + *
+ *

+ * + * @generated + */ +public class FeatureToSetImpl extends EObjectImpl implements FeatureToSet { + /** + * The default value of the '{@link #getFeatureName() Feature Name}' attribute. + * + * + * @see #getFeatureName() + * @generated + * @ordered + */ + protected static final String FEATURE_NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getFeatureName() Feature Name}' attribute. + * + * + * @see #getFeatureName() + * @generated + * @ordered + */ + protected String featureName = FEATURE_NAME_EDEFAULT; + + /** + * The cached value of the '{@link #getValue() Value}' containment reference. + * + * + * @see #getValue() + * @generated + * @ordered + */ + protected FeatureValue value; + + /** + * + * + * @generated + */ + protected FeatureToSetImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ModifySemanticValuesActionConfigurationPackage.Literals.FEATURE_TO_SET; + } + + /** + * + * + * @generated + */ + public String getFeatureName() { + return featureName; + } + + /** + * + * + * @generated + */ + public void setFeatureName(String newFeatureName) { + String oldFeatureName = featureName; + featureName = newFeatureName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__FEATURE_NAME, oldFeatureName, featureName)); + } + + /** + * + * + * @generated + */ + public FeatureValue getValue() { + return value; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetValue(FeatureValue newValue, NotificationChain msgs) { + FeatureValue oldValue = value; + value = newValue; + if (eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE, oldValue, newValue); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setValue(FeatureValue newValue) { + if (newValue != value) { + NotificationChain msgs = null; + if (value != null) + msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE, null, msgs); + if (newValue != null) + msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE, null, msgs); + msgs = basicSetValue(newValue, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE, newValue, newValue)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE: + return basicSetValue(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__FEATURE_NAME: + return getFeatureName(); + case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE: + return getValue(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__FEATURE_NAME: + setFeatureName((String)newValue); + return; + case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE: + setValue((FeatureValue)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__FEATURE_NAME: + setFeatureName(FEATURE_NAME_EDEFAULT); + return; + case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE: + setValue((FeatureValue)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__FEATURE_NAME: + return FEATURE_NAME_EDEFAULT == null ? featureName != null : !FEATURE_NAME_EDEFAULT.equals(featureName); + case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET__VALUE: + return value != null; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (featureName: "); + result.append(featureName); + result.append(')'); + return result.toString(); + } + +} //FeatureToSetImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureValueImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureValueImpl.java new file mode 100644 index 00000000000..14f25be6e05 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/FeatureValueImpl.java @@ -0,0 +1,45 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.EObjectImpl; + +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; + +/** + * + * An implementation of the model object 'Feature Value'. + * + *

+ *

+ * + * @generated + */ +public abstract class FeatureValueImpl extends EObjectImpl implements FeatureValue { + /** + * + * + * @generated + */ + protected FeatureValueImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ModifySemanticValuesActionConfigurationPackage.Literals.FEATURE_VALUE; + } + +} //FeatureValueImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ListValueImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ListValueImpl.java new file mode 100644 index 00000000000..87d157f600b --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ListValueImpl.java @@ -0,0 +1,136 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.util.EObjectResolvingEList; + +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; + +/** + * + * An implementation of the model object 'List Value'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ListValueImpl#getValues Values}
  • + *
+ *

+ * + * @generated + */ +public class ListValueImpl extends FeatureValueImpl implements ListValue { + /** + * The cached value of the '{@link #getValues() Values}' reference list. + * + * + * @see #getValues() + * @generated + * @ordered + */ + protected EList values; + + /** + * + * + * @generated + */ + protected ListValueImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ModifySemanticValuesActionConfigurationPackage.Literals.LIST_VALUE; + } + + /** + * + * + * @generated + */ + public EList getValues() { + if (values == null) { + values = new EObjectResolvingEList(FeatureValue.class, this, ModifySemanticValuesActionConfigurationPackage.LIST_VALUE__VALUES); + } + return values; + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.LIST_VALUE__VALUES: + return getValues(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.LIST_VALUE__VALUES: + getValues().clear(); + getValues().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.LIST_VALUE__VALUES: + getValues().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.LIST_VALUE__VALUES: + return values != null && !values.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //ListValueImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationFactoryImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationFactoryImpl.java new file mode 100644 index 00000000000..0428ac0a226 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationFactoryImpl.java @@ -0,0 +1,154 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.*; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class ModifySemanticValuesActionConfigurationFactoryImpl extends EFactoryImpl implements ModifySemanticValuesActionConfigurationFactory { + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static ModifySemanticValuesActionConfigurationFactory init() { + try { + ModifySemanticValuesActionConfigurationFactory theModifySemanticValuesActionConfigurationFactory = (ModifySemanticValuesActionConfigurationFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.eclipse.org/papyrus/diagram/types/modifysemanticvaluesactionconfiguration/0.8"); + if (theModifySemanticValuesActionConfigurationFactory != null) { + return theModifySemanticValuesActionConfigurationFactory; + } + } + catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new ModifySemanticValuesActionConfigurationFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public ModifySemanticValuesActionConfigurationFactoryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION: return createModifySemanticValuesActionConfiguration(); + case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET: return createFeatureToSet(); + case ModifySemanticValuesActionConfigurationPackage.DYNAMIC_VALUE: return createDynamicValue(); + case ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE: return createConstantValue(); + case ModifySemanticValuesActionConfigurationPackage.LIST_VALUE: return createListValue(); + case ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE: return createQueryExecutionValue(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public ModifySemanticValuesActionConfiguration createModifySemanticValuesActionConfiguration() { + ModifySemanticValuesActionConfigurationImpl modifySemanticValuesActionConfiguration = new ModifySemanticValuesActionConfigurationImpl(); + return modifySemanticValuesActionConfiguration; + } + + /** + * + * + * @generated + */ + public FeatureToSet createFeatureToSet() { + FeatureToSetImpl featureToSet = new FeatureToSetImpl(); + return featureToSet; + } + + /** + * + * + * @generated + */ + public DynamicValue createDynamicValue() { + DynamicValueImpl dynamicValue = new DynamicValueImpl(); + return dynamicValue; + } + + /** + * + * + * @generated + */ + public ConstantValue createConstantValue() { + ConstantValueImpl constantValue = new ConstantValueImpl(); + return constantValue; + } + + /** + * + * + * @generated + */ + public ListValue createListValue() { + ListValueImpl listValue = new ListValueImpl(); + return listValue; + } + + /** + * + * + * @generated + */ + public QueryExecutionValue createQueryExecutionValue() { + QueryExecutionValueImpl queryExecutionValue = new QueryExecutionValueImpl(); + return queryExecutionValue; + } + + /** + * + * + * @generated + */ + public ModifySemanticValuesActionConfigurationPackage getModifySemanticValuesActionConfigurationPackage() { + return (ModifySemanticValuesActionConfigurationPackage)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static ModifySemanticValuesActionConfigurationPackage getPackage() { + return ModifySemanticValuesActionConfigurationPackage.eINSTANCE; + } + +} //ModifySemanticValuesActionConfigurationFactoryImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationImpl.java new file mode 100644 index 00000000000..0fca96c3f37 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationImpl.java @@ -0,0 +1,156 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; + + +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; +import org.eclipse.papyrus.infra.extendedtypes.impl.PostActionConfigurationImpl; + +/** + * + * An implementation of the model object 'Modify Semantic Values Action Configuration'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.ModifySemanticValuesActionConfigurationImpl#getFeaturesToSet Features To Set}
  • + *
+ *

+ * + * @generated + */ +public class ModifySemanticValuesActionConfigurationImpl extends PostActionConfigurationImpl implements ModifySemanticValuesActionConfiguration { + /** + * The cached value of the '{@link #getFeaturesToSet() Features To Set}' containment reference list. + * + * + * @see #getFeaturesToSet() + * @generated + * @ordered + */ + protected EList featuresToSet; + + /** + * + * + * @generated + */ + protected ModifySemanticValuesActionConfigurationImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ModifySemanticValuesActionConfigurationPackage.Literals.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION; + } + + /** + * + * + * @generated + */ + public EList getFeaturesToSet() { + if (featuresToSet == null) { + featuresToSet = new EObjectContainmentEList(FeatureToSet.class, this, ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET); + } + return featuresToSet; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET: + return ((InternalEList)getFeaturesToSet()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET: + return getFeaturesToSet(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET: + getFeaturesToSet().clear(); + getFeaturesToSet().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET: + getFeaturesToSet().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET: + return featuresToSet != null && !featuresToSet.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //ModifySemanticValuesActionConfigurationImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationPackageImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationPackageImpl.java new file mode 100644 index 00000000000..ebb557aab5b --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/ModifySemanticValuesActionConfigurationPackageImpl.java @@ -0,0 +1,384 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EcorePackage; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + + + +import org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.DynamicValue; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationFactory; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue; +import org.eclipse.papyrus.infra.queries.core.configuration.ConfigurationPackage; + +import org.eclipse.uml2.uml.UMLPackage; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class ModifySemanticValuesActionConfigurationPackageImpl extends EPackageImpl implements ModifySemanticValuesActionConfigurationPackage { + /** + * + * + * @generated + */ + private EClass modifySemanticValuesActionConfigurationEClass = null; + + /** + * + * + * @generated + */ + private EClass featureToSetEClass = null; + + /** + * + * + * @generated + */ + private EClass featureValueEClass = null; + + /** + * + * + * @generated + */ + private EClass dynamicValueEClass = null; + + /** + * + * + * @generated + */ + private EClass constantValueEClass = null; + + /** + * + * + * @generated + */ + private EClass listValueEClass = null; + + /** + * + * + * @generated + */ + private EClass queryExecutionValueEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage#eNS_URI + * @see #init() + * @generated + */ + private ModifySemanticValuesActionConfigurationPackageImpl() { + super(eNS_URI, ModifySemanticValuesActionConfigurationFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link ModifySemanticValuesActionConfigurationPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static ModifySemanticValuesActionConfigurationPackage init() { + if (isInited) return (ModifySemanticValuesActionConfigurationPackage)EPackage.Registry.INSTANCE.getEPackage(ModifySemanticValuesActionConfigurationPackage.eNS_URI); + + // Obtain or create and register package + ModifySemanticValuesActionConfigurationPackageImpl theModifySemanticValuesActionConfigurationPackage = (ModifySemanticValuesActionConfigurationPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof ModifySemanticValuesActionConfigurationPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new ModifySemanticValuesActionConfigurationPackageImpl()); + + isInited = true; + + // Initialize simple dependencies + ExtendedtypesPackage.eINSTANCE.eClass(); + + // Create package meta-data objects + theModifySemanticValuesActionConfigurationPackage.createPackageContents(); + + // Initialize created meta-data + theModifySemanticValuesActionConfigurationPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theModifySemanticValuesActionConfigurationPackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(ModifySemanticValuesActionConfigurationPackage.eNS_URI, theModifySemanticValuesActionConfigurationPackage); + return theModifySemanticValuesActionConfigurationPackage; + } + + /** + * + * + * @generated + */ + public EClass getModifySemanticValuesActionConfiguration() { + return modifySemanticValuesActionConfigurationEClass; + } + + /** + * + * + * @generated + */ + public EReference getModifySemanticValuesActionConfiguration_FeaturesToSet() { + return (EReference)modifySemanticValuesActionConfigurationEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EClass getFeatureToSet() { + return featureToSetEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getFeatureToSet_FeatureName() { + return (EAttribute)featureToSetEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EReference getFeatureToSet_Value() { + return (EReference)featureToSetEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EClass getFeatureValue() { + return featureValueEClass; + } + + /** + * + * + * @generated + */ + public EClass getDynamicValue() { + return dynamicValueEClass; + } + + /** + * + * + * @generated + */ + public EClass getConstantValue() { + return constantValueEClass; + } + + /** + * + * + * @generated + */ + public EReference getConstantValue_ValueInstance() { + return (EReference)constantValueEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EClass getListValue() { + return listValueEClass; + } + + /** + * + * + * @generated + */ + public EReference getListValue_Values() { + return (EReference)listValueEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EClass getQueryExecutionValue() { + return queryExecutionValueEClass; + } + + /** + * + * + * @generated + */ + public EReference getQueryExecutionValue_Configuration() { + return (EReference)queryExecutionValueEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public ModifySemanticValuesActionConfigurationFactory getModifySemanticValuesActionConfigurationFactory() { + return (ModifySemanticValuesActionConfigurationFactory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + modifySemanticValuesActionConfigurationEClass = createEClass(MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION); + createEReference(modifySemanticValuesActionConfigurationEClass, MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION__FEATURES_TO_SET); + + featureToSetEClass = createEClass(FEATURE_TO_SET); + createEAttribute(featureToSetEClass, FEATURE_TO_SET__FEATURE_NAME); + createEReference(featureToSetEClass, FEATURE_TO_SET__VALUE); + + featureValueEClass = createEClass(FEATURE_VALUE); + + dynamicValueEClass = createEClass(DYNAMIC_VALUE); + + constantValueEClass = createEClass(CONSTANT_VALUE); + createEReference(constantValueEClass, CONSTANT_VALUE__VALUE_INSTANCE); + + listValueEClass = createEClass(LIST_VALUE); + createEReference(listValueEClass, LIST_VALUE__VALUES); + + queryExecutionValueEClass = createEClass(QUERY_EXECUTION_VALUE); + createEReference(queryExecutionValueEClass, QUERY_EXECUTION_VALUE__CONFIGURATION); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + ExtendedtypesPackage theExtendedtypesPackage = (ExtendedtypesPackage)EPackage.Registry.INSTANCE.getEPackage(ExtendedtypesPackage.eNS_URI); + EcorePackage theEcorePackage = (EcorePackage)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI); + UMLPackage theUMLPackage = (UMLPackage)EPackage.Registry.INSTANCE.getEPackage(UMLPackage.eNS_URI); + ConfigurationPackage theConfigurationPackage = (ConfigurationPackage)EPackage.Registry.INSTANCE.getEPackage(ConfigurationPackage.eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + modifySemanticValuesActionConfigurationEClass.getESuperTypes().add(theExtendedtypesPackage.getPostActionConfiguration()); + dynamicValueEClass.getESuperTypes().add(this.getFeatureValue()); + constantValueEClass.getESuperTypes().add(this.getFeatureValue()); + listValueEClass.getESuperTypes().add(this.getFeatureValue()); + queryExecutionValueEClass.getESuperTypes().add(this.getFeatureValue()); + + // Initialize classes and features; add operations and parameters + initEClass(modifySemanticValuesActionConfigurationEClass, ModifySemanticValuesActionConfiguration.class, "ModifySemanticValuesActionConfiguration", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getModifySemanticValuesActionConfiguration_FeaturesToSet(), this.getFeatureToSet(), null, "featuresToSet", null, 0, -1, ModifySemanticValuesActionConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(featureToSetEClass, FeatureToSet.class, "FeatureToSet", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getFeatureToSet_FeatureName(), theEcorePackage.getEString(), "featureName", null, 1, 1, FeatureToSet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getFeatureToSet_Value(), this.getFeatureValue(), null, "value", null, 1, 1, FeatureToSet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(featureValueEClass, FeatureValue.class, "FeatureValue", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + initEClass(dynamicValueEClass, DynamicValue.class, "DynamicValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + initEClass(constantValueEClass, ConstantValue.class, "ConstantValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getConstantValue_ValueInstance(), theUMLPackage.getValueSpecification(), null, "valueInstance", null, 0, 1, ConstantValue.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(listValueEClass, ListValue.class, "ListValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getListValue_Values(), this.getFeatureValue(), null, "values", null, 0, -1, ListValue.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(queryExecutionValueEClass, QueryExecutionValue.class, "QueryExecutionValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getQueryExecutionValue_Configuration(), theConfigurationPackage.getQueryConfiguration(), null, "configuration", null, 0, 1, QueryExecutionValue.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} //ModifySemanticValuesActionConfigurationPackageImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/QueryExecutionValueImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/QueryExecutionValueImpl.java new file mode 100644 index 00000000000..483568aa46e --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/impl/QueryExecutionValueImpl.java @@ -0,0 +1,161 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + + +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue; +import org.eclipse.papyrus.infra.queries.core.configuration.QueryConfiguration; + +/** + * + * An implementation of the model object 'Query Execution Value'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.impl.QueryExecutionValueImpl#getConfiguration Configuration}
  • + *
+ *

+ * + * @generated + */ +public class QueryExecutionValueImpl extends FeatureValueImpl implements QueryExecutionValue { + /** + * The cached value of the '{@link #getConfiguration() Configuration}' reference. + * + * + * @see #getConfiguration() + * @generated + * @ordered + */ + protected QueryConfiguration configuration; + + /** + * + * + * @generated + */ + protected QueryExecutionValueImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ModifySemanticValuesActionConfigurationPackage.Literals.QUERY_EXECUTION_VALUE; + } + + /** + * + * + * @generated + */ + public QueryConfiguration getConfiguration() { + if (configuration != null && configuration.eIsProxy()) { + InternalEObject oldConfiguration = (InternalEObject)configuration; + configuration = (QueryConfiguration)eResolveProxy(oldConfiguration); + if (configuration != oldConfiguration) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE__CONFIGURATION, oldConfiguration, configuration)); + } + } + return configuration; + } + + /** + * + * + * @generated + */ + public QueryConfiguration basicGetConfiguration() { + return configuration; + } + + /** + * + * + * @generated + */ + public void setConfiguration(QueryConfiguration newConfiguration) { + QueryConfiguration oldConfiguration = configuration; + configuration = newConfiguration; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE__CONFIGURATION, oldConfiguration, configuration)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE__CONFIGURATION: + if (resolve) return getConfiguration(); + return basicGetConfiguration(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE__CONFIGURATION: + setConfiguration((QueryConfiguration)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE__CONFIGURATION: + setConfiguration((QueryConfiguration)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE__CONFIGURATION: + return configuration != null; + } + return super.eIsSet(featureID); + } + +} //QueryExecutionValueImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationAdapterFactory.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationAdapterFactory.java new file mode 100644 index 00000000000..3ae79b3d992 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationAdapterFactory.java @@ -0,0 +1,271 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + + +import org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.*; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage + * @generated + */ +public class ModifySemanticValuesActionConfigurationAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * + * + * @generated + */ + protected static ModifySemanticValuesActionConfigurationPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public ModifySemanticValuesActionConfigurationAdapterFactory() { + if (modelPackage == null) { + modelPackage = ModifySemanticValuesActionConfigurationPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) { + if (object == modelPackage) { + return true; + } + if (object instanceof EObject) { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected ModifySemanticValuesActionConfigurationSwitch modelSwitch = + new ModifySemanticValuesActionConfigurationSwitch() { + @Override + public Adapter caseModifySemanticValuesActionConfiguration(ModifySemanticValuesActionConfiguration object) { + return createModifySemanticValuesActionConfigurationAdapter(); + } + @Override + public Adapter caseFeatureToSet(FeatureToSet object) { + return createFeatureToSetAdapter(); + } + @Override + public Adapter caseFeatureValue(FeatureValue object) { + return createFeatureValueAdapter(); + } + @Override + public Adapter caseDynamicValue(DynamicValue object) { + return createDynamicValueAdapter(); + } + @Override + public Adapter caseConstantValue(ConstantValue object) { + return createConstantValueAdapter(); + } + @Override + public Adapter caseListValue(ListValue object) { + return createListValueAdapter(); + } + @Override + public Adapter caseQueryExecutionValue(QueryExecutionValue object) { + return createQueryExecutionValueAdapter(); + } + @Override + public Adapter caseActionConfiguration(ActionConfiguration object) { + return createActionConfigurationAdapter(); + } + @Override + public Adapter casePostActionConfiguration(PostActionConfiguration object) { + return createPostActionConfigurationAdapter(); + } + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration Modify Semantic Values Action Configuration}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration + * @generated + */ + public Adapter createModifySemanticValuesActionConfigurationAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet Feature To Set}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet + * @generated + */ + public Adapter createFeatureToSetAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue Feature Value}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue + * @generated + */ + public Adapter createFeatureValueAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.DynamicValue Dynamic Value}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.DynamicValue + * @generated + */ + public Adapter createDynamicValueAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue Constant Value}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue + * @generated + */ + public Adapter createConstantValueAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue List Value}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue + * @generated + */ + public Adapter createListValueAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue Query Execution Value}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue + * @generated + */ + public Adapter createQueryExecutionValueAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration Action Configuration}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration + * @generated + */ + public Adapter createActionConfigurationAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration Post Action Configuration}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration + * @generated + */ + public Adapter createPostActionConfigurationAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //ModifySemanticValuesActionConfigurationAdapterFactory diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceFactoryImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceFactoryImpl.java new file mode 100644 index 00000000000..91222121e14 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceFactoryImpl.java @@ -0,0 +1,56 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.emf.ecore.resource.Resource; + +import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; + +import org.eclipse.emf.ecore.xmi.XMLResource; + +/** + * + * The Resource Factory associated with the package. + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util.ModifySemanticValuesActionConfigurationResourceImpl + * @generated + */ +public class ModifySemanticValuesActionConfigurationResourceFactoryImpl extends ResourceFactoryImpl { + /** + * Creates an instance of the resource factory. + * + * + * @generated + */ + public ModifySemanticValuesActionConfigurationResourceFactoryImpl() { + super(); + } + + /** + * Creates an instance of the resource. + * + * + * @generated + */ + @Override + public Resource createResource(URI uri) { + XMLResource result = new ModifySemanticValuesActionConfigurationResourceImpl(uri); + result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); + result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); + + result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); + + result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); + result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); + + result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE); + return result; + } + +} //ModifySemanticValuesActionConfigurationResourceFactoryImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceImpl.java new file mode 100644 index 00000000000..1e8ff788b37 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationResourceImpl.java @@ -0,0 +1,32 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; + +/** + * + * The Resource associated with the package. + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util.ModifySemanticValuesActionConfigurationResourceFactoryImpl + * @generated + */ +public class ModifySemanticValuesActionConfigurationResourceImpl extends XMLResourceImpl { + /** + * Creates an instance of the resource. + * + * + * @param uri the URI of the new resource. + * @generated + */ + public ModifySemanticValuesActionConfigurationResourceImpl(URI uri) { + super(uri); + } + +} //ModifySemanticValuesActionConfigurationResourceImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationSwitch.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationSwitch.java new file mode 100644 index 00000000000..ccc9aa955f5 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationSwitch.java @@ -0,0 +1,279 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + + +import org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.*; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage + * @generated + */ +public class ModifySemanticValuesActionConfigurationSwitch extends Switch { + /** + * The cached model package + * + * + * @generated + */ + protected static ModifySemanticValuesActionConfigurationPackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public ModifySemanticValuesActionConfigurationSwitch() { + if (modelPackage == null) { + modelPackage = ModifySemanticValuesActionConfigurationPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @parameter ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case ModifySemanticValuesActionConfigurationPackage.MODIFY_SEMANTIC_VALUES_ACTION_CONFIGURATION: { + ModifySemanticValuesActionConfiguration modifySemanticValuesActionConfiguration = (ModifySemanticValuesActionConfiguration)theEObject; + T result = caseModifySemanticValuesActionConfiguration(modifySemanticValuesActionConfiguration); + if (result == null) result = casePostActionConfiguration(modifySemanticValuesActionConfiguration); + if (result == null) result = caseActionConfiguration(modifySemanticValuesActionConfiguration); + if (result == null) result = defaultCase(theEObject); + return result; + } + case ModifySemanticValuesActionConfigurationPackage.FEATURE_TO_SET: { + FeatureToSet featureToSet = (FeatureToSet)theEObject; + T result = caseFeatureToSet(featureToSet); + if (result == null) result = defaultCase(theEObject); + return result; + } + case ModifySemanticValuesActionConfigurationPackage.FEATURE_VALUE: { + FeatureValue featureValue = (FeatureValue)theEObject; + T result = caseFeatureValue(featureValue); + if (result == null) result = defaultCase(theEObject); + return result; + } + case ModifySemanticValuesActionConfigurationPackage.DYNAMIC_VALUE: { + DynamicValue dynamicValue = (DynamicValue)theEObject; + T result = caseDynamicValue(dynamicValue); + if (result == null) result = caseFeatureValue(dynamicValue); + if (result == null) result = defaultCase(theEObject); + return result; + } + case ModifySemanticValuesActionConfigurationPackage.CONSTANT_VALUE: { + ConstantValue constantValue = (ConstantValue)theEObject; + T result = caseConstantValue(constantValue); + if (result == null) result = caseFeatureValue(constantValue); + if (result == null) result = defaultCase(theEObject); + return result; + } + case ModifySemanticValuesActionConfigurationPackage.LIST_VALUE: { + ListValue listValue = (ListValue)theEObject; + T result = caseListValue(listValue); + if (result == null) result = caseFeatureValue(listValue); + if (result == null) result = defaultCase(theEObject); + return result; + } + case ModifySemanticValuesActionConfigurationPackage.QUERY_EXECUTION_VALUE: { + QueryExecutionValue queryExecutionValue = (QueryExecutionValue)theEObject; + T result = caseQueryExecutionValue(queryExecutionValue); + if (result == null) result = caseFeatureValue(queryExecutionValue); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'Modify Semantic Values Action Configuration'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Modify Semantic Values Action Configuration'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseModifySemanticValuesActionConfiguration(ModifySemanticValuesActionConfiguration object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Feature To Set'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Feature To Set'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseFeatureToSet(FeatureToSet object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Feature Value'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Feature Value'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseFeatureValue(FeatureValue object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Dynamic Value'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Dynamic Value'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseDynamicValue(DynamicValue object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Constant Value'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Constant Value'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseConstantValue(ConstantValue object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'List Value'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'List Value'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseListValue(ListValue object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Query Execution Value'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Query Execution Value'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseQueryExecutionValue(QueryExecutionValue object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Action Configuration'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Action Configuration'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseActionConfiguration(ActionConfiguration object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Post Action Configuration'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Post Action Configuration'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePostActionConfiguration(PostActionConfiguration object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //ModifySemanticValuesActionConfigurationSwitch diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationXMLProcessor.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationXMLProcessor.java new file mode 100644 index 00000000000..75cf9df4e82 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src-gen/org/eclipse/papyrus/infra/extendedtypes/emf/modifysemanticvaluesactionconfiguration/util/ModifySemanticValuesActionConfigurationXMLProcessor.java @@ -0,0 +1,54 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util; + +import java.util.Map; + +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.resource.Resource; + +import org.eclipse.emf.ecore.xmi.util.XMLProcessor; + +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfigurationPackage; + +/** + * This class contains helper methods to serialize and deserialize XML documents + * + * + * @generated + */ +public class ModifySemanticValuesActionConfigurationXMLProcessor extends XMLProcessor { + + /** + * Public constructor to instantiate the helper. + * + * + * @generated + */ + public ModifySemanticValuesActionConfigurationXMLProcessor() { + super((EPackage.Registry.INSTANCE)); + ModifySemanticValuesActionConfigurationPackage.eINSTANCE.eClass(); + } + + /** + * Register for "*" and "xml" file extensions the ModifySemanticValuesActionConfigurationResourceFactoryImpl factory. + * + * + * @generated + */ + @Override + protected Map getRegistrations() { + if (registrations == null) { + super.getRegistrations(); + registrations.put(XML_EXTENSION, new ModifySemanticValuesActionConfigurationResourceFactoryImpl()); + registrations.put(STAR_EXTENSION, new ModifySemanticValuesActionConfigurationResourceFactoryImpl()); + } + return registrations; + } + +} //ModifySemanticValuesActionConfigurationXMLProcessor diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/extendedtypes/emf/Activator.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/extendedtypes/emf/Activator.java deleted file mode 100644 index a540803106b..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/extendedtypes/emf/Activator.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.eclipse.papyrus.extendedtypes.emf; - -import org.eclipse.papyrus.log.LogHelper; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.extendedtypes.emf"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** Logging 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(this); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - @Override - public void stop(BundleContext context) throws Exception { - log = null; - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/extendedtypes/emf/providers/ModifySemanticValuesActionProvider.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/extendedtypes/emf/providers/ModifySemanticValuesActionProvider.java deleted file mode 100644 index cc17212a490..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/extendedtypes/emf/providers/ModifySemanticValuesActionProvider.java +++ /dev/null @@ -1,186 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.extendedtypes.emf.providers; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; -import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; -import org.eclipse.gmf.runtime.common.core.service.IOperation; -import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; -import org.eclipse.papyrus.core.queries.configuration.QueryConfiguration; -import org.eclipse.papyrus.core.queries.converter.ConverterNotfoundException; -import org.eclipse.papyrus.core.queries.converter.ConverterRegistry; -import org.eclipse.papyrus.core.queries.modisco.QueryUtil; -import org.eclipse.papyrus.extendedtypes.ActionConfiguration; -import org.eclipse.papyrus.extendedtypes.emf.Activator; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue; -import org.eclipse.papyrus.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util.ModifySemanticValuesActionConfigurationSwitch; -import org.eclipse.papyrus.extendedtypes.providers.GetAllExtendedElementTypeActionProvidersOperation; -import org.eclipse.papyrus.extendedtypes.providers.GetExtendedElementTypeActionProviderOperation; -import org.eclipse.papyrus.extendedtypes.providers.IExtendedElementTypeActionProvider; -import org.eclipse.papyrus.service.edit.service.ElementEditServiceUtils; -import org.eclipse.papyrus.service.edit.service.IElementEditService; - -/** - * Provider for Action that set semantic values to an element on creation - */ -public class ModifySemanticValuesActionProvider extends AbstractProvider implements IExtendedElementTypeActionProvider { - - /** - * {@inheritDoc} - */ - public boolean provides(IOperation operation) { - if(operation instanceof GetAllExtendedElementTypeActionProvidersOperation) { - return true; - } - if(operation instanceof GetExtendedElementTypeActionProviderOperation) { - return (((GetExtendedElementTypeActionProviderOperation)operation).getActionConfiguration() instanceof ModifySemanticValuesActionConfiguration); - } - return false; - } - - /** - * {@inheritDoc} - */ - public ICommand getICommand(List elementsToEdit, ActionConfiguration configuration) { - // try to create the command that will apply the stereotypes - if(!(configuration instanceof ModifySemanticValuesActionConfiguration)) { - Activator.log.error("Trying to configure a modify semantic values action configuration with a configuration which is not a semantic value one: " + configuration, null); - return UnexecutableCommand.INSTANCE; - } - - CompositeCommand compositeCommand = new CompositeCommand("Set Values"); - ModifySemanticValuesActionConfiguration modifySemanticValuesActionConfiguration = (ModifySemanticValuesActionConfiguration)configuration; - - // for each object in the list of eobjects to edit, create the stereotype apply command - for(Object objectToEdit : elementsToEdit) { - // for each feature in the configuration, sets the value - if(objectToEdit instanceof EObject) { - for(FeatureToSet featureToSet : modifySemanticValuesActionConfiguration.getFeaturesToSet()) { - // create a command from a set request and use the Papyrus edit service - EObject eObject = (EObject)objectToEdit; - EStructuralFeature feature = eObject.eClass().getEStructuralFeature(featureToSet.getFeatureName()); - if(feature != null && feature.isChangeable()) { - // retrieve the value to set - FeatureValue featureValue = featureToSet.getValue(); - Object value = computeValue(eObject, feature, featureValue); - SetRequest request = new SetRequest(eObject, feature, value); - IElementEditService service = ElementEditServiceUtils.getCommandProvider(eObject); - ICommand command = service.getEditCommand(request); - if(command != null) { - compositeCommand.add(command); - } - } - } - - // for dynamic features, opens the pop up and ask for the values to set - } - } - return compositeCommand; - } - - /** - * Retrieves the value from the feature value parameter - * - * @param eObject - * the context of the value - * @param feature - * the feature for which the value is computed - * @param featureValue - * the representation of the value of the feature from which to compute the real value - * @return the value of the feature - */ - protected Object computeValue(final EObject eObject, final EStructuralFeature feature, FeatureValue featureValue) { - Object value = new ModifySemanticValuesActionConfigurationSwitch() { - - /** - * {@inheritDoc} - */ - @Override - public Object caseListValue(ListValue listValue) { - List values = new ArrayList(); - for(FeatureValue fValue : listValue.getValues()) { - Object value = computeValue(eObject, feature, fValue); - values.add(value); - } - return values; - }; - - /** - * {@inheritDoc} - */ - @Override - public Object caseQueryExecutionValue(QueryExecutionValue queryExecutionValue) { - Object value = null; - QueryConfiguration configuration = queryExecutionValue.getConfiguration(); - try { - value = QueryUtil.evaluateQuery(eObject, configuration); - } catch (Exception e) { - Activator.log.error(e); - } - return value; - }; - - /** - * {@inheritDoc} - */ - @Override - public Object caseConstantValue(ConstantValue constantValue) { - Class parameterType = feature.getEType().getInstanceClass(); - try { - Object convertedValue = ConverterRegistry.getSingleton().convert(parameterType, constantValue.getValueInstance()); - return convertedValue; - } catch (ConverterNotfoundException e) { - Activator.log.error(e); - } - return null; - } - - }.doSwitch(featureValue); - - return value; - } - - /** - * {@inheritDoc} - */ - public ICommand getBeforeCreateValidationCommand(List elementsToEdit, ActionConfiguration configuration) { - // here, element to edit should be the parent of the created element on which the stereotype is applied. - ModifySemanticValuesActionConfiguration modifySemanticValuesActionConfiguration = (ModifySemanticValuesActionConfiguration)configuration; - - for(Object objectToEdit : elementsToEdit) { - // FIXME ... - } - // returns a null command, which means it is possible to apply the stereotype - return null; - } - - /** - * {@inheritDoc} - */ - public void setConfiguration(IConfigurationElement element) { - // something to do here ? - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/infra/extendedtypes/emf/Activator.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/infra/extendedtypes/emf/Activator.java new file mode 100644 index 00000000000..8692f17824c --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/infra/extendedtypes/emf/Activator.java @@ -0,0 +1,58 @@ +package org.eclipse.papyrus.infra.extendedtypes.emf; + +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 + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.extendedtypes.emf"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** Logging 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(this); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + log = null; + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/infra/extendedtypes/emf/providers/ModifySemanticValuesActionProvider.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/infra/extendedtypes/emf/providers/ModifySemanticValuesActionProvider.java new file mode 100644 index 00000000000..5ecc4b638bd --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes.emf/src/org/eclipse/papyrus/infra/extendedtypes/emf/providers/ModifySemanticValuesActionProvider.java @@ -0,0 +1,186 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.extendedtypes.emf.providers; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; +import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; +import org.eclipse.gmf.runtime.common.core.service.IOperation; +import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; +import org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.emf.Activator; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ConstantValue; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureToSet; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.FeatureValue; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ListValue; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.ModifySemanticValuesActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.QueryExecutionValue; +import org.eclipse.papyrus.infra.extendedtypes.emf.modifysemanticvaluesactionconfiguration.util.ModifySemanticValuesActionConfigurationSwitch; +import org.eclipse.papyrus.infra.extendedtypes.providers.GetAllExtendedElementTypeActionProvidersOperation; +import org.eclipse.papyrus.infra.extendedtypes.providers.GetExtendedElementTypeActionProviderOperation; +import org.eclipse.papyrus.infra.extendedtypes.providers.IExtendedElementTypeActionProvider; +import org.eclipse.papyrus.infra.queries.core.configuration.QueryConfiguration; +import org.eclipse.papyrus.infra.queries.core.converter.ConverterNotfoundException; +import org.eclipse.papyrus.infra.queries.core.converter.ConverterRegistry; +import org.eclipse.papyrus.infra.queries.core.modisco.QueryUtil; +import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; +import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; + +/** + * Provider for Action that set semantic values to an element on creation + */ +public class ModifySemanticValuesActionProvider extends AbstractProvider implements IExtendedElementTypeActionProvider { + + /** + * {@inheritDoc} + */ + public boolean provides(IOperation operation) { + if(operation instanceof GetAllExtendedElementTypeActionProvidersOperation) { + return true; + } + if(operation instanceof GetExtendedElementTypeActionProviderOperation) { + return (((GetExtendedElementTypeActionProviderOperation)operation).getActionConfiguration() instanceof ModifySemanticValuesActionConfiguration); + } + return false; + } + + /** + * {@inheritDoc} + */ + public ICommand getICommand(List elementsToEdit, ActionConfiguration configuration) { + // try to create the command that will apply the stereotypes + if(!(configuration instanceof ModifySemanticValuesActionConfiguration)) { + Activator.log.error("Trying to configure a modify semantic values action configuration with a configuration which is not a semantic value one: " + configuration, null); + return UnexecutableCommand.INSTANCE; + } + + CompositeCommand compositeCommand = new CompositeCommand("Set Values"); + ModifySemanticValuesActionConfiguration modifySemanticValuesActionConfiguration = (ModifySemanticValuesActionConfiguration)configuration; + + // for each object in the list of eobjects to edit, create the stereotype apply command + for(Object objectToEdit : elementsToEdit) { + // for each feature in the configuration, sets the value + if(objectToEdit instanceof EObject) { + for(FeatureToSet featureToSet : modifySemanticValuesActionConfiguration.getFeaturesToSet()) { + // create a command from a set request and use the Papyrus edit service + EObject eObject = (EObject)objectToEdit; + EStructuralFeature feature = eObject.eClass().getEStructuralFeature(featureToSet.getFeatureName()); + if(feature != null && feature.isChangeable()) { + // retrieve the value to set + FeatureValue featureValue = featureToSet.getValue(); + Object value = computeValue(eObject, feature, featureValue); + SetRequest request = new SetRequest(eObject, feature, value); + IElementEditService service = ElementEditServiceUtils.getCommandProvider(eObject); + ICommand command = service.getEditCommand(request); + if(command != null) { + compositeCommand.add(command); + } + } + } + + // for dynamic features, opens the pop up and ask for the values to set + } + } + return compositeCommand; + } + + /** + * Retrieves the value from the feature value parameter + * + * @param eObject + * the context of the value + * @param feature + * the feature for which the value is computed + * @param featureValue + * the representation of the value of the feature from which to compute the real value + * @return the value of the feature + */ + protected Object computeValue(final EObject eObject, final EStructuralFeature feature, FeatureValue featureValue) { + Object value = new ModifySemanticValuesActionConfigurationSwitch() { + + /** + * {@inheritDoc} + */ + @Override + public Object caseListValue(ListValue listValue) { + List values = new ArrayList(); + for(FeatureValue fValue : listValue.getValues()) { + Object value = computeValue(eObject, feature, fValue); + values.add(value); + } + return values; + }; + + /** + * {@inheritDoc} + */ + @Override + public Object caseQueryExecutionValue(QueryExecutionValue queryExecutionValue) { + Object value = null; + QueryConfiguration configuration = queryExecutionValue.getConfiguration(); + try { + value = QueryUtil.evaluateQuery(eObject, configuration); + } catch (Exception e) { + Activator.log.error(e); + } + return value; + }; + + /** + * {@inheritDoc} + */ + @Override + public Object caseConstantValue(ConstantValue constantValue) { + Class parameterType = feature.getEType().getInstanceClass(); + try { + Object convertedValue = ConverterRegistry.getSingleton().convert(parameterType, constantValue.getValueInstance()); + return convertedValue; + } catch (ConverterNotfoundException e) { + Activator.log.error(e); + } + return null; + } + + }.doSwitch(featureValue); + + return value; + } + + /** + * {@inheritDoc} + */ + public ICommand getBeforeCreateValidationCommand(List elementsToEdit, ActionConfiguration configuration) { + // here, element to edit should be the parent of the created element on which the stereotype is applied. + ModifySemanticValuesActionConfiguration modifySemanticValuesActionConfiguration = (ModifySemanticValuesActionConfiguration)configuration; + + for(Object objectToEdit : elementsToEdit) { + // FIXME ... + } + // returns a null command, which means it is possible to apply the stereotype + return null; + } + + /** + * {@inheritDoc} + */ + public void setConfiguration(IConfigurationElement element) { + // something to do here ? + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/META-INF/MANIFEST.MF b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/META-INF/MANIFEST.MF index e90007e5865..dd2695f757b 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/META-INF/MANIFEST.MF +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/META-INF/MANIFEST.MF @@ -1,11 +1,11 @@ Manifest-Version: 1.0 -Export-Package: org.eclipse.papyrus.extendedtypes, - org.eclipse.papyrus.extendedtypes.advices, - org.eclipse.papyrus.extendedtypes.impl, - org.eclipse.papyrus.extendedtypes.preferences, - org.eclipse.papyrus.extendedtypes.providers, - org.eclipse.papyrus.extendedtypes.types, - org.eclipse.papyrus.extendedtypes.util +Export-Package: org.eclipse.papyrus.infra.extendedtypes, + org.eclipse.papyrus.infra.extendedtypes.advices, + org.eclipse.papyrus.infra.extendedtypes.impl, + org.eclipse.papyrus.infra.extendedtypes.preferences, + org.eclipse.papyrus.infra.extendedtypes.providers, + org.eclipse.papyrus.infra.extendedtypes.types, + org.eclipse.papyrus.infra.extendedtypes.util Bundle-ActivationPolicy: lazy Bundle-ClassPath: . Bundle-Name: %pluginName @@ -25,6 +25,6 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0", Bundle-Vendor: %providerName Bundle-Version: 0.9.0.qualifier Bundle-ManifestVersion: 2 -Bundle-Activator: org.eclipse.papyrus.extendedtypes.Activator +Bundle-Activator: org.eclipse.papyrus.infra.extendedtypes.Activator Bundle-SymbolicName: org.eclipse.papyrus.infra.extendedtypes;singleton:=true diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/model/ExtendedTypes.ecore b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/model/ExtendedTypes.ecore index 0d378b102c4..d8480ae3cf4 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/model/ExtendedTypes.ecore +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/model/ExtendedTypes.ecore @@ -20,7 +20,7 @@ + eType="ecore:EClass ../../org.eclipse.papyrus.infra.queries.core.configuration/model/Configuration.ecore#//QueryConfiguration"/> - + diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/model/ExtendedTypes.genmodel b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/model/ExtendedTypes.genmodel index 46d050f55f9..5c09902e186 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/model/ExtendedTypes.genmodel +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/model/ExtendedTypes.genmodel @@ -1,11 +1,11 @@ + xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.eclipse.papyrus.infra.extendedtypes/src-gen" + editDirectory="/org.eclipse.papyrus.infra.extendedtypes.edit/src-gen" editorDirectory="/org.eclipse.papyrus.infra.extendedtypes.editor/src-gen" + modelPluginID="org.eclipse.papyrus.infra.extendedtypes" modelName="ExtendedTypes" + testsDirectory="/org.eclipse.papyrus.infra.extendedtypes.tests/src-gen" importerID="org.eclipse.emf.importer.ecore" + complianceLevel="5.0" copyrightFields="false" usedGenPackages="platform:/plugin/org.eclipse.papyrus.infra.queries.core.configuration/model/Configuration.genmodel#//configuration platform:/plugin/org.eclipse.emf.ecore/model/Ecore.genmodel#//ecore platform:/plugin/org.eclipse.emf.facet.infra.query/model/query.genmodel#//query platform:/plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml"> ExtendedTypes.ecore diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/plugin.xml b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/plugin.xml index b862ddec900..1a7444208b4 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/plugin.xml +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/plugin.xml @@ -15,21 +15,21 @@ + class="org.eclipse.papyrus.infra.extendedtypes.util.ExtendedtypesResourceFactoryImpl"/> @@ -39,7 +39,7 @@ + context="org.eclipse.papyrus.infra.services.edit.TypeContext"> diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/extendedElementTypeActionProvider.exsd b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/extendedElementTypeActionProvider.exsd index 9ffbc995646..5ddeeda67ac 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/extendedElementTypeActionProvider.exsd +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/extendedElementTypeActionProvider.exsd @@ -1,9 +1,9 @@ - + - + This extension point provides the mechanism to add providers that create aspect actions on extended element types @@ -89,7 +89,7 @@ This is the class that implements the provider. - + @@ -99,7 +99,7 @@ Class that describes the action configuration - + diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/extendedTypesSetConfiguration.exsd b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/extendedTypesSetConfiguration.exsd index 20c436cb1cf..ef2762d198a 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/extendedTypesSetConfiguration.exsd +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/schema/extendedTypesSetConfiguration.exsd @@ -1,9 +1,9 @@ - + - + This extension point is used to registered new extended element types for creation of semantic elements with specific post/pre actions and validation. diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ActionConfiguration.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ActionConfiguration.java deleted file mode 100644 index a3cc5cdee5f..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ActionConfiguration.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes; - -import org.eclipse.emf.ecore.EObject; - -/** - * - * A representation of the model object 'Action Configuration'. - * - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.ActionConfiguration#getLabel Label}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.ActionConfiguration#getId Id}
  • - *
- *

- * - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getActionConfiguration() - * @model abstract="true" - * @generated - */ -public interface ActionConfiguration extends EObject { - /** - * Returns the value of the 'Label' attribute. - * - *

- * If the meaning of the 'Label' attribute isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Label' attribute. - * @see #setLabel(String) - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getActionConfiguration_Label() - * @model - * @generated - */ - String getLabel(); - - /** - * Sets the value of the '{@link org.eclipse.papyrus.extendedtypes.ActionConfiguration#getLabel Label}' attribute. - * - * - * @param value the new value of the 'Label' attribute. - * @see #getLabel() - * @generated - */ - void setLabel(String value); - - /** - * Returns the value of the 'Id' attribute. - * - *

- * If the meaning of the 'Id' attribute isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Id' attribute. - * @see #setId(String) - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getActionConfiguration_Id() - * @model required="true" - * @generated - */ - String getId(); - - /** - * Sets the value of the '{@link org.eclipse.papyrus.extendedtypes.ActionConfiguration#getId Id}' attribute. - * - * - * @param value the new value of the 'Id' attribute. - * @see #getId() - * @generated - */ - void setId(String value); - -} // ActionConfiguration diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedElementTypeConfiguration.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedElementTypeConfiguration.java deleted file mode 100644 index 6766cca2710..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedElementTypeConfiguration.java +++ /dev/null @@ -1,236 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes; - -import org.eclipse.emf.common.util.EList; - -import org.eclipse.emf.ecore.EObject; - -import org.eclipse.papyrus.core.queries.configuration.QueryConfiguration; - -/** - * - * A representation of the model object 'Extended Element Type Configuration'. - * - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getName Name}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getId Id}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getIconEntry Icon Entry}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getHint Hint}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getKindName Kind Name}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getSpecializedTypesID Specialized Types ID}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getPreValidation Pre Validation}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getPreAction Pre Action}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getPostAction Post Action}
  • - *
- *

- * - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration() - * @model - * @generated - */ -public interface ExtendedElementTypeConfiguration extends EObject { - /** - * Returns the value of the 'Name' attribute. - * - *

- * If the meaning of the 'Name' attribute isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Name' attribute. - * @see #setName(String) - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_Name() - * @model required="true" - * @generated - */ - String getName(); - - /** - * Sets the value of the '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getName Name}' attribute. - * - * - * @param value the new value of the 'Name' attribute. - * @see #getName() - * @generated - */ - void setName(String value); - - /** - * Returns the value of the 'Id' attribute. - * - *

- * If the meaning of the 'Id' attribute isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Id' attribute. - * @see #setId(String) - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_Id() - * @model required="true" - * @generated - */ - String getId(); - - /** - * Sets the value of the '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getId Id}' attribute. - * - * - * @param value the new value of the 'Id' attribute. - * @see #getId() - * @generated - */ - void setId(String value); - - /** - * Returns the value of the 'Icon Entry' containment reference. - * - *

- * If the meaning of the 'Icon Entry' containment reference isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Icon Entry' containment reference. - * @see #setIconEntry(IconEntry) - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_IconEntry() - * @model containment="true" - * @generated - */ - IconEntry getIconEntry(); - - /** - * Sets the value of the '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getIconEntry Icon Entry}' containment reference. - * - * - * @param value the new value of the 'Icon Entry' containment reference. - * @see #getIconEntry() - * @generated - */ - void setIconEntry(IconEntry value); - - /** - * Returns the value of the 'Hint' attribute. - * The default value is "ExtendedElements". - * - *

- * If the meaning of the 'Hint' attribute isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Hint' attribute. - * @see #setHint(String) - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_Hint() - * @model default="ExtendedElements" - * @generated - */ - String getHint(); - - /** - * Sets the value of the '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getHint Hint}' attribute. - * - * - * @param value the new value of the 'Hint' attribute. - * @see #getHint() - * @generated - */ - void setHint(String value); - - /** - * Returns the value of the 'Kind Name' attribute. - * The default value is "org.eclipse.gmf.runtime.emf.type.core.IHintedType". - * - *

- * If the meaning of the 'Kind Name' attribute isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Kind Name' attribute. - * @see #setKindName(String) - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_KindName() - * @model default="org.eclipse.gmf.runtime.emf.type.core.IHintedType" - * @generated - */ - String getKindName(); - - /** - * Sets the value of the '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getKindName Kind Name}' attribute. - * - * - * @param value the new value of the 'Kind Name' attribute. - * @see #getKindName() - * @generated - */ - void setKindName(String value); - - /** - * Returns the value of the 'Specialized Types ID' attribute list. - * The list contents are of type {@link java.lang.String}. - * - *

- * If the meaning of the 'Specialized Types ID' attribute list isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Specialized Types ID' attribute list. - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_SpecializedTypesID() - * @model required="true" - * @generated - */ - EList getSpecializedTypesID(); - - /** - * Returns the value of the 'Pre Validation' reference list. - * The list contents are of type {@link org.eclipse.papyrus.core.queries.configuration.QueryConfiguration}. - * - *

- * If the meaning of the 'Pre Validation' reference list isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Pre Validation' reference list. - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_PreValidation() - * @model - * @generated - */ - EList getPreValidation(); - - /** - * Returns the value of the 'Pre Action' containment reference list. - * The list contents are of type {@link org.eclipse.papyrus.extendedtypes.PreActionConfiguration}. - * - *

- * If the meaning of the 'Pre Action' containment reference list isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Pre Action' containment reference list. - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_PreAction() - * @model containment="true" - * @generated - */ - EList getPreAction(); - - /** - * Returns the value of the 'Post Action' containment reference list. - * The list contents are of type {@link org.eclipse.papyrus.extendedtypes.PostActionConfiguration}. - * - *

- * If the meaning of the 'Post Action' containment reference list isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Post Action' containment reference list. - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_PostAction() - * @model containment="true" - * @generated - */ - EList getPostAction(); - -} // ExtendedElementTypeConfiguration diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedElementTypeSet.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedElementTypeSet.java deleted file mode 100644 index 3e813ca309e..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedElementTypeSet.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes; - -import org.eclipse.emf.common.util.EList; - -import org.eclipse.emf.ecore.EObject; - -/** - * - * A representation of the model object 'Extended Element Type Set'. - * - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeSet#getElementType Element Type}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeSet#getId Id}
  • - *
- *

- * - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeSet() - * @model - * @generated - */ -public interface ExtendedElementTypeSet extends EObject { - /** - * Returns the value of the 'Element Type' containment reference list. - * The list contents are of type {@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration}. - * - *

- * If the meaning of the 'Element Type' containment reference list isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Element Type' containment reference list. - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeSet_ElementType() - * @model containment="true" required="true" - * @generated - */ - EList getElementType(); - - /** - * Returns the value of the 'Id' attribute. - * - *

- * If the meaning of the 'Id' attribute isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Id' attribute. - * @see #setId(String) - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeSet_Id() - * @model required="true" - * @generated - */ - String getId(); - - /** - * Sets the value of the '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeSet#getId Id}' attribute. - * - * - * @param value the new value of the 'Id' attribute. - * @see #getId() - * @generated - */ - void setId(String value); - -} // ExtendedElementTypeSet diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedtypesFactory.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedtypesFactory.java deleted file mode 100644 index 1b90617db96..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedtypesFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes; - -import org.eclipse.emf.ecore.EFactory; - -/** - * - * The Factory for the model. - * It provides a create method for each non-abstract class of the model. - * - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage - * @generated - */ -public interface ExtendedtypesFactory extends EFactory { - /** - * The singleton instance of the factory. - * - * - * @generated - */ - ExtendedtypesFactory eINSTANCE = org.eclipse.papyrus.extendedtypes.impl.ExtendedtypesFactoryImpl.init(); - - /** - * Returns a new object of class 'Extended Element Type Set'. - * - * - * @return a new object of class 'Extended Element Type Set'. - * @generated - */ - ExtendedElementTypeSet createExtendedElementTypeSet(); - - /** - * Returns a new object of class 'Extended Element Type Configuration'. - * - * - * @return a new object of class 'Extended Element Type Configuration'. - * @generated - */ - ExtendedElementTypeConfiguration createExtendedElementTypeConfiguration(); - - /** - * Returns a new object of class 'Icon Entry'. - * - * - * @return a new object of class 'Icon Entry'. - * @generated - */ - IconEntry createIconEntry(); - - /** - * Returns the package supported by this factory. - * - * - * @return the package supported by this factory. - * @generated - */ - ExtendedtypesPackage getExtendedtypesPackage(); - -} //ExtendedtypesFactory diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedtypesPackage.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedtypesPackage.java deleted file mode 100644 index ca11cef8a86..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/ExtendedtypesPackage.java +++ /dev/null @@ -1,777 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; - -/** - * - * The Package for the model. - * It contains accessors for the meta objects to represent - *
    - *
  • each class,
  • - *
  • each feature of each class,
  • - *
  • each enum,
  • - *
  • and each data type
  • - *
- * - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesFactory - * @model kind="package" - * @generated - */ -public interface ExtendedtypesPackage extends EPackage { - /** - * The package name. - * - * - * @generated - */ - String eNAME = "extendedtypes"; - - /** - * The package namespace URI. - * - * - * @generated - */ - String eNS_URI = "http://www.eclipse.org/papyrus/diagram/types/extendedtypes/0.7"; - - /** - * The package namespace name. - * - * - * @generated - */ - String eNS_PREFIX = "extendedtypes"; - - /** - * The singleton instance of the package. - * - * - * @generated - */ - ExtendedtypesPackage eINSTANCE = org.eclipse.papyrus.extendedtypes.impl.ExtendedtypesPackageImpl.init(); - - /** - * The meta object id for the '{@link org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeSetImpl Extended Element Type Set}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeSetImpl - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedtypesPackageImpl#getExtendedElementTypeSet() - * @generated - */ - int EXTENDED_ELEMENT_TYPE_SET = 0; - - /** - * The feature id for the 'Element Type' containment reference list. - * - * - * @generated - * @ordered - */ - int EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE = 0; - - /** - * The feature id for the 'Id' attribute. - * - * - * @generated - * @ordered - */ - int EXTENDED_ELEMENT_TYPE_SET__ID = 1; - - /** - * The number of structural features of the 'Extended Element Type Set' class. - * - * - * @generated - * @ordered - */ - int EXTENDED_ELEMENT_TYPE_SET_FEATURE_COUNT = 2; - - /** - * The meta object id for the '{@link org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeConfigurationImpl Extended Element Type Configuration}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeConfigurationImpl - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedtypesPackageImpl#getExtendedElementTypeConfiguration() - * @generated - */ - int EXTENDED_ELEMENT_TYPE_CONFIGURATION = 1; - - /** - * The feature id for the 'Name' attribute. - * - * - * @generated - * @ordered - */ - int EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME = 0; - - /** - * The feature id for the 'Id' attribute. - * - * - * @generated - * @ordered - */ - int EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID = 1; - - /** - * The feature id for the 'Icon Entry' containment reference. - * - * - * @generated - * @ordered - */ - int EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY = 2; - - /** - * The feature id for the 'Hint' attribute. - * - * - * @generated - * @ordered - */ - int EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT = 3; - - /** - * The feature id for the 'Kind Name' attribute. - * - * - * @generated - * @ordered - */ - int EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME = 4; - - /** - * The feature id for the 'Specialized Types ID' attribute list. - * - * - * @generated - * @ordered - */ - int EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID = 5; - - /** - * The feature id for the 'Pre Validation' reference list. - * - * - * @generated - * @ordered - */ - int EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION = 6; - - /** - * The feature id for the 'Pre Action' containment reference list. - * - * - * @generated - * @ordered - */ - int EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION = 7; - - /** - * The feature id for the 'Post Action' containment reference list. - * - * - * @generated - * @ordered - */ - int EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION = 8; - - /** - * The number of structural features of the 'Extended Element Type Configuration' class. - * - * - * @generated - * @ordered - */ - int EXTENDED_ELEMENT_TYPE_CONFIGURATION_FEATURE_COUNT = 9; - - /** - * The meta object id for the '{@link org.eclipse.papyrus.extendedtypes.impl.IconEntryImpl Icon Entry}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.impl.IconEntryImpl - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedtypesPackageImpl#getIconEntry() - * @generated - */ - int ICON_ENTRY = 2; - - /** - * The feature id for the 'Icon Path' attribute. - * - * - * @generated - * @ordered - */ - int ICON_ENTRY__ICON_PATH = 0; - - /** - * The feature id for the 'Bundle Id' attribute. - * - * - * @generated - * @ordered - */ - int ICON_ENTRY__BUNDLE_ID = 1; - - /** - * The number of structural features of the 'Icon Entry' class. - * - * - * @generated - * @ordered - */ - int ICON_ENTRY_FEATURE_COUNT = 2; - - /** - * The meta object id for the '{@link org.eclipse.papyrus.extendedtypes.impl.ActionConfigurationImpl Action Configuration}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.impl.ActionConfigurationImpl - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedtypesPackageImpl#getActionConfiguration() - * @generated - */ - int ACTION_CONFIGURATION = 3; - - /** - * The feature id for the 'Label' attribute. - * - * - * @generated - * @ordered - */ - int ACTION_CONFIGURATION__LABEL = 0; - - /** - * The feature id for the 'Id' attribute. - * - * - * @generated - * @ordered - */ - int ACTION_CONFIGURATION__ID = 1; - - /** - * The number of structural features of the 'Action Configuration' class. - * - * - * @generated - * @ordered - */ - int ACTION_CONFIGURATION_FEATURE_COUNT = 2; - - /** - * The meta object id for the '{@link org.eclipse.papyrus.extendedtypes.impl.PreActionConfigurationImpl Pre Action Configuration}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.impl.PreActionConfigurationImpl - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedtypesPackageImpl#getPreActionConfiguration() - * @generated - */ - int PRE_ACTION_CONFIGURATION = 4; - - /** - * The feature id for the 'Label' attribute. - * - * - * @generated - * @ordered - */ - int PRE_ACTION_CONFIGURATION__LABEL = ACTION_CONFIGURATION__LABEL; - - /** - * The feature id for the 'Id' attribute. - * - * - * @generated - * @ordered - */ - int PRE_ACTION_CONFIGURATION__ID = ACTION_CONFIGURATION__ID; - - /** - * The number of structural features of the 'Pre Action Configuration' class. - * - * - * @generated - * @ordered - */ - int PRE_ACTION_CONFIGURATION_FEATURE_COUNT = ACTION_CONFIGURATION_FEATURE_COUNT + 0; - - /** - * The meta object id for the '{@link org.eclipse.papyrus.extendedtypes.impl.PostActionConfigurationImpl Post Action Configuration}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.impl.PostActionConfigurationImpl - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedtypesPackageImpl#getPostActionConfiguration() - * @generated - */ - int POST_ACTION_CONFIGURATION = 5; - - /** - * The feature id for the 'Label' attribute. - * - * - * @generated - * @ordered - */ - int POST_ACTION_CONFIGURATION__LABEL = ACTION_CONFIGURATION__LABEL; - - /** - * The feature id for the 'Id' attribute. - * - * - * @generated - * @ordered - */ - int POST_ACTION_CONFIGURATION__ID = ACTION_CONFIGURATION__ID; - - /** - * The number of structural features of the 'Post Action Configuration' class. - * - * - * @generated - * @ordered - */ - int POST_ACTION_CONFIGURATION_FEATURE_COUNT = ACTION_CONFIGURATION_FEATURE_COUNT + 0; - - - /** - * Returns the meta object for class '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeSet Extended Element Type Set}'. - * - * - * @return the meta object for class 'Extended Element Type Set'. - * @see org.eclipse.papyrus.extendedtypes.ExtendedElementTypeSet - * @generated - */ - EClass getExtendedElementTypeSet(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeSet#getElementType Element Type}'. - * - * - * @return the meta object for the containment reference list 'Element Type'. - * @see org.eclipse.papyrus.extendedtypes.ExtendedElementTypeSet#getElementType() - * @see #getExtendedElementTypeSet() - * @generated - */ - EReference getExtendedElementTypeSet_ElementType(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeSet#getId Id}'. - * - * - * @return the meta object for the attribute 'Id'. - * @see org.eclipse.papyrus.extendedtypes.ExtendedElementTypeSet#getId() - * @see #getExtendedElementTypeSet() - * @generated - */ - EAttribute getExtendedElementTypeSet_Id(); - - /** - * Returns the meta object for class '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration Extended Element Type Configuration}'. - * - * - * @return the meta object for class 'Extended Element Type Configuration'. - * @see org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration - * @generated - */ - EClass getExtendedElementTypeConfiguration(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getName Name}'. - * - * - * @return the meta object for the attribute 'Name'. - * @see org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getName() - * @see #getExtendedElementTypeConfiguration() - * @generated - */ - EAttribute getExtendedElementTypeConfiguration_Name(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getId Id}'. - * - * - * @return the meta object for the attribute 'Id'. - * @see org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getId() - * @see #getExtendedElementTypeConfiguration() - * @generated - */ - EAttribute getExtendedElementTypeConfiguration_Id(); - - /** - * Returns the meta object for the containment reference '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getIconEntry Icon Entry}'. - * - * - * @return the meta object for the containment reference 'Icon Entry'. - * @see org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getIconEntry() - * @see #getExtendedElementTypeConfiguration() - * @generated - */ - EReference getExtendedElementTypeConfiguration_IconEntry(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getHint Hint}'. - * - * - * @return the meta object for the attribute 'Hint'. - * @see org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getHint() - * @see #getExtendedElementTypeConfiguration() - * @generated - */ - EAttribute getExtendedElementTypeConfiguration_Hint(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getKindName Kind Name}'. - * - * - * @return the meta object for the attribute 'Kind Name'. - * @see org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getKindName() - * @see #getExtendedElementTypeConfiguration() - * @generated - */ - EAttribute getExtendedElementTypeConfiguration_KindName(); - - /** - * Returns the meta object for the attribute list '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getSpecializedTypesID Specialized Types ID}'. - * - * - * @return the meta object for the attribute list 'Specialized Types ID'. - * @see org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getSpecializedTypesID() - * @see #getExtendedElementTypeConfiguration() - * @generated - */ - EAttribute getExtendedElementTypeConfiguration_SpecializedTypesID(); - - /** - * Returns the meta object for the reference list '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getPreValidation Pre Validation}'. - * - * - * @return the meta object for the reference list 'Pre Validation'. - * @see org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getPreValidation() - * @see #getExtendedElementTypeConfiguration() - * @generated - */ - EReference getExtendedElementTypeConfiguration_PreValidation(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getPreAction Pre Action}'. - * - * - * @return the meta object for the containment reference list 'Pre Action'. - * @see org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getPreAction() - * @see #getExtendedElementTypeConfiguration() - * @generated - */ - EReference getExtendedElementTypeConfiguration_PreAction(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getPostAction Post Action}'. - * - * - * @return the meta object for the containment reference list 'Post Action'. - * @see org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration#getPostAction() - * @see #getExtendedElementTypeConfiguration() - * @generated - */ - EReference getExtendedElementTypeConfiguration_PostAction(); - - /** - * Returns the meta object for class '{@link org.eclipse.papyrus.extendedtypes.IconEntry Icon Entry}'. - * - * - * @return the meta object for class 'Icon Entry'. - * @see org.eclipse.papyrus.extendedtypes.IconEntry - * @generated - */ - EClass getIconEntry(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.papyrus.extendedtypes.IconEntry#getIconPath Icon Path}'. - * - * - * @return the meta object for the attribute 'Icon Path'. - * @see org.eclipse.papyrus.extendedtypes.IconEntry#getIconPath() - * @see #getIconEntry() - * @generated - */ - EAttribute getIconEntry_IconPath(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.papyrus.extendedtypes.IconEntry#getBundleId Bundle Id}'. - * - * - * @return the meta object for the attribute 'Bundle Id'. - * @see org.eclipse.papyrus.extendedtypes.IconEntry#getBundleId() - * @see #getIconEntry() - * @generated - */ - EAttribute getIconEntry_BundleId(); - - /** - * Returns the meta object for class '{@link org.eclipse.papyrus.extendedtypes.ActionConfiguration Action Configuration}'. - * - * - * @return the meta object for class 'Action Configuration'. - * @see org.eclipse.papyrus.extendedtypes.ActionConfiguration - * @generated - */ - EClass getActionConfiguration(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.papyrus.extendedtypes.ActionConfiguration#getLabel Label}'. - * - * - * @return the meta object for the attribute 'Label'. - * @see org.eclipse.papyrus.extendedtypes.ActionConfiguration#getLabel() - * @see #getActionConfiguration() - * @generated - */ - EAttribute getActionConfiguration_Label(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.papyrus.extendedtypes.ActionConfiguration#getId Id}'. - * - * - * @return the meta object for the attribute 'Id'. - * @see org.eclipse.papyrus.extendedtypes.ActionConfiguration#getId() - * @see #getActionConfiguration() - * @generated - */ - EAttribute getActionConfiguration_Id(); - - /** - * Returns the meta object for class '{@link org.eclipse.papyrus.extendedtypes.PreActionConfiguration Pre Action Configuration}'. - * - * - * @return the meta object for class 'Pre Action Configuration'. - * @see org.eclipse.papyrus.extendedtypes.PreActionConfiguration - * @generated - */ - EClass getPreActionConfiguration(); - - /** - * Returns the meta object for class '{@link org.eclipse.papyrus.extendedtypes.PostActionConfiguration Post Action Configuration}'. - * - * - * @return the meta object for class 'Post Action Configuration'. - * @see org.eclipse.papyrus.extendedtypes.PostActionConfiguration - * @generated - */ - EClass getPostActionConfiguration(); - - /** - * Returns the factory that creates the instances of the model. - * - * - * @return the factory that creates the instances of the model. - * @generated - */ - ExtendedtypesFactory getExtendedtypesFactory(); - - /** - * - * Defines literals for the meta objects that represent - *
    - *
  • each class,
  • - *
  • each feature of each class,
  • - *
  • each enum,
  • - *
  • and each data type
  • - *
- * - * @generated - */ - interface Literals { - /** - * The meta object literal for the '{@link org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeSetImpl Extended Element Type Set}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeSetImpl - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedtypesPackageImpl#getExtendedElementTypeSet() - * @generated - */ - EClass EXTENDED_ELEMENT_TYPE_SET = eINSTANCE.getExtendedElementTypeSet(); - - /** - * The meta object literal for the 'Element Type' containment reference list feature. - * - * - * @generated - */ - EReference EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE = eINSTANCE.getExtendedElementTypeSet_ElementType(); - - /** - * The meta object literal for the 'Id' attribute feature. - * - * - * @generated - */ - EAttribute EXTENDED_ELEMENT_TYPE_SET__ID = eINSTANCE.getExtendedElementTypeSet_Id(); - - /** - * The meta object literal for the '{@link org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeConfigurationImpl Extended Element Type Configuration}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeConfigurationImpl - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedtypesPackageImpl#getExtendedElementTypeConfiguration() - * @generated - */ - EClass EXTENDED_ELEMENT_TYPE_CONFIGURATION = eINSTANCE.getExtendedElementTypeConfiguration(); - - /** - * The meta object literal for the 'Name' attribute feature. - * - * - * @generated - */ - EAttribute EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME = eINSTANCE.getExtendedElementTypeConfiguration_Name(); - - /** - * The meta object literal for the 'Id' attribute feature. - * - * - * @generated - */ - EAttribute EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID = eINSTANCE.getExtendedElementTypeConfiguration_Id(); - - /** - * The meta object literal for the 'Icon Entry' containment reference feature. - * - * - * @generated - */ - EReference EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY = eINSTANCE.getExtendedElementTypeConfiguration_IconEntry(); - - /** - * The meta object literal for the 'Hint' attribute feature. - * - * - * @generated - */ - EAttribute EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT = eINSTANCE.getExtendedElementTypeConfiguration_Hint(); - - /** - * The meta object literal for the 'Kind Name' attribute feature. - * - * - * @generated - */ - EAttribute EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME = eINSTANCE.getExtendedElementTypeConfiguration_KindName(); - - /** - * The meta object literal for the 'Specialized Types ID' attribute list feature. - * - * - * @generated - */ - EAttribute EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID = eINSTANCE.getExtendedElementTypeConfiguration_SpecializedTypesID(); - - /** - * The meta object literal for the 'Pre Validation' reference list feature. - * - * - * @generated - */ - EReference EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION = eINSTANCE.getExtendedElementTypeConfiguration_PreValidation(); - - /** - * The meta object literal for the 'Pre Action' containment reference list feature. - * - * - * @generated - */ - EReference EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION = eINSTANCE.getExtendedElementTypeConfiguration_PreAction(); - - /** - * The meta object literal for the 'Post Action' containment reference list feature. - * - * - * @generated - */ - EReference EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION = eINSTANCE.getExtendedElementTypeConfiguration_PostAction(); - - /** - * The meta object literal for the '{@link org.eclipse.papyrus.extendedtypes.impl.IconEntryImpl Icon Entry}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.impl.IconEntryImpl - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedtypesPackageImpl#getIconEntry() - * @generated - */ - EClass ICON_ENTRY = eINSTANCE.getIconEntry(); - - /** - * The meta object literal for the 'Icon Path' attribute feature. - * - * - * @generated - */ - EAttribute ICON_ENTRY__ICON_PATH = eINSTANCE.getIconEntry_IconPath(); - - /** - * The meta object literal for the 'Bundle Id' attribute feature. - * - * - * @generated - */ - EAttribute ICON_ENTRY__BUNDLE_ID = eINSTANCE.getIconEntry_BundleId(); - - /** - * The meta object literal for the '{@link org.eclipse.papyrus.extendedtypes.impl.ActionConfigurationImpl Action Configuration}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.impl.ActionConfigurationImpl - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedtypesPackageImpl#getActionConfiguration() - * @generated - */ - EClass ACTION_CONFIGURATION = eINSTANCE.getActionConfiguration(); - - /** - * The meta object literal for the 'Label' attribute feature. - * - * - * @generated - */ - EAttribute ACTION_CONFIGURATION__LABEL = eINSTANCE.getActionConfiguration_Label(); - - /** - * The meta object literal for the 'Id' attribute feature. - * - * - * @generated - */ - EAttribute ACTION_CONFIGURATION__ID = eINSTANCE.getActionConfiguration_Id(); - - /** - * The meta object literal for the '{@link org.eclipse.papyrus.extendedtypes.impl.PreActionConfigurationImpl Pre Action Configuration}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.impl.PreActionConfigurationImpl - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedtypesPackageImpl#getPreActionConfiguration() - * @generated - */ - EClass PRE_ACTION_CONFIGURATION = eINSTANCE.getPreActionConfiguration(); - - /** - * The meta object literal for the '{@link org.eclipse.papyrus.extendedtypes.impl.PostActionConfigurationImpl Post Action Configuration}' class. - * - * - * @see org.eclipse.papyrus.extendedtypes.impl.PostActionConfigurationImpl - * @see org.eclipse.papyrus.extendedtypes.impl.ExtendedtypesPackageImpl#getPostActionConfiguration() - * @generated - */ - EClass POST_ACTION_CONFIGURATION = eINSTANCE.getPostActionConfiguration(); - - } - -} //ExtendedtypesPackage diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/IconEntry.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/IconEntry.java deleted file mode 100644 index a94d6bd87f0..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/IconEntry.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes; - -import org.eclipse.emf.ecore.EObject; - -/** - * - * A representation of the model object 'Icon Entry'. - * - * - *

- * The following features are supported: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.IconEntry#getIconPath Icon Path}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.IconEntry#getBundleId Bundle Id}
  • - *
- *

- * - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getIconEntry() - * @model - * @generated - */ -public interface IconEntry extends EObject { - /** - * Returns the value of the 'Icon Path' attribute. - * - *

- * If the meaning of the 'Icon Path' attribute isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Icon Path' attribute. - * @see #setIconPath(String) - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getIconEntry_IconPath() - * @model - * @generated - */ - String getIconPath(); - - /** - * Sets the value of the '{@link org.eclipse.papyrus.extendedtypes.IconEntry#getIconPath Icon Path}' attribute. - * - * - * @param value the new value of the 'Icon Path' attribute. - * @see #getIconPath() - * @generated - */ - void setIconPath(String value); - - /** - * Returns the value of the 'Bundle Id' attribute. - * - *

- * If the meaning of the 'Bundle Id' attribute isn't clear, - * there really should be more of a description here... - *

- * - * @return the value of the 'Bundle Id' attribute. - * @see #setBundleId(String) - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getIconEntry_BundleId() - * @model - * @generated - */ - String getBundleId(); - - /** - * Sets the value of the '{@link org.eclipse.papyrus.extendedtypes.IconEntry#getBundleId Bundle Id}' attribute. - * - * - * @param value the new value of the 'Bundle Id' attribute. - * @see #getBundleId() - * @generated - */ - void setBundleId(String value); - -} // IconEntry diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/PostActionConfiguration.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/PostActionConfiguration.java deleted file mode 100644 index 75a34df8a6e..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/PostActionConfiguration.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes; - - -/** - * - * A representation of the model object 'Post Action Configuration'. - * - * - * - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getPostActionConfiguration() - * @model abstract="true" - * @generated - */ -public interface PostActionConfiguration extends ActionConfiguration { -} // PostActionConfiguration diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/PreActionConfiguration.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/PreActionConfiguration.java deleted file mode 100644 index 779575ff063..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/PreActionConfiguration.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes; - - -/** - * - * A representation of the model object 'Pre Action Configuration'. - * - * - * - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#getPreActionConfiguration() - * @model abstract="true" - * @generated - */ -public interface PreActionConfiguration extends ActionConfiguration { -} // PreActionConfiguration diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ActionConfigurationImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ActionConfigurationImpl.java deleted file mode 100644 index e1c9ec9e578..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ActionConfigurationImpl.java +++ /dev/null @@ -1,221 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.impl; - -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; - -import org.eclipse.papyrus.extendedtypes.ActionConfiguration; -import org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage; - -/** - * - * An implementation of the model object 'Action Configuration'. - * - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.impl.ActionConfigurationImpl#getLabel Label}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.impl.ActionConfigurationImpl#getId Id}
  • - *
- *

- * - * @generated - */ -public abstract class ActionConfigurationImpl extends EObjectImpl implements ActionConfiguration { - /** - * The default value of the '{@link #getLabel() Label}' attribute. - * - * - * @see #getLabel() - * @generated - * @ordered - */ - protected static final String LABEL_EDEFAULT = null; - - /** - * The cached value of the '{@link #getLabel() Label}' attribute. - * - * - * @see #getLabel() - * @generated - * @ordered - */ - protected String label = LABEL_EDEFAULT; - - /** - * The default value of the '{@link #getId() Id}' attribute. - * - * - * @see #getId() - * @generated - * @ordered - */ - protected static final String ID_EDEFAULT = null; - - /** - * The cached value of the '{@link #getId() Id}' attribute. - * - * - * @see #getId() - * @generated - * @ordered - */ - protected String id = ID_EDEFAULT; - - /** - * - * - * @generated - */ - protected ActionConfigurationImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return ExtendedtypesPackage.Literals.ACTION_CONFIGURATION; - } - - /** - * - * - * @generated - */ - public String getLabel() { - return label; - } - - /** - * - * - * @generated - */ - public void setLabel(String newLabel) { - String oldLabel = label; - label = newLabel; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.ACTION_CONFIGURATION__LABEL, oldLabel, label)); - } - - /** - * - * - * @generated - */ - public String getId() { - return id; - } - - /** - * - * - * @generated - */ - public void setId(String newId) { - String oldId = id; - id = newId; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.ACTION_CONFIGURATION__ID, oldId, id)); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case ExtendedtypesPackage.ACTION_CONFIGURATION__LABEL: - return getLabel(); - case ExtendedtypesPackage.ACTION_CONFIGURATION__ID: - return getId(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case ExtendedtypesPackage.ACTION_CONFIGURATION__LABEL: - setLabel((String)newValue); - return; - case ExtendedtypesPackage.ACTION_CONFIGURATION__ID: - setId((String)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case ExtendedtypesPackage.ACTION_CONFIGURATION__LABEL: - setLabel(LABEL_EDEFAULT); - return; - case ExtendedtypesPackage.ACTION_CONFIGURATION__ID: - setId(ID_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case ExtendedtypesPackage.ACTION_CONFIGURATION__LABEL: - return LABEL_EDEFAULT == null ? label != null : !LABEL_EDEFAULT.equals(label); - case ExtendedtypesPackage.ACTION_CONFIGURATION__ID: - return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); - } - return super.eIsSet(featureID); - } - - /** - * - * - * @generated - */ - @Override - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (label: "); - result.append(label); - result.append(", id: "); - result.append(id); - result.append(')'); - return result.toString(); - } - -} //ActionConfigurationImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedElementTypeConfigurationImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedElementTypeConfigurationImpl.java deleted file mode 100644 index 842f8093a35..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedElementTypeConfigurationImpl.java +++ /dev/null @@ -1,566 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.impl; - -import java.util.Collection; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; - -import org.eclipse.emf.common.util.EList; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; - -import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.EObjectResolvingEList; -import org.eclipse.emf.ecore.util.InternalEList; - -import org.eclipse.papyrus.core.queries.configuration.QueryConfiguration; - -import org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration; -import org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage; -import org.eclipse.papyrus.extendedtypes.IconEntry; -import org.eclipse.papyrus.extendedtypes.PostActionConfiguration; -import org.eclipse.papyrus.extendedtypes.PreActionConfiguration; - -/** - * - * An implementation of the model object 'Extended Element Type Configuration'. - * - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getName Name}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getId Id}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getIconEntry Icon Entry}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getHint Hint}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getKindName Kind Name}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getSpecializedTypesID Specialized Types ID}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getPreValidation Pre Validation}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getPreAction Pre Action}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getPostAction Post Action}
  • - *
- *

- * - * @generated - */ -public class ExtendedElementTypeConfigurationImpl extends EObjectImpl implements ExtendedElementTypeConfiguration { - /** - * The default value of the '{@link #getName() Name}' attribute. - * - * - * @see #getName() - * @generated - * @ordered - */ - protected static final String NAME_EDEFAULT = null; - - /** - * The cached value of the '{@link #getName() Name}' attribute. - * - * - * @see #getName() - * @generated - * @ordered - */ - protected String name = NAME_EDEFAULT; - - /** - * The default value of the '{@link #getId() Id}' attribute. - * - * - * @see #getId() - * @generated - * @ordered - */ - protected static final String ID_EDEFAULT = null; - - /** - * The cached value of the '{@link #getId() Id}' attribute. - * - * - * @see #getId() - * @generated - * @ordered - */ - protected String id = ID_EDEFAULT; - - /** - * The cached value of the '{@link #getIconEntry() Icon Entry}' containment reference. - * - * - * @see #getIconEntry() - * @generated - * @ordered - */ - protected IconEntry iconEntry; - - /** - * The default value of the '{@link #getHint() Hint}' attribute. - * - * - * @see #getHint() - * @generated - * @ordered - */ - protected static final String HINT_EDEFAULT = "ExtendedElements"; - - /** - * The cached value of the '{@link #getHint() Hint}' attribute. - * - * - * @see #getHint() - * @generated - * @ordered - */ - protected String hint = HINT_EDEFAULT; - - /** - * The default value of the '{@link #getKindName() Kind Name}' attribute. - * - * - * @see #getKindName() - * @generated - * @ordered - */ - protected static final String KIND_NAME_EDEFAULT = "org.eclipse.gmf.runtime.emf.type.core.IHintedType"; - - /** - * The cached value of the '{@link #getKindName() Kind Name}' attribute. - * - * - * @see #getKindName() - * @generated - * @ordered - */ - protected String kindName = KIND_NAME_EDEFAULT; - - /** - * The cached value of the '{@link #getSpecializedTypesID() Specialized Types ID}' attribute list. - * - * - * @see #getSpecializedTypesID() - * @generated - * @ordered - */ - protected EList specializedTypesID; - - /** - * The cached value of the '{@link #getPreValidation() Pre Validation}' reference list. - * - * - * @see #getPreValidation() - * @generated - * @ordered - */ - protected EList preValidation; - - /** - * The cached value of the '{@link #getPreAction() Pre Action}' containment reference list. - * - * - * @see #getPreAction() - * @generated - * @ordered - */ - protected EList preAction; - - /** - * The cached value of the '{@link #getPostAction() Post Action}' containment reference list. - * - * - * @see #getPostAction() - * @generated - * @ordered - */ - protected EList postAction; - - /** - * - * - * @generated - */ - protected ExtendedElementTypeConfigurationImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return ExtendedtypesPackage.Literals.EXTENDED_ELEMENT_TYPE_CONFIGURATION; - } - - /** - * - * - * @generated - */ - public String getName() { - return name; - } - - /** - * - * - * @generated - */ - public void setName(String newName) { - String oldName = name; - name = newName; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME, oldName, name)); - } - - /** - * - * - * @generated - */ - public String getId() { - return id; - } - - /** - * - * - * @generated - */ - public void setId(String newId) { - String oldId = id; - id = newId; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID, oldId, id)); - } - - /** - * - * - * @generated - */ - public IconEntry getIconEntry() { - return iconEntry; - } - - /** - * - * - * @generated - */ - public NotificationChain basicSetIconEntry(IconEntry newIconEntry, NotificationChain msgs) { - IconEntry oldIconEntry = iconEntry; - iconEntry = newIconEntry; - if (eNotificationRequired()) { - ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY, oldIconEntry, newIconEntry); - if (msgs == null) msgs = notification; else msgs.add(notification); - } - return msgs; - } - - /** - * - * - * @generated - */ - public void setIconEntry(IconEntry newIconEntry) { - if (newIconEntry != iconEntry) { - NotificationChain msgs = null; - if (iconEntry != null) - msgs = ((InternalEObject)iconEntry).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY, null, msgs); - if (newIconEntry != null) - msgs = ((InternalEObject)newIconEntry).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY, null, msgs); - msgs = basicSetIconEntry(newIconEntry, msgs); - if (msgs != null) msgs.dispatch(); - } - else if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY, newIconEntry, newIconEntry)); - } - - /** - * - * - * @generated - */ - public String getHint() { - return hint; - } - - /** - * - * - * @generated - */ - public void setHint(String newHint) { - String oldHint = hint; - hint = newHint; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT, oldHint, hint)); - } - - /** - * - * - * @generated - */ - public String getKindName() { - return kindName; - } - - /** - * - * - * @generated - */ - public void setKindName(String newKindName) { - String oldKindName = kindName; - kindName = newKindName; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME, oldKindName, kindName)); - } - - /** - * - * - * @generated - */ - public EList getSpecializedTypesID() { - if (specializedTypesID == null) { - specializedTypesID = new EDataTypeUniqueEList(String.class, this, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID); - } - return specializedTypesID; - } - - /** - * - * - * @generated - */ - public EList getPreValidation() { - if (preValidation == null) { - preValidation = new EObjectResolvingEList(QueryConfiguration.class, this, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION); - } - return preValidation; - } - - /** - * - * - * @generated - */ - public EList getPreAction() { - if (preAction == null) { - preAction = new EObjectContainmentEList(PreActionConfiguration.class, this, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION); - } - return preAction; - } - - /** - * - * - * @generated - */ - public EList getPostAction() { - if (postAction == null) { - postAction = new EObjectContainmentEList(PostActionConfiguration.class, this, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION); - } - return postAction; - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY: - return basicSetIconEntry(null, msgs); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION: - return ((InternalEList)getPreAction()).basicRemove(otherEnd, msgs); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION: - return ((InternalEList)getPostAction()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME: - return getName(); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID: - return getId(); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY: - return getIconEntry(); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT: - return getHint(); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME: - return getKindName(); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID: - return getSpecializedTypesID(); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION: - return getPreValidation(); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION: - return getPreAction(); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION: - return getPostAction(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME: - setName((String)newValue); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID: - setId((String)newValue); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY: - setIconEntry((IconEntry)newValue); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT: - setHint((String)newValue); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME: - setKindName((String)newValue); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID: - getSpecializedTypesID().clear(); - getSpecializedTypesID().addAll((Collection)newValue); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION: - getPreValidation().clear(); - getPreValidation().addAll((Collection)newValue); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION: - getPreAction().clear(); - getPreAction().addAll((Collection)newValue); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION: - getPostAction().clear(); - getPostAction().addAll((Collection)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME: - setName(NAME_EDEFAULT); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID: - setId(ID_EDEFAULT); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY: - setIconEntry((IconEntry)null); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT: - setHint(HINT_EDEFAULT); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME: - setKindName(KIND_NAME_EDEFAULT); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID: - getSpecializedTypesID().clear(); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION: - getPreValidation().clear(); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION: - getPreAction().clear(); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION: - getPostAction().clear(); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME: - return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID: - return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY: - return iconEntry != null; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT: - return HINT_EDEFAULT == null ? hint != null : !HINT_EDEFAULT.equals(hint); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME: - return KIND_NAME_EDEFAULT == null ? kindName != null : !KIND_NAME_EDEFAULT.equals(kindName); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID: - return specializedTypesID != null && !specializedTypesID.isEmpty(); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION: - return preValidation != null && !preValidation.isEmpty(); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION: - return preAction != null && !preAction.isEmpty(); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION: - return postAction != null && !postAction.isEmpty(); - } - return super.eIsSet(featureID); - } - - /** - * - * - * @generated - */ - @Override - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (name: "); - result.append(name); - result.append(", id: "); - result.append(id); - result.append(", hint: "); - result.append(hint); - result.append(", kindName: "); - result.append(kindName); - result.append(", specializedTypesID: "); - result.append(specializedTypesID); - result.append(')'); - return result.toString(); - } - -} //ExtendedElementTypeConfigurationImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedElementTypeSetImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedElementTypeSetImpl.java deleted file mode 100644 index 59bf954607d..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedElementTypeSetImpl.java +++ /dev/null @@ -1,226 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.impl; - -import java.util.Collection; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; - -import org.eclipse.emf.common.util.EList; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; - -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.InternalEList; - -import org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration; -import org.eclipse.papyrus.extendedtypes.ExtendedElementTypeSet; -import org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage; - -/** - * - * An implementation of the model object 'Extended Element Type Set'. - * - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeSetImpl#getElementType Element Type}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.impl.ExtendedElementTypeSetImpl#getId Id}
  • - *
- *

- * - * @generated - */ -public class ExtendedElementTypeSetImpl extends EObjectImpl implements ExtendedElementTypeSet { - /** - * The cached value of the '{@link #getElementType() Element Type}' containment reference list. - * - * - * @see #getElementType() - * @generated - * @ordered - */ - protected EList elementType; - - /** - * The default value of the '{@link #getId() Id}' attribute. - * - * - * @see #getId() - * @generated - * @ordered - */ - protected static final String ID_EDEFAULT = null; - - /** - * The cached value of the '{@link #getId() Id}' attribute. - * - * - * @see #getId() - * @generated - * @ordered - */ - protected String id = ID_EDEFAULT; - - /** - * - * - * @generated - */ - protected ExtendedElementTypeSetImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return ExtendedtypesPackage.Literals.EXTENDED_ELEMENT_TYPE_SET; - } - - /** - * - * - * @generated - */ - public EList getElementType() { - if (elementType == null) { - elementType = new EObjectContainmentEList(ExtendedElementTypeConfiguration.class, this, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE); - } - return elementType; - } - - /** - * - * - * @generated - */ - public String getId() { - return id; - } - - /** - * - * - * @generated - */ - public void setId(String newId) { - String oldId = id; - id = newId; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ID, oldId, id)); - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE: - return ((InternalEList)getElementType()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE: - return getElementType(); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ID: - return getId(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE: - getElementType().clear(); - getElementType().addAll((Collection)newValue); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ID: - setId((String)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE: - getElementType().clear(); - return; - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ID: - setId(ID_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE: - return elementType != null && !elementType.isEmpty(); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ID: - return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); - } - return super.eIsSet(featureID); - } - - /** - * - * - * @generated - */ - @Override - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (id: "); - result.append(id); - result.append(')'); - return result.toString(); - } - -} //ExtendedElementTypeSetImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedtypesFactoryImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedtypesFactoryImpl.java deleted file mode 100644 index d2617e6a23f..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedtypesFactoryImpl.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.impl; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; - -import org.eclipse.emf.ecore.impl.EFactoryImpl; - -import org.eclipse.emf.ecore.plugin.EcorePlugin; - -import org.eclipse.papyrus.extendedtypes.*; - -/** - * - * An implementation of the model Factory. - * - * @generated - */ -public class ExtendedtypesFactoryImpl extends EFactoryImpl implements ExtendedtypesFactory { - /** - * Creates the default factory implementation. - * - * - * @generated - */ - public static ExtendedtypesFactory init() { - try { - ExtendedtypesFactory theExtendedtypesFactory = (ExtendedtypesFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.eclipse.org/papyrus/diagram/types/extendedtypes/0.7"); - if (theExtendedtypesFactory != null) { - return theExtendedtypesFactory; - } - } - catch (Exception exception) { - EcorePlugin.INSTANCE.log(exception); - } - return new ExtendedtypesFactoryImpl(); - } - - /** - * Creates an instance of the factory. - * - * - * @generated - */ - public ExtendedtypesFactoryImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - public EObject create(EClass eClass) { - switch (eClass.getClassifierID()) { - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET: return createExtendedElementTypeSet(); - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION: return createExtendedElementTypeConfiguration(); - case ExtendedtypesPackage.ICON_ENTRY: return createIconEntry(); - default: - throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); - } - } - - /** - * - * - * @generated - */ - public ExtendedElementTypeSet createExtendedElementTypeSet() { - ExtendedElementTypeSetImpl extendedElementTypeSet = new ExtendedElementTypeSetImpl(); - return extendedElementTypeSet; - } - - /** - * - * - * @generated - */ - public ExtendedElementTypeConfiguration createExtendedElementTypeConfiguration() { - ExtendedElementTypeConfigurationImpl extendedElementTypeConfiguration = new ExtendedElementTypeConfigurationImpl(); - return extendedElementTypeConfiguration; - } - - /** - * - * - * @generated - */ - public IconEntry createIconEntry() { - IconEntryImpl iconEntry = new IconEntryImpl(); - return iconEntry; - } - - /** - * - * - * @generated - */ - public ExtendedtypesPackage getExtendedtypesPackage() { - return (ExtendedtypesPackage)getEPackage(); - } - - /** - * - * - * @deprecated - * @generated - */ - @Deprecated - public static ExtendedtypesPackage getPackage() { - return ExtendedtypesPackage.eINSTANCE; - } - -} //ExtendedtypesFactoryImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedtypesPackageImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedtypesPackageImpl.java deleted file mode 100644 index 648c7bf8c39..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/ExtendedtypesPackageImpl.java +++ /dev/null @@ -1,453 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.impl; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.EcorePackage; - -import org.eclipse.emf.ecore.impl.EPackageImpl; - -import org.eclipse.papyrus.core.queries.configuration.ConfigurationPackage; - -import org.eclipse.papyrus.extendedtypes.ActionConfiguration; -import org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration; -import org.eclipse.papyrus.extendedtypes.ExtendedElementTypeSet; -import org.eclipse.papyrus.extendedtypes.ExtendedtypesFactory; -import org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage; -import org.eclipse.papyrus.extendedtypes.IconEntry; -import org.eclipse.papyrus.extendedtypes.PostActionConfiguration; -import org.eclipse.papyrus.extendedtypes.PreActionConfiguration; - -/** - * - * An implementation of the model Package. - * - * @generated - */ -public class ExtendedtypesPackageImpl extends EPackageImpl implements ExtendedtypesPackage { - /** - * - * - * @generated - */ - private EClass extendedElementTypeSetEClass = null; - - /** - * - * - * @generated - */ - private EClass extendedElementTypeConfigurationEClass = null; - - /** - * - * - * @generated - */ - private EClass iconEntryEClass = null; - - /** - * - * - * @generated - */ - private EClass actionConfigurationEClass = null; - - /** - * - * - * @generated - */ - private EClass preActionConfigurationEClass = null; - - /** - * - * - * @generated - */ - private EClass postActionConfigurationEClass = null; - - /** - * Creates an instance of the model Package, registered with - * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package - * package URI value. - *

Note: the correct way to create the package is via the static - * factory method {@link #init init()}, which also performs - * initialization of the package, or returns the registered package, - * if one already exists. - * - * - * @see org.eclipse.emf.ecore.EPackage.Registry - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage#eNS_URI - * @see #init() - * @generated - */ - private ExtendedtypesPackageImpl() { - super(eNS_URI, ExtendedtypesFactory.eINSTANCE); - } - - /** - * - * - * @generated - */ - private static boolean isInited = false; - - /** - * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. - * - *

This method is used to initialize {@link ExtendedtypesPackage#eINSTANCE} when that field is accessed. - * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. - * - * - * @see #eNS_URI - * @see #createPackageContents() - * @see #initializePackageContents() - * @generated - */ - public static ExtendedtypesPackage init() { - if (isInited) return (ExtendedtypesPackage)EPackage.Registry.INSTANCE.getEPackage(ExtendedtypesPackage.eNS_URI); - - // Obtain or create and register package - ExtendedtypesPackageImpl theExtendedtypesPackage = (ExtendedtypesPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof ExtendedtypesPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new ExtendedtypesPackageImpl()); - - isInited = true; - - // Initialize simple dependencies - ConfigurationPackage.eINSTANCE.eClass(); - - // Create package meta-data objects - theExtendedtypesPackage.createPackageContents(); - - // Initialize created meta-data - theExtendedtypesPackage.initializePackageContents(); - - // Mark meta-data to indicate it can't be changed - theExtendedtypesPackage.freeze(); - - - // Update the registry and return the package - EPackage.Registry.INSTANCE.put(ExtendedtypesPackage.eNS_URI, theExtendedtypesPackage); - return theExtendedtypesPackage; - } - - /** - * - * - * @generated - */ - public EClass getExtendedElementTypeSet() { - return extendedElementTypeSetEClass; - } - - /** - * - * - * @generated - */ - public EReference getExtendedElementTypeSet_ElementType() { - return (EReference)extendedElementTypeSetEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EAttribute getExtendedElementTypeSet_Id() { - return (EAttribute)extendedElementTypeSetEClass.getEStructuralFeatures().get(1); - } - - /** - * - * - * @generated - */ - public EClass getExtendedElementTypeConfiguration() { - return extendedElementTypeConfigurationEClass; - } - - /** - * - * - * @generated - */ - public EAttribute getExtendedElementTypeConfiguration_Name() { - return (EAttribute)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EAttribute getExtendedElementTypeConfiguration_Id() { - return (EAttribute)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(1); - } - - /** - * - * - * @generated - */ - public EReference getExtendedElementTypeConfiguration_IconEntry() { - return (EReference)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(2); - } - - /** - * - * - * @generated - */ - public EAttribute getExtendedElementTypeConfiguration_Hint() { - return (EAttribute)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(3); - } - - /** - * - * - * @generated - */ - public EAttribute getExtendedElementTypeConfiguration_KindName() { - return (EAttribute)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(4); - } - - /** - * - * - * @generated - */ - public EAttribute getExtendedElementTypeConfiguration_SpecializedTypesID() { - return (EAttribute)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(5); - } - - /** - * - * - * @generated - */ - public EReference getExtendedElementTypeConfiguration_PreValidation() { - return (EReference)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(6); - } - - /** - * - * - * @generated - */ - public EReference getExtendedElementTypeConfiguration_PreAction() { - return (EReference)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(7); - } - - /** - * - * - * @generated - */ - public EReference getExtendedElementTypeConfiguration_PostAction() { - return (EReference)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(8); - } - - /** - * - * - * @generated - */ - public EClass getIconEntry() { - return iconEntryEClass; - } - - /** - * - * - * @generated - */ - public EAttribute getIconEntry_IconPath() { - return (EAttribute)iconEntryEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EAttribute getIconEntry_BundleId() { - return (EAttribute)iconEntryEClass.getEStructuralFeatures().get(1); - } - - /** - * - * - * @generated - */ - public EClass getActionConfiguration() { - return actionConfigurationEClass; - } - - /** - * - * - * @generated - */ - public EAttribute getActionConfiguration_Label() { - return (EAttribute)actionConfigurationEClass.getEStructuralFeatures().get(0); - } - - /** - * - * - * @generated - */ - public EAttribute getActionConfiguration_Id() { - return (EAttribute)actionConfigurationEClass.getEStructuralFeatures().get(1); - } - - /** - * - * - * @generated - */ - public EClass getPreActionConfiguration() { - return preActionConfigurationEClass; - } - - /** - * - * - * @generated - */ - public EClass getPostActionConfiguration() { - return postActionConfigurationEClass; - } - - /** - * - * - * @generated - */ - public ExtendedtypesFactory getExtendedtypesFactory() { - return (ExtendedtypesFactory)getEFactoryInstance(); - } - - /** - * - * - * @generated - */ - private boolean isCreated = false; - - /** - * Creates the meta-model objects for the package. This method is - * guarded to have no affect on any invocation but its first. - * - * - * @generated - */ - public void createPackageContents() { - if (isCreated) return; - isCreated = true; - - // Create classes and their features - extendedElementTypeSetEClass = createEClass(EXTENDED_ELEMENT_TYPE_SET); - createEReference(extendedElementTypeSetEClass, EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE); - createEAttribute(extendedElementTypeSetEClass, EXTENDED_ELEMENT_TYPE_SET__ID); - - extendedElementTypeConfigurationEClass = createEClass(EXTENDED_ELEMENT_TYPE_CONFIGURATION); - createEAttribute(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME); - createEAttribute(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID); - createEReference(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY); - createEAttribute(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT); - createEAttribute(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME); - createEAttribute(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID); - createEReference(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION); - createEReference(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION); - createEReference(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION); - - iconEntryEClass = createEClass(ICON_ENTRY); - createEAttribute(iconEntryEClass, ICON_ENTRY__ICON_PATH); - createEAttribute(iconEntryEClass, ICON_ENTRY__BUNDLE_ID); - - actionConfigurationEClass = createEClass(ACTION_CONFIGURATION); - createEAttribute(actionConfigurationEClass, ACTION_CONFIGURATION__LABEL); - createEAttribute(actionConfigurationEClass, ACTION_CONFIGURATION__ID); - - preActionConfigurationEClass = createEClass(PRE_ACTION_CONFIGURATION); - - postActionConfigurationEClass = createEClass(POST_ACTION_CONFIGURATION); - } - - /** - * - * - * @generated - */ - private boolean isInitialized = false; - - /** - * Complete the initialization of the package and its meta-model. This - * method is guarded to have no affect on any invocation but its first. - * - * - * @generated - */ - public void initializePackageContents() { - if (isInitialized) return; - isInitialized = true; - - // Initialize package - setName(eNAME); - setNsPrefix(eNS_PREFIX); - setNsURI(eNS_URI); - - // Obtain other dependent packages - ConfigurationPackage theConfigurationPackage = (ConfigurationPackage)EPackage.Registry.INSTANCE.getEPackage(ConfigurationPackage.eNS_URI); - EcorePackage theEcorePackage = (EcorePackage)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI); - - // Create type parameters - - // Set bounds for type parameters - - // Add supertypes to classes - preActionConfigurationEClass.getESuperTypes().add(this.getActionConfiguration()); - postActionConfigurationEClass.getESuperTypes().add(this.getActionConfiguration()); - - // Initialize classes and features; add operations and parameters - initEClass(extendedElementTypeSetEClass, ExtendedElementTypeSet.class, "ExtendedElementTypeSet", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getExtendedElementTypeSet_ElementType(), this.getExtendedElementTypeConfiguration(), null, "elementType", null, 1, -1, ExtendedElementTypeSet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getExtendedElementTypeSet_Id(), ecorePackage.getEString(), "id", null, 1, 1, ExtendedElementTypeSet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(extendedElementTypeConfigurationEClass, ExtendedElementTypeConfiguration.class, "ExtendedElementTypeConfiguration", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getExtendedElementTypeConfiguration_Name(), ecorePackage.getEString(), "name", null, 1, 1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getExtendedElementTypeConfiguration_Id(), ecorePackage.getEString(), "id", null, 1, 1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getExtendedElementTypeConfiguration_IconEntry(), this.getIconEntry(), null, "iconEntry", null, 0, 1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getExtendedElementTypeConfiguration_Hint(), ecorePackage.getEString(), "hint", "ExtendedElements", 0, 1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getExtendedElementTypeConfiguration_KindName(), ecorePackage.getEString(), "kindName", "org.eclipse.gmf.runtime.emf.type.core.IHintedType", 0, 1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getExtendedElementTypeConfiguration_SpecializedTypesID(), ecorePackage.getEString(), "specializedTypesID", null, 1, -1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getExtendedElementTypeConfiguration_PreValidation(), theConfigurationPackage.getQueryConfiguration(), null, "preValidation", null, 0, -1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getExtendedElementTypeConfiguration_PreAction(), this.getPreActionConfiguration(), null, "preAction", null, 0, -1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getExtendedElementTypeConfiguration_PostAction(), this.getPostActionConfiguration(), null, "postAction", null, 0, -1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(iconEntryEClass, IconEntry.class, "IconEntry", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getIconEntry_IconPath(), ecorePackage.getEString(), "iconPath", null, 0, 1, IconEntry.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getIconEntry_BundleId(), ecorePackage.getEString(), "bundleId", null, 0, 1, IconEntry.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(actionConfigurationEClass, ActionConfiguration.class, "ActionConfiguration", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getActionConfiguration_Label(), theEcorePackage.getEString(), "label", null, 0, 1, ActionConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getActionConfiguration_Id(), theEcorePackage.getEString(), "id", null, 1, 1, ActionConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(preActionConfigurationEClass, PreActionConfiguration.class, "PreActionConfiguration", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - - initEClass(postActionConfigurationEClass, PostActionConfiguration.class, "PostActionConfiguration", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - - // Create resource - createResource(eNS_URI); - } - -} //ExtendedtypesPackageImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/IconEntryImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/IconEntryImpl.java deleted file mode 100644 index 266ff64040d..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/IconEntryImpl.java +++ /dev/null @@ -1,221 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.impl; - -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; - -import org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage; -import org.eclipse.papyrus.extendedtypes.IconEntry; - -/** - * - * An implementation of the model object 'Icon Entry'. - * - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.papyrus.extendedtypes.impl.IconEntryImpl#getIconPath Icon Path}
  • - *
  • {@link org.eclipse.papyrus.extendedtypes.impl.IconEntryImpl#getBundleId Bundle Id}
  • - *
- *

- * - * @generated - */ -public class IconEntryImpl extends EObjectImpl implements IconEntry { - /** - * The default value of the '{@link #getIconPath() Icon Path}' attribute. - * - * - * @see #getIconPath() - * @generated - * @ordered - */ - protected static final String ICON_PATH_EDEFAULT = null; - - /** - * The cached value of the '{@link #getIconPath() Icon Path}' attribute. - * - * - * @see #getIconPath() - * @generated - * @ordered - */ - protected String iconPath = ICON_PATH_EDEFAULT; - - /** - * The default value of the '{@link #getBundleId() Bundle Id}' attribute. - * - * - * @see #getBundleId() - * @generated - * @ordered - */ - protected static final String BUNDLE_ID_EDEFAULT = null; - - /** - * The cached value of the '{@link #getBundleId() Bundle Id}' attribute. - * - * - * @see #getBundleId() - * @generated - * @ordered - */ - protected String bundleId = BUNDLE_ID_EDEFAULT; - - /** - * - * - * @generated - */ - protected IconEntryImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return ExtendedtypesPackage.Literals.ICON_ENTRY; - } - - /** - * - * - * @generated - */ - public String getIconPath() { - return iconPath; - } - - /** - * - * - * @generated - */ - public void setIconPath(String newIconPath) { - String oldIconPath = iconPath; - iconPath = newIconPath; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.ICON_ENTRY__ICON_PATH, oldIconPath, iconPath)); - } - - /** - * - * - * @generated - */ - public String getBundleId() { - return bundleId; - } - - /** - * - * - * @generated - */ - public void setBundleId(String newBundleId) { - String oldBundleId = bundleId; - bundleId = newBundleId; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.ICON_ENTRY__BUNDLE_ID, oldBundleId, bundleId)); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case ExtendedtypesPackage.ICON_ENTRY__ICON_PATH: - return getIconPath(); - case ExtendedtypesPackage.ICON_ENTRY__BUNDLE_ID: - return getBundleId(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case ExtendedtypesPackage.ICON_ENTRY__ICON_PATH: - setIconPath((String)newValue); - return; - case ExtendedtypesPackage.ICON_ENTRY__BUNDLE_ID: - setBundleId((String)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case ExtendedtypesPackage.ICON_ENTRY__ICON_PATH: - setIconPath(ICON_PATH_EDEFAULT); - return; - case ExtendedtypesPackage.ICON_ENTRY__BUNDLE_ID: - setBundleId(BUNDLE_ID_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case ExtendedtypesPackage.ICON_ENTRY__ICON_PATH: - return ICON_PATH_EDEFAULT == null ? iconPath != null : !ICON_PATH_EDEFAULT.equals(iconPath); - case ExtendedtypesPackage.ICON_ENTRY__BUNDLE_ID: - return BUNDLE_ID_EDEFAULT == null ? bundleId != null : !BUNDLE_ID_EDEFAULT.equals(bundleId); - } - return super.eIsSet(featureID); - } - - /** - * - * - * @generated - */ - @Override - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (iconPath: "); - result.append(iconPath); - result.append(", bundleId: "); - result.append(bundleId); - result.append(')'); - return result.toString(); - } - -} //IconEntryImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/PostActionConfigurationImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/PostActionConfigurationImpl.java deleted file mode 100644 index 6884c9e6878..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/PostActionConfigurationImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.impl; - -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage; -import org.eclipse.papyrus.extendedtypes.PostActionConfiguration; - -/** - * - * An implementation of the model object 'Post Action Configuration'. - * - *

- *

- * - * @generated - */ -public abstract class PostActionConfigurationImpl extends ActionConfigurationImpl implements PostActionConfiguration { - /** - * - * - * @generated - */ - protected PostActionConfigurationImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return ExtendedtypesPackage.Literals.POST_ACTION_CONFIGURATION; - } - -} //PostActionConfigurationImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/PreActionConfigurationImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/PreActionConfigurationImpl.java deleted file mode 100644 index 3925064d19b..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/impl/PreActionConfigurationImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.impl; - -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage; -import org.eclipse.papyrus.extendedtypes.PreActionConfiguration; - -/** - * - * An implementation of the model object 'Pre Action Configuration'. - * - *

- *

- * - * @generated - */ -public abstract class PreActionConfigurationImpl extends ActionConfigurationImpl implements PreActionConfiguration { - /** - * - * - * @generated - */ - protected PreActionConfigurationImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return ExtendedtypesPackage.Literals.PRE_ACTION_CONFIGURATION; - } - -} //PreActionConfigurationImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesAdapterFactory.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesAdapterFactory.java deleted file mode 100644 index 30ea49f307e..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesAdapterFactory.java +++ /dev/null @@ -1,214 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.util; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notifier; - -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; - -import org.eclipse.emf.ecore.EObject; - -import org.eclipse.papyrus.extendedtypes.*; - -/** - * - * The Adapter Factory for the model. - * It provides an adapter createXXX method for each class of the model. - * - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage - * @generated - */ -public class ExtendedtypesAdapterFactory extends AdapterFactoryImpl { - /** - * The cached model package. - * - * - * @generated - */ - protected static ExtendedtypesPackage modelPackage; - - /** - * Creates an instance of the adapter factory. - * - * - * @generated - */ - public ExtendedtypesAdapterFactory() { - if (modelPackage == null) { - modelPackage = ExtendedtypesPackage.eINSTANCE; - } - } - - /** - * Returns whether this factory is applicable for the type of the object. - * - * This implementation returns true if the object is either the model's package or is an instance object of the model. - * - * @return whether this factory is applicable for the type of the object. - * @generated - */ - @Override - public boolean isFactoryForType(Object object) { - if (object == modelPackage) { - return true; - } - if (object instanceof EObject) { - return ((EObject)object).eClass().getEPackage() == modelPackage; - } - return false; - } - - /** - * The switch that delegates to the createXXX methods. - * - * - * @generated - */ - protected ExtendedtypesSwitch modelSwitch = - new ExtendedtypesSwitch() { - @Override - public Adapter caseExtendedElementTypeSet(ExtendedElementTypeSet object) { - return createExtendedElementTypeSetAdapter(); - } - @Override - public Adapter caseExtendedElementTypeConfiguration(ExtendedElementTypeConfiguration object) { - return createExtendedElementTypeConfigurationAdapter(); - } - @Override - public Adapter caseIconEntry(IconEntry object) { - return createIconEntryAdapter(); - } - @Override - public Adapter caseActionConfiguration(ActionConfiguration object) { - return createActionConfigurationAdapter(); - } - @Override - public Adapter casePreActionConfiguration(PreActionConfiguration object) { - return createPreActionConfigurationAdapter(); - } - @Override - public Adapter casePostActionConfiguration(PostActionConfiguration object) { - return createPostActionConfigurationAdapter(); - } - @Override - public Adapter defaultCase(EObject object) { - return createEObjectAdapter(); - } - }; - - /** - * Creates an adapter for the target. - * - * - * @param target the object to adapt. - * @return the adapter for the target. - * @generated - */ - @Override - public Adapter createAdapter(Notifier target) { - return modelSwitch.doSwitch((EObject)target); - } - - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeSet Extended Element Type Set}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.extendedtypes.ExtendedElementTypeSet - * @generated - */ - public Adapter createExtendedElementTypeSetAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration Extended Element Type Configuration}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration - * @generated - */ - public Adapter createExtendedElementTypeConfigurationAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.extendedtypes.IconEntry Icon Entry}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.extendedtypes.IconEntry - * @generated - */ - public Adapter createIconEntryAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.extendedtypes.ActionConfiguration Action Configuration}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.extendedtypes.ActionConfiguration - * @generated - */ - public Adapter createActionConfigurationAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.extendedtypes.PreActionConfiguration Pre Action Configuration}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.extendedtypes.PreActionConfiguration - * @generated - */ - public Adapter createPreActionConfigurationAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.extendedtypes.PostActionConfiguration Post Action Configuration}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see org.eclipse.papyrus.extendedtypes.PostActionConfiguration - * @generated - */ - public Adapter createPostActionConfigurationAdapter() { - return null; - } - - /** - * Creates a new adapter for the default case. - * - * This default implementation returns null. - * - * @return the new adapter. - * @generated - */ - public Adapter createEObjectAdapter() { - return null; - } - -} //ExtendedtypesAdapterFactory diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesResourceFactoryImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesResourceFactoryImpl.java deleted file mode 100644 index 38f2adfd709..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesResourceFactoryImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.util; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.resource.Resource; - -import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; - -import org.eclipse.emf.ecore.xmi.XMLResource; - -/** - * - * The Resource Factory associated with the package. - * - * @see org.eclipse.papyrus.extendedtypes.util.ExtendedtypesResourceImpl - * @generated - */ -public class ExtendedtypesResourceFactoryImpl extends ResourceFactoryImpl { - /** - * Creates an instance of the resource factory. - * - * - * @generated - */ - public ExtendedtypesResourceFactoryImpl() { - super(); - } - - /** - * Creates an instance of the resource. - * - * - * @generated - */ - @Override - public Resource createResource(URI uri) { - XMLResource result = new ExtendedtypesResourceImpl(uri); - result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - - result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); - result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE); - return result; - } - -} //ExtendedtypesResourceFactoryImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesResourceImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesResourceImpl.java deleted file mode 100644 index ab3b7d0e0b8..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesResourceImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.util; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; - -/** - * - * The Resource associated with the package. - * - * @see org.eclipse.papyrus.extendedtypes.util.ExtendedtypesResourceFactoryImpl - * @generated - */ -public class ExtendedtypesResourceImpl extends XMLResourceImpl { - /** - * Creates an instance of the resource. - * - * - * @param uri the URI of the new resource. - * @generated - */ - public ExtendedtypesResourceImpl(URI uri) { - super(uri); - } - -} //ExtendedtypesResourceImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesSwitch.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesSwitch.java deleted file mode 100644 index 3dcf150839f..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesSwitch.java +++ /dev/null @@ -1,237 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.util; - -import java.util.List; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; - -import org.eclipse.papyrus.extendedtypes.*; - -/** - * - * The Switch for the model's inheritance hierarchy. - * It supports the call {@link #doSwitch(EObject) doSwitch(object)} - * to invoke the caseXXX method for each class of the model, - * starting with the actual class of the object - * and proceeding up the inheritance hierarchy - * until a non-null result is returned, - * which is the result of the switch. - * - * @see org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage - * @generated - */ -public class ExtendedtypesSwitch { - /** - * The cached model package - * - * - * @generated - */ - protected static ExtendedtypesPackage modelPackage; - - /** - * Creates an instance of the switch. - * - * - * @generated - */ - public ExtendedtypesSwitch() { - if (modelPackage == null) { - modelPackage = ExtendedtypesPackage.eINSTANCE; - } - } - - /** - * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. - * - * - * @return the first non-null result returned by a caseXXX call. - * @generated - */ - public T doSwitch(EObject theEObject) { - return doSwitch(theEObject.eClass(), theEObject); - } - - /** - * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. - * - * - * @return the first non-null result returned by a caseXXX call. - * @generated - */ - protected T doSwitch(EClass theEClass, EObject theEObject) { - if (theEClass.eContainer() == modelPackage) { - return doSwitch(theEClass.getClassifierID(), theEObject); - } - else { - List eSuperTypes = theEClass.getESuperTypes(); - return - eSuperTypes.isEmpty() ? - defaultCase(theEObject) : - doSwitch(eSuperTypes.get(0), theEObject); - } - } - - /** - * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. - * - * - * @return the first non-null result returned by a caseXXX call. - * @generated - */ - protected T doSwitch(int classifierID, EObject theEObject) { - switch (classifierID) { - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET: { - ExtendedElementTypeSet extendedElementTypeSet = (ExtendedElementTypeSet)theEObject; - T result = caseExtendedElementTypeSet(extendedElementTypeSet); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION: { - ExtendedElementTypeConfiguration extendedElementTypeConfiguration = (ExtendedElementTypeConfiguration)theEObject; - T result = caseExtendedElementTypeConfiguration(extendedElementTypeConfiguration); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ExtendedtypesPackage.ICON_ENTRY: { - IconEntry iconEntry = (IconEntry)theEObject; - T result = caseIconEntry(iconEntry); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ExtendedtypesPackage.ACTION_CONFIGURATION: { - ActionConfiguration actionConfiguration = (ActionConfiguration)theEObject; - T result = caseActionConfiguration(actionConfiguration); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ExtendedtypesPackage.PRE_ACTION_CONFIGURATION: { - PreActionConfiguration preActionConfiguration = (PreActionConfiguration)theEObject; - T result = casePreActionConfiguration(preActionConfiguration); - if (result == null) result = caseActionConfiguration(preActionConfiguration); - if (result == null) result = defaultCase(theEObject); - return result; - } - case ExtendedtypesPackage.POST_ACTION_CONFIGURATION: { - PostActionConfiguration postActionConfiguration = (PostActionConfiguration)theEObject; - T result = casePostActionConfiguration(postActionConfiguration); - if (result == null) result = caseActionConfiguration(postActionConfiguration); - if (result == null) result = defaultCase(theEObject); - return result; - } - default: return defaultCase(theEObject); - } - } - - /** - * Returns the result of interpreting the object as an instance of 'Extended Element Type Set'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Extended Element Type Set'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseExtendedElementTypeSet(ExtendedElementTypeSet object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'Extended Element Type Configuration'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Extended Element Type Configuration'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseExtendedElementTypeConfiguration(ExtendedElementTypeConfiguration object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'Icon Entry'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Icon Entry'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseIconEntry(IconEntry object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'Action Configuration'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Action Configuration'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseActionConfiguration(ActionConfiguration object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'Pre Action Configuration'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Pre Action Configuration'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T casePreActionConfiguration(PreActionConfiguration object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'Post Action Configuration'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Post Action Configuration'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T casePostActionConfiguration(PostActionConfiguration object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'EObject'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch, but this is the last case anyway. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'EObject'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) - * @generated - */ - public T defaultCase(EObject object) { - return null; - } - -} //ExtendedtypesSwitch diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesXMLProcessor.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesXMLProcessor.java deleted file mode 100644 index 4c6a74ae81a..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/extendedtypes/util/ExtendedtypesXMLProcessor.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * - * - * - * $Id$ - */ -package org.eclipse.papyrus.extendedtypes.util; - -import java.util.Map; - -import org.eclipse.emf.ecore.EPackage; - -import org.eclipse.emf.ecore.resource.Resource; - -import org.eclipse.emf.ecore.xmi.util.XMLProcessor; - -import org.eclipse.papyrus.extendedtypes.ExtendedtypesPackage; - -/** - * This class contains helper methods to serialize and deserialize XML documents - * - * - * @generated - */ -public class ExtendedtypesXMLProcessor extends XMLProcessor { - - /** - * Public constructor to instantiate the helper. - * - * - * @generated - */ - public ExtendedtypesXMLProcessor() { - super((EPackage.Registry.INSTANCE)); - ExtendedtypesPackage.eINSTANCE.eClass(); - } - - /** - * Register for "*" and "xml" file extensions the ExtendedtypesResourceFactoryImpl factory. - * - * - * @generated - */ - @Override - protected Map getRegistrations() { - if (registrations == null) { - super.getRegistrations(); - registrations.put(XML_EXTENSION, new ExtendedtypesResourceFactoryImpl()); - registrations.put(STAR_EXTENSION, new ExtendedtypesResourceFactoryImpl()); - } - return registrations; - } - -} //ExtendedtypesXMLProcessor diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ActionConfiguration.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ActionConfiguration.java new file mode 100644 index 00000000000..df2cf89d490 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ActionConfiguration.java @@ -0,0 +1,81 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Action Configuration'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration#getLabel Label}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration#getId Id}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getActionConfiguration() + * @model abstract="true" + * @generated + */ +public interface ActionConfiguration extends EObject { + /** + * Returns the value of the 'Label' attribute. + * + *

+ * If the meaning of the 'Label' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Label' attribute. + * @see #setLabel(String) + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getActionConfiguration_Label() + * @model + * @generated + */ + String getLabel(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration#getLabel Label}' attribute. + * + * + * @param value the new value of the 'Label' attribute. + * @see #getLabel() + * @generated + */ + void setLabel(String value); + + /** + * Returns the value of the 'Id' attribute. + * + *

+ * If the meaning of the 'Id' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Id' attribute. + * @see #setId(String) + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getActionConfiguration_Id() + * @model required="true" + * @generated + */ + String getId(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration#getId Id}' attribute. + * + * + * @param value the new value of the 'Id' attribute. + * @see #getId() + * @generated + */ + void setId(String value); + +} // ActionConfiguration diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedElementTypeConfiguration.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedElementTypeConfiguration.java new file mode 100644 index 00000000000..204abfd1c85 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedElementTypeConfiguration.java @@ -0,0 +1,236 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +import org.eclipse.papyrus.infra.queries.core.configuration.QueryConfiguration; + +/** + * + * A representation of the model object 'Extended Element Type Configuration'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getName Name}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getId Id}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getIconEntry Icon Entry}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getHint Hint}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getKindName Kind Name}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getSpecializedTypesID Specialized Types ID}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getPreValidation Pre Validation}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getPreAction Pre Action}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getPostAction Post Action}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration() + * @model + * @generated + */ +public interface ExtendedElementTypeConfiguration extends EObject { + /** + * Returns the value of the 'Name' attribute. + * + *

+ * If the meaning of the 'Name' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Name' attribute. + * @see #setName(String) + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_Name() + * @model required="true" + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getName Name}' attribute. + * + * + * @param value the new value of the 'Name' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + + /** + * Returns the value of the 'Id' attribute. + * + *

+ * If the meaning of the 'Id' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Id' attribute. + * @see #setId(String) + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_Id() + * @model required="true" + * @generated + */ + String getId(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getId Id}' attribute. + * + * + * @param value the new value of the 'Id' attribute. + * @see #getId() + * @generated + */ + void setId(String value); + + /** + * Returns the value of the 'Icon Entry' containment reference. + * + *

+ * If the meaning of the 'Icon Entry' containment reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Icon Entry' containment reference. + * @see #setIconEntry(IconEntry) + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_IconEntry() + * @model containment="true" + * @generated + */ + IconEntry getIconEntry(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getIconEntry Icon Entry}' containment reference. + * + * + * @param value the new value of the 'Icon Entry' containment reference. + * @see #getIconEntry() + * @generated + */ + void setIconEntry(IconEntry value); + + /** + * Returns the value of the 'Hint' attribute. + * The default value is "ExtendedElements". + * + *

+ * If the meaning of the 'Hint' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Hint' attribute. + * @see #setHint(String) + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_Hint() + * @model default="ExtendedElements" + * @generated + */ + String getHint(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getHint Hint}' attribute. + * + * + * @param value the new value of the 'Hint' attribute. + * @see #getHint() + * @generated + */ + void setHint(String value); + + /** + * Returns the value of the 'Kind Name' attribute. + * The default value is "org.eclipse.gmf.runtime.emf.type.core.IHintedType". + * + *

+ * If the meaning of the 'Kind Name' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Kind Name' attribute. + * @see #setKindName(String) + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_KindName() + * @model default="org.eclipse.gmf.runtime.emf.type.core.IHintedType" + * @generated + */ + String getKindName(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getKindName Kind Name}' attribute. + * + * + * @param value the new value of the 'Kind Name' attribute. + * @see #getKindName() + * @generated + */ + void setKindName(String value); + + /** + * Returns the value of the 'Specialized Types ID' attribute list. + * The list contents are of type {@link java.lang.String}. + * + *

+ * If the meaning of the 'Specialized Types ID' attribute list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Specialized Types ID' attribute list. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_SpecializedTypesID() + * @model required="true" + * @generated + */ + EList getSpecializedTypesID(); + + /** + * Returns the value of the 'Pre Validation' reference list. + * The list contents are of type {@link org.eclipse.papyrus.infra.queries.core.configuration.QueryConfiguration}. + * + *

+ * If the meaning of the 'Pre Validation' reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Pre Validation' reference list. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_PreValidation() + * @model + * @generated + */ + EList getPreValidation(); + + /** + * Returns the value of the 'Pre Action' containment reference list. + * The list contents are of type {@link org.eclipse.papyrus.infra.extendedtypes.PreActionConfiguration}. + * + *

+ * If the meaning of the 'Pre Action' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Pre Action' containment reference list. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_PreAction() + * @model containment="true" + * @generated + */ + EList getPreAction(); + + /** + * Returns the value of the 'Post Action' containment reference list. + * The list contents are of type {@link org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration}. + * + *

+ * If the meaning of the 'Post Action' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Post Action' containment reference list. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeConfiguration_PostAction() + * @model containment="true" + * @generated + */ + EList getPostAction(); + +} // ExtendedElementTypeConfiguration diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedElementTypeSet.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedElementTypeSet.java new file mode 100644 index 00000000000..25b13ec32e4 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedElementTypeSet.java @@ -0,0 +1,73 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Extended Element Type Set'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSet#getElementType Element Type}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSet#getId Id}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeSet() + * @model + * @generated + */ +public interface ExtendedElementTypeSet extends EObject { + /** + * Returns the value of the 'Element Type' containment reference list. + * The list contents are of type {@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration}. + * + *

+ * If the meaning of the 'Element Type' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Element Type' containment reference list. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeSet_ElementType() + * @model containment="true" required="true" + * @generated + */ + EList getElementType(); + + /** + * Returns the value of the 'Id' attribute. + * + *

+ * If the meaning of the 'Id' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Id' attribute. + * @see #setId(String) + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getExtendedElementTypeSet_Id() + * @model required="true" + * @generated + */ + String getId(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSet#getId Id}' attribute. + * + * + * @param value the new value of the 'Id' attribute. + * @see #getId() + * @generated + */ + void setId(String value); + +} // ExtendedElementTypeSet diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedtypesFactory.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedtypesFactory.java new file mode 100644 index 00000000000..f395b7b0c55 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedtypesFactory.java @@ -0,0 +1,64 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage + * @generated + */ +public interface ExtendedtypesFactory extends EFactory { + /** + * The singleton instance of the factory. + * + * + * @generated + */ + ExtendedtypesFactory eINSTANCE = org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedtypesFactoryImpl.init(); + + /** + * Returns a new object of class 'Extended Element Type Set'. + * + * + * @return a new object of class 'Extended Element Type Set'. + * @generated + */ + ExtendedElementTypeSet createExtendedElementTypeSet(); + + /** + * Returns a new object of class 'Extended Element Type Configuration'. + * + * + * @return a new object of class 'Extended Element Type Configuration'. + * @generated + */ + ExtendedElementTypeConfiguration createExtendedElementTypeConfiguration(); + + /** + * Returns a new object of class 'Icon Entry'. + * + * + * @return a new object of class 'Icon Entry'. + * @generated + */ + IconEntry createIconEntry(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + ExtendedtypesPackage getExtendedtypesPackage(); + +} //ExtendedtypesFactory diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedtypesPackage.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedtypesPackage.java new file mode 100644 index 00000000000..fc3457ac112 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/ExtendedtypesPackage.java @@ -0,0 +1,777 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesFactory + * @model kind="package" + * @generated + */ +public interface ExtendedtypesPackage extends EPackage { + /** + * The package name. + * + * + * @generated + */ + String eNAME = "extendedtypes"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://www.eclipse.org/papyrus/diagram/types/extendedtypes/0.7"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "extendedtypes"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + ExtendedtypesPackage eINSTANCE = org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedtypesPackageImpl.init(); + + /** + * The meta object id for the '{@link org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeSetImpl Extended Element Type Set}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeSetImpl + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedtypesPackageImpl#getExtendedElementTypeSet() + * @generated + */ + int EXTENDED_ELEMENT_TYPE_SET = 0; + + /** + * The feature id for the 'Element Type' containment reference list. + * + * + * @generated + * @ordered + */ + int EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE = 0; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int EXTENDED_ELEMENT_TYPE_SET__ID = 1; + + /** + * The number of structural features of the 'Extended Element Type Set' class. + * + * + * @generated + * @ordered + */ + int EXTENDED_ELEMENT_TYPE_SET_FEATURE_COUNT = 2; + + /** + * The meta object id for the '{@link org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeConfigurationImpl Extended Element Type Configuration}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeConfigurationImpl + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedtypesPackageImpl#getExtendedElementTypeConfiguration() + * @generated + */ + int EXTENDED_ELEMENT_TYPE_CONFIGURATION = 1; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME = 0; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID = 1; + + /** + * The feature id for the 'Icon Entry' containment reference. + * + * + * @generated + * @ordered + */ + int EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY = 2; + + /** + * The feature id for the 'Hint' attribute. + * + * + * @generated + * @ordered + */ + int EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT = 3; + + /** + * The feature id for the 'Kind Name' attribute. + * + * + * @generated + * @ordered + */ + int EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME = 4; + + /** + * The feature id for the 'Specialized Types ID' attribute list. + * + * + * @generated + * @ordered + */ + int EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID = 5; + + /** + * The feature id for the 'Pre Validation' reference list. + * + * + * @generated + * @ordered + */ + int EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION = 6; + + /** + * The feature id for the 'Pre Action' containment reference list. + * + * + * @generated + * @ordered + */ + int EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION = 7; + + /** + * The feature id for the 'Post Action' containment reference list. + * + * + * @generated + * @ordered + */ + int EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION = 8; + + /** + * The number of structural features of the 'Extended Element Type Configuration' class. + * + * + * @generated + * @ordered + */ + int EXTENDED_ELEMENT_TYPE_CONFIGURATION_FEATURE_COUNT = 9; + + /** + * The meta object id for the '{@link org.eclipse.papyrus.infra.extendedtypes.impl.IconEntryImpl Icon Entry}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.impl.IconEntryImpl + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedtypesPackageImpl#getIconEntry() + * @generated + */ + int ICON_ENTRY = 2; + + /** + * The feature id for the 'Icon Path' attribute. + * + * + * @generated + * @ordered + */ + int ICON_ENTRY__ICON_PATH = 0; + + /** + * The feature id for the 'Bundle Id' attribute. + * + * + * @generated + * @ordered + */ + int ICON_ENTRY__BUNDLE_ID = 1; + + /** + * The number of structural features of the 'Icon Entry' class. + * + * + * @generated + * @ordered + */ + int ICON_ENTRY_FEATURE_COUNT = 2; + + /** + * The meta object id for the '{@link org.eclipse.papyrus.infra.extendedtypes.impl.ActionConfigurationImpl Action Configuration}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ActionConfigurationImpl + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedtypesPackageImpl#getActionConfiguration() + * @generated + */ + int ACTION_CONFIGURATION = 3; + + /** + * The feature id for the 'Label' attribute. + * + * + * @generated + * @ordered + */ + int ACTION_CONFIGURATION__LABEL = 0; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int ACTION_CONFIGURATION__ID = 1; + + /** + * The number of structural features of the 'Action Configuration' class. + * + * + * @generated + * @ordered + */ + int ACTION_CONFIGURATION_FEATURE_COUNT = 2; + + /** + * The meta object id for the '{@link org.eclipse.papyrus.infra.extendedtypes.impl.PreActionConfigurationImpl Pre Action Configuration}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.impl.PreActionConfigurationImpl + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedtypesPackageImpl#getPreActionConfiguration() + * @generated + */ + int PRE_ACTION_CONFIGURATION = 4; + + /** + * The feature id for the 'Label' attribute. + * + * + * @generated + * @ordered + */ + int PRE_ACTION_CONFIGURATION__LABEL = ACTION_CONFIGURATION__LABEL; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int PRE_ACTION_CONFIGURATION__ID = ACTION_CONFIGURATION__ID; + + /** + * The number of structural features of the 'Pre Action Configuration' class. + * + * + * @generated + * @ordered + */ + int PRE_ACTION_CONFIGURATION_FEATURE_COUNT = ACTION_CONFIGURATION_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.eclipse.papyrus.infra.extendedtypes.impl.PostActionConfigurationImpl Post Action Configuration}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.impl.PostActionConfigurationImpl + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedtypesPackageImpl#getPostActionConfiguration() + * @generated + */ + int POST_ACTION_CONFIGURATION = 5; + + /** + * The feature id for the 'Label' attribute. + * + * + * @generated + * @ordered + */ + int POST_ACTION_CONFIGURATION__LABEL = ACTION_CONFIGURATION__LABEL; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int POST_ACTION_CONFIGURATION__ID = ACTION_CONFIGURATION__ID; + + /** + * The number of structural features of the 'Post Action Configuration' class. + * + * + * @generated + * @ordered + */ + int POST_ACTION_CONFIGURATION_FEATURE_COUNT = ACTION_CONFIGURATION_FEATURE_COUNT + 0; + + + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSet Extended Element Type Set}'. + * + * + * @return the meta object for class 'Extended Element Type Set'. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSet + * @generated + */ + EClass getExtendedElementTypeSet(); + + /** + * Returns the meta object for the containment reference list '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSet#getElementType Element Type}'. + * + * + * @return the meta object for the containment reference list 'Element Type'. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSet#getElementType() + * @see #getExtendedElementTypeSet() + * @generated + */ + EReference getExtendedElementTypeSet_ElementType(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSet#getId Id}'. + * + * + * @return the meta object for the attribute 'Id'. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSet#getId() + * @see #getExtendedElementTypeSet() + * @generated + */ + EAttribute getExtendedElementTypeSet_Id(); + + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration Extended Element Type Configuration}'. + * + * + * @return the meta object for class 'Extended Element Type Configuration'. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration + * @generated + */ + EClass getExtendedElementTypeConfiguration(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getName Name}'. + * + * + * @return the meta object for the attribute 'Name'. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getName() + * @see #getExtendedElementTypeConfiguration() + * @generated + */ + EAttribute getExtendedElementTypeConfiguration_Name(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getId Id}'. + * + * + * @return the meta object for the attribute 'Id'. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getId() + * @see #getExtendedElementTypeConfiguration() + * @generated + */ + EAttribute getExtendedElementTypeConfiguration_Id(); + + /** + * Returns the meta object for the containment reference '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getIconEntry Icon Entry}'. + * + * + * @return the meta object for the containment reference 'Icon Entry'. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getIconEntry() + * @see #getExtendedElementTypeConfiguration() + * @generated + */ + EReference getExtendedElementTypeConfiguration_IconEntry(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getHint Hint}'. + * + * + * @return the meta object for the attribute 'Hint'. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getHint() + * @see #getExtendedElementTypeConfiguration() + * @generated + */ + EAttribute getExtendedElementTypeConfiguration_Hint(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getKindName Kind Name}'. + * + * + * @return the meta object for the attribute 'Kind Name'. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getKindName() + * @see #getExtendedElementTypeConfiguration() + * @generated + */ + EAttribute getExtendedElementTypeConfiguration_KindName(); + + /** + * Returns the meta object for the attribute list '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getSpecializedTypesID Specialized Types ID}'. + * + * + * @return the meta object for the attribute list 'Specialized Types ID'. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getSpecializedTypesID() + * @see #getExtendedElementTypeConfiguration() + * @generated + */ + EAttribute getExtendedElementTypeConfiguration_SpecializedTypesID(); + + /** + * Returns the meta object for the reference list '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getPreValidation Pre Validation}'. + * + * + * @return the meta object for the reference list 'Pre Validation'. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getPreValidation() + * @see #getExtendedElementTypeConfiguration() + * @generated + */ + EReference getExtendedElementTypeConfiguration_PreValidation(); + + /** + * Returns the meta object for the containment reference list '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getPreAction Pre Action}'. + * + * + * @return the meta object for the containment reference list 'Pre Action'. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getPreAction() + * @see #getExtendedElementTypeConfiguration() + * @generated + */ + EReference getExtendedElementTypeConfiguration_PreAction(); + + /** + * Returns the meta object for the containment reference list '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getPostAction Post Action}'. + * + * + * @return the meta object for the containment reference list 'Post Action'. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration#getPostAction() + * @see #getExtendedElementTypeConfiguration() + * @generated + */ + EReference getExtendedElementTypeConfiguration_PostAction(); + + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.infra.extendedtypes.IconEntry Icon Entry}'. + * + * + * @return the meta object for class 'Icon Entry'. + * @see org.eclipse.papyrus.infra.extendedtypes.IconEntry + * @generated + */ + EClass getIconEntry(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.papyrus.infra.extendedtypes.IconEntry#getIconPath Icon Path}'. + * + * + * @return the meta object for the attribute 'Icon Path'. + * @see org.eclipse.papyrus.infra.extendedtypes.IconEntry#getIconPath() + * @see #getIconEntry() + * @generated + */ + EAttribute getIconEntry_IconPath(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.papyrus.infra.extendedtypes.IconEntry#getBundleId Bundle Id}'. + * + * + * @return the meta object for the attribute 'Bundle Id'. + * @see org.eclipse.papyrus.infra.extendedtypes.IconEntry#getBundleId() + * @see #getIconEntry() + * @generated + */ + EAttribute getIconEntry_BundleId(); + + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration Action Configuration}'. + * + * + * @return the meta object for class 'Action Configuration'. + * @see org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration + * @generated + */ + EClass getActionConfiguration(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration#getLabel Label}'. + * + * + * @return the meta object for the attribute 'Label'. + * @see org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration#getLabel() + * @see #getActionConfiguration() + * @generated + */ + EAttribute getActionConfiguration_Label(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration#getId Id}'. + * + * + * @return the meta object for the attribute 'Id'. + * @see org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration#getId() + * @see #getActionConfiguration() + * @generated + */ + EAttribute getActionConfiguration_Id(); + + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.infra.extendedtypes.PreActionConfiguration Pre Action Configuration}'. + * + * + * @return the meta object for class 'Pre Action Configuration'. + * @see org.eclipse.papyrus.infra.extendedtypes.PreActionConfiguration + * @generated + */ + EClass getPreActionConfiguration(); + + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration Post Action Configuration}'. + * + * + * @return the meta object for class 'Post Action Configuration'. + * @see org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration + * @generated + */ + EClass getPostActionConfiguration(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + ExtendedtypesFactory getExtendedtypesFactory(); + + /** + * + * Defines literals for the meta objects that represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeSetImpl Extended Element Type Set}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeSetImpl + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedtypesPackageImpl#getExtendedElementTypeSet() + * @generated + */ + EClass EXTENDED_ELEMENT_TYPE_SET = eINSTANCE.getExtendedElementTypeSet(); + + /** + * The meta object literal for the 'Element Type' containment reference list feature. + * + * + * @generated + */ + EReference EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE = eINSTANCE.getExtendedElementTypeSet_ElementType(); + + /** + * The meta object literal for the 'Id' attribute feature. + * + * + * @generated + */ + EAttribute EXTENDED_ELEMENT_TYPE_SET__ID = eINSTANCE.getExtendedElementTypeSet_Id(); + + /** + * The meta object literal for the '{@link org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeConfigurationImpl Extended Element Type Configuration}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeConfigurationImpl + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedtypesPackageImpl#getExtendedElementTypeConfiguration() + * @generated + */ + EClass EXTENDED_ELEMENT_TYPE_CONFIGURATION = eINSTANCE.getExtendedElementTypeConfiguration(); + + /** + * The meta object literal for the 'Name' attribute feature. + * + * + * @generated + */ + EAttribute EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME = eINSTANCE.getExtendedElementTypeConfiguration_Name(); + + /** + * The meta object literal for the 'Id' attribute feature. + * + * + * @generated + */ + EAttribute EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID = eINSTANCE.getExtendedElementTypeConfiguration_Id(); + + /** + * The meta object literal for the 'Icon Entry' containment reference feature. + * + * + * @generated + */ + EReference EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY = eINSTANCE.getExtendedElementTypeConfiguration_IconEntry(); + + /** + * The meta object literal for the 'Hint' attribute feature. + * + * + * @generated + */ + EAttribute EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT = eINSTANCE.getExtendedElementTypeConfiguration_Hint(); + + /** + * The meta object literal for the 'Kind Name' attribute feature. + * + * + * @generated + */ + EAttribute EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME = eINSTANCE.getExtendedElementTypeConfiguration_KindName(); + + /** + * The meta object literal for the 'Specialized Types ID' attribute list feature. + * + * + * @generated + */ + EAttribute EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID = eINSTANCE.getExtendedElementTypeConfiguration_SpecializedTypesID(); + + /** + * The meta object literal for the 'Pre Validation' reference list feature. + * + * + * @generated + */ + EReference EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION = eINSTANCE.getExtendedElementTypeConfiguration_PreValidation(); + + /** + * The meta object literal for the 'Pre Action' containment reference list feature. + * + * + * @generated + */ + EReference EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION = eINSTANCE.getExtendedElementTypeConfiguration_PreAction(); + + /** + * The meta object literal for the 'Post Action' containment reference list feature. + * + * + * @generated + */ + EReference EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION = eINSTANCE.getExtendedElementTypeConfiguration_PostAction(); + + /** + * The meta object literal for the '{@link org.eclipse.papyrus.infra.extendedtypes.impl.IconEntryImpl Icon Entry}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.impl.IconEntryImpl + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedtypesPackageImpl#getIconEntry() + * @generated + */ + EClass ICON_ENTRY = eINSTANCE.getIconEntry(); + + /** + * The meta object literal for the 'Icon Path' attribute feature. + * + * + * @generated + */ + EAttribute ICON_ENTRY__ICON_PATH = eINSTANCE.getIconEntry_IconPath(); + + /** + * The meta object literal for the 'Bundle Id' attribute feature. + * + * + * @generated + */ + EAttribute ICON_ENTRY__BUNDLE_ID = eINSTANCE.getIconEntry_BundleId(); + + /** + * The meta object literal for the '{@link org.eclipse.papyrus.infra.extendedtypes.impl.ActionConfigurationImpl Action Configuration}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ActionConfigurationImpl + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedtypesPackageImpl#getActionConfiguration() + * @generated + */ + EClass ACTION_CONFIGURATION = eINSTANCE.getActionConfiguration(); + + /** + * The meta object literal for the 'Label' attribute feature. + * + * + * @generated + */ + EAttribute ACTION_CONFIGURATION__LABEL = eINSTANCE.getActionConfiguration_Label(); + + /** + * The meta object literal for the 'Id' attribute feature. + * + * + * @generated + */ + EAttribute ACTION_CONFIGURATION__ID = eINSTANCE.getActionConfiguration_Id(); + + /** + * The meta object literal for the '{@link org.eclipse.papyrus.infra.extendedtypes.impl.PreActionConfigurationImpl Pre Action Configuration}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.impl.PreActionConfigurationImpl + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedtypesPackageImpl#getPreActionConfiguration() + * @generated + */ + EClass PRE_ACTION_CONFIGURATION = eINSTANCE.getPreActionConfiguration(); + + /** + * The meta object literal for the '{@link org.eclipse.papyrus.infra.extendedtypes.impl.PostActionConfigurationImpl Post Action Configuration}' class. + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.impl.PostActionConfigurationImpl + * @see org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedtypesPackageImpl#getPostActionConfiguration() + * @generated + */ + EClass POST_ACTION_CONFIGURATION = eINSTANCE.getPostActionConfiguration(); + + } + +} //ExtendedtypesPackage diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/IconEntry.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/IconEntry.java new file mode 100644 index 00000000000..821a7f03939 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/IconEntry.java @@ -0,0 +1,81 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Icon Entry'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.IconEntry#getIconPath Icon Path}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.IconEntry#getBundleId Bundle Id}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getIconEntry() + * @model + * @generated + */ +public interface IconEntry extends EObject { + /** + * Returns the value of the 'Icon Path' attribute. + * + *

+ * If the meaning of the 'Icon Path' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Icon Path' attribute. + * @see #setIconPath(String) + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getIconEntry_IconPath() + * @model + * @generated + */ + String getIconPath(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.extendedtypes.IconEntry#getIconPath Icon Path}' attribute. + * + * + * @param value the new value of the 'Icon Path' attribute. + * @see #getIconPath() + * @generated + */ + void setIconPath(String value); + + /** + * Returns the value of the 'Bundle Id' attribute. + * + *

+ * If the meaning of the 'Bundle Id' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Bundle Id' attribute. + * @see #setBundleId(String) + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getIconEntry_BundleId() + * @model + * @generated + */ + String getBundleId(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.extendedtypes.IconEntry#getBundleId Bundle Id}' attribute. + * + * + * @param value the new value of the 'Bundle Id' attribute. + * @see #getBundleId() + * @generated + */ + void setBundleId(String value); + +} // IconEntry diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/PostActionConfiguration.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/PostActionConfiguration.java new file mode 100644 index 00000000000..176d3995b88 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/PostActionConfiguration.java @@ -0,0 +1,21 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes; + + +/** + * + * A representation of the model object 'Post Action Configuration'. + * + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getPostActionConfiguration() + * @model abstract="true" + * @generated + */ +public interface PostActionConfiguration extends ActionConfiguration { +} // PostActionConfiguration diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/PreActionConfiguration.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/PreActionConfiguration.java new file mode 100644 index 00000000000..23ac073d44b --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/PreActionConfiguration.java @@ -0,0 +1,21 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes; + + +/** + * + * A representation of the model object 'Pre Action Configuration'. + * + * + * + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#getPreActionConfiguration() + * @model abstract="true" + * @generated + */ +public interface PreActionConfiguration extends ActionConfiguration { +} // PreActionConfiguration diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ActionConfigurationImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ActionConfigurationImpl.java new file mode 100644 index 00000000000..0a9a345c347 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ActionConfigurationImpl.java @@ -0,0 +1,221 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.impl; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; + +import org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage; + +/** + * + * An implementation of the model object 'Action Configuration'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.impl.ActionConfigurationImpl#getLabel Label}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.impl.ActionConfigurationImpl#getId Id}
  • + *
+ *

+ * + * @generated + */ +public abstract class ActionConfigurationImpl extends EObjectImpl implements ActionConfiguration { + /** + * The default value of the '{@link #getLabel() Label}' attribute. + * + * + * @see #getLabel() + * @generated + * @ordered + */ + protected static final String LABEL_EDEFAULT = null; + + /** + * The cached value of the '{@link #getLabel() Label}' attribute. + * + * + * @see #getLabel() + * @generated + * @ordered + */ + protected String label = LABEL_EDEFAULT; + + /** + * The default value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected static final String ID_EDEFAULT = null; + + /** + * The cached value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected String id = ID_EDEFAULT; + + /** + * + * + * @generated + */ + protected ActionConfigurationImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ExtendedtypesPackage.Literals.ACTION_CONFIGURATION; + } + + /** + * + * + * @generated + */ + public String getLabel() { + return label; + } + + /** + * + * + * @generated + */ + public void setLabel(String newLabel) { + String oldLabel = label; + label = newLabel; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.ACTION_CONFIGURATION__LABEL, oldLabel, label)); + } + + /** + * + * + * @generated + */ + public String getId() { + return id; + } + + /** + * + * + * @generated + */ + public void setId(String newId) { + String oldId = id; + id = newId; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.ACTION_CONFIGURATION__ID, oldId, id)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ExtendedtypesPackage.ACTION_CONFIGURATION__LABEL: + return getLabel(); + case ExtendedtypesPackage.ACTION_CONFIGURATION__ID: + return getId(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ExtendedtypesPackage.ACTION_CONFIGURATION__LABEL: + setLabel((String)newValue); + return; + case ExtendedtypesPackage.ACTION_CONFIGURATION__ID: + setId((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ExtendedtypesPackage.ACTION_CONFIGURATION__LABEL: + setLabel(LABEL_EDEFAULT); + return; + case ExtendedtypesPackage.ACTION_CONFIGURATION__ID: + setId(ID_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ExtendedtypesPackage.ACTION_CONFIGURATION__LABEL: + return LABEL_EDEFAULT == null ? label != null : !LABEL_EDEFAULT.equals(label); + case ExtendedtypesPackage.ACTION_CONFIGURATION__ID: + return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (label: "); + result.append(label); + result.append(", id: "); + result.append(id); + result.append(')'); + return result.toString(); + } + +} //ActionConfigurationImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedElementTypeConfigurationImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedElementTypeConfigurationImpl.java new file mode 100644 index 00000000000..665504c4c45 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedElementTypeConfigurationImpl.java @@ -0,0 +1,566 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; + +import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.EObjectResolvingEList; +import org.eclipse.emf.ecore.util.InternalEList; + + +import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage; +import org.eclipse.papyrus.infra.extendedtypes.IconEntry; +import org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.PreActionConfiguration; +import org.eclipse.papyrus.infra.queries.core.configuration.QueryConfiguration; + +/** + * + * An implementation of the model object 'Extended Element Type Configuration'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getName Name}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getId Id}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getIconEntry Icon Entry}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getHint Hint}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getKindName Kind Name}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getSpecializedTypesID Specialized Types ID}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getPreValidation Pre Validation}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getPreAction Pre Action}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeConfigurationImpl#getPostAction Post Action}
  • + *
+ *

+ * + * @generated + */ +public class ExtendedElementTypeConfigurationImpl extends EObjectImpl implements ExtendedElementTypeConfiguration { + /** + * The default value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * The default value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected static final String ID_EDEFAULT = null; + + /** + * The cached value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected String id = ID_EDEFAULT; + + /** + * The cached value of the '{@link #getIconEntry() Icon Entry}' containment reference. + * + * + * @see #getIconEntry() + * @generated + * @ordered + */ + protected IconEntry iconEntry; + + /** + * The default value of the '{@link #getHint() Hint}' attribute. + * + * + * @see #getHint() + * @generated + * @ordered + */ + protected static final String HINT_EDEFAULT = "ExtendedElements"; + + /** + * The cached value of the '{@link #getHint() Hint}' attribute. + * + * + * @see #getHint() + * @generated + * @ordered + */ + protected String hint = HINT_EDEFAULT; + + /** + * The default value of the '{@link #getKindName() Kind Name}' attribute. + * + * + * @see #getKindName() + * @generated + * @ordered + */ + protected static final String KIND_NAME_EDEFAULT = "org.eclipse.gmf.runtime.emf.type.core.IHintedType"; + + /** + * The cached value of the '{@link #getKindName() Kind Name}' attribute. + * + * + * @see #getKindName() + * @generated + * @ordered + */ + protected String kindName = KIND_NAME_EDEFAULT; + + /** + * The cached value of the '{@link #getSpecializedTypesID() Specialized Types ID}' attribute list. + * + * + * @see #getSpecializedTypesID() + * @generated + * @ordered + */ + protected EList specializedTypesID; + + /** + * The cached value of the '{@link #getPreValidation() Pre Validation}' reference list. + * + * + * @see #getPreValidation() + * @generated + * @ordered + */ + protected EList preValidation; + + /** + * The cached value of the '{@link #getPreAction() Pre Action}' containment reference list. + * + * + * @see #getPreAction() + * @generated + * @ordered + */ + protected EList preAction; + + /** + * The cached value of the '{@link #getPostAction() Post Action}' containment reference list. + * + * + * @see #getPostAction() + * @generated + * @ordered + */ + protected EList postAction; + + /** + * + * + * @generated + */ + protected ExtendedElementTypeConfigurationImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ExtendedtypesPackage.Literals.EXTENDED_ELEMENT_TYPE_CONFIGURATION; + } + + /** + * + * + * @generated + */ + public String getName() { + return name; + } + + /** + * + * + * @generated + */ + public void setName(String newName) { + String oldName = name; + name = newName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME, oldName, name)); + } + + /** + * + * + * @generated + */ + public String getId() { + return id; + } + + /** + * + * + * @generated + */ + public void setId(String newId) { + String oldId = id; + id = newId; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID, oldId, id)); + } + + /** + * + * + * @generated + */ + public IconEntry getIconEntry() { + return iconEntry; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetIconEntry(IconEntry newIconEntry, NotificationChain msgs) { + IconEntry oldIconEntry = iconEntry; + iconEntry = newIconEntry; + if (eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY, oldIconEntry, newIconEntry); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setIconEntry(IconEntry newIconEntry) { + if (newIconEntry != iconEntry) { + NotificationChain msgs = null; + if (iconEntry != null) + msgs = ((InternalEObject)iconEntry).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY, null, msgs); + if (newIconEntry != null) + msgs = ((InternalEObject)newIconEntry).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY, null, msgs); + msgs = basicSetIconEntry(newIconEntry, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY, newIconEntry, newIconEntry)); + } + + /** + * + * + * @generated + */ + public String getHint() { + return hint; + } + + /** + * + * + * @generated + */ + public void setHint(String newHint) { + String oldHint = hint; + hint = newHint; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT, oldHint, hint)); + } + + /** + * + * + * @generated + */ + public String getKindName() { + return kindName; + } + + /** + * + * + * @generated + */ + public void setKindName(String newKindName) { + String oldKindName = kindName; + kindName = newKindName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME, oldKindName, kindName)); + } + + /** + * + * + * @generated + */ + public EList getSpecializedTypesID() { + if (specializedTypesID == null) { + specializedTypesID = new EDataTypeUniqueEList(String.class, this, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID); + } + return specializedTypesID; + } + + /** + * + * + * @generated + */ + public EList getPreValidation() { + if (preValidation == null) { + preValidation = new EObjectResolvingEList(QueryConfiguration.class, this, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION); + } + return preValidation; + } + + /** + * + * + * @generated + */ + public EList getPreAction() { + if (preAction == null) { + preAction = new EObjectContainmentEList(PreActionConfiguration.class, this, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION); + } + return preAction; + } + + /** + * + * + * @generated + */ + public EList getPostAction() { + if (postAction == null) { + postAction = new EObjectContainmentEList(PostActionConfiguration.class, this, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION); + } + return postAction; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY: + return basicSetIconEntry(null, msgs); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION: + return ((InternalEList)getPreAction()).basicRemove(otherEnd, msgs); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION: + return ((InternalEList)getPostAction()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME: + return getName(); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID: + return getId(); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY: + return getIconEntry(); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT: + return getHint(); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME: + return getKindName(); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID: + return getSpecializedTypesID(); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION: + return getPreValidation(); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION: + return getPreAction(); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION: + return getPostAction(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME: + setName((String)newValue); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID: + setId((String)newValue); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY: + setIconEntry((IconEntry)newValue); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT: + setHint((String)newValue); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME: + setKindName((String)newValue); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID: + getSpecializedTypesID().clear(); + getSpecializedTypesID().addAll((Collection)newValue); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION: + getPreValidation().clear(); + getPreValidation().addAll((Collection)newValue); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION: + getPreAction().clear(); + getPreAction().addAll((Collection)newValue); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION: + getPostAction().clear(); + getPostAction().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME: + setName(NAME_EDEFAULT); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID: + setId(ID_EDEFAULT); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY: + setIconEntry((IconEntry)null); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT: + setHint(HINT_EDEFAULT); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME: + setKindName(KIND_NAME_EDEFAULT); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID: + getSpecializedTypesID().clear(); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION: + getPreValidation().clear(); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION: + getPreAction().clear(); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION: + getPostAction().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID: + return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY: + return iconEntry != null; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT: + return HINT_EDEFAULT == null ? hint != null : !HINT_EDEFAULT.equals(hint); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME: + return KIND_NAME_EDEFAULT == null ? kindName != null : !KIND_NAME_EDEFAULT.equals(kindName); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID: + return specializedTypesID != null && !specializedTypesID.isEmpty(); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION: + return preValidation != null && !preValidation.isEmpty(); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION: + return preAction != null && !preAction.isEmpty(); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION: + return postAction != null && !postAction.isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (name: "); + result.append(name); + result.append(", id: "); + result.append(id); + result.append(", hint: "); + result.append(hint); + result.append(", kindName: "); + result.append(kindName); + result.append(", specializedTypesID: "); + result.append(specializedTypesID); + result.append(')'); + return result.toString(); + } + +} //ExtendedElementTypeConfigurationImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedElementTypeSetImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedElementTypeSetImpl.java new file mode 100644 index 00000000000..774ba9dc82c --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedElementTypeSetImpl.java @@ -0,0 +1,226 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; + +import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSet; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage; + +/** + * + * An implementation of the model object 'Extended Element Type Set'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeSetImpl#getElementType Element Type}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.impl.ExtendedElementTypeSetImpl#getId Id}
  • + *
+ *

+ * + * @generated + */ +public class ExtendedElementTypeSetImpl extends EObjectImpl implements ExtendedElementTypeSet { + /** + * The cached value of the '{@link #getElementType() Element Type}' containment reference list. + * + * + * @see #getElementType() + * @generated + * @ordered + */ + protected EList elementType; + + /** + * The default value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected static final String ID_EDEFAULT = null; + + /** + * The cached value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected String id = ID_EDEFAULT; + + /** + * + * + * @generated + */ + protected ExtendedElementTypeSetImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ExtendedtypesPackage.Literals.EXTENDED_ELEMENT_TYPE_SET; + } + + /** + * + * + * @generated + */ + public EList getElementType() { + if (elementType == null) { + elementType = new EObjectContainmentEList(ExtendedElementTypeConfiguration.class, this, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE); + } + return elementType; + } + + /** + * + * + * @generated + */ + public String getId() { + return id; + } + + /** + * + * + * @generated + */ + public void setId(String newId) { + String oldId = id; + id = newId; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ID, oldId, id)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE: + return ((InternalEList)getElementType()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE: + return getElementType(); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ID: + return getId(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE: + getElementType().clear(); + getElementType().addAll((Collection)newValue); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ID: + setId((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE: + getElementType().clear(); + return; + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ID: + setId(ID_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE: + return elementType != null && !elementType.isEmpty(); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET__ID: + return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (id: "); + result.append(id); + result.append(')'); + return result.toString(); + } + +} //ExtendedElementTypeSetImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedtypesFactoryImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedtypesFactoryImpl.java new file mode 100644 index 00000000000..5dd87034cbf --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedtypesFactoryImpl.java @@ -0,0 +1,121 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.impl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +import org.eclipse.papyrus.infra.extendedtypes.*; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class ExtendedtypesFactoryImpl extends EFactoryImpl implements ExtendedtypesFactory { + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static ExtendedtypesFactory init() { + try { + ExtendedtypesFactory theExtendedtypesFactory = (ExtendedtypesFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.eclipse.org/papyrus/diagram/types/extendedtypes/0.7"); + if (theExtendedtypesFactory != null) { + return theExtendedtypesFactory; + } + } + catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new ExtendedtypesFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public ExtendedtypesFactoryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET: return createExtendedElementTypeSet(); + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION: return createExtendedElementTypeConfiguration(); + case ExtendedtypesPackage.ICON_ENTRY: return createIconEntry(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public ExtendedElementTypeSet createExtendedElementTypeSet() { + ExtendedElementTypeSetImpl extendedElementTypeSet = new ExtendedElementTypeSetImpl(); + return extendedElementTypeSet; + } + + /** + * + * + * @generated + */ + public ExtendedElementTypeConfiguration createExtendedElementTypeConfiguration() { + ExtendedElementTypeConfigurationImpl extendedElementTypeConfiguration = new ExtendedElementTypeConfigurationImpl(); + return extendedElementTypeConfiguration; + } + + /** + * + * + * @generated + */ + public IconEntry createIconEntry() { + IconEntryImpl iconEntry = new IconEntryImpl(); + return iconEntry; + } + + /** + * + * + * @generated + */ + public ExtendedtypesPackage getExtendedtypesPackage() { + return (ExtendedtypesPackage)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static ExtendedtypesPackage getPackage() { + return ExtendedtypesPackage.eINSTANCE; + } + +} //ExtendedtypesFactoryImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedtypesPackageImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedtypesPackageImpl.java new file mode 100644 index 00000000000..6e9614951f9 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/ExtendedtypesPackageImpl.java @@ -0,0 +1,453 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.impl; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EcorePackage; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + + +import org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSet; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesFactory; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage; +import org.eclipse.papyrus.infra.extendedtypes.IconEntry; +import org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.PreActionConfiguration; +import org.eclipse.papyrus.infra.queries.core.configuration.ConfigurationPackage; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class ExtendedtypesPackageImpl extends EPackageImpl implements ExtendedtypesPackage { + /** + * + * + * @generated + */ + private EClass extendedElementTypeSetEClass = null; + + /** + * + * + * @generated + */ + private EClass extendedElementTypeConfigurationEClass = null; + + /** + * + * + * @generated + */ + private EClass iconEntryEClass = null; + + /** + * + * + * @generated + */ + private EClass actionConfigurationEClass = null; + + /** + * + * + * @generated + */ + private EClass preActionConfigurationEClass = null; + + /** + * + * + * @generated + */ + private EClass postActionConfigurationEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage#eNS_URI + * @see #init() + * @generated + */ + private ExtendedtypesPackageImpl() { + super(eNS_URI, ExtendedtypesFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link ExtendedtypesPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static ExtendedtypesPackage init() { + if (isInited) return (ExtendedtypesPackage)EPackage.Registry.INSTANCE.getEPackage(ExtendedtypesPackage.eNS_URI); + + // Obtain or create and register package + ExtendedtypesPackageImpl theExtendedtypesPackage = (ExtendedtypesPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof ExtendedtypesPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new ExtendedtypesPackageImpl()); + + isInited = true; + + // Initialize simple dependencies + ConfigurationPackage.eINSTANCE.eClass(); + + // Create package meta-data objects + theExtendedtypesPackage.createPackageContents(); + + // Initialize created meta-data + theExtendedtypesPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theExtendedtypesPackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(ExtendedtypesPackage.eNS_URI, theExtendedtypesPackage); + return theExtendedtypesPackage; + } + + /** + * + * + * @generated + */ + public EClass getExtendedElementTypeSet() { + return extendedElementTypeSetEClass; + } + + /** + * + * + * @generated + */ + public EReference getExtendedElementTypeSet_ElementType() { + return (EReference)extendedElementTypeSetEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getExtendedElementTypeSet_Id() { + return (EAttribute)extendedElementTypeSetEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EClass getExtendedElementTypeConfiguration() { + return extendedElementTypeConfigurationEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getExtendedElementTypeConfiguration_Name() { + return (EAttribute)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getExtendedElementTypeConfiguration_Id() { + return (EAttribute)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EReference getExtendedElementTypeConfiguration_IconEntry() { + return (EReference)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EAttribute getExtendedElementTypeConfiguration_Hint() { + return (EAttribute)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + public EAttribute getExtendedElementTypeConfiguration_KindName() { + return (EAttribute)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(4); + } + + /** + * + * + * @generated + */ + public EAttribute getExtendedElementTypeConfiguration_SpecializedTypesID() { + return (EAttribute)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(5); + } + + /** + * + * + * @generated + */ + public EReference getExtendedElementTypeConfiguration_PreValidation() { + return (EReference)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(6); + } + + /** + * + * + * @generated + */ + public EReference getExtendedElementTypeConfiguration_PreAction() { + return (EReference)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(7); + } + + /** + * + * + * @generated + */ + public EReference getExtendedElementTypeConfiguration_PostAction() { + return (EReference)extendedElementTypeConfigurationEClass.getEStructuralFeatures().get(8); + } + + /** + * + * + * @generated + */ + public EClass getIconEntry() { + return iconEntryEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getIconEntry_IconPath() { + return (EAttribute)iconEntryEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getIconEntry_BundleId() { + return (EAttribute)iconEntryEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EClass getActionConfiguration() { + return actionConfigurationEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getActionConfiguration_Label() { + return (EAttribute)actionConfigurationEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getActionConfiguration_Id() { + return (EAttribute)actionConfigurationEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EClass getPreActionConfiguration() { + return preActionConfigurationEClass; + } + + /** + * + * + * @generated + */ + public EClass getPostActionConfiguration() { + return postActionConfigurationEClass; + } + + /** + * + * + * @generated + */ + public ExtendedtypesFactory getExtendedtypesFactory() { + return (ExtendedtypesFactory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + extendedElementTypeSetEClass = createEClass(EXTENDED_ELEMENT_TYPE_SET); + createEReference(extendedElementTypeSetEClass, EXTENDED_ELEMENT_TYPE_SET__ELEMENT_TYPE); + createEAttribute(extendedElementTypeSetEClass, EXTENDED_ELEMENT_TYPE_SET__ID); + + extendedElementTypeConfigurationEClass = createEClass(EXTENDED_ELEMENT_TYPE_CONFIGURATION); + createEAttribute(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__NAME); + createEAttribute(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__ID); + createEReference(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__ICON_ENTRY); + createEAttribute(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__HINT); + createEAttribute(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__KIND_NAME); + createEAttribute(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__SPECIALIZED_TYPES_ID); + createEReference(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_VALIDATION); + createEReference(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__PRE_ACTION); + createEReference(extendedElementTypeConfigurationEClass, EXTENDED_ELEMENT_TYPE_CONFIGURATION__POST_ACTION); + + iconEntryEClass = createEClass(ICON_ENTRY); + createEAttribute(iconEntryEClass, ICON_ENTRY__ICON_PATH); + createEAttribute(iconEntryEClass, ICON_ENTRY__BUNDLE_ID); + + actionConfigurationEClass = createEClass(ACTION_CONFIGURATION); + createEAttribute(actionConfigurationEClass, ACTION_CONFIGURATION__LABEL); + createEAttribute(actionConfigurationEClass, ACTION_CONFIGURATION__ID); + + preActionConfigurationEClass = createEClass(PRE_ACTION_CONFIGURATION); + + postActionConfigurationEClass = createEClass(POST_ACTION_CONFIGURATION); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + ConfigurationPackage theConfigurationPackage = (ConfigurationPackage)EPackage.Registry.INSTANCE.getEPackage(ConfigurationPackage.eNS_URI); + EcorePackage theEcorePackage = (EcorePackage)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + preActionConfigurationEClass.getESuperTypes().add(this.getActionConfiguration()); + postActionConfigurationEClass.getESuperTypes().add(this.getActionConfiguration()); + + // Initialize classes and features; add operations and parameters + initEClass(extendedElementTypeSetEClass, ExtendedElementTypeSet.class, "ExtendedElementTypeSet", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getExtendedElementTypeSet_ElementType(), this.getExtendedElementTypeConfiguration(), null, "elementType", null, 1, -1, ExtendedElementTypeSet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getExtendedElementTypeSet_Id(), ecorePackage.getEString(), "id", null, 1, 1, ExtendedElementTypeSet.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(extendedElementTypeConfigurationEClass, ExtendedElementTypeConfiguration.class, "ExtendedElementTypeConfiguration", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getExtendedElementTypeConfiguration_Name(), ecorePackage.getEString(), "name", null, 1, 1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getExtendedElementTypeConfiguration_Id(), ecorePackage.getEString(), "id", null, 1, 1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getExtendedElementTypeConfiguration_IconEntry(), this.getIconEntry(), null, "iconEntry", null, 0, 1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getExtendedElementTypeConfiguration_Hint(), ecorePackage.getEString(), "hint", "ExtendedElements", 0, 1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getExtendedElementTypeConfiguration_KindName(), ecorePackage.getEString(), "kindName", "org.eclipse.gmf.runtime.emf.type.core.IHintedType", 0, 1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getExtendedElementTypeConfiguration_SpecializedTypesID(), ecorePackage.getEString(), "specializedTypesID", null, 1, -1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getExtendedElementTypeConfiguration_PreValidation(), theConfigurationPackage.getQueryConfiguration(), null, "preValidation", null, 0, -1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getExtendedElementTypeConfiguration_PreAction(), this.getPreActionConfiguration(), null, "preAction", null, 0, -1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getExtendedElementTypeConfiguration_PostAction(), this.getPostActionConfiguration(), null, "postAction", null, 0, -1, ExtendedElementTypeConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(iconEntryEClass, IconEntry.class, "IconEntry", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getIconEntry_IconPath(), ecorePackage.getEString(), "iconPath", null, 0, 1, IconEntry.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getIconEntry_BundleId(), ecorePackage.getEString(), "bundleId", null, 0, 1, IconEntry.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(actionConfigurationEClass, ActionConfiguration.class, "ActionConfiguration", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getActionConfiguration_Label(), theEcorePackage.getEString(), "label", null, 0, 1, ActionConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getActionConfiguration_Id(), theEcorePackage.getEString(), "id", null, 1, 1, ActionConfiguration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(preActionConfigurationEClass, PreActionConfiguration.class, "PreActionConfiguration", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + initEClass(postActionConfigurationEClass, PostActionConfiguration.class, "PostActionConfiguration", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + // Create resource + createResource(eNS_URI); + } + +} //ExtendedtypesPackageImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/IconEntryImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/IconEntryImpl.java new file mode 100644 index 00000000000..b08cf5ca164 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/IconEntryImpl.java @@ -0,0 +1,221 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.impl; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; + +import org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage; +import org.eclipse.papyrus.infra.extendedtypes.IconEntry; + +/** + * + * An implementation of the model object 'Icon Entry'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.impl.IconEntryImpl#getIconPath Icon Path}
  • + *
  • {@link org.eclipse.papyrus.infra.extendedtypes.impl.IconEntryImpl#getBundleId Bundle Id}
  • + *
+ *

+ * + * @generated + */ +public class IconEntryImpl extends EObjectImpl implements IconEntry { + /** + * The default value of the '{@link #getIconPath() Icon Path}' attribute. + * + * + * @see #getIconPath() + * @generated + * @ordered + */ + protected static final String ICON_PATH_EDEFAULT = null; + + /** + * The cached value of the '{@link #getIconPath() Icon Path}' attribute. + * + * + * @see #getIconPath() + * @generated + * @ordered + */ + protected String iconPath = ICON_PATH_EDEFAULT; + + /** + * The default value of the '{@link #getBundleId() Bundle Id}' attribute. + * + * + * @see #getBundleId() + * @generated + * @ordered + */ + protected static final String BUNDLE_ID_EDEFAULT = null; + + /** + * The cached value of the '{@link #getBundleId() Bundle Id}' attribute. + * + * + * @see #getBundleId() + * @generated + * @ordered + */ + protected String bundleId = BUNDLE_ID_EDEFAULT; + + /** + * + * + * @generated + */ + protected IconEntryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ExtendedtypesPackage.Literals.ICON_ENTRY; + } + + /** + * + * + * @generated + */ + public String getIconPath() { + return iconPath; + } + + /** + * + * + * @generated + */ + public void setIconPath(String newIconPath) { + String oldIconPath = iconPath; + iconPath = newIconPath; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.ICON_ENTRY__ICON_PATH, oldIconPath, iconPath)); + } + + /** + * + * + * @generated + */ + public String getBundleId() { + return bundleId; + } + + /** + * + * + * @generated + */ + public void setBundleId(String newBundleId) { + String oldBundleId = bundleId; + bundleId = newBundleId; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ExtendedtypesPackage.ICON_ENTRY__BUNDLE_ID, oldBundleId, bundleId)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ExtendedtypesPackage.ICON_ENTRY__ICON_PATH: + return getIconPath(); + case ExtendedtypesPackage.ICON_ENTRY__BUNDLE_ID: + return getBundleId(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ExtendedtypesPackage.ICON_ENTRY__ICON_PATH: + setIconPath((String)newValue); + return; + case ExtendedtypesPackage.ICON_ENTRY__BUNDLE_ID: + setBundleId((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ExtendedtypesPackage.ICON_ENTRY__ICON_PATH: + setIconPath(ICON_PATH_EDEFAULT); + return; + case ExtendedtypesPackage.ICON_ENTRY__BUNDLE_ID: + setBundleId(BUNDLE_ID_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ExtendedtypesPackage.ICON_ENTRY__ICON_PATH: + return ICON_PATH_EDEFAULT == null ? iconPath != null : !ICON_PATH_EDEFAULT.equals(iconPath); + case ExtendedtypesPackage.ICON_ENTRY__BUNDLE_ID: + return BUNDLE_ID_EDEFAULT == null ? bundleId != null : !BUNDLE_ID_EDEFAULT.equals(bundleId); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (iconPath: "); + result.append(iconPath); + result.append(", bundleId: "); + result.append(bundleId); + result.append(')'); + return result.toString(); + } + +} //IconEntryImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/PostActionConfigurationImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/PostActionConfigurationImpl.java new file mode 100644 index 00000000000..0e88b37107a --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/PostActionConfigurationImpl.java @@ -0,0 +1,43 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.impl; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage; +import org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration; + +/** + * + * An implementation of the model object 'Post Action Configuration'. + * + *

+ *

+ * + * @generated + */ +public abstract class PostActionConfigurationImpl extends ActionConfigurationImpl implements PostActionConfiguration { + /** + * + * + * @generated + */ + protected PostActionConfigurationImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ExtendedtypesPackage.Literals.POST_ACTION_CONFIGURATION; + } + +} //PostActionConfigurationImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/PreActionConfigurationImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/PreActionConfigurationImpl.java new file mode 100644 index 00000000000..c8fdb274db0 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/impl/PreActionConfigurationImpl.java @@ -0,0 +1,43 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.impl; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage; +import org.eclipse.papyrus.infra.extendedtypes.PreActionConfiguration; + +/** + * + * An implementation of the model object 'Pre Action Configuration'. + * + *

+ *

+ * + * @generated + */ +public abstract class PreActionConfigurationImpl extends ActionConfigurationImpl implements PreActionConfiguration { + /** + * + * + * @generated + */ + protected PreActionConfigurationImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ExtendedtypesPackage.Literals.PRE_ACTION_CONFIGURATION; + } + +} //PreActionConfigurationImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesAdapterFactory.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesAdapterFactory.java new file mode 100644 index 00000000000..e01cd3065cf --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesAdapterFactory.java @@ -0,0 +1,214 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.util; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +import org.eclipse.papyrus.infra.extendedtypes.*; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage + * @generated + */ +public class ExtendedtypesAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * + * + * @generated + */ + protected static ExtendedtypesPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public ExtendedtypesAdapterFactory() { + if (modelPackage == null) { + modelPackage = ExtendedtypesPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) { + if (object == modelPackage) { + return true; + } + if (object instanceof EObject) { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected ExtendedtypesSwitch modelSwitch = + new ExtendedtypesSwitch() { + @Override + public Adapter caseExtendedElementTypeSet(ExtendedElementTypeSet object) { + return createExtendedElementTypeSetAdapter(); + } + @Override + public Adapter caseExtendedElementTypeConfiguration(ExtendedElementTypeConfiguration object) { + return createExtendedElementTypeConfigurationAdapter(); + } + @Override + public Adapter caseIconEntry(IconEntry object) { + return createIconEntryAdapter(); + } + @Override + public Adapter caseActionConfiguration(ActionConfiguration object) { + return createActionConfigurationAdapter(); + } + @Override + public Adapter casePreActionConfiguration(PreActionConfiguration object) { + return createPreActionConfigurationAdapter(); + } + @Override + public Adapter casePostActionConfiguration(PostActionConfiguration object) { + return createPostActionConfigurationAdapter(); + } + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSet Extended Element Type Set}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSet + * @generated + */ + public Adapter createExtendedElementTypeSetAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration Extended Element Type Configuration}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration + * @generated + */ + public Adapter createExtendedElementTypeConfigurationAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.extendedtypes.IconEntry Icon Entry}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.extendedtypes.IconEntry + * @generated + */ + public Adapter createIconEntryAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration Action Configuration}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration + * @generated + */ + public Adapter createActionConfigurationAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.extendedtypes.PreActionConfiguration Pre Action Configuration}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.extendedtypes.PreActionConfiguration + * @generated + */ + public Adapter createPreActionConfigurationAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration Post Action Configuration}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration + * @generated + */ + public Adapter createPostActionConfigurationAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //ExtendedtypesAdapterFactory diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesResourceFactoryImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesResourceFactoryImpl.java new file mode 100644 index 00000000000..e5bdffd726c --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesResourceFactoryImpl.java @@ -0,0 +1,56 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.util; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.emf.ecore.resource.Resource; + +import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; + +import org.eclipse.emf.ecore.xmi.XMLResource; + +/** + * + * The Resource Factory associated with the package. + * + * @see org.eclipse.papyrus.infra.extendedtypes.util.ExtendedtypesResourceImpl + * @generated + */ +public class ExtendedtypesResourceFactoryImpl extends ResourceFactoryImpl { + /** + * Creates an instance of the resource factory. + * + * + * @generated + */ + public ExtendedtypesResourceFactoryImpl() { + super(); + } + + /** + * Creates an instance of the resource. + * + * + * @generated + */ + @Override + public Resource createResource(URI uri) { + XMLResource result = new ExtendedtypesResourceImpl(uri); + result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); + result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); + + result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); + + result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); + result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); + + result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE); + return result; + } + +} //ExtendedtypesResourceFactoryImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesResourceImpl.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesResourceImpl.java new file mode 100644 index 00000000000..e4994a02137 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesResourceImpl.java @@ -0,0 +1,32 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.util; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; + +/** + * + * The Resource associated with the package. + * + * @see org.eclipse.papyrus.infra.extendedtypes.util.ExtendedtypesResourceFactoryImpl + * @generated + */ +public class ExtendedtypesResourceImpl extends XMLResourceImpl { + /** + * Creates an instance of the resource. + * + * + * @param uri the URI of the new resource. + * @generated + */ + public ExtendedtypesResourceImpl(URI uri) { + super(uri); + } + +} //ExtendedtypesResourceImpl diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesSwitch.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesSwitch.java new file mode 100644 index 00000000000..876800c46f2 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesSwitch.java @@ -0,0 +1,237 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.util; + +import java.util.List; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; + +import org.eclipse.papyrus.infra.extendedtypes.*; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage + * @generated + */ +public class ExtendedtypesSwitch { + /** + * The cached model package + * + * + * @generated + */ + protected static ExtendedtypesPackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public ExtendedtypesSwitch() { + if (modelPackage == null) { + modelPackage = ExtendedtypesPackage.eINSTANCE; + } + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + public T doSwitch(EObject theEObject) { + return doSwitch(theEObject.eClass(), theEObject); + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + protected T doSwitch(EClass theEClass, EObject theEObject) { + if (theEClass.eContainer() == modelPackage) { + return doSwitch(theEClass.getClassifierID(), theEObject); + } + else { + List eSuperTypes = theEClass.getESuperTypes(); + return + eSuperTypes.isEmpty() ? + defaultCase(theEObject) : + doSwitch(eSuperTypes.get(0), theEObject); + } + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_SET: { + ExtendedElementTypeSet extendedElementTypeSet = (ExtendedElementTypeSet)theEObject; + T result = caseExtendedElementTypeSet(extendedElementTypeSet); + if (result == null) result = defaultCase(theEObject); + return result; + } + case ExtendedtypesPackage.EXTENDED_ELEMENT_TYPE_CONFIGURATION: { + ExtendedElementTypeConfiguration extendedElementTypeConfiguration = (ExtendedElementTypeConfiguration)theEObject; + T result = caseExtendedElementTypeConfiguration(extendedElementTypeConfiguration); + if (result == null) result = defaultCase(theEObject); + return result; + } + case ExtendedtypesPackage.ICON_ENTRY: { + IconEntry iconEntry = (IconEntry)theEObject; + T result = caseIconEntry(iconEntry); + if (result == null) result = defaultCase(theEObject); + return result; + } + case ExtendedtypesPackage.ACTION_CONFIGURATION: { + ActionConfiguration actionConfiguration = (ActionConfiguration)theEObject; + T result = caseActionConfiguration(actionConfiguration); + if (result == null) result = defaultCase(theEObject); + return result; + } + case ExtendedtypesPackage.PRE_ACTION_CONFIGURATION: { + PreActionConfiguration preActionConfiguration = (PreActionConfiguration)theEObject; + T result = casePreActionConfiguration(preActionConfiguration); + if (result == null) result = caseActionConfiguration(preActionConfiguration); + if (result == null) result = defaultCase(theEObject); + return result; + } + case ExtendedtypesPackage.POST_ACTION_CONFIGURATION: { + PostActionConfiguration postActionConfiguration = (PostActionConfiguration)theEObject; + T result = casePostActionConfiguration(postActionConfiguration); + if (result == null) result = caseActionConfiguration(postActionConfiguration); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'Extended Element Type Set'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Extended Element Type Set'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseExtendedElementTypeSet(ExtendedElementTypeSet object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Extended Element Type Configuration'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Extended Element Type Configuration'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseExtendedElementTypeConfiguration(ExtendedElementTypeConfiguration object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Icon Entry'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Icon Entry'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseIconEntry(IconEntry object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Action Configuration'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Action Configuration'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseActionConfiguration(ActionConfiguration object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Pre Action Configuration'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Pre Action Configuration'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePreActionConfiguration(PreActionConfiguration object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Post Action Configuration'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Post Action Configuration'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePostActionConfiguration(PostActionConfiguration object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + public T defaultCase(EObject object) { + return null; + } + +} //ExtendedtypesSwitch diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesXMLProcessor.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesXMLProcessor.java new file mode 100644 index 00000000000..039118406b3 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src-gen/org/eclipse/papyrus/infra/extendedtypes/util/ExtendedtypesXMLProcessor.java @@ -0,0 +1,54 @@ +/** + * + * + * + * $Id$ + */ +package org.eclipse.papyrus.infra.extendedtypes.util; + +import java.util.Map; + +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.resource.Resource; + +import org.eclipse.emf.ecore.xmi.util.XMLProcessor; + +import org.eclipse.papyrus.infra.extendedtypes.ExtendedtypesPackage; + +/** + * This class contains helper methods to serialize and deserialize XML documents + * + * + * @generated + */ +public class ExtendedtypesXMLProcessor extends XMLProcessor { + + /** + * Public constructor to instantiate the helper. + * + * + * @generated + */ + public ExtendedtypesXMLProcessor() { + super((EPackage.Registry.INSTANCE)); + ExtendedtypesPackage.eINSTANCE.eClass(); + } + + /** + * Register for "*" and "xml" file extensions the ExtendedtypesResourceFactoryImpl factory. + * + * + * @generated + */ + @Override + protected Map getRegistrations() { + if (registrations == null) { + super.getRegistrations(); + registrations.put(XML_EXTENSION, new ExtendedtypesResourceFactoryImpl()); + registrations.put(STAR_EXTENSION, new ExtendedtypesResourceFactoryImpl()); + } + return registrations; + } + +} //ExtendedtypesXMLProcessor diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/Activator.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/Activator.java deleted file mode 100644 index b82465c8e8d..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/Activator.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.eclipse.papyrus.extendedtypes; - -import org.eclipse.papyrus.log.LogHelper; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.extendedtypes"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** Logging 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(this); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - @Override - public void stop(BundleContext context) throws Exception { - log = null; - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/ExtendedEditHelperAdvice.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/ExtendedEditHelperAdvice.java deleted file mode 100644 index 48f60917e4b..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/ExtendedEditHelperAdvice.java +++ /dev/null @@ -1,108 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.extendedtypes; - -import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; -import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; -import org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration; -import org.eclipse.papyrus.extendedtypes.PostActionConfiguration; -import org.eclipse.papyrus.extendedtypes.providers.ExtendedElementTypeActionService; -import org.eclipse.papyrus.extendedtypes.providers.ProviderNotFoundException; -import org.eclipse.papyrus.extendedtypes.types.IExtendedHintedElementType; - -/** - * Edit helper Advice for extended element types. This allows modification of the configure request executed right after the creation of the element - */ -public class ExtendedEditHelperAdvice extends AbstractEditHelperAdvice { - - /** - * Constructor. - * - */ - public ExtendedEditHelperAdvice() { - } - - /** - * {@inheritDoc} - */ - @Override - public boolean approveRequest(IEditCommandRequest request) { - return super.approveRequest(request); - } - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getBeforeEditContextCommand(GetEditContextRequest request) { - return super.getBeforeEditContextCommand(request); - } - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getBeforeCreateCommand(CreateElementRequest request) { - return super.getBeforeCreateCommand(request); - } - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getAfterConfigureCommand(ConfigureRequest request) { - // for the list of post actions, returns a list of commands. - // there should be a factory that delivers commands from the model - - CompositeCommand compositeCommand = new CompositeCommand("AfterConfigureCommand"); - IElementType type = request.getTypeToConfigure(); - if(type instanceof IExtendedHintedElementType) { - IExtendedHintedElementType extendedHintedElementType = (IExtendedHintedElementType)type; - ExtendedElementTypeConfiguration configuration = extendedHintedElementType.getConfiguration(); - for(PostActionConfiguration postActionConfiguration : configuration.getPostAction()) { - ICommand command = null; - try { - command = ExtendedElementTypeActionService.getInstance().getICommand(request.getElementsToEdit(), postActionConfiguration); - } catch (ProviderNotFoundException e) { - Activator.log.error(e); - } - if(command != null) { - compositeCommand.add(command); - } - } - - // return the composite command only if it is not empty - if(!compositeCommand.isEmpty()) { - return compositeCommand; - } - } - - - // post-action. Here, this is null. - return super.getAfterConfigureCommand(request); - } - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getAfterCreateCommand(CreateElementRequest request) { - return super.getAfterCreateCommand(request); - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/ExtendedSemanticTypeDescriptor.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/ExtendedSemanticTypeDescriptor.java deleted file mode 100644 index 9f46c37ee84..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/ExtendedSemanticTypeDescriptor.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.eclipse.papyrus.extendedtypes; - -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; -import org.eclipse.gmf.runtime.emf.type.core.IContainerDescriptor; -import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.ISpecializationTypeDescriptor; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice; -import org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration; -import org.eclipse.papyrus.extendedtypes.IconEntry; -import org.eclipse.papyrus.extendedtypes.types.ExtendedHintedTypeFactory; -import org.osgi.framework.Bundle; - - -/** - * new descriptor implementation for on-the-fly added descriptor - */ -public class ExtendedSemanticTypeDescriptor implements ISpecializationTypeDescriptor { - - /** constant for specific semantic hint */ - public static final String EXTENDED_ELEMENTS = "ExtendedElements"; - - /** configuration of this descriptor */ - private final ExtendedElementTypeConfiguration configuration; - - /** cache of the specialized types */ - private List specializedTypes = null; - - /** - * Constructor. - * - * @param configuration - * the configuration of this descriptor - */ - public ExtendedSemanticTypeDescriptor(ExtendedElementTypeConfiguration configuration) { - this.configuration = configuration; - } - - /** - * Returns the configuration of the element type - * - * @return the configuration of the element type - */ - public ExtendedElementTypeConfiguration getConfiguration() { - return configuration; - } - - /** - * {@inheritDoc} - */ - public String getId() { - return configuration.getId(); - } - - /** - * {@inheritDoc} - */ - public URL getIconURL() { - IconEntry entry = configuration.getIconEntry(); - Bundle bundle = Platform.getBundle(entry.getBundleId()); - if(bundle == null) { - return null; - } - URL result = bundle.getEntry(entry.getIconPath()); - return result; - } - - /** - * {@inheritDoc} - */ - public String getName() { - return configuration.getName(); - } - - /** - * {@inheritDoc} - */ - public String getKindName() { - return configuration.getKindName(); - } - - /** - * {@inheritDoc} - */ - public String getParamValue(String paramName) { - if(ExtendedHintedTypeFactory.SEMANTIC_HINT_PARAM_NAME.equals(paramName)) { - return configuration.getHint(); - } - return EXTENDED_ELEMENTS; - } - - /** - * {@inheritDoc} - */ - public IContainerDescriptor getContainerDescriptor() { - return null; - } - - /** - * {@inheritDoc} - */ - public IElementType[] getSpecializedTypes() { - if(specializedTypes == null) { - specializedTypes = new ArrayList(); - for(String specializedTypeId : configuration.getSpecializedTypesID()) { - IElementType type = ElementTypeRegistry.getInstance().getType(specializedTypeId); - if(type != null) { - specializedTypes.add(type); - } else { - Activator.log.error("Impossible to find the type " + specializedTypeId, null); - } - } - } - return specializedTypes.toArray(new IElementType[specializedTypes.size()]); - } - - /** - * {@inheritDoc} - */ - public IElementMatcher getMatcher() { - return null; - } - - /** - * {@inheritDoc} - */ - public IEditHelperAdvice getEditHelperAdvice() { - return new ExtendedEditHelperAdvice(); - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/ExtendedTypesRegistry.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/ExtendedTypesRegistry.java deleted file mode 100644 index 8f3b9fe13cb..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/ExtendedTypesRegistry.java +++ /dev/null @@ -1,270 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.extendedtypes; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -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.emf.type.core.ElementTypeRegistry; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; -import org.eclipse.papyrus.extendedtypes.preferences.ExtendedTypesPreferences; -import org.eclipse.papyrus.extendedtypes.types.ExtendedHintedTypeFactory; -import org.osgi.framework.Bundle; - - -/** - * Registry for all extended types. - */ -public class ExtendedTypesRegistry { - - /** private singleton instance */ - private static ExtendedTypesRegistry registry; - - /** list of retrieved extended type sets */ - protected List extendedTypeSets = null; - - /** unique resource set to load all extended types models */ - protected ResourceSet extendedTypesResourceSet = null; - - /** - * Private constructor. - */ - private ExtendedTypesRegistry() { - - } - - /** - * returns the singleton instance of this registry - * - * @return the singleton instance of this registry - */ - public static synchronized ExtendedTypesRegistry getInstance() { - if(registry == null) { - registry = new ExtendedTypesRegistry(); - registry.init(); - } - return registry; - } - - /** - * Inits the registry. - */ - protected void init() { - // 0. Reset the values - extendedTypesResourceSet = null; - extendedTypeSets = null; - - // 1. create the resource set - extendedTypesResourceSet = createResourceSet(); - // 2. create the list only when registry is acceded for the first time - extendedTypeSets = loadExtendedTypeSets(); - } - - /** - * Retrieves and loads extended type sets registered in the platform. It should also load configuration sets from the workspace. - */ - protected List loadExtendedTypeSets() { - List extendedElementTypeSets = new ArrayList(); - - // 1. retrieve from the workspace - // TODO implement retrieve from workspace - - // 2. retrieve from the platform. - List registeredSets = loadExtendedTypeSetsFromPlatform(); - if(registeredSets != null && !registeredSets.isEmpty()) { - extendedElementTypeSets.addAll(registeredSets); - } - - return extendedElementTypeSets; - } - - /** - * Creates the resource set that contains all models for extended types - * - * @return the resource set newly created. - */ - protected ResourceSet createResourceSet() { - ResourceSet set = new ResourceSetImpl(); - return set; - } - - /** - * Loads the extensions in the platform - * - * @return the list of extension registered in the platform - */ - protected List loadExtendedTypeSetsFromPlatform() { - List platformElementTypeSets = new ArrayList(); - - IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(IExtendedTypeExtensionPoint.EXTENSION_POINT_ID); - // for each element, parses and retrieve the model file. then loads it and returns the root element - for(IConfigurationElement element : elements) { - String modelPath = element.getAttribute(IExtendedTypeExtensionPoint.PATH); - String extendedTypeSetId = element.getAttribute(IExtendedTypeExtensionPoint.ID); - String contributorID = element.getContributor().getName(); - if(Platform.inDebugMode()) { - Activator.log.debug("[Reading extension point]"); - Activator.log.debug("- Path to the model: " + modelPath); - Activator.log.debug("- id of the container bundle: " + contributorID); - Activator.log.debug("- id of the extended type set: " + extendedTypeSetId); - } - ExtendedElementTypeSet set = getExtendedElementTypeSet(extendedTypeSetId, modelPath, contributorID); - if(set != null) { - platformElementTypeSets.add(set); - } - } - - return platformElementTypeSets; - } - - /** - *

- * Loads the resource containing the extended element type set model. - *

- *

- * It looks the model file in the fragments first, then in the plugin itself.
- * If this is already a fragment, it should look in the fragment only - *

- * - * @param extendedTypesID - * id of the extended type set to load - * @param modelPath - * path of the model in the bundle - * @param bundleId - * id of the bundle containing the model file - * @return the loaded file or null if some problem occured during loading - */ - protected ExtendedElementTypeSet getExtendedElementTypeSet(String extendedTypesID, String modelPath, String bundleId) { - // 1. look in preferences. - String filePath = ExtendedTypesPreferences.getExtendedTypesRedefinition(extendedTypesID); - if(filePath != null) { - getExtendedElementTypeSetInPluginStateArea(extendedTypesID); - } - - // 2. no local redefinition. Load extended type set from plugin definition - Bundle bundle = Platform.getBundle(bundleId); - if(Platform.isFragment(bundle)) { - return getExtendedElementTypeSetInBundle(modelPath, bundleId); - } else { // this is a plugin. Search in sub fragments, then in the plugin - Bundle[] fragments = Platform.getFragments(bundle); - // no fragment, so the file should be in the plugin itself - if(fragments == null) { - return getExtendedElementTypeSetInBundle(modelPath, bundleId); - } else { - for(Bundle fragment : fragments) { - ExtendedElementTypeSet extendedElementTypeSet = getExtendedElementTypeSetInBundle(modelPath, fragment.getSymbolicName()); - if(extendedElementTypeSet != null) { - return extendedElementTypeSet; - } - } - // not found in fragments. Look in the plugin itself - return getExtendedElementTypeSetInBundle(modelPath, bundleId); - } - } - } - - /** - * Retrieves the contribution in the plugin area - * - * @param path - * the path of the element type set to load in the plugin area - */ - protected ExtendedElementTypeSet getExtendedElementTypeSetInPluginStateArea(String path) { - // read in preferences area - IPath resourcePath = Activator.getDefault().getStateLocation().append(path); - URI uri = URI.createFileURI(resourcePath.toOSString()); - if(uri != null && uri.isFile()) { - Resource resource = extendedTypesResourceSet.createResource(uri); - try { - resource.load(null); - } catch (IOException e) { - return null; - } - EObject content = resource.getContents().get(0); - if(content instanceof ExtendedElementTypeSet) { - return (ExtendedElementTypeSet)content; - } - Activator.log.error("Impossible to cast the object into an ExtendedElementTypeSet: " + content, null); - return null; - } - return null; - } - - /** - * - * @param modelPath - * path of the model in the bundle - * @param bundleId - * id of the bundle containing the model file - * @return the loaded file or null if some problem occured during loading - */ - protected ExtendedElementTypeSet getExtendedElementTypeSetInBundle(String modelPath, String bundleID) { - Resource resource = extendedTypesResourceSet.createResource(URI.createPlatformPluginURI(bundleID + Path.SEPARATOR + modelPath, true)); - try { - resource.load(null); - } catch (IOException e) { - return null; - } - EObject content = resource.getContents().get(0); - if(content instanceof ExtendedElementTypeSet) { - return (ExtendedElementTypeSet)content; - } - Activator.log.error("Impossible to cast the object into an ExtendedElementTypeSet: " + content, null); - return null; - } - - /** - * Gets the element type for id. May return null if this element is not registered. - * - * @param id - * the type ID - * @return the registered type with this ID, or null if there - * is none. - */ - public IElementType getType(String id) { - // 1. checks if the element already exists - IElementType type = ElementTypeRegistry.getInstance().getType(id); - - // 2. If it exists, returns it as usual - if(type != null) { - return type; - } - - // 3. It does not exists. It could be retrieve in the extended type sets - for(ExtendedElementTypeSet set : extendedTypeSets) { - for(ExtendedElementTypeConfiguration elementTypeConfiguration : set.getElementType()) { - if(id.equals(elementTypeConfiguration.getId())) { - // create and add in the standard registry the required element type from its configuration - @SuppressWarnings("restriction") - ISpecializationType createSpecializationType = ExtendedHintedTypeFactory.getInstance().createSpecializationType(new ExtendedSemanticTypeDescriptor(elementTypeConfiguration)); - - // register it, so it should be accessible next time - ElementTypeRegistry.getInstance().register(createSpecializationType); - return createSpecializationType; - } - } - } - return null; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/IExtendedTypeExtensionPoint.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/IExtendedTypeExtensionPoint.java deleted file mode 100644 index 25928dcd59d..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/IExtendedTypeExtensionPoint.java +++ /dev/null @@ -1,40 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.extendedtypes; - - -/** - * Constants for the extension point - */ -public interface IExtendedTypeExtensionPoint { - - /** ID of the extension point */ - public final static String EXTENSION_POINT_ID = Activator.PLUGIN_ID + ".extendedTypesSetConfiguration"; - - /** attribute: path to the model file in the bundle */ - public static final String PATH = "path"; - - /** attribute: identifier of the contribution */ - public static final String ID = "id"; - - /** attribute: name of the configuration */ - public static final String NAME = "name"; - - /** attribute: icon of the configuration */ - public static final String ICON = "icon"; - - /** attribute: description of the configuration */ - public static final String DESCRIPTION = "description"; - - /** element: element for the configuration element */ - public static final String CONFIGURATION = "configuration"; -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/advices/ExtendedTypesOwnerAdvice.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/advices/ExtendedTypesOwnerAdvice.java deleted file mode 100644 index 1096a4a58a8..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/advices/ExtendedTypesOwnerAdvice.java +++ /dev/null @@ -1,102 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.extendedtypes.advices; - -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; -import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; -import org.eclipse.papyrus.core.queries.configuration.QueryConfiguration; -import org.eclipse.papyrus.core.queries.modisco.QueryUtil; -import org.eclipse.papyrus.extendedtypes.Activator; -import org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration; -import org.eclipse.papyrus.extendedtypes.PostActionConfiguration; -import org.eclipse.papyrus.extendedtypes.providers.ExtendedElementTypeActionService; -import org.eclipse.papyrus.extendedtypes.providers.ProviderNotFoundException; -import org.eclipse.papyrus.extendedtypes.types.IExtendedHintedElementType; - - -/** - * Advice for potential owners of Extended Element Types. This advice will help to the pre/post validation for the creation of child element which is - * describe by the extended type - */ -public class ExtendedTypesOwnerAdvice extends AbstractEditHelperAdvice { - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getBeforeCreateCommand(CreateElementRequest request) { - // test if the type element to be created is an extended one. If yes, test the validation queries. - // if they are valid, return identity command, which does nothing - // else, if not valid, return a not executable command - IElementType typeToCreate = request.getElementType(); - if(typeToCreate instanceof IExtendedHintedElementType) { - ExtendedElementTypeConfiguration configuration = ((IExtendedHintedElementType)typeToCreate).getConfiguration(); - List queryConfigurations = configuration.getPreValidation(); - if(queryConfigurations == null || queryConfigurations.isEmpty()) { - return super.getBeforeCreateCommand(request); - } - - // check all validation rules given by the configuration - for(Object objectToEdit : request.getElementsToEdit()) { - // there are queries to test - for(QueryConfiguration queryConfiguration : queryConfigurations) { - try { - boolean result = QueryUtil.evaluateBooleanQuery((EObject)objectToEdit, queryConfiguration); - if(!result) { - // return an unexecutable command, so the create command will not be executable - return UnexecutableCommand.INSTANCE; - } - } catch (Exception e) { - Activator.log.error(e); - } - } - } - - // Check all pre and post action validation rules. They are given by the provider of the action - CompositeCommand compositeCommand = new CompositeCommand("PreValidationPostAction"); - for(PostActionConfiguration postActionConfiguration : configuration.getPostAction()) { - ICommand command = null; - try { - command = ExtendedElementTypeActionService.getInstance().getPreValidationCommand(request.getElementsToEdit(), postActionConfiguration); - } catch (ProviderNotFoundException e) { - Activator.log.error(e); - } - if(command != null) { - compositeCommand.add(command); - } - } - // get the super command - ICommand superCommand = super.getBeforeCreateCommand(request); - - // if not null, adds it to the result - if(superCommand != null) { - compositeCommand.compose(superCommand); - } - - // if result not null, returns the composite command - if(!compositeCommand.isEmpty()) { - return compositeCommand; - } - return super.getBeforeCreateCommand(request); - } - return super.getBeforeCreateCommand(request); - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/preferences/ExtendedTypesPreferences.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/preferences/ExtendedTypesPreferences.java deleted file mode 100644 index 6ab78615117..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/preferences/ExtendedTypesPreferences.java +++ /dev/null @@ -1,197 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.extendedtypes.preferences; - -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.papyrus.extendedtypes.Activator; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.WorkbenchException; -import org.eclipse.ui.XMLMemento; - - -/** - * Preferences management for extended types - */ -public class ExtendedTypesPreferences { - - /** id for the preference store for extended types redefinitions */ - public final static String EXTENDED_TYPES_REDEFINITIONS = "extendedTypesRedefinitions"; //$NON-NLS-1$ - - /** id for the node: extended types redefinition */ - public final static String EXTENDED_TYPES_REDEFINITION = "extendedTypesRedefinition"; //$NON-NLS-1$ - - /** name of the ID attribute */ - public final static String ID = "id"; //$NON-NLS-1$ - - /** name for the field giving the path to the XML file */ - public final static String PATH = "path"; //$NON-NLS-1$ - - /** - * Returns the preference store used to store extended types preferences. - * - * @return the preference store of the plugin - */ - protected static IPreferenceStore getPreferenceStore() { - return Activator.getDefault().getPreferenceStore(); - } - - /** - * Retrieves the root memento from the plugin preferences for all extended types redefinition - * redefinitions. - * - * @return the root memento if there were existing customizations, a newly created one otherwise (empty one) - */ - protected static XMLMemento getLocalRedefinitions() { - String sValue = getPreferenceStore().getString(EXTENDED_TYPES_REDEFINITIONS); - try { - if(sValue != null && !sValue.equals("")) { //$NON-NLS-1$ - XMLMemento rootMemento = XMLMemento.createReadRoot(new StringReader(sValue)); - return rootMemento; - } else { - return XMLMemento.createWriteRoot(EXTENDED_TYPES_REDEFINITIONS); - } - } catch (WorkbenchException e) { - Activator.log.error("Impossible to read preferences for extended types local redefinitions", e); - } - return null; - } - - /** - * Register a new local redefinition of a extendedTypes. - * - * @param extendedTypesID - * the id of the extendedTypes to register - * @param path - * the path to the configuration of the extendedTypes - * @return the memento that has been registered - */ - public static IMemento registerLocalRedefinition(String extendedTypesID, String path) { - XMLMemento rootMemento = getLocalRedefinitions(); - - // try to find an existing local definition for this extendedTypes - IMemento memento = getExtendedTypesRedefinitionNode(extendedTypesID); - - // if one exists, remove it from the preferences - if(memento != null) { - unregisterLocalRedefinition(extendedTypesID); - } - - // then register the new one - IMemento newMemento = rootMemento.createChild(EXTENDED_TYPES_REDEFINITION); - newMemento.putString(ID, extendedTypesID); - newMemento.putString(PATH, path); - - saveLocalRedefinitions(rootMemento); - - return newMemento; - } - - /** - * Returns the memento associated to the extendedTypes, or null if none exists - * - * @param extendedTypesID - * the identifier of the extendedTypes to find - * @return the memento found or null if no customization exists for this extendedTypes - */ - private static IMemento getExtendedTypesRedefinitionNode(String extendedTypesID) { - XMLMemento rootMemento = getLocalRedefinitions(); - IMemento[] redefinitions = rootMemento.getChildren(EXTENDED_TYPES_REDEFINITION); - for(IMemento redefinitionMemento : redefinitions) { - String extendedTypesNodeID = redefinitionMemento.getString(ID); - // check equals. extendedTypes ID is not null, as checked at the begining of the method. - if(extendedTypesID.equals(extendedTypesNodeID)) { - return redefinitionMemento; - } - } - return null; - } - - /** - * Returns the path for a given extended type local redefinition - * - * @param extendedTypesID - * the unique identifier of the extended type to retrieve - * @return the path to the configuration of the extended types or null if no customization exists for this extended type - * configuration - */ - public static String getExtendedTypesRedefinition(String extendedTypesID) { - if(extendedTypesID == null) { - Activator.log.debug("Trying to find preferences for a null extended type set identifier"); - } - IMemento memento = getExtendedTypesRedefinitionNode(extendedTypesID); - if(memento != null) { - return memento.getString(PATH); - } - return null; - } - - /** - * Unregister a specific local redefinition - * - * @param extendedTypesID - * the identifier of the extended types set to unregister - */ - public static void unregisterLocalRedefinition(String extendedTypesID) { - XMLMemento rootMemento = getLocalRedefinitions(); - // no remove method... - // so, creation of a new root memento, then, duplicate all entries - // except the one to - // delete... - XMLMemento newRootMemento = XMLMemento.createWriteRoot(EXTENDED_TYPES_REDEFINITIONS); - for(IMemento memento : rootMemento.getChildren(EXTENDED_TYPES_REDEFINITION)) { - if(!memento.getString(ID).equals(extendedTypesID)) { - newRootMemento.putMemento(memento); - } - } - // save new Memento - saveLocalRedefinitions(newRootMemento); - - } - - /** - * saves the given root memento with the given key in the preference area - * - * @param xmlMemento - * the memento to save - * @param key - * the key for the preference store - */ - private static void saveMemento(XMLMemento xmlMemento, String key) { - // save memento - StringWriter writer = new StringWriter(); - try { - xmlMemento.save(writer); - - if(getPreferenceStore() != null) { - getPreferenceStore().setValue(key, writer.toString()); - } - } catch (IOException e) { - Activator.log.error("input/ouput exception", e); - } - } - - /** - * Saves the set of local redefinitions into the preference store - * - * @param rootMemento - * the memento to save - */ - public static void saveLocalRedefinitions(XMLMemento rootMemento) { - saveMemento(rootMemento, EXTENDED_TYPES_REDEFINITIONS); - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/ExtendedElementTypeActionService.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/ExtendedElementTypeActionService.java deleted file mode 100644 index 41962878914..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/ExtendedElementTypeActionService.java +++ /dev/null @@ -1,198 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.extendedtypes.providers; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.common.core.service.ExecutionStrategy; -import org.eclipse.gmf.runtime.common.core.service.IOperation; -import org.eclipse.gmf.runtime.common.core.service.IProvider; -import org.eclipse.gmf.runtime.common.core.service.Service; -import org.eclipse.gmf.runtime.common.ui.services.util.ActivityFilterProviderDescriptor; -import org.eclipse.papyrus.extendedtypes.ActionConfiguration; -import org.eclipse.papyrus.extendedtypes.Activator; - - -/** - * Service to retrieve the provider giving the command for a specific {@link ActionConfiguration} - */ -public class ExtendedElementTypeActionService extends Service { - - /** singleton instance of this service */ - protected final static ExtendedElementTypeActionService instance = new ExtendedElementTypeActionService(); - - /** - * initialize the service - */ - static { - instance.configureProviders(Activator.PLUGIN_ID, "extendedElementTypeActionProvider"); //$NON-NLS-1$ - } - - /** - * Default constructor. - */ - protected ExtendedElementTypeActionService() { - - } - - /** - * Returns the singleton instance of this service - * - * @return the singleton instance of this service - */ - synchronized public static ExtendedElementTypeActionService getInstance() { - return instance; - } - - /** - * @see org.eclipse.gmf.runtime.common.core.service.Service#newProviderDescriptor(org.eclipse.core.runtime.IConfigurationElement) - */ - protected Service.ProviderDescriptor newProviderDescriptor(IConfigurationElement element) { - return new ProviderDescriptor(element); - } - - /** - * Returns all providers in the service - * - * @return the list of providers found or an empty list. - */ - public List getProviders() { - List providers = new ArrayList(); - execute(ExecutionStrategy.REVERSE, new GetAllExtendedElementTypeActionProvidersOperation(providers)); - return providers; - } - - /** - * Returns the provider with the given identifier - * - * @param actionConfiguration - * the actionConfiguration for the provider to retrieve - * @return the provider found or null. - */ - public IExtendedElementTypeActionProvider getProvider(ActionConfiguration actionConfiguration) { - @SuppressWarnings({ "unchecked", "rawtypes" }) - List providers = (List)execute(ExecutionStrategy.REVERSE, new GetExtendedElementTypeActionProviderOperation(actionConfiguration)); - Iterator it = providers.iterator(); - while(it.hasNext()) { - IExtendedElementTypeActionProvider aspectActionProvider = (IExtendedElementTypeActionProvider)it.next(); - if(aspectActionProvider != null) { - return aspectActionProvider; - } - } - return null; // backward compatibility - } - - /** - * Returns the command for the given {@link ActionConfiguration}. - * - * @param elementsToEdit - * list of elements to edit - * - * @param configuration - * the configuration of the action - * @return the {@link ICommand} configured by the parameter or null. - * @throws ProviderNotFoundException - * exception thrown when the provider was not found for this configuration - */ - public ICommand getICommand(List elementsToEdit, ActionConfiguration configuration) throws ProviderNotFoundException { - IExtendedElementTypeActionProvider provider = getProvider(configuration); - if(provider != null) { - return provider.getICommand(elementsToEdit, configuration); - } - throw new ProviderNotFoundException(configuration); - } - - /** - * Returns the command for the given {@link ActionConfiguration}. - * - * @param elementsToEdit - * list of elements to edit - * - * @param configuration - * the configuration of the action - * @return the {@link ICommand} configured by the parameter or null. - * @throws ProviderNotFoundException - * exception thrown when the provider was not found for this configuration - */ - public ICommand getPreValidationCommand(List elementsToEdit, ActionConfiguration configuration) throws ProviderNotFoundException { - IExtendedElementTypeActionProvider provider = getProvider(configuration); - if(provider != null) { - return provider.getBeforeCreateValidationCommand(elementsToEdit, configuration); - } - throw new ProviderNotFoundException(configuration); - } - - /** - * A descriptor for aspect tool providers defined by a configuration element. - */ - protected static class ProviderDescriptor extends ActivityFilterProviderDescriptor { - - /** the provider configuration parsed from XML */ - protected ExtentedElementTypeActionProviderConfiguration providerConfiguration; - - /** - * Constructs a ISemanticProvider descriptor for - * the specified configuration element. - * - * @param element - * The configuration element describing the provider. - */ - public ProviderDescriptor(IConfigurationElement element) { - super(element); - this.providerConfiguration = ExtentedElementTypeActionProviderConfiguration.parse(element); - Assert.isNotNull(providerConfiguration); - } - - /** - * @see org.eclipse.gmf.runtime.common.core.service.IProvider#provides(org.eclipse.gmf.runtime.common.core.service.IOperation) - */ - public boolean provides(IOperation operation) { - if(!super.provides(operation)) { - return false; - } - if(operation instanceof GetAllExtendedElementTypeActionProvidersOperation) { - return true; - } - if(operation instanceof GetExtendedElementTypeActionProviderOperation) { - String providerConfigurationClassName = providerConfiguration.getConfigurationClassName(); - if(providerConfigurationClassName == null) { - Activator.log.error("Error during the parsing of the action configuration extension point", null); - return false; - } - String configurationClassName = ((GetExtendedElementTypeActionProviderOperation)operation).getActionConfiguration().eClass().getInstanceClassName(); - return providerConfigurationClassName.equals(configurationClassName); - } - return false; - } - - /** - * @see org.eclipse.gmf.runtime.common.core.service.Service.ProviderDescriptor#getProvider() - */ - public IProvider getProvider() { - if(provider == null) { - IProvider newProvider = super.getProvider(); - if(provider instanceof IExtendedElementTypeActionProvider) { - IExtendedElementTypeActionProvider defaultProvider = (IExtendedElementTypeActionProvider)newProvider; - defaultProvider.setConfiguration(getElement()); - } - return newProvider; - } - return super.getProvider(); - } - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/ExtentedElementTypeActionProviderConfiguration.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/ExtentedElementTypeActionProviderConfiguration.java deleted file mode 100644 index 441e715d477..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/ExtentedElementTypeActionProviderConfiguration.java +++ /dev/null @@ -1,82 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.extendedtypes.providers; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.gmf.runtime.common.core.service.AbstractProviderConfiguration; - -/** - * Provider configuration for the aspect tool factory extension point. - */ -public class ExtentedElementTypeActionProviderConfiguration extends AbstractProviderConfiguration { - - /** field for provider class name */ - protected static final String CLASS = "class"; - - /** field for configuration class name */ - private static final String CONFIGURATION_CLASS = "configurationClass"; - - /** class name of the provider */ - protected final String className; - - /** class name of the configuration */ - private final String configurationClassName; - - /** - * Creates and builds a new provider contribution descriptor by parsing its configuration element. - * - * @param configElement - * A provider XML configuration element - * @return A provider XML contribution descriptor - */ - public static ExtentedElementTypeActionProviderConfiguration parse(IConfigurationElement configElement) { - Assert.isNotNull(configElement, "null provider configuration element"); //$NON-NLS-1$ - return new ExtentedElementTypeActionProviderConfiguration(configElement); - } - - /** - * Creates a new ProviderContributionDescriptor instance - * by parsing its configuration element. - * - * @param configElement - * The provider XML configuration element - */ - protected ExtentedElementTypeActionProviderConfiguration(IConfigurationElement configElement) { - // retrieve only ID, to test if the factory is the right one before creating whole element - className = configElement.getAttribute(CLASS); - Assert.isNotNull(className, "impossible to get the class name for the provider"); - - configurationClassName = configElement.getAttribute(CONFIGURATION_CLASS); - Assert.isNotNull(className, "impossible to get the class name for the provider"); - } - - - /** - * Returns the class name of the provider configured by this configuration - * - * @return the id of the factory - */ - public String getClassName() { - return className; - } - - /** - * Name of the configuration class - * - * @return the configuration Class Name - */ - public String getConfigurationClassName() { - return configurationClassName; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/GetAllExtendedElementTypeActionProvidersOperation.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/GetAllExtendedElementTypeActionProvidersOperation.java deleted file mode 100644 index 311ad2211e1..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/GetAllExtendedElementTypeActionProvidersOperation.java +++ /dev/null @@ -1,48 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.extendedtypes.providers; - -import java.util.List; - -import org.eclipse.gmf.runtime.common.core.service.IOperation; -import org.eclipse.gmf.runtime.common.core.service.IProvider; - - -/** - * Operation that returns all providers for the {@link ExtendedElementTypeActionService}. - */ -public class GetAllExtendedElementTypeActionProvidersOperation implements IOperation { - - /** list of providers to fill */ - private final List providers; - - /** - * Creates a new GetAllExtendedElementTypeActionProvidersOperation. - * - * @param providers - * the list of providers to fill - */ - public GetAllExtendedElementTypeActionProvidersOperation(List providers) { - this.providers = providers; - } - - /** - * {@inheritDoc} - */ - public Object execute(IProvider provider) { - if(provider instanceof IExtendedElementTypeActionProvider) { - providers.add((IExtendedElementTypeActionProvider)provider); - } - return providers; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/GetExtendedElementTypeActionProviderOperation.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/GetExtendedElementTypeActionProviderOperation.java deleted file mode 100644 index 972ff5817c2..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/GetExtendedElementTypeActionProviderOperation.java +++ /dev/null @@ -1,53 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.extendedtypes.providers; - -import org.eclipse.gmf.runtime.common.core.service.IOperation; -import org.eclipse.gmf.runtime.common.core.service.IProvider; -import org.eclipse.papyrus.extendedtypes.ActionConfiguration; - - -/** - * Operation that returns the first provider with given id - */ -public class GetExtendedElementTypeActionProviderOperation implements IOperation { - - /** action configuration for the provider to find */ - private final ActionConfiguration actionConfiguration; - - /** - * Creates a new {@link GetExtendedElementTypeActionProviderOperation}. - * - * @param actionConfiguration - * action configuration for the provider to find - */ - public GetExtendedElementTypeActionProviderOperation(ActionConfiguration actionConfiguration) { - this.actionConfiguration = actionConfiguration; - } - - /** - * {@inheritDoc} - */ - public Object execute(IProvider provider) { - return provider; - } - - /** - * Returns the action configuration for this operation - * - * @return the action configuration for this operation - */ - public ActionConfiguration getActionConfiguration() { - return actionConfiguration; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/IExtendedElementTypeActionProvider.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/IExtendedElementTypeActionProvider.java deleted file mode 100644 index 01cc38df3f0..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/IExtendedElementTypeActionProvider.java +++ /dev/null @@ -1,61 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.extendedtypes.providers; - -import java.util.List; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.common.core.service.IProvider; -import org.eclipse.papyrus.extendedtypes.ActionConfiguration; - - -/** - * Provider for extended element types action - */ -public interface IExtendedElementTypeActionProvider extends IProvider { - - /** - * Returns the command to execute for the given configuration - * - * @param elementsToEdit - * list of elements to edit - * - * @param configuration - * the configuration for the command - * - * @return the command to execute for the given configuration - */ - public ICommand getICommand(List elementsToEdit, ActionConfiguration configuration); - - /** - * Returns the command to execute for the given configuration to check if it will be executable - * - * @param elementsToEdit - * list of elements to edit - * - * @param configuration - * the configuration for the command - * - * @return the command to execute for the given configuration. should do nothing on the model (either null or identity command), only return an - * Unexecutable command if creation is not allowed - */ - public ICommand getBeforeCreateValidationCommand(List elementsToEdit, ActionConfiguration configuration); - - /** - * Sets the configuration for this provider, given the configuration element - * - * @param element - * the element that configures this provider - */ - public void setConfiguration(IConfigurationElement element); -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/ProviderNotFoundException.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/ProviderNotFoundException.java deleted file mode 100644 index c02c70f5725..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/providers/ProviderNotFoundException.java +++ /dev/null @@ -1,36 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.extendedtypes.providers; - -import org.eclipse.papyrus.extendedtypes.ActionConfiguration; - - -/** - * Exception thrown when a provider was not found - */ -public class ProviderNotFoundException extends Exception { - - /** serial UID */ - private static final long serialVersionUID = 8919294410894098831L; - - /** - * Constructor. - * - * @param configuration - * the configuration for which a provider was searched - * - */ - public ProviderNotFoundException(ActionConfiguration configuration) { - super("Provider not found for configuration " + ((configuration != null) ? configuration.getLabel() : "null") + "[" + ((configuration != null) ? configuration.getId() : "null") + "]"); - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/types/ExtendedHintedTypeFactory.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/types/ExtendedHintedTypeFactory.java deleted file mode 100644 index 905e84a3377..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/types/ExtendedHintedTypeFactory.java +++ /dev/null @@ -1,125 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.extendedtypes.types; - -import org.eclipse.gmf.runtime.emf.type.core.AbstractElementTypeFactory; -import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; -import org.eclipse.gmf.runtime.emf.type.core.ISpecializationTypeDescriptor; -import org.eclipse.gmf.runtime.emf.type.core.SpecializationType; -import org.eclipse.gmf.runtime.emf.type.core.internal.impl.HintedTypeFactory; -import org.eclipse.papyrus.extendedtypes.Activator; -import org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration; -import org.eclipse.papyrus.extendedtypes.ExtendedSemanticTypeDescriptor; - - -/** - * Factory for ExtendedHintedType elements - */ -public class ExtendedHintedTypeFactory extends AbstractElementTypeFactory { - - /** - * The hinted type kind. This string is specified in the XML 'kind' - * attribute of any element type that is a hinted type. - */ - public static final String HINTED_TYPE_KIND = "org.eclipse.gmf.runtime.emf.core.internal.util.IHintedType"; //$NON-NLS-1$ - - /** - * The semantic hint parameter name. - */ - public static final String SEMANTIC_HINT_PARAM_NAME = "semanticHint"; //$NON-NLS-1$ - - /** singleton instance of this factory */ - private static ExtendedHintedTypeFactory instance; - - /** - * Returns the singleton instance of this factory. - * - * @return the singleton instance of this factory. - */ - public synchronized static ExtendedHintedTypeFactory getInstance() { - if(instance == null) { - instance = new ExtendedHintedTypeFactory(); - } - return instance; - } - - /** - * Private Constructor. - * - */ - private ExtendedHintedTypeFactory() { - - } - - /** - * The extended hinted specialization type class. - */ - private static final class ExtendedHintedSpecializationType extends SpecializationType implements IExtendedHintedElementType { - - /** The semantic hint */ - private final String semanticHint; - - /** element type configuration */ - private final ExtendedElementTypeConfiguration configuration; - - /** - * Constructs a new hinted type. - * - * @param descriptor - * the specialization type descriptor - * @param semanticHint - * the semantic hint - */ - public ExtendedHintedSpecializationType(ISpecializationTypeDescriptor descriptor, String semanticHint, ExtendedElementTypeConfiguration configuration) { - super(descriptor); - this.semanticHint = semanticHint; - this.configuration = configuration; - } - - /** - * Gets the semantic hint. - */ - public String getSemanticHint() { - return semanticHint; - } - - /** - * {@inheritDoc} - */ - public ExtendedElementTypeConfiguration getConfiguration() { - return configuration; - } - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("restriction") - @Override - public ISpecializationType createSpecializationType(ISpecializationTypeDescriptor descriptor) { - - String semanticHint = descriptor.getParamValue(SEMANTIC_HINT_PARAM_NAME); - - if(descriptor instanceof ExtendedSemanticTypeDescriptor) { - ExtendedElementTypeConfiguration configuration = ((ExtendedSemanticTypeDescriptor)descriptor).getConfiguration(); - return new ExtendedHintedSpecializationType(descriptor, semanticHint, configuration); - } - - // used default factory. Should never happen - Activator.log.warn("The Extended type factory should never use HintedTypeFactory from GMF"); - return new HintedTypeFactory().createSpecializationType(descriptor); - } - - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/types/IExtendedHintedElementType.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/types/IExtendedHintedElementType.java deleted file mode 100644 index 2d7e884dd34..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/types/IExtendedHintedElementType.java +++ /dev/null @@ -1,31 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.extendedtypes.types; - -import org.eclipse.gmf.runtime.emf.type.core.IHintedType; -import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; -import org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration; - - -/** - * Element Type that contains a configuration for extensions (Pre/Post actions and validation) - */ -public interface IExtendedHintedElementType extends ISpecializationType, IHintedType { - - /** - * Returns the Element Type configuration associated to the element type. - * @return the Element Type configuration associated to the element type. - */ - public ExtendedElementTypeConfiguration getConfiguration(); -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/util/ElementTypeUtils.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/util/ElementTypeUtils.java deleted file mode 100644 index 9cd9f1d0203..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/extendedtypes/util/ElementTypeUtils.java +++ /dev/null @@ -1,156 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.extendedtypes.util; - -import java.util.List; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.IMetamodelType; -import org.eclipse.papyrus.core.queries.configuration.QueryConfiguration; -import org.eclipse.papyrus.extendedtypes.ExtendedElementTypeConfiguration; -import org.eclipse.papyrus.extendedtypes.PostActionConfiguration; -import org.eclipse.papyrus.extendedtypes.PreActionConfiguration; -import org.eclipse.papyrus.extendedtypes.types.IExtendedHintedElementType; - - -/** - * Utility class for {@link IElementType}. - */ -public class ElementTypeUtils { - - /** - * Tests if two elements types are equivalent - * - * @param referenceType - * the reference type for the comparison - * @param typeToCompare - * the type that is compared to the reference one - * @return true if both types are equivalent semantically - */ - public static boolean isSemanticallyEquivalent(IElementType referenceType, IElementType typeToCompare) { - boolean isEquivalent = true; - - // first : easy test... - if(typeToCompare.equals(referenceType)) { - return true; - } - - // 2. test the kind of element. - if(referenceType instanceof IMetamodelType) { - if(!(typeToCompare instanceof IMetamodelType)) { - return false; - } else { - EClass referenceEclass = ((IMetamodelType)referenceType).getEClass(); - EClass eclassToCompare = ((IMetamodelType)typeToCompare).getEClass(); - - isEquivalent = isEquivalent && referenceEclass.equals(eclassToCompare); - } - } else { - if((typeToCompare instanceof IMetamodelType)) { - return false; - } - } - - // metaclasses are equivalent. check for extended types now... - if(referenceType instanceof IExtendedHintedElementType) { - if(typeToCompare instanceof IExtendedHintedElementType) { - isEquivalent = isEquivalent && isSemanticallyEquivalent((IExtendedHintedElementType)referenceType, (IExtendedHintedElementType)typeToCompare); - } - } - - return isEquivalent; - } - - /** - * Tests if two elements types are equivalent (configuration) - * - * @param referenceType - * the reference type for the comparison - * @param typeToCompare - * the type that is compared to the reference one - * @return true if both types are equivalent semantically - */ - public static boolean isSemanticallyEquivalent(IExtendedHintedElementType referenceType, IExtendedHintedElementType typeToCompare) { - - boolean isEquivalent = true; - // check all pre/post action and validation - ExtendedElementTypeConfiguration referenceConfiguration = referenceType.getConfiguration(); - ExtendedElementTypeConfiguration configurationToCompare = typeToCompare.getConfiguration(); - - List referencePrevalidation = referenceConfiguration.getPreValidation(); - List prevalidationToCompare = configurationToCompare.getPreValidation(); - if(referencePrevalidation != null) { - isEquivalent = isEquivalent && isEquivalent(referencePrevalidation, prevalidationToCompare); - } else if(prevalidationToCompare != null) { - isEquivalent = false; - } - - List referencePreaction = referenceConfiguration.getPreAction(); - List preactionToCompare = configurationToCompare.getPreAction(); - if(referencePreaction != null) { - isEquivalent = isEquivalent && isEquivalent(referencePreaction, preactionToCompare); - } else if(preactionToCompare != null) { - isEquivalent = false; - } - - List referencePostaction = referenceConfiguration.getPostAction(); - List postactionToCompare = configurationToCompare.getPostAction(); - if(referencePostaction != null) { - isEquivalent = isEquivalent && isEquivalent(referencePostaction, postactionToCompare); - } else if(postactionToCompare != null) { - isEquivalent = false; - } - - return isEquivalent; - } - - public static boolean isEquivalent(List referenceList, List listToCompare) { - boolean isEquivalent = true; - if(referenceList == null) { - // only one is null : false - if(listToCompare != null) { - return false; - } else { - // both are null: true - return true; - } - } else { - // only one is null: false - if(listToCompare == null) { - return false; - } - } - - // check emptyness. If both empty : equivalent - if(referenceList.isEmpty() && listToCompare.isEmpty()) { - return true; - } - - // check size. If different, false - if(referenceList.size() != listToCompare.size()) { - return false; - } - - for(int i = 0; i < referenceList.size(); i++) { - EObject reference = referenceList.get(i); - EObject compared = listToCompare.get(i); - isEquivalent = isEquivalent && EcoreUtil.equals(reference, compared); - } - - return isEquivalent; - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/Activator.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/Activator.java new file mode 100644 index 00000000000..6a325c5357d --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/Activator.java @@ -0,0 +1,58 @@ +package org.eclipse.papyrus.infra.extendedtypes; + +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 + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.extendedtypes"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** Logging 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(this); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + log = null; + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedEditHelperAdvice.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedEditHelperAdvice.java new file mode 100644 index 00000000000..f2745d790c4 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedEditHelperAdvice.java @@ -0,0 +1,108 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.extendedtypes; + +import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; +import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.providers.ExtendedElementTypeActionService; +import org.eclipse.papyrus.infra.extendedtypes.providers.ProviderNotFoundException; +import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType; + +/** + * Edit helper Advice for extended element types. This allows modification of the configure request executed right after the creation of the element + */ +public class ExtendedEditHelperAdvice extends AbstractEditHelperAdvice { + + /** + * Constructor. + * + */ + public ExtendedEditHelperAdvice() { + } + + /** + * {@inheritDoc} + */ + @Override + public boolean approveRequest(IEditCommandRequest request) { + return super.approveRequest(request); + } + + /** + * {@inheritDoc} + */ + @Override + protected ICommand getBeforeEditContextCommand(GetEditContextRequest request) { + return super.getBeforeEditContextCommand(request); + } + + /** + * {@inheritDoc} + */ + @Override + protected ICommand getBeforeCreateCommand(CreateElementRequest request) { + return super.getBeforeCreateCommand(request); + } + + /** + * {@inheritDoc} + */ + @Override + protected ICommand getAfterConfigureCommand(ConfigureRequest request) { + // for the list of post actions, returns a list of commands. + // there should be a factory that delivers commands from the model + + CompositeCommand compositeCommand = new CompositeCommand("AfterConfigureCommand"); + IElementType type = request.getTypeToConfigure(); + if(type instanceof IExtendedHintedElementType) { + IExtendedHintedElementType extendedHintedElementType = (IExtendedHintedElementType)type; + ExtendedElementTypeConfiguration configuration = extendedHintedElementType.getConfiguration(); + for(PostActionConfiguration postActionConfiguration : configuration.getPostAction()) { + ICommand command = null; + try { + command = ExtendedElementTypeActionService.getInstance().getICommand(request.getElementsToEdit(), postActionConfiguration); + } catch (ProviderNotFoundException e) { + Activator.log.error(e); + } + if(command != null) { + compositeCommand.add(command); + } + } + + // return the composite command only if it is not empty + if(!compositeCommand.isEmpty()) { + return compositeCommand; + } + } + + + // post-action. Here, this is null. + return super.getAfterConfigureCommand(request); + } + + /** + * {@inheritDoc} + */ + @Override + protected ICommand getAfterCreateCommand(CreateElementRequest request) { + return super.getAfterCreateCommand(request); + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedSemanticTypeDescriptor.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedSemanticTypeDescriptor.java new file mode 100644 index 00000000000..7338284fa7f --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedSemanticTypeDescriptor.java @@ -0,0 +1,136 @@ +package org.eclipse.papyrus.infra.extendedtypes; + +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; +import org.eclipse.gmf.runtime.emf.type.core.IContainerDescriptor; +import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.ISpecializationTypeDescriptor; +import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.IconEntry; +import org.eclipse.papyrus.infra.extendedtypes.types.ExtendedHintedTypeFactory; +import org.osgi.framework.Bundle; + + +/** + * new descriptor implementation for on-the-fly added descriptor + */ +public class ExtendedSemanticTypeDescriptor implements ISpecializationTypeDescriptor { + + /** constant for specific semantic hint */ + public static final String EXTENDED_ELEMENTS = "ExtendedElements"; + + /** configuration of this descriptor */ + private final ExtendedElementTypeConfiguration configuration; + + /** cache of the specialized types */ + private List specializedTypes = null; + + /** + * Constructor. + * + * @param configuration + * the configuration of this descriptor + */ + public ExtendedSemanticTypeDescriptor(ExtendedElementTypeConfiguration configuration) { + this.configuration = configuration; + } + + /** + * Returns the configuration of the element type + * + * @return the configuration of the element type + */ + public ExtendedElementTypeConfiguration getConfiguration() { + return configuration; + } + + /** + * {@inheritDoc} + */ + public String getId() { + return configuration.getId(); + } + + /** + * {@inheritDoc} + */ + public URL getIconURL() { + IconEntry entry = configuration.getIconEntry(); + Bundle bundle = Platform.getBundle(entry.getBundleId()); + if(bundle == null) { + return null; + } + URL result = bundle.getEntry(entry.getIconPath()); + return result; + } + + /** + * {@inheritDoc} + */ + public String getName() { + return configuration.getName(); + } + + /** + * {@inheritDoc} + */ + public String getKindName() { + return configuration.getKindName(); + } + + /** + * {@inheritDoc} + */ + public String getParamValue(String paramName) { + if(ExtendedHintedTypeFactory.SEMANTIC_HINT_PARAM_NAME.equals(paramName)) { + return configuration.getHint(); + } + return EXTENDED_ELEMENTS; + } + + /** + * {@inheritDoc} + */ + public IContainerDescriptor getContainerDescriptor() { + return null; + } + + /** + * {@inheritDoc} + */ + public IElementType[] getSpecializedTypes() { + if(specializedTypes == null) { + specializedTypes = new ArrayList(); + for(String specializedTypeId : configuration.getSpecializedTypesID()) { + IElementType type = ElementTypeRegistry.getInstance().getType(specializedTypeId); + if(type != null) { + specializedTypes.add(type); + } else { + Activator.log.error("Impossible to find the type " + specializedTypeId, null); + } + } + } + return specializedTypes.toArray(new IElementType[specializedTypes.size()]); + } + + /** + * {@inheritDoc} + */ + public IElementMatcher getMatcher() { + return null; + } + + /** + * {@inheritDoc} + */ + public IEditHelperAdvice getEditHelperAdvice() { + return new ExtendedEditHelperAdvice(); + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedTypesRegistry.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedTypesRegistry.java new file mode 100644 index 00000000000..ed59661baf1 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/ExtendedTypesRegistry.java @@ -0,0 +1,272 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.extendedtypes; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +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.emf.type.core.ElementTypeRegistry; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeSet; +import org.eclipse.papyrus.infra.extendedtypes.preferences.ExtendedTypesPreferences; +import org.eclipse.papyrus.infra.extendedtypes.types.ExtendedHintedTypeFactory; +import org.osgi.framework.Bundle; + + +/** + * Registry for all extended types. + */ +public class ExtendedTypesRegistry { + + /** private singleton instance */ + private static ExtendedTypesRegistry registry; + + /** list of retrieved extended type sets */ + protected List extendedTypeSets = null; + + /** unique resource set to load all extended types models */ + protected ResourceSet extendedTypesResourceSet = null; + + /** + * Private constructor. + */ + private ExtendedTypesRegistry() { + + } + + /** + * returns the singleton instance of this registry + * + * @return the singleton instance of this registry + */ + public static synchronized ExtendedTypesRegistry getInstance() { + if(registry == null) { + registry = new ExtendedTypesRegistry(); + registry.init(); + } + return registry; + } + + /** + * Inits the registry. + */ + protected void init() { + // 0. Reset the values + extendedTypesResourceSet = null; + extendedTypeSets = null; + + // 1. create the resource set + extendedTypesResourceSet = createResourceSet(); + // 2. create the list only when registry is acceded for the first time + extendedTypeSets = loadExtendedTypeSets(); + } + + /** + * Retrieves and loads extended type sets registered in the platform. It should also load configuration sets from the workspace. + */ + protected List loadExtendedTypeSets() { + List extendedElementTypeSets = new ArrayList(); + + // 1. retrieve from the workspace + // TODO implement retrieve from workspace + + // 2. retrieve from the platform. + List registeredSets = loadExtendedTypeSetsFromPlatform(); + if(registeredSets != null && !registeredSets.isEmpty()) { + extendedElementTypeSets.addAll(registeredSets); + } + + return extendedElementTypeSets; + } + + /** + * Creates the resource set that contains all models for extended types + * + * @return the resource set newly created. + */ + protected ResourceSet createResourceSet() { + ResourceSet set = new ResourceSetImpl(); + return set; + } + + /** + * Loads the extensions in the platform + * + * @return the list of extension registered in the platform + */ + protected List loadExtendedTypeSetsFromPlatform() { + List platformElementTypeSets = new ArrayList(); + + IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(IExtendedTypeExtensionPoint.EXTENSION_POINT_ID); + // for each element, parses and retrieve the model file. then loads it and returns the root element + for(IConfigurationElement element : elements) { + String modelPath = element.getAttribute(IExtendedTypeExtensionPoint.PATH); + String extendedTypeSetId = element.getAttribute(IExtendedTypeExtensionPoint.ID); + String contributorID = element.getContributor().getName(); + if(Platform.inDebugMode()) { + Activator.log.debug("[Reading extension point]"); + Activator.log.debug("- Path to the model: " + modelPath); + Activator.log.debug("- id of the container bundle: " + contributorID); + Activator.log.debug("- id of the extended type set: " + extendedTypeSetId); + } + ExtendedElementTypeSet set = getExtendedElementTypeSet(extendedTypeSetId, modelPath, contributorID); + if(set != null) { + platformElementTypeSets.add(set); + } + } + + return platformElementTypeSets; + } + + /** + *

+ * Loads the resource containing the extended element type set model. + *

+ *

+ * It looks the model file in the fragments first, then in the plugin itself.
+ * If this is already a fragment, it should look in the fragment only + *

+ * + * @param extendedTypesID + * id of the extended type set to load + * @param modelPath + * path of the model in the bundle + * @param bundleId + * id of the bundle containing the model file + * @return the loaded file or null if some problem occured during loading + */ + protected ExtendedElementTypeSet getExtendedElementTypeSet(String extendedTypesID, String modelPath, String bundleId) { + // 1. look in preferences. + String filePath = ExtendedTypesPreferences.getExtendedTypesRedefinition(extendedTypesID); + if(filePath != null) { + getExtendedElementTypeSetInPluginStateArea(extendedTypesID); + } + + // 2. no local redefinition. Load extended type set from plugin definition + Bundle bundle = Platform.getBundle(bundleId); + if(Platform.isFragment(bundle)) { + return getExtendedElementTypeSetInBundle(modelPath, bundleId); + } else { // this is a plugin. Search in sub fragments, then in the plugin + Bundle[] fragments = Platform.getFragments(bundle); + // no fragment, so the file should be in the plugin itself + if(fragments == null) { + return getExtendedElementTypeSetInBundle(modelPath, bundleId); + } else { + for(Bundle fragment : fragments) { + ExtendedElementTypeSet extendedElementTypeSet = getExtendedElementTypeSetInBundle(modelPath, fragment.getSymbolicName()); + if(extendedElementTypeSet != null) { + return extendedElementTypeSet; + } + } + // not found in fragments. Look in the plugin itself + return getExtendedElementTypeSetInBundle(modelPath, bundleId); + } + } + } + + /** + * Retrieves the contribution in the plugin area + * + * @param path + * the path of the element type set to load in the plugin area + */ + protected ExtendedElementTypeSet getExtendedElementTypeSetInPluginStateArea(String path) { + // read in preferences area + IPath resourcePath = Activator.getDefault().getStateLocation().append(path); + URI uri = URI.createFileURI(resourcePath.toOSString()); + if(uri != null && uri.isFile()) { + Resource resource = extendedTypesResourceSet.createResource(uri); + try { + resource.load(null); + } catch (IOException e) { + return null; + } + EObject content = resource.getContents().get(0); + if(content instanceof ExtendedElementTypeSet) { + return (ExtendedElementTypeSet)content; + } + Activator.log.error("Impossible to cast the object into an ExtendedElementTypeSet: " + content, null); + return null; + } + return null; + } + + /** + * + * @param modelPath + * path of the model in the bundle + * @param bundleId + * id of the bundle containing the model file + * @return the loaded file or null if some problem occured during loading + */ + protected ExtendedElementTypeSet getExtendedElementTypeSetInBundle(String modelPath, String bundleID) { + Resource resource = extendedTypesResourceSet.createResource(URI.createPlatformPluginURI(bundleID + Path.SEPARATOR + modelPath, true)); + try { + resource.load(null); + } catch (IOException e) { + return null; + } + EObject content = resource.getContents().get(0); + if(content instanceof ExtendedElementTypeSet) { + return (ExtendedElementTypeSet)content; + } + Activator.log.error("Impossible to cast the object into an ExtendedElementTypeSet: " + content, null); + return null; + } + + /** + * Gets the element type for id. May return null if this element is not registered. + * + * @param id + * the type ID + * @return the registered type with this ID, or null if there + * is none. + */ + public IElementType getType(String id) { + // 1. checks if the element already exists + IElementType type = ElementTypeRegistry.getInstance().getType(id); + + // 2. If it exists, returns it as usual + if(type != null) { + return type; + } + + // 3. It does not exists. It could be retrieve in the extended type sets + for(ExtendedElementTypeSet set : extendedTypeSets) { + for(ExtendedElementTypeConfiguration elementTypeConfiguration : set.getElementType()) { + if(id.equals(elementTypeConfiguration.getId())) { + // create and add in the standard registry the required element type from its configuration + @SuppressWarnings("restriction") + ISpecializationType createSpecializationType = ExtendedHintedTypeFactory.getInstance().createSpecializationType(new ExtendedSemanticTypeDescriptor(elementTypeConfiguration)); + + // register it, so it should be accessible next time + ElementTypeRegistry.getInstance().register(createSpecializationType); + return createSpecializationType; + } + } + } + return null; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/IExtendedTypeExtensionPoint.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/IExtendedTypeExtensionPoint.java new file mode 100644 index 00000000000..515f92c97c2 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/IExtendedTypeExtensionPoint.java @@ -0,0 +1,40 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.extendedtypes; + + +/** + * Constants for the extension point + */ +public interface IExtendedTypeExtensionPoint { + + /** ID of the extension point */ + public final static String EXTENSION_POINT_ID = Activator.PLUGIN_ID + ".extendedTypesSetConfiguration"; + + /** attribute: path to the model file in the bundle */ + public static final String PATH = "path"; + + /** attribute: identifier of the contribution */ + public static final String ID = "id"; + + /** attribute: name of the configuration */ + public static final String NAME = "name"; + + /** attribute: icon of the configuration */ + public static final String ICON = "icon"; + + /** attribute: description of the configuration */ + public static final String DESCRIPTION = "description"; + + /** element: element for the configuration element */ + public static final String CONFIGURATION = "configuration"; +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/advices/ExtendedTypesOwnerAdvice.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/advices/ExtendedTypesOwnerAdvice.java new file mode 100644 index 00000000000..a55bfc2bb41 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/advices/ExtendedTypesOwnerAdvice.java @@ -0,0 +1,102 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.extendedtypes.advices; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; +import org.eclipse.papyrus.infra.extendedtypes.Activator; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.providers.ExtendedElementTypeActionService; +import org.eclipse.papyrus.infra.extendedtypes.providers.ProviderNotFoundException; +import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType; +import org.eclipse.papyrus.infra.queries.core.configuration.QueryConfiguration; +import org.eclipse.papyrus.infra.queries.core.modisco.QueryUtil; + + +/** + * Advice for potential owners of Extended Element Types. This advice will help to the pre/post validation for the creation of child element which is + * describe by the extended type + */ +public class ExtendedTypesOwnerAdvice extends AbstractEditHelperAdvice { + + /** + * {@inheritDoc} + */ + @Override + protected ICommand getBeforeCreateCommand(CreateElementRequest request) { + // test if the type element to be created is an extended one. If yes, test the validation queries. + // if they are valid, return identity command, which does nothing + // else, if not valid, return a not executable command + IElementType typeToCreate = request.getElementType(); + if(typeToCreate instanceof IExtendedHintedElementType) { + ExtendedElementTypeConfiguration configuration = ((IExtendedHintedElementType)typeToCreate).getConfiguration(); + List queryConfigurations = configuration.getPreValidation(); + if(queryConfigurations == null || queryConfigurations.isEmpty()) { + return super.getBeforeCreateCommand(request); + } + + // check all validation rules given by the configuration + for(Object objectToEdit : request.getElementsToEdit()) { + // there are queries to test + for(QueryConfiguration queryConfiguration : queryConfigurations) { + try { + boolean result = QueryUtil.evaluateBooleanQuery((EObject)objectToEdit, queryConfiguration); + if(!result) { + // return an unexecutable command, so the create command will not be executable + return UnexecutableCommand.INSTANCE; + } + } catch (Exception e) { + Activator.log.error(e); + } + } + } + + // Check all pre and post action validation rules. They are given by the provider of the action + CompositeCommand compositeCommand = new CompositeCommand("PreValidationPostAction"); + for(PostActionConfiguration postActionConfiguration : configuration.getPostAction()) { + ICommand command = null; + try { + command = ExtendedElementTypeActionService.getInstance().getPreValidationCommand(request.getElementsToEdit(), postActionConfiguration); + } catch (ProviderNotFoundException e) { + Activator.log.error(e); + } + if(command != null) { + compositeCommand.add(command); + } + } + // get the super command + ICommand superCommand = super.getBeforeCreateCommand(request); + + // if not null, adds it to the result + if(superCommand != null) { + compositeCommand.compose(superCommand); + } + + // if result not null, returns the composite command + if(!compositeCommand.isEmpty()) { + return compositeCommand; + } + return super.getBeforeCreateCommand(request); + } + return super.getBeforeCreateCommand(request); + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/preferences/ExtendedTypesPreferences.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/preferences/ExtendedTypesPreferences.java new file mode 100644 index 00000000000..caccc00c2bf --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/preferences/ExtendedTypesPreferences.java @@ -0,0 +1,197 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.extendedtypes.preferences; + +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.papyrus.infra.extendedtypes.Activator; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.WorkbenchException; +import org.eclipse.ui.XMLMemento; + + +/** + * Preferences management for extended types + */ +public class ExtendedTypesPreferences { + + /** id for the preference store for extended types redefinitions */ + public final static String EXTENDED_TYPES_REDEFINITIONS = "extendedTypesRedefinitions"; //$NON-NLS-1$ + + /** id for the node: extended types redefinition */ + public final static String EXTENDED_TYPES_REDEFINITION = "extendedTypesRedefinition"; //$NON-NLS-1$ + + /** name of the ID attribute */ + public final static String ID = "id"; //$NON-NLS-1$ + + /** name for the field giving the path to the XML file */ + public final static String PATH = "path"; //$NON-NLS-1$ + + /** + * Returns the preference store used to store extended types preferences. + * + * @return the preference store of the plugin + */ + protected static IPreferenceStore getPreferenceStore() { + return Activator.getDefault().getPreferenceStore(); + } + + /** + * Retrieves the root memento from the plugin preferences for all extended types redefinition + * redefinitions. + * + * @return the root memento if there were existing customizations, a newly created one otherwise (empty one) + */ + protected static XMLMemento getLocalRedefinitions() { + String sValue = getPreferenceStore().getString(EXTENDED_TYPES_REDEFINITIONS); + try { + if(sValue != null && !sValue.equals("")) { //$NON-NLS-1$ + XMLMemento rootMemento = XMLMemento.createReadRoot(new StringReader(sValue)); + return rootMemento; + } else { + return XMLMemento.createWriteRoot(EXTENDED_TYPES_REDEFINITIONS); + } + } catch (WorkbenchException e) { + Activator.log.error("Impossible to read preferences for extended types local redefinitions", e); + } + return null; + } + + /** + * Register a new local redefinition of a extendedTypes. + * + * @param extendedTypesID + * the id of the extendedTypes to register + * @param path + * the path to the configuration of the extendedTypes + * @return the memento that has been registered + */ + public static IMemento registerLocalRedefinition(String extendedTypesID, String path) { + XMLMemento rootMemento = getLocalRedefinitions(); + + // try to find an existing local definition for this extendedTypes + IMemento memento = getExtendedTypesRedefinitionNode(extendedTypesID); + + // if one exists, remove it from the preferences + if(memento != null) { + unregisterLocalRedefinition(extendedTypesID); + } + + // then register the new one + IMemento newMemento = rootMemento.createChild(EXTENDED_TYPES_REDEFINITION); + newMemento.putString(ID, extendedTypesID); + newMemento.putString(PATH, path); + + saveLocalRedefinitions(rootMemento); + + return newMemento; + } + + /** + * Returns the memento associated to the extendedTypes, or null if none exists + * + * @param extendedTypesID + * the identifier of the extendedTypes to find + * @return the memento found or null if no customization exists for this extendedTypes + */ + private static IMemento getExtendedTypesRedefinitionNode(String extendedTypesID) { + XMLMemento rootMemento = getLocalRedefinitions(); + IMemento[] redefinitions = rootMemento.getChildren(EXTENDED_TYPES_REDEFINITION); + for(IMemento redefinitionMemento : redefinitions) { + String extendedTypesNodeID = redefinitionMemento.getString(ID); + // check equals. extendedTypes ID is not null, as checked at the begining of the method. + if(extendedTypesID.equals(extendedTypesNodeID)) { + return redefinitionMemento; + } + } + return null; + } + + /** + * Returns the path for a given extended type local redefinition + * + * @param extendedTypesID + * the unique identifier of the extended type to retrieve + * @return the path to the configuration of the extended types or null if no customization exists for this extended type + * configuration + */ + public static String getExtendedTypesRedefinition(String extendedTypesID) { + if(extendedTypesID == null) { + Activator.log.debug("Trying to find preferences for a null extended type set identifier"); + } + IMemento memento = getExtendedTypesRedefinitionNode(extendedTypesID); + if(memento != null) { + return memento.getString(PATH); + } + return null; + } + + /** + * Unregister a specific local redefinition + * + * @param extendedTypesID + * the identifier of the extended types set to unregister + */ + public static void unregisterLocalRedefinition(String extendedTypesID) { + XMLMemento rootMemento = getLocalRedefinitions(); + // no remove method... + // so, creation of a new root memento, then, duplicate all entries + // except the one to + // delete... + XMLMemento newRootMemento = XMLMemento.createWriteRoot(EXTENDED_TYPES_REDEFINITIONS); + for(IMemento memento : rootMemento.getChildren(EXTENDED_TYPES_REDEFINITION)) { + if(!memento.getString(ID).equals(extendedTypesID)) { + newRootMemento.putMemento(memento); + } + } + // save new Memento + saveLocalRedefinitions(newRootMemento); + + } + + /** + * saves the given root memento with the given key in the preference area + * + * @param xmlMemento + * the memento to save + * @param key + * the key for the preference store + */ + private static void saveMemento(XMLMemento xmlMemento, String key) { + // save memento + StringWriter writer = new StringWriter(); + try { + xmlMemento.save(writer); + + if(getPreferenceStore() != null) { + getPreferenceStore().setValue(key, writer.toString()); + } + } catch (IOException e) { + Activator.log.error("input/ouput exception", e); + } + } + + /** + * Saves the set of local redefinitions into the preference store + * + * @param rootMemento + * the memento to save + */ + public static void saveLocalRedefinitions(XMLMemento rootMemento) { + saveMemento(rootMemento, EXTENDED_TYPES_REDEFINITIONS); + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtendedElementTypeActionService.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtendedElementTypeActionService.java new file mode 100644 index 00000000000..bb3e3d7c957 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtendedElementTypeActionService.java @@ -0,0 +1,198 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.extendedtypes.providers; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.core.service.ExecutionStrategy; +import org.eclipse.gmf.runtime.common.core.service.IOperation; +import org.eclipse.gmf.runtime.common.core.service.IProvider; +import org.eclipse.gmf.runtime.common.core.service.Service; +import org.eclipse.gmf.runtime.common.ui.services.util.ActivityFilterProviderDescriptor; +import org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.Activator; + + +/** + * Service to retrieve the provider giving the command for a specific {@link ActionConfiguration} + */ +public class ExtendedElementTypeActionService extends Service { + + /** singleton instance of this service */ + protected final static ExtendedElementTypeActionService instance = new ExtendedElementTypeActionService(); + + /** + * initialize the service + */ + static { + instance.configureProviders(Activator.PLUGIN_ID, "extendedElementTypeActionProvider"); //$NON-NLS-1$ + } + + /** + * Default constructor. + */ + protected ExtendedElementTypeActionService() { + + } + + /** + * Returns the singleton instance of this service + * + * @return the singleton instance of this service + */ + synchronized public static ExtendedElementTypeActionService getInstance() { + return instance; + } + + /** + * @see org.eclipse.gmf.runtime.common.core.service.Service#newProviderDescriptor(org.eclipse.core.runtime.IConfigurationElement) + */ + protected Service.ProviderDescriptor newProviderDescriptor(IConfigurationElement element) { + return new ProviderDescriptor(element); + } + + /** + * Returns all providers in the service + * + * @return the list of providers found or an empty list. + */ + public List getProviders() { + List providers = new ArrayList(); + execute(ExecutionStrategy.REVERSE, new GetAllExtendedElementTypeActionProvidersOperation(providers)); + return providers; + } + + /** + * Returns the provider with the given identifier + * + * @param actionConfiguration + * the actionConfiguration for the provider to retrieve + * @return the provider found or null. + */ + public IExtendedElementTypeActionProvider getProvider(ActionConfiguration actionConfiguration) { + @SuppressWarnings({ "unchecked", "rawtypes" }) + List providers = (List)execute(ExecutionStrategy.REVERSE, new GetExtendedElementTypeActionProviderOperation(actionConfiguration)); + Iterator it = providers.iterator(); + while(it.hasNext()) { + IExtendedElementTypeActionProvider aspectActionProvider = (IExtendedElementTypeActionProvider)it.next(); + if(aspectActionProvider != null) { + return aspectActionProvider; + } + } + return null; // backward compatibility + } + + /** + * Returns the command for the given {@link ActionConfiguration}. + * + * @param elementsToEdit + * list of elements to edit + * + * @param configuration + * the configuration of the action + * @return the {@link ICommand} configured by the parameter or null. + * @throws ProviderNotFoundException + * exception thrown when the provider was not found for this configuration + */ + public ICommand getICommand(List elementsToEdit, ActionConfiguration configuration) throws ProviderNotFoundException { + IExtendedElementTypeActionProvider provider = getProvider(configuration); + if(provider != null) { + return provider.getICommand(elementsToEdit, configuration); + } + throw new ProviderNotFoundException(configuration); + } + + /** + * Returns the command for the given {@link ActionConfiguration}. + * + * @param elementsToEdit + * list of elements to edit + * + * @param configuration + * the configuration of the action + * @return the {@link ICommand} configured by the parameter or null. + * @throws ProviderNotFoundException + * exception thrown when the provider was not found for this configuration + */ + public ICommand getPreValidationCommand(List elementsToEdit, ActionConfiguration configuration) throws ProviderNotFoundException { + IExtendedElementTypeActionProvider provider = getProvider(configuration); + if(provider != null) { + return provider.getBeforeCreateValidationCommand(elementsToEdit, configuration); + } + throw new ProviderNotFoundException(configuration); + } + + /** + * A descriptor for aspect tool providers defined by a configuration element. + */ + protected static class ProviderDescriptor extends ActivityFilterProviderDescriptor { + + /** the provider configuration parsed from XML */ + protected ExtentedElementTypeActionProviderConfiguration providerConfiguration; + + /** + * Constructs a ISemanticProvider descriptor for + * the specified configuration element. + * + * @param element + * The configuration element describing the provider. + */ + public ProviderDescriptor(IConfigurationElement element) { + super(element); + this.providerConfiguration = ExtentedElementTypeActionProviderConfiguration.parse(element); + Assert.isNotNull(providerConfiguration); + } + + /** + * @see org.eclipse.gmf.runtime.common.core.service.IProvider#provides(org.eclipse.gmf.runtime.common.core.service.IOperation) + */ + public boolean provides(IOperation operation) { + if(!super.provides(operation)) { + return false; + } + if(operation instanceof GetAllExtendedElementTypeActionProvidersOperation) { + return true; + } + if(operation instanceof GetExtendedElementTypeActionProviderOperation) { + String providerConfigurationClassName = providerConfiguration.getConfigurationClassName(); + if(providerConfigurationClassName == null) { + Activator.log.error("Error during the parsing of the action configuration extension point", null); + return false; + } + String configurationClassName = ((GetExtendedElementTypeActionProviderOperation)operation).getActionConfiguration().eClass().getInstanceClassName(); + return providerConfigurationClassName.equals(configurationClassName); + } + return false; + } + + /** + * @see org.eclipse.gmf.runtime.common.core.service.Service.ProviderDescriptor#getProvider() + */ + public IProvider getProvider() { + if(provider == null) { + IProvider newProvider = super.getProvider(); + if(provider instanceof IExtendedElementTypeActionProvider) { + IExtendedElementTypeActionProvider defaultProvider = (IExtendedElementTypeActionProvider)newProvider; + defaultProvider.setConfiguration(getElement()); + } + return newProvider; + } + return super.getProvider(); + } + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtentedElementTypeActionProviderConfiguration.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtentedElementTypeActionProviderConfiguration.java new file mode 100644 index 00000000000..f83bf684864 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ExtentedElementTypeActionProviderConfiguration.java @@ -0,0 +1,82 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.extendedtypes.providers; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.gmf.runtime.common.core.service.AbstractProviderConfiguration; + +/** + * Provider configuration for the aspect tool factory extension point. + */ +public class ExtentedElementTypeActionProviderConfiguration extends AbstractProviderConfiguration { + + /** field for provider class name */ + protected static final String CLASS = "class"; + + /** field for configuration class name */ + private static final String CONFIGURATION_CLASS = "configurationClass"; + + /** class name of the provider */ + protected final String className; + + /** class name of the configuration */ + private final String configurationClassName; + + /** + * Creates and builds a new provider contribution descriptor by parsing its configuration element. + * + * @param configElement + * A provider XML configuration element + * @return A provider XML contribution descriptor + */ + public static ExtentedElementTypeActionProviderConfiguration parse(IConfigurationElement configElement) { + Assert.isNotNull(configElement, "null provider configuration element"); //$NON-NLS-1$ + return new ExtentedElementTypeActionProviderConfiguration(configElement); + } + + /** + * Creates a new ProviderContributionDescriptor instance + * by parsing its configuration element. + * + * @param configElement + * The provider XML configuration element + */ + protected ExtentedElementTypeActionProviderConfiguration(IConfigurationElement configElement) { + // retrieve only ID, to test if the factory is the right one before creating whole element + className = configElement.getAttribute(CLASS); + Assert.isNotNull(className, "impossible to get the class name for the provider"); + + configurationClassName = configElement.getAttribute(CONFIGURATION_CLASS); + Assert.isNotNull(className, "impossible to get the class name for the provider"); + } + + + /** + * Returns the class name of the provider configured by this configuration + * + * @return the id of the factory + */ + public String getClassName() { + return className; + } + + /** + * Name of the configuration class + * + * @return the configuration Class Name + */ + public String getConfigurationClassName() { + return configurationClassName; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetAllExtendedElementTypeActionProvidersOperation.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetAllExtendedElementTypeActionProvidersOperation.java new file mode 100644 index 00000000000..d74978422f7 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetAllExtendedElementTypeActionProvidersOperation.java @@ -0,0 +1,48 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.extendedtypes.providers; + +import java.util.List; + +import org.eclipse.gmf.runtime.common.core.service.IOperation; +import org.eclipse.gmf.runtime.common.core.service.IProvider; + + +/** + * Operation that returns all providers for the {@link ExtendedElementTypeActionService}. + */ +public class GetAllExtendedElementTypeActionProvidersOperation implements IOperation { + + /** list of providers to fill */ + private final List providers; + + /** + * Creates a new GetAllExtendedElementTypeActionProvidersOperation. + * + * @param providers + * the list of providers to fill + */ + public GetAllExtendedElementTypeActionProvidersOperation(List providers) { + this.providers = providers; + } + + /** + * {@inheritDoc} + */ + public Object execute(IProvider provider) { + if(provider instanceof IExtendedElementTypeActionProvider) { + providers.add((IExtendedElementTypeActionProvider)provider); + } + return providers; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetExtendedElementTypeActionProviderOperation.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetExtendedElementTypeActionProviderOperation.java new file mode 100644 index 00000000000..259036144d5 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/GetExtendedElementTypeActionProviderOperation.java @@ -0,0 +1,53 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.extendedtypes.providers; + +import org.eclipse.gmf.runtime.common.core.service.IOperation; +import org.eclipse.gmf.runtime.common.core.service.IProvider; +import org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration; + + +/** + * Operation that returns the first provider with given id + */ +public class GetExtendedElementTypeActionProviderOperation implements IOperation { + + /** action configuration for the provider to find */ + private final ActionConfiguration actionConfiguration; + + /** + * Creates a new {@link GetExtendedElementTypeActionProviderOperation}. + * + * @param actionConfiguration + * action configuration for the provider to find + */ + public GetExtendedElementTypeActionProviderOperation(ActionConfiguration actionConfiguration) { + this.actionConfiguration = actionConfiguration; + } + + /** + * {@inheritDoc} + */ + public Object execute(IProvider provider) { + return provider; + } + + /** + * Returns the action configuration for this operation + * + * @return the action configuration for this operation + */ + public ActionConfiguration getActionConfiguration() { + return actionConfiguration; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/IExtendedElementTypeActionProvider.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/IExtendedElementTypeActionProvider.java new file mode 100644 index 00000000000..d383700eb3c --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/IExtendedElementTypeActionProvider.java @@ -0,0 +1,61 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.extendedtypes.providers; + +import java.util.List; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.core.service.IProvider; +import org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration; + + +/** + * Provider for extended element types action + */ +public interface IExtendedElementTypeActionProvider extends IProvider { + + /** + * Returns the command to execute for the given configuration + * + * @param elementsToEdit + * list of elements to edit + * + * @param configuration + * the configuration for the command + * + * @return the command to execute for the given configuration + */ + public ICommand getICommand(List elementsToEdit, ActionConfiguration configuration); + + /** + * Returns the command to execute for the given configuration to check if it will be executable + * + * @param elementsToEdit + * list of elements to edit + * + * @param configuration + * the configuration for the command + * + * @return the command to execute for the given configuration. should do nothing on the model (either null or identity command), only return an + * Unexecutable command if creation is not allowed + */ + public ICommand getBeforeCreateValidationCommand(List elementsToEdit, ActionConfiguration configuration); + + /** + * Sets the configuration for this provider, given the configuration element + * + * @param element + * the element that configures this provider + */ + public void setConfiguration(IConfigurationElement element); +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ProviderNotFoundException.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ProviderNotFoundException.java new file mode 100644 index 00000000000..6bf6503f25a --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/providers/ProviderNotFoundException.java @@ -0,0 +1,36 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.extendedtypes.providers; + +import org.eclipse.papyrus.infra.extendedtypes.ActionConfiguration; + + +/** + * Exception thrown when a provider was not found + */ +public class ProviderNotFoundException extends Exception { + + /** serial UID */ + private static final long serialVersionUID = 8919294410894098831L; + + /** + * Constructor. + * + * @param configuration + * the configuration for which a provider was searched + * + */ + public ProviderNotFoundException(ActionConfiguration configuration) { + super("Provider not found for configuration " + ((configuration != null) ? configuration.getLabel() : "null") + "[" + ((configuration != null) ? configuration.getId() : "null") + "]"); + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/types/ExtendedHintedTypeFactory.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/types/ExtendedHintedTypeFactory.java new file mode 100644 index 00000000000..8c20fdcb626 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/types/ExtendedHintedTypeFactory.java @@ -0,0 +1,125 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.extendedtypes.types; + +import org.eclipse.gmf.runtime.emf.type.core.AbstractElementTypeFactory; +import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; +import org.eclipse.gmf.runtime.emf.type.core.ISpecializationTypeDescriptor; +import org.eclipse.gmf.runtime.emf.type.core.SpecializationType; +import org.eclipse.gmf.runtime.emf.type.core.internal.impl.HintedTypeFactory; +import org.eclipse.papyrus.infra.extendedtypes.Activator; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedSemanticTypeDescriptor; + + +/** + * Factory for ExtendedHintedType elements + */ +public class ExtendedHintedTypeFactory extends AbstractElementTypeFactory { + + /** + * The hinted type kind. This string is specified in the XML 'kind' + * attribute of any element type that is a hinted type. + */ + public static final String HINTED_TYPE_KIND = "org.eclipse.gmf.runtime.emf.core.internal.util.IHintedType"; //$NON-NLS-1$ + + /** + * The semantic hint parameter name. + */ + public static final String SEMANTIC_HINT_PARAM_NAME = "semanticHint"; //$NON-NLS-1$ + + /** singleton instance of this factory */ + private static ExtendedHintedTypeFactory instance; + + /** + * Returns the singleton instance of this factory. + * + * @return the singleton instance of this factory. + */ + public synchronized static ExtendedHintedTypeFactory getInstance() { + if(instance == null) { + instance = new ExtendedHintedTypeFactory(); + } + return instance; + } + + /** + * Private Constructor. + * + */ + private ExtendedHintedTypeFactory() { + + } + + /** + * The extended hinted specialization type class. + */ + private static final class ExtendedHintedSpecializationType extends SpecializationType implements IExtendedHintedElementType { + + /** The semantic hint */ + private final String semanticHint; + + /** element type configuration */ + private final ExtendedElementTypeConfiguration configuration; + + /** + * Constructs a new hinted type. + * + * @param descriptor + * the specialization type descriptor + * @param semanticHint + * the semantic hint + */ + public ExtendedHintedSpecializationType(ISpecializationTypeDescriptor descriptor, String semanticHint, ExtendedElementTypeConfiguration configuration) { + super(descriptor); + this.semanticHint = semanticHint; + this.configuration = configuration; + } + + /** + * Gets the semantic hint. + */ + public String getSemanticHint() { + return semanticHint; + } + + /** + * {@inheritDoc} + */ + public ExtendedElementTypeConfiguration getConfiguration() { + return configuration; + } + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("restriction") + @Override + public ISpecializationType createSpecializationType(ISpecializationTypeDescriptor descriptor) { + + String semanticHint = descriptor.getParamValue(SEMANTIC_HINT_PARAM_NAME); + + if(descriptor instanceof ExtendedSemanticTypeDescriptor) { + ExtendedElementTypeConfiguration configuration = ((ExtendedSemanticTypeDescriptor)descriptor).getConfiguration(); + return new ExtendedHintedSpecializationType(descriptor, semanticHint, configuration); + } + + // used default factory. Should never happen + Activator.log.warn("The Extended type factory should never use HintedTypeFactory from GMF"); + return new HintedTypeFactory().createSpecializationType(descriptor); + } + + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/types/IExtendedHintedElementType.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/types/IExtendedHintedElementType.java new file mode 100644 index 00000000000..39afa41a5bc --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/types/IExtendedHintedElementType.java @@ -0,0 +1,31 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.extendedtypes.types; + +import org.eclipse.gmf.runtime.emf.type.core.IHintedType; +import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration; + + +/** + * Element Type that contains a configuration for extensions (Pre/Post actions and validation) + */ +public interface IExtendedHintedElementType extends ISpecializationType, IHintedType { + + /** + * Returns the Element Type configuration associated to the element type. + * @return the Element Type configuration associated to the element type. + */ + public ExtendedElementTypeConfiguration getConfiguration(); +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/util/ElementTypeUtils.java b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/util/ElementTypeUtils.java new file mode 100644 index 00000000000..d9338692cfe --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.extendedtypes/src/org/eclipse/papyrus/infra/extendedtypes/util/ElementTypeUtils.java @@ -0,0 +1,156 @@ +/***************************************************************************** + * Copyright (c) 2010 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.extendedtypes.util; + +import java.util.List; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.IMetamodelType; +import org.eclipse.papyrus.infra.extendedtypes.ExtendedElementTypeConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.PostActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.PreActionConfiguration; +import org.eclipse.papyrus.infra.extendedtypes.types.IExtendedHintedElementType; +import org.eclipse.papyrus.infra.queries.core.configuration.QueryConfiguration; + + +/** + * Utility class for {@link IElementType}. + */ +public class ElementTypeUtils { + + /** + * Tests if two elements types are equivalent + * + * @param referenceType + * the reference type for the comparison + * @param typeToCompare + * the type that is compared to the reference one + * @return true if both types are equivalent semantically + */ + public static boolean isSemanticallyEquivalent(IElementType referenceType, IElementType typeToCompare) { + boolean isEquivalent = true; + + // first : easy test... + if(typeToCompare.equals(referenceType)) { + return true; + } + + // 2. test the kind of element. + if(referenceType instanceof IMetamodelType) { + if(!(typeToCompare instanceof IMetamodelType)) { + return false; + } else { + EClass referenceEclass = ((IMetamodelType)referenceType).getEClass(); + EClass eclassToCompare = ((IMetamodelType)typeToCompare).getEClass(); + + isEquivalent = isEquivalent && referenceEclass.equals(eclassToCompare); + } + } else { + if((typeToCompare instanceof IMetamodelType)) { + return false; + } + } + + // metaclasses are equivalent. check for extended types now... + if(referenceType instanceof IExtendedHintedElementType) { + if(typeToCompare instanceof IExtendedHintedElementType) { + isEquivalent = isEquivalent && isSemanticallyEquivalent((IExtendedHintedElementType)referenceType, (IExtendedHintedElementType)typeToCompare); + } + } + + return isEquivalent; + } + + /** + * Tests if two elements types are equivalent (configuration) + * + * @param referenceType + * the reference type for the comparison + * @param typeToCompare + * the type that is compared to the reference one + * @return true if both types are equivalent semantically + */ + public static boolean isSemanticallyEquivalent(IExtendedHintedElementType referenceType, IExtendedHintedElementType typeToCompare) { + + boolean isEquivalent = true; + // check all pre/post action and validation + ExtendedElementTypeConfiguration referenceConfiguration = referenceType.getConfiguration(); + ExtendedElementTypeConfiguration configurationToCompare = typeToCompare.getConfiguration(); + + List referencePrevalidation = referenceConfiguration.getPreValidation(); + List prevalidationToCompare = configurationToCompare.getPreValidation(); + if(referencePrevalidation != null) { + isEquivalent = isEquivalent && isEquivalent(referencePrevalidation, prevalidationToCompare); + } else if(prevalidationToCompare != null) { + isEquivalent = false; + } + + List referencePreaction = referenceConfiguration.getPreAction(); + List preactionToCompare = configurationToCompare.getPreAction(); + if(referencePreaction != null) { + isEquivalent = isEquivalent && isEquivalent(referencePreaction, preactionToCompare); + } else if(preactionToCompare != null) { + isEquivalent = false; + } + + List referencePostaction = referenceConfiguration.getPostAction(); + List postactionToCompare = configurationToCompare.getPostAction(); + if(referencePostaction != null) { + isEquivalent = isEquivalent && isEquivalent(referencePostaction, postactionToCompare); + } else if(postactionToCompare != null) { + isEquivalent = false; + } + + return isEquivalent; + } + + public static boolean isEquivalent(List referenceList, List listToCompare) { + boolean isEquivalent = true; + if(referenceList == null) { + // only one is null : false + if(listToCompare != null) { + return false; + } else { + // both are null: true + return true; + } + } else { + // only one is null: false + if(listToCompare == null) { + return false; + } + } + + // check emptyness. If both empty : equivalent + if(referenceList.isEmpty() && listToCompare.isEmpty()) { + return true; + } + + // check size. If different, false + if(referenceList.size() != listToCompare.size()) { + return false; + } + + for(int i = 0; i < referenceList.size(); i++) { + EObject reference = referenceList.get(i); + EObject compared = listToCompare.get(i); + isEquivalent = isEquivalent && EcoreUtil.equals(reference, compared); + } + + return isEquivalent; + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/META-INF/MANIFEST.MF b/plugins/infra/org.eclipse.papyrus.infra.onefile/META-INF/MANIFEST.MF index d5fbd68f1cd..1485427a07c 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/META-INF/MANIFEST.MF +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/META-INF/MANIFEST.MF @@ -4,14 +4,14 @@ Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="0.9.0", org.eclipse.team.ui, org.eclipse.ui.navigator.resources, org.eclipse.papyrus.infra.ui.resources;bundle-version="0.9.0" -Export-Package: org.eclipse.papyrus.onefile.model, - org.eclipse.papyrus.onefile.utils +Export-Package: org.eclipse.papyrus.infra.onefile.model, + org.eclipse.papyrus.infra.onefile.utils Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-Version: 0.9.0.qualifier Bundle-Name: %pluginName Bundle-ManifestVersion: 2 -Bundle-Activator: org.eclipse.papyrus.onefile.Activator +Bundle-Activator: org.eclipse.papyrus.infra.onefile.Activator Bundle-SymbolicName: org.eclipse.papyrus.infra.onefile;singleton:=true Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/plugin.xml b/plugins/infra/org.eclipse.papyrus.infra.onefile/plugin.xml index c6b00c436b8..b7dc00eb415 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/plugin.xml +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/plugin.xml @@ -5,8 +5,8 @@ + adaptableType="org.eclipse.papyrus.infra.onefile.model.IPapyrusFile" + class="org.eclipse.papyrus.infra.onefile.model.adapters.ModelAdapterFactory"> + adaptableType="org.eclipse.papyrus.infra.onefile.model.ISubResourceFile" + class="org.eclipse.papyrus.infra.onefile.model.adapters.SubResourceAdapterFactory"> @@ -38,33 +38,33 @@ name="One File Model Provider" point="org.eclipse.core.resources.modelProviders"> + class="org.eclipse.papyrus.infra.onefile.providers.OneFileModelProvider"/> + value="org.eclipse.papyrus.infra.onefile.model.IPapyrusFile"> + value="org.eclipse.papyrus.infra.onefile.providers.OneFileModelProvider"> @@ -81,26 +81,26 @@ + value="org.eclipse.papyrus.infra.onefile.model.IPapyrusFile"> + class="org.eclipse.papyrus.infra.onefile.model.adapters.PapyrusCommonDropAdapterAssistant" + id="org.eclipse.papyrus.infra.onefile.PapyrusDropAssistant"> + class="org.eclipse.papyrus.infra.onefile.providers.PapyrusViewerSorter" + id="org.eclipse.papyrus.infra.onefile.sorter"> @@ -108,19 +108,19 @@ value="org.eclipse.core.resources.IResource"> + value="org.eclipse.papyrus.infra.onefile.model.IPapyrusFile"> + value="org.eclipse.papyrus.infra.onefile.model.ISubResourceFile"> + class="org.eclipse.papyrus.infra.onefile.providers.ISubresourceFileActionProvider" + id="org.eclipse.papyrus.infra.onefile.DiContent.EditActions"> + value="org.eclipse.papyrus.infra.onefile.model.ISubResourceFile"> @@ -130,20 +130,20 @@ + pattern="org.eclipse.papyrus.infra.onefile.DiContent"/> + pattern="org.eclipse.papyrus.infra.onefile.onlyDiFilter"> + pattern="org.eclipse.papyrus.infra.onefile.DiContent"> + pattern="org.eclipse.papyrus.infra.onefile.oneFileLinkHelper"> @@ -155,13 +155,13 @@ viewerId="org.eclipse.ui.navigator.ProjectExplorer"> + pattern="org.eclipse.papyrus.infra.onefile.onlyDiFilter"> + pattern="org.eclipse.papyrus.infra.onefile.DiContent"> + pattern="org.eclipse.papyrus.infra.onefile.oneFileLinkHelper"> @@ -173,10 +173,10 @@ viewerId="org.eclipse.team.ui.navigatorViewer"> + pattern="org.eclipse.papyrus.infra.onefile.onlyDiFilter"> + pattern="org.eclipse.papyrus.infra.onefile.DiContent"> @@ -184,10 +184,10 @@ viewerId="org.eclipse.team.svn.ui.workspaceSynchronization"> + pattern="org.eclipse.papyrus.infra.onefile.onlyDiFilter"> + pattern="org.eclipse.papyrus.infra.onefile.DiContent"> @@ -195,15 +195,15 @@ viewerId="org.eclipse.team.cvs.ui.workspaceSynchronization"> + pattern="org.eclipse.papyrus.infra.onefile.onlyDiFilter"> + pattern="org.eclipse.papyrus.infra.onefile.DiContent"> + viewerId="org.eclipse.papyrus.infra.onefile.DiContent"> @@ -215,8 +215,8 @@ + class="org.eclipse.papyrus.infra.onefile.model.adapters.PapyrusLinkHelper" + id="org.eclipse.papyrus.infra.onefile.oneFileLinkHelper"> + value="org.eclipse.papyrus.infra.onefile.model.IPapyrusFile"> + point="org.eclipse.papyrus.infra.onefile.modelFactory"> @@ -261,14 +261,14 @@ point="org.eclipse.ui.decorators"> + name="org.eclipse.papyrus.infra.onefile.model.IPapyrusFile"> diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/schema/modelFactory.exsd b/plugins/infra/org.eclipse.papyrus.infra.onefile/schema/modelFactory.exsd index 1c6e4e0eccb..fc5fb322311 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/schema/modelFactory.exsd +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/schema/modelFactory.exsd @@ -1,9 +1,9 @@ - + - + This extension point allows developer to change implementation of logical navigator model. @@ -55,7 +55,7 @@ the instance of the factory - + diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/Activator.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/Activator.java new file mode 100644 index 00000000000..9fe35decad7 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/Activator.java @@ -0,0 +1,69 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.onefile"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext + * ) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext + * ) + */ + @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; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/matcher/OnlyDiFilter.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/matcher/OnlyDiFilter.java new file mode 100644 index 00000000000..ef0a6282e26 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/matcher/OnlyDiFilter.java @@ -0,0 +1,55 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.matcher; + +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; +import org.eclipse.papyrus.infra.onefile.utils.OneFileUtils; + +/** + * Filter hiding di files and associated. the filter enables the content + * provider + * + * @author tfaure + * + */ +public class OnlyDiFilter extends ViewerFilter { + + public static final String FILTER_ID = "org.eclipse.papyrus.infra.onefile.onlyDiFilter"; + + /* + * (non-Javadoc) + * + * @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) { + return OneFileUtils.isVisible(element); + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.viewers.ViewerFilter#isFilterProperty(java.lang.Object, + * java.lang.String) + * + * @Override + */ + public boolean isFilterProperty(Object element, String property) { + return true; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/IPapyrusElement.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/IPapyrusElement.java new file mode 100644 index 00000000000..05278754782 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/IPapyrusElement.java @@ -0,0 +1,34 @@ +package org.eclipse.papyrus.infra.onefile.model; + +import org.eclipse.core.resources.IProject; +import org.eclipse.swt.graphics.Image; + +/** + * Basic operations for Papyrus Model Elements + * + * @author tristan.faure@atosorigin.com + * + */ +public interface IPapyrusElement { + /** + * Return the text displayed for the {@link IPapyrusFile} + * + * @return + */ + String getText(); + + /** + * Return the image displayed for the {@link IPapyrusFile} + * + * @return + */ + Image getImage(); + + /** + * Return the project containing the {@link IPapyrusFile} + * + * @return an {@link IProject} + */ + IProject getProject(); + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/IPapyrusFile.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/IPapyrusFile.java new file mode 100644 index 00000000000..ec3c15c72f0 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/IPapyrusFile.java @@ -0,0 +1,56 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.model; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; + +/** + * Contract for Papyrus Files representation + * + * @author tristan.faure@atosorigin.com + * + */ +public interface IPapyrusFile extends IPapyrusElement, IAdaptable { + + /** + * Return the resources associated to the DI, the di must be included in the + * resutl + * + * @return + */ + IResource[] getAssociatedResources(); + + /** + * Return the main file (normally the di) + * + * @return + */ + IFile getMainFile(); + + /** + * Return the parent of the current {@link IPapyrusFile} + * + * @return an IContainer + */ + IContainer getParent(); + + /** + * Return the text displayed for the {@link IPapyrusFile} + * + * @return + */ + String getName(); + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/IPapyrusModelFactory.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/IPapyrusModelFactory.java new file mode 100644 index 00000000000..4bab65b8de2 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/IPapyrusModelFactory.java @@ -0,0 +1,50 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.model; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; + +/** + * Factory able to create instances of model interfaces + * + * @author tristan.faure@atosorigin.com + * + */ +public interface IPapyrusModelFactory { + + /** + * Create an instance of {@link IPapyrusFile} with the given file + * + * @param file + * @return + */ + IPapyrusFile createIPapyrusFile(IFile file); + + /** + * Create an instanceof {@link IPapyrusFile} with the given file and the + * given {@link IPapyrusFile} + * + * @param papy + * @param r + * @return + */ + ISubResourceFile createISubResourceFile(IPapyrusFile papy, IFile r); + + /** + * Determines if the file in parameter is a di + * + * @param file + * @return + */ + boolean isDi(IResource file); +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/ISubResourceFile.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/ISubResourceFile.java new file mode 100644 index 00000000000..5fa95fdeca6 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/ISubResourceFile.java @@ -0,0 +1,30 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.model; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IAdaptable; + +/** + * Contract for elements bellow an {@link IPapyrusFile} + * + * @author tfaure + * + */ +public interface ISubResourceFile extends IPapyrusElement, IAdaptable { + /** + * Returns the IFile associted to the {@link ISubResourceFile} + * + * @return + */ + IFile getFile(); +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/PapyrusModelHelper.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/PapyrusModelHelper.java new file mode 100644 index 00000000000..8bb7e02f83a --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/PapyrusModelHelper.java @@ -0,0 +1,111 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.model; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.papyrus.infra.onefile.Activator; +import org.osgi.framework.Bundle; + +/** + * Helper class able to get the correct {@link IPapyrusModelFactory} + * + * @author tfaure + * + */ +public class PapyrusModelHelper { + + private static final String MODEL_FACTORY = "modelFactory"; + static List segments; + + static { + IConfigurationElement[] elements = Platform + .getExtensionRegistry() + .getConfigurationElementsFor(Activator.PLUGIN_ID, MODEL_FACTORY); + segments = new ArrayList(elements.length); + for (IConfigurationElement e : elements) { + Segment s = new PapyrusModelHelper.Segment(); + try { + s.priority = Integer.parseInt(e.getAttribute("priority")); + s.bundle = Platform.getBundle(e.getContributor().getName()); + s.className = e.getAttribute("instance"); + segments.add(s); + } catch (NumberFormatException ex) { + // in case of exception the process continue but the stack is + // traced + ex.printStackTrace(); + } + } + // sort elements according to their priorities + Collections.sort(segments, new Comparator() { + public int compare(Segment o1, Segment o2) { + Integer val1 = 0; + Integer val2 = 0; + if (o1 != null) { + val1 = o1.priority; + } + if (o2 != null) { + val2 = o2.priority; + } + return val1.compareTo(val2); + } + }); + } + + /** + * get the {@link IPapyrusModelFactory} in the current platform + * + * @return a {@link IPapyrusModelFactory} + */ + public static IPapyrusModelFactory getPapyrusModelFactory() { + if (segments == null || segments.size() == 0) { + throw new RuntimeException( + "Initialisation error, please register extension to " + + Activator.PLUGIN_ID + "." + MODEL_FACTORY); + } + // segments are sorted by priorities, the highest is at the end of the + // list + return segments.get(segments.size() - 1).getFactory(); + } + + /** + * Utility class to save extension point information + * + */ + private static class Segment { + public String className; + Bundle bundle; + int priority; + IPapyrusModelFactory instance = null; + + IPapyrusModelFactory getFactory() { + if (instance == null) { + try { + instance = (IPapyrusModelFactory) bundle.loadClass( + className).newInstance(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + return instance; + } + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/ModelAdapterFactory.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/ModelAdapterFactory.java new file mode 100644 index 00000000000..da1a6bb6d2c --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/ModelAdapterFactory.java @@ -0,0 +1,63 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.model.adapters; + +import java.util.Arrays; +import java.util.Collection; + +import org.eclipse.core.resources.mapping.ResourceMapping; +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; +import org.eclipse.papyrus.infra.onefile.model.mapping.PapyrusResourceMapping; +import org.eclipse.ui.IContributorResourceAdapter; +import org.eclipse.ui.ide.IContributorResourceAdapter2; + +/** + * Adapter factory to adapt {@link IPapyrusFile} + * + * @author tristan.faure@atosorigin.com + */ +@SuppressWarnings("rawtypes") +public class ModelAdapterFactory implements IAdapterFactory { + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, + * java.lang.Class) + */ + public Object getAdapter(Object adaptableObject, Class adapterType) { + if(ResourceMapping.class.equals(adapterType)) { + if(adaptableObject instanceof IPapyrusFile) { + return new PapyrusResourceMapping((IPapyrusFile)adaptableObject); + } + } + if(IContributorResourceAdapter.class.equals(adapterType)) { + return new PapyrusModelContributorResourceAdapter(); + } + if(IContributorResourceAdapter2.class.equals(adapterType)) { + return new PapyrusModelContributorResourceAdapter(); + } + if(Collection.class.equals(adapterType)) { + if(adaptableObject instanceof IPapyrusFile) { + return Arrays.asList(((IPapyrusFile)adaptableObject).getAssociatedResources()); + } + } + return null; + } + + public Class[] getAdapterList() { + return new Class[]{}; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/PapyrusCommonDropAdapterAssistant.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/PapyrusCommonDropAdapterAssistant.java new file mode 100644 index 00000000000..658c791413d --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/PapyrusCommonDropAdapterAssistant.java @@ -0,0 +1,81 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.model.adapters; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.util.LocalSelectionTransfer; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; +import org.eclipse.swt.dnd.DropTargetEvent; +import org.eclipse.swt.dnd.TransferData; +import org.eclipse.ui.navigator.CommonDropAdapter; +import org.eclipse.ui.navigator.resources.ResourceDropAdapterAssistant; + +/** + * Assistant to manage drag and drop of {@link IPapyrusFile} + * {@link IPapyrusFile} are not adapted to {@link IResource} to prevent + * misunderstanding so during transfer the selection is changed + * + * @author tristan.faure@atosorigin.com + * + */ +public class PapyrusCommonDropAdapterAssistant extends + ResourceDropAdapterAssistant { + + @Override + public IStatus validateDrop(Object target, int aDropOperation, + TransferData transferType) { + manageSelection(); + return super.validateDrop(target, aDropOperation, transferType); + } + + @Override + public IStatus handleDrop(CommonDropAdapter aDropAdapter, + DropTargetEvent aDropTargetEvent, Object aTarget) { + manageSelection(); + return super.handleDrop(aDropAdapter, aDropTargetEvent, aTarget); + } + + @Override + protected void doInit() { + super.doInit(); + manageSelection(); + } + + private void manageSelection() { + List elements = new ArrayList(); + ISelection selec = LocalSelectionTransfer.getTransfer().getSelection(); + if (selec instanceof IStructuredSelection) { + IStructuredSelection struc = (IStructuredSelection) selec; + for (Iterator i = struc.iterator(); i.hasNext();) { + Object o = i.next(); + if (o instanceof IPapyrusFile) { + IPapyrusFile papy = (IPapyrusFile) o; + // TODO if a drop assistant is implemented use previous implementation : + // elements.add(papy.getMainFile()); + elements.addAll(Arrays.asList(papy.getAssociatedResources())); + } + } + } + LocalSelectionTransfer.getTransfer().setSelection( + new StructuredSelection(elements)); + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/PapyrusLinkHelper.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/PapyrusLinkHelper.java new file mode 100644 index 00000000000..22dff1ebe5f --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/PapyrusLinkHelper.java @@ -0,0 +1,75 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.model.adapters; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; +import org.eclipse.papyrus.infra.onefile.model.PapyrusModelHelper; +import org.eclipse.papyrus.infra.onefile.utils.OneFileUtils; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.navigator.ILinkHelper; + +/** + * Link the Papyrus Editor with {@link IPapyrusFile} + * + * @author tristan.faure@atosorigin.com + * + */ +public class PapyrusLinkHelper implements ILinkHelper { + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.navigator.ILinkHelper#findSelection(org.eclipse.ui. + * IEditorInput) + */ + public IStructuredSelection findSelection(IEditorInput anInput) { + List select = new ArrayList(); + if(anInput instanceof IFileEditorInput) { + IFileEditorInput input = (IFileEditorInput)anInput; + IPapyrusFile papy = PapyrusModelHelper.getPapyrusModelFactory().createIPapyrusFile(input.getFile()); + select.add(papy); + IResource res = papy.getMainFile(); + while(res.getParent() != null) { + select.add(0, res.getParent()); + res = res.getParent(); + } + return new StructuredSelection(papy); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.navigator.ILinkHelper#activateEditor(org.eclipse.ui. + * IWorkbenchPage, org.eclipse.jface.viewers.IStructuredSelection) + */ + public void activateEditor(IWorkbenchPage page, IStructuredSelection selection) { + if(selection == null || selection.isEmpty()) + return; + Object element = selection.getFirstElement(); + IEditorPart part = OneFileUtils.isOpenInEditor(element); + if(part != null) { + page.bringToTop(part); + } + + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/PapyrusModelContributorResourceAdapter.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/PapyrusModelContributorResourceAdapter.java new file mode 100644 index 00000000000..4a99e2764c4 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/PapyrusModelContributorResourceAdapter.java @@ -0,0 +1,38 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atos.net - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.model.adapters; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.mapping.ResourceMapping; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.ui.ide.IContributorResourceAdapter2; + + +/** + * Another Adapter + * + * @author tfaure + * + */ +public class PapyrusModelContributorResourceAdapter implements IContributorResourceAdapter2 { + + public IResource getAdaptedResource(IAdaptable adaptable) { + IResource res = (IResource)adaptable.getAdapter(IResource.class); + return res; + } + + public ResourceMapping getAdaptedResourceMapping(IAdaptable adaptable) { + ResourceMapping res = (ResourceMapping)adaptable.getAdapter(ResourceMapping.class); + return res; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/SubResourceAdapterFactory.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/SubResourceAdapterFactory.java new file mode 100644 index 00000000000..3db270726c5 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/adapters/SubResourceAdapterFactory.java @@ -0,0 +1,56 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.model.adapters; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.mapping.ResourceMapping; +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.papyrus.infra.onefile.model.ISubResourceFile; +import org.eclipse.papyrus.infra.onefile.model.impl.SubResourceFile; +import org.eclipse.papyrus.infra.onefile.model.mapping.SubResourceMapping; +import org.eclipse.ui.IContributorResourceAdapter; + +/** + * Adapter Factory for {@link SubResourceFile} + * + * @author tristan.faure@atosorigin.com + * + */ +public class SubResourceAdapterFactory implements IAdapterFactory { + + public Object getAdapter(Object adaptableObject, Class adapterType) { + if(ResourceMapping.class.equals(adapterType)) { + if(adaptableObject instanceof ISubResourceFile) { + return new SubResourceMapping((ISubResourceFile)adaptableObject); + } + } else if(IFile.class.equals(adapterType)) { + if(adaptableObject instanceof ISubResourceFile) { + return ((ISubResourceFile)adaptableObject).getFile(); + } + } else if(IContributorResourceAdapter.class.equals(adapterType)) { + if(adaptableObject instanceof ISubResourceFile) { + return new PapyrusModelContributorResourceAdapter(); + } + } else if(IResource.class.equals(adapterType)) { + if(adaptableObject instanceof ISubResourceFile) { + return ((ISubResourceFile)adaptableObject).getFile(); + } + } + return null; + } + + public Class[] getAdapterList() { + return new Class[]{}; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/PapyrusFile.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/PapyrusFile.java new file mode 100644 index 00000000000..249450434ed --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/PapyrusFile.java @@ -0,0 +1,103 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.model.impl; + +import java.util.ArrayList; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.papyrus.infra.core.utils.PapyrusImageUtils; +import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; +import org.eclipse.papyrus.infra.onefile.utils.OneFileUtils; +import org.eclipse.swt.graphics.Image; + +/** + * Default Implementation of {@link IPapyrusFile} + * + * @author tristan.faure@atosorigin.com + * + */ +public class PapyrusFile implements IPapyrusFile { + + private final IFile file; + + + public PapyrusFile(IFile file) { + this.file = file; + } + + public IFile getMainFile() { + return file; + } + + public IResource[] getAssociatedResources() { + ArrayList files = new ArrayList(); + try { + for(IResource res : file.getParent().members()) { + if(res instanceof IFile && OneFileUtils.withoutFileExtension(file).equals(OneFileUtils.withoutFileExtension(res))) { + files.add((IFile)res); + } + } + } catch (CoreException e) { + } + return files.toArray(new IResource[]{}); + } + + public String getLabel() { + return file.getName(); + } + + + + @Override + public int hashCode() { + return getMainFile().hashCode(); + } + + @Override + public boolean equals(Object obj) { + if(obj instanceof PapyrusFile) { + PapyrusFile papy = (PapyrusFile)obj; + return getMainFile().equals(papy.getMainFile()); + } + return super.equals(obj); + } + + public IProject getProject() { + return file.getProject(); + } + + public IContainer getParent() { + return file.getParent(); + } + + public String getName() { + return file.getName(); + } + + public String getText() { + return getName().substring(0, getName().lastIndexOf('.')); + } + + public Image getImage() { + return PapyrusImageUtils.getDefaultIcon(); + } + + public Object getAdapter(Class adapter) { + return Platform.getAdapterManager().getAdapter(this, adapter); + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/PapyrusModelFactory.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/PapyrusModelFactory.java new file mode 100644 index 00000000000..654916c3e5a --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/PapyrusModelFactory.java @@ -0,0 +1,35 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.model.impl; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel; +import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; +import org.eclipse.papyrus.infra.onefile.model.IPapyrusModelFactory; +import org.eclipse.papyrus.infra.onefile.model.ISubResourceFile; + +public class PapyrusModelFactory implements IPapyrusModelFactory { + + public IPapyrusFile createIPapyrusFile(IFile file) { + return new PapyrusFile(file); + } + + public ISubResourceFile createISubResourceFile(IPapyrusFile papy, IFile r) { + return new SubResourceFile(papy, r); + } + + public boolean isDi(IResource file) { + return DiModel.DI_FILE_EXTENSION.equals(file.getFileExtension()); + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/SubResourceFile.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/SubResourceFile.java new file mode 100644 index 00000000000..d15d6a5c12e --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/SubResourceFile.java @@ -0,0 +1,74 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.model.impl; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; +import org.eclipse.papyrus.infra.onefile.model.ISubResourceFile; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.PlatformUI; + +/** + * Default implementation of {@link ISubResourceFile} + * + * @author tristan.faure@atosorigin.com + * + */ +public class SubResourceFile implements ISubResourceFile { + @SuppressWarnings("unused") + private IPapyrusFile parent; + private final IFile subResource; + + public SubResourceFile(IPapyrusFile papy, IFile r) { + this.parent = papy; + this.subResource = r; + } + + public IProject getProject() { + return subResource.getProject(); + } + + @Override + public String toString() { + String fileExtension = subResource.getFileExtension(); + return fileExtension != null ? fileExtension : subResource.getName(); + } + + public IFile getFile() { + return subResource; + } + + public Image getImage() { + Image image = JFaceResources.getImage(getFile().getFileExtension()); + if (image == null) { + ImageDescriptor desc = PlatformUI.getWorkbench() + .getEditorRegistry() + .getImageDescriptor(getFile().getName()); + JFaceResources.getImageRegistry().put(getFile().getFileExtension(), + desc); + } + return JFaceResources.getImage(getFile().getFileExtension()); + } + + public String getText() { + return toString(); + } + + public Object getAdapter(Class adapter) { + return Platform.getAdapterManager().getAdapter(this, adapter); + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/mapping/PapyrusResourceMapping.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/mapping/PapyrusResourceMapping.java new file mode 100644 index 00000000000..d3cd48ef868 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/mapping/PapyrusResourceMapping.java @@ -0,0 +1,84 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.model.mapping; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceVisitor; +import org.eclipse.core.resources.mapping.ResourceMapping; +import org.eclipse.core.resources.mapping.ResourceMappingContext; +import org.eclipse.core.resources.mapping.ResourceTraversal; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; +import org.eclipse.papyrus.infra.onefile.model.PapyrusModelHelper; +import org.eclipse.papyrus.infra.onefile.providers.OneFileModelProvider; + +/** + * Resource Mapping for Papyrus File + * + */ +public class PapyrusResourceMapping extends ResourceMapping { + + private final IPapyrusFile papyrusFile; + + public PapyrusResourceMapping(IPapyrusFile adaptableObject) { + this.papyrusFile = adaptableObject; + } + + public PapyrusResourceMapping(IFile resource) { + this.papyrusFile = PapyrusModelHelper.getPapyrusModelFactory() + .createIPapyrusFile(resource); + } + + @Override + public Object getModelObject() { + return papyrusFile; + } + + @Override + public String getModelProviderId() { + return OneFileModelProvider.MODEL_PROVIDER_ID; + } + + @Override + public IProject[] getProjects() { + return new IProject[] { papyrusFile.getProject() }; + } + + @Override + public ResourceTraversal[] getTraversals(ResourceMappingContext context, + IProgressMonitor monitor) throws CoreException { + // if (ResourceMappingContext.LOCAL_CONTEXT == context) + // { + // return new ResourceTraversal[]{new ResourceTraversal(new + // IResource[]{papyrusFile.get()}, IResource.DEPTH_ONE, + // IResource.NONE)}; + // } + // else + // { + return new ResourceTraversal[] { new ResourceTraversal( + papyrusFile.getAssociatedResources(), IResource.DEPTH_INFINITE, + IResource.NONE) }; + // } + + } + + @Override + public void accept(ResourceMappingContext context, + IResourceVisitor visitor, IProgressMonitor monitor) + throws CoreException { + super.accept(context, visitor, monitor); + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/mapping/SubResourceMapping.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/mapping/SubResourceMapping.java new file mode 100644 index 00000000000..0d2d33ae43b --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/mapping/SubResourceMapping.java @@ -0,0 +1,71 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.model.mapping; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceVisitor; +import org.eclipse.core.resources.mapping.ResourceMapping; +import org.eclipse.core.resources.mapping.ResourceMappingContext; +import org.eclipse.core.resources.mapping.ResourceTraversal; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.papyrus.infra.onefile.model.ISubResourceFile; +import org.eclipse.papyrus.infra.onefile.providers.OneFileModelProvider; + +public class SubResourceMapping extends ResourceMapping { + private final ISubResourceFile file; + + public SubResourceMapping(ISubResourceFile adaptableObject) { + this.file = adaptableObject; + } + + @Override + public Object getModelObject() { + return file; + } + + @Override + public String getModelProviderId() { + return OneFileModelProvider.MODEL_PROVIDER_ID; + } + + @Override + public IProject[] getProjects() { + return new IProject[] { file.getProject() }; + } + + @Override + public ResourceTraversal[] getTraversals(ResourceMappingContext context, + IProgressMonitor monitor) throws CoreException { + // if (ResourceMappingContext.LOCAL_CONTEXT == context) + // { + // return new ResourceTraversal[]{new ResourceTraversal(new + // IResource[]{papyrusFile.get()}, IResource.DEPTH_ONE, + // IResource.NONE)}; + // } + // else + // { + return new ResourceTraversal[] { new ResourceTraversal( + new IResource[] { file.getFile() }, IResource.DEPTH_INFINITE, + IResource.NONE) }; + // } + + } + + @Override + public void accept(ResourceMappingContext context, + IResourceVisitor visitor, IProgressMonitor monitor) + throws CoreException { + super.accept(context, visitor, monitor); + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/ISubresourceFileActionProvider.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/ISubresourceFileActionProvider.java new file mode 100644 index 00000000000..4150e690090 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/ISubresourceFileActionProvider.java @@ -0,0 +1,76 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin) tristan.faure@ato.net - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.providers; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.ui.actions.ActionContext; +import org.eclipse.ui.internal.navigator.resources.actions.EditActionProvider; + + +/** + * An edit action provider to provide Copy/Paste/Delete on sub resources + * + * @author Tristan Faure + * + */ +@SuppressWarnings("restriction") +public class ISubresourceFileActionProvider extends EditActionProvider { + + @Override + public void setContext(ActionContext context) { + // TODO Auto-generated method stub + List resources = new LinkedList(); + if(context.getSelection() instanceof IStructuredSelection) { + IStructuredSelection contextSelec = (IStructuredSelection)context.getSelection(); + for(Iterator i = contextSelec.iterator(); i.hasNext();) { + Object o = i.next(); + IResource res = adapt(o, IResource.class); + if(res != null) { + resources.add(res); + } + } + } + if(!resources.isEmpty()) { + ISelection selec = new StructuredSelection(resources); + super.setContext(new ActionContext(selec)); + } else { + super.setContext(context); + } + } + + @SuppressWarnings("unchecked") + public T adapt(Object o, Class aClass) { + T result = null; + if(aClass.isInstance(o)) { + result = (T)o; + } + if(o instanceof IAdaptable) { + IAdaptable adaptable = (IAdaptable)o; + result = (T)adaptable.getAdapter(aClass); + } + if(result == null) { + result = (T)Platform.getAdapterManager().getAdapter(o, aClass); + } + + return result; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/OneFileDecorator.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/OneFileDecorator.java new file mode 100644 index 00000000000..07192e3e340 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/OneFileDecorator.java @@ -0,0 +1,173 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan FAURE (Atos) tristan.faure@atos.net - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.providers; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.IDecoration; +import org.eclipse.jface.viewers.IDecorationContext; +import org.eclipse.jface.viewers.ILightweightLabelDecorator; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.ui.internal.WorkbenchPlugin; +import org.eclipse.ui.internal.decorators.DecorationBuilder; + + +/** + * This decorator computes decoration of related files + * for each decoration an intersection is made + * and the {@link IPapyrusFile} will have the same decoration of the set + * + * @author tfaure + * + */ +@SuppressWarnings("restriction") +public class OneFileDecorator extends LabelProvider implements ILightweightLabelDecorator { + + public void decorate(Object element, IDecoration decoration) { + if(element instanceof IPapyrusFile) { + IPapyrusFile papy = (IPapyrusFile)element; + IResource[] associatedResources = papy.getAssociatedResources(); + FilteredDecorationBuilder builder = new FilteredDecorationBuilder(decoration.getDecorationContext(), associatedResources.length); + for(IResource r : associatedResources) { + WorkbenchPlugin.getDefault().getDecoratorManager().getLightweightManager().getDecorations(r, builder); + } + builder.handleDecoration(decoration); + } + } + + /** + * The builder which intercepts decoration + * + * @author tfaure + * + */ + protected class FilteredDecorationBuilder extends DecorationBuilder { + + /** overlay, prefix and suffixes can be several so the number of occurences is saved */ + private Map overlay = new HashMap(); + + + private Map prefixString = new HashMap(); + + + private Map suffixString = new HashMap(); + + + private Color bgColor = null; + + private boolean flagBgColor = false; + + private Font newFont = null; + + private boolean flagNewFont = false; + + private Color fgColor = null; + + private boolean flagFgColor = false; + + private final int nbResource; + + public FilteredDecorationBuilder(IDecorationContext context, int nbResource) { + super(context); + this.nbResource = nbResource; + } + + public void addOverlay(ImageDescriptor overlay) { + Integer result = this.overlay.get(overlay); + if(result == null) { + result = 0; + } + result++; + this.overlay.put(overlay, result); + } + + public void addPrefix(String prefixString) { + Integer result = this.prefixString.get(prefixString); + if(result == null) { + result = 0; + } + result++; + this.prefixString.put(prefixString, result); + } + + public void addSuffix(String suffixString) { + Integer result = this.suffixString.get(suffixString); + if(result == null) { + result = 0; + } + result++; + this.suffixString.put(suffixString, result); + } + + public void setBackgroundColor(Color bgColor) { + if(this.bgColor == null && !flagBgColor) { + this.bgColor = bgColor; + flagBgColor = true; + } else if(this.bgColor != null && !this.bgColor.equals(bgColor)) { + this.bgColor = null; + } + } + + public void setFont(Font newFont) { + if(this.newFont == null && !flagNewFont) { + this.newFont = newFont; + flagNewFont = true; + } else if(this.newFont != null && !this.newFont.equals(newFont)) { + this.newFont = null; + } + } + + public void setForegroundColor(Color fgColor) { + if(this.fgColor == null && !flagFgColor) { + this.fgColor = fgColor; + flagFgColor = true; + } else if(this.fgColor != null && !this.fgColor.equals(fgColor)) { + this.fgColor = null; + } + } + + public void handleDecoration(IDecoration decoration) { + if(fgColor != null) { + decoration.setForegroundColor(fgColor); + } + if(bgColor != null) { + decoration.setBackgroundColor(bgColor); + } + if(newFont != null) { + decoration.setFont(newFont); + } + for(ImageDescriptor desc : overlay.keySet()) { + if(overlay.get(desc) == nbResource) { + decoration.addOverlay(desc); + } + } + for(String s : prefixString.keySet()) { + if(prefixString.get(s) == nbResource) { + decoration.addPrefix(s); + } + } + for(String s : suffixString.keySet()) { + if(suffixString.get(s) == nbResource) { + decoration.addSuffix(s); + } + } + } + } + + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/OneFileModelProvider.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/OneFileModelProvider.java new file mode 100644 index 00000000000..d5be4b85394 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/OneFileModelProvider.java @@ -0,0 +1,62 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.providers; + +import org.eclipse.core.internal.resources.mapping.SimpleResourceMapping; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.mapping.ModelProvider; +import org.eclipse.core.resources.mapping.ResourceMapping; +import org.eclipse.core.resources.mapping.ResourceMappingContext; +import org.eclipse.core.resources.mapping.ResourceTraversal; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.papyrus.infra.onefile.model.mapping.PapyrusResourceMapping; +import org.eclipse.papyrus.infra.onefile.utils.OneFileUtils; + +@SuppressWarnings("restriction") +public class OneFileModelProvider extends ModelProvider { + + public static String MODEL_PROVIDER_ID = "org.eclipse.papyrus.infra.onefile.modelProvider"; + + public OneFileModelProvider() { + } + + public ResourceMapping[] getMappings(IResource resource, ResourceMappingContext context, IProgressMonitor monitor) { + if(OneFileUtils.isDi(resource)) { + return new ResourceMapping[]{ new PapyrusResourceMapping((IFile)resource) }; + } + return new ResourceMapping[]{ new SimpleResourceMapping(resource) }; + } + + @Override + public ResourceMapping[] getMappings(IResource[] resources, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { + return super.getMappings(resources, context, monitor); + } + + @Override + public ResourceTraversal[] getTraversals(ResourceMapping[] mappings, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { + return super.getTraversals(mappings, context, monitor); + } + + @Override + public ResourceMapping[] getMappings(ResourceTraversal[] traversals, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { + return super.getMappings(traversals, context, monitor); + } + + @SuppressWarnings("rawtypes") + @Override + public Object getAdapter(Class adapter) { + return super.getAdapter(adapter); + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusContentProvider.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusContentProvider.java new file mode 100644 index 00000000000..ff36d321448 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusContentProvider.java @@ -0,0 +1,268 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.providers; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.viewers.AbstractTreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.papyrus.infra.onefile.matcher.OnlyDiFilter; +import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; +import org.eclipse.papyrus.infra.onefile.model.PapyrusModelHelper; +import org.eclipse.papyrus.infra.onefile.utils.OneFileUtils; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.model.WorkbenchContentProvider; +import org.eclipse.ui.navigator.CommonViewer; + +/** + * Content provider able to retrieve Papyrus children from an {@link IContainer} + * + * @author Tristan FAURE + * + */ +public class PapyrusContentProvider extends WorkbenchContentProvider { + + + private CommonViewer common; + + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + super.inputChanged(viewer, oldInput, newInput); + if(viewer instanceof CommonViewer) { + common = (CommonViewer)viewer; + } + } + + /** + * Determine if the current navigator is filtered or not + * + * @return true if the viewer is filtered + */ + public boolean isFiltered() { + return common != null && common.getNavigatorContentService() != null && common.getNavigatorContentService().getFilterService() != null && common.getNavigatorContentService().getFilterService().isActive(OnlyDiFilter.FILTER_ID); + } + + @Override + public void dispose() { + super.dispose(); + } + + public Object[] getElements(Object inputElement) { + if(inputElement instanceof IWorkspaceRoot) { + return null; + } + List result = new LinkedList(); + try { + if(isFiltered()) { + if(inputElement instanceof IPapyrusFile) { + IPapyrusFile file = (IPapyrusFile)inputElement; + for(IResource r : file.getAssociatedResources()) { + result.add(PapyrusModelHelper.getPapyrusModelFactory().createISubResourceFile(file, (IFile)r)); + } + } else { + IResource[] members = null; + if(inputElement instanceof IContainer) { + members = ((IContainer)inputElement).members(); + } + if(members != null) { + for(IResource r : members) { + if(r instanceof IContainer && !(r instanceof IProject)) { + IContainer cont = (IContainer)r; + result.add(cont); + } else if(r instanceof IFile) { + if(OneFileUtils.isDi(r)) { + IPapyrusFile createIPapyrusFile = PapyrusModelHelper.getPapyrusModelFactory().createIPapyrusFile((IFile)r); + result.add(createIPapyrusFile); + } else { + if(!OneFileUtils.diExists(r.getName(), r.getParent())) { + result.add(r); + } + } + } else { + result.add(r); + } + } + } + } + + } + } catch (CoreException e) { + } + return result.isEmpty() ? null : result.toArray(); + } + + public Object[] getChildren(Object inputElement) { + return getElements(inputElement); + } + + public Object getParent(Object element) { + if(element instanceof IPapyrusFile) { + IPapyrusFile papyFile = (IPapyrusFile)element; + return papyFile.getParent(); + } + return null; + } + + public boolean hasChildren(Object element) { + return OneFileUtils.hasChildren(element); + } + + @Override + protected void processDelta(IResourceDelta delta) { + super.processDelta(delta); + if(!isFiltered()) { + return; + } + Control ctrl = common.getControl(); + if(ctrl == null || ctrl.isDisposed()) { + return; + } + + + final Collection runnables = new ArrayList(); + processPapyrusDelta(delta, runnables); + + if(runnables.isEmpty()) { + return; + } + + //Are we in the UIThread? If so spin it until we are done + ctrl.getDisplay().asyncExec(new Runnable() { + + /* + * (non-Javadoc) + * + * @see java.lang.Runnable#run() + */ + public void run() { + //Abort if this happens after disposes + Control ctrl = common.getControl(); + if(ctrl == null || ctrl.isDisposed()) { + return; + } + runUpdates(runnables); + } + }); + + } + + private void runUpdates(Collection runnables) { + Iterator runnableIterator = runnables.iterator(); + while(runnableIterator.hasNext()) { + ((Runnable)runnableIterator.next()).run(); + } + + } + + protected void processPapyrusDelta(IResourceDelta delta, Collection runnables) { + IResourceDelta[] affectedChildren = delta.getAffectedChildren(IResourceDelta.CHANGED); + + // Handle changed children . + for(int i = 0; i < affectedChildren.length; i++) { + processPapyrusDelta(affectedChildren[i], runnables); + } + + IResourceDelta[] addedChildren = delta.getAffectedChildren(IResourceDelta.ADDED); + + final Object[] addedObjects; + + // Process additions before removals as to not cause selection + // preservation prior to new objects being added + // Handle added children. Issue one update for all insertions. + if(addedChildren.length > 0) { + addedObjects = new Object[addedChildren.length]; + for(int i = 0; i < addedChildren.length; i++) { + addedObjects[i] = addedChildren[i].getResource(); + } + } else { + addedObjects = new Object[0]; + } + + // Handle removed children. Issue one update for all removals. + // heuristic test for items moving within same folder (i.e. renames) + Runnable addAndRemove = new Runnable() { + + public void run() { + if(common instanceof AbstractTreeViewer) { + AbstractTreeViewer treeViewer = (AbstractTreeViewer)common; + // Disable redraw until the operation is finished so we don't + // get a flash of both the new and old item (in the case of + // rename) + // Only do this if we're both adding and removing files (the + // rename case) + try { + // need to handle resource addition + if(addedObjects.length > 0) { + ArrayList elements = new ArrayList(addedObjects.length); + ArrayList toAdd = new ArrayList(addedObjects.length); + for(Object r : addedObjects) { + if(r instanceof IResource) { + IResource current = (IResource)r; + if(OneFileUtils.diExists(current.getName(), current.getParent())) { + elements.add(PapyrusModelHelper.getPapyrusModelFactory().createIPapyrusFile(OneFileUtils.getDi(current.getName(), current.getParent()))); + } + if(OneFileUtils.isDi(current)) { + toAdd.add(PapyrusModelHelper.getPapyrusModelFactory().createIPapyrusFile((IFile)current)); + } + } + } + for(Object o : elements) { + common.refresh(o); + } + for(IPapyrusFile o : toAdd) { + common.add(o.getParent(), o); + } + } + } finally { + + } + } + } + }; + runnables.add(addAndRemove); + } + + // @Override + // protected ITreeContentProvider getDelegateContentProvider() { + // if(provider == null) { + // provider = new WorkbenchContentProvider(); + // } + // return provider; + // } + // + // @Override + // protected String getModelProviderId() { + // return OneFileModelProvider.MODEL_PROVIDER_ID; + // } + // + // @Override + // protected Object getModelRoot() { + // return null; + // } + + // @Override + // protected ResourceTraversal[] getTraversals(ISynchronizationContext context, Object object) { + // return null; + // } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusLabelProvider.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusLabelProvider.java new file mode 100644 index 00000000000..b1b4a45581f --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusLabelProvider.java @@ -0,0 +1,67 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.providers; + +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; +import org.eclipse.papyrus.infra.onefile.model.ISubResourceFile; +import org.eclipse.swt.graphics.Image; + +/** + * Label Provider for Papyrus Model Elements + * + * @author tristan.faure@atosorigin.com + * + */ +public class PapyrusLabelProvider implements ILabelProvider { + + public void addListener(ILabelProviderListener listener) { + } + + public void dispose() { + } + + public boolean isLabelProperty(Object element, String property) { + return true; + } + + public void removeListener(ILabelProviderListener listener) { + } + + public Image getImage(Object element) { + if (element instanceof IPapyrusFile) { + IPapyrusFile papyFile = (IPapyrusFile) element; + return papyFile.getImage(); + } + if (element instanceof ISubResourceFile) { + return ((ISubResourceFile) element).getImage(); + } + return null; + } + + public String getText(Object element) { + if (element instanceof IPapyrusFile) { + IPapyrusFile papyFile = (IPapyrusFile) element; + return papyFile.getText(); + } + if (element instanceof ISubResourceFile) { + return ((ISubResourceFile) element).getText(); + } + if (element instanceof IResource) { + return ((IResource) element).getName(); + } + return null; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusModelActionProvider.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusModelActionProvider.java new file mode 100644 index 00000000000..82654f67490 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusModelActionProvider.java @@ -0,0 +1,316 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.providers; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; +import org.eclipse.papyrus.infra.onefile.utils.OneFileUtils; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbenchCommandConstants; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.WorkbenchException; +import org.eclipse.ui.actions.ActionContext; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.actions.CopyResourceAction; +import org.eclipse.ui.actions.DeleteResourceAction; +import org.eclipse.ui.actions.MoveResourceAction; +import org.eclipse.ui.actions.RefreshAction; +import org.eclipse.ui.actions.RenameResourceAction; +import org.eclipse.ui.ide.IDE; +import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; +import org.eclipse.ui.navigator.CommonActionProvider; +import org.eclipse.ui.navigator.ICommonActionConstants; +import org.eclipse.ui.navigator.ICommonActionExtensionSite; +import org.eclipse.ui.navigator.ICommonMenuConstants; +import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite; + +/** + * Actions available through an {@link IPapyrusFile} + * + * @author tfaure + * + */ +@SuppressWarnings({ "restriction", "rawtypes" }) +public class PapyrusModelActionProvider extends CommonActionProvider { + + private boolean fInViewPart = false; + + private ICommonViewerWorkbenchSite workbenchSite; + + private Action openAction; + + private Action deleteAction; + + private Action copyAction; + + private Action renameAction; + + private Action refreshAction; + + private Action moveAction; + + public PapyrusModelActionProvider() { + + } + + @Override + protected boolean filterAction(IAction action) { + return super.filterAction(action); + } + + @Override + public void fillActionBars(IActionBars actionBars) { + if(fInViewPart) { + actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, openAction); + actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction); + actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction); + actionBars.setGlobalActionHandler(ActionFactory.MOVE.getId(), moveAction); + actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction); + actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction); + + } + super.fillActionBars(actionBars); + } + + @Override + public void fillContextMenu(IMenuManager menu) { + super.fillContextMenu(menu); + appendToGroup(menu, openAction, ICommonMenuConstants.GROUP_OPEN); + appendToGroup(menu, deleteAction, ICommonMenuConstants.GROUP_EDIT); + appendToGroup(menu, moveAction, ICommonMenuConstants.GROUP_EDIT); + appendToGroup(menu, copyAction, ICommonMenuConstants.GROUP_EDIT); + appendToGroup(menu, renameAction, ICommonMenuConstants.GROUP_EDIT); + appendToGroup(menu, refreshAction, ICommonMenuConstants.GROUP_EDIT); + } + + private void appendToGroup(IMenuManager menu, IAction action, String id) { + if(action != null && action.isEnabled()) { + menu.appendToGroup(id, action); + } + } + + @Override + public void init(ICommonActionExtensionSite site) { + if(site.getViewSite() instanceof ICommonViewerWorkbenchSite) { + workbenchSite = (ICommonViewerWorkbenchSite)site.getViewSite(); + } + if(workbenchSite != null) { + if(workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) { + fInViewPart = true; + } + makeActions(); + } + } + + private void makeActions() { + final IWorkbenchPartSite provider = workbenchSite.getSite(); + final ActionHelper helper = new ActionHelper(); + openAction = new Action() { + + @Override + public void run() { + if(getIFile() != null) { + try { + IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), getIFile(), true); + } catch (WorkbenchException e) { + } + } + } + + public IFile getIFile() { + return helper.getIFile(getContext()); + } + + @Override + public boolean isEnabled() { + return getIFile() != null; + } + + @Override + public String getText() { + return IDEWorkbenchMessages.OpenFileAction_text; + } + }; + + deleteAction = new DeleteResourceAction(provider) { + + @Override + public boolean isEnabled() { + return getSelectedResources() != null && getSelectedResources().size() > 0 && OneFileUtils.isDi((IResource)getSelectedResources().get(0)); + + } + + @Override + public IStructuredSelection getStructuredSelection() { + return helper.getOneStructuredSelection(getContext()); + } + + @Override + protected List getSelectedResources() { + return helper.getOneSelectedResources(getContext()); + } + }; + + moveAction = new MoveResourceAction(provider) { + + @Override + public IStructuredSelection getStructuredSelection() { + return helper.getStructuredSelection(getContext()); + } + + @Override + protected List getSelectedResources() { + return helper.getSelectedResources(getContext()); + } + }; + + copyAction = new CopyResourceAction(provider) { + + @Override + public IStructuredSelection getStructuredSelection() { + return helper.getStructuredSelection(getContext()); + } + + @Override + protected List getSelectedResources() { + return helper.getSelectedResources(getContext()); + } + }; + + renameAction = new RenameResourceAction(provider) { + + @Override + public IStructuredSelection getStructuredSelection() { + IStructuredSelection selec = helper.getOneStructuredSelection(getContext()); + return selec != null ? selec : super.getStructuredSelection(); + } + + @Override + protected List getSelectedResources() { + return helper.getOneSelectedResources(getContext()); + } + + }; + + refreshAction = new RefreshAction(provider) { + + @Override + public void run() { + super.run(); + } + + }; + + makeAction(openAction, ICommonActionConstants.OPEN, ISharedImages.IMG_TOOL_COPY, ISharedImages.IMG_TOOL_COPY_DISABLED); + makeAction(deleteAction, IWorkbenchCommandConstants.EDIT_DELETE, ISharedImages.IMG_TOOL_DELETE, ISharedImages.IMG_TOOL_DELETE_DISABLED); + makeAction(moveAction, ActionFactory.MOVE.getId(), null, null); + makeAction(copyAction, IWorkbenchCommandConstants.EDIT_CUT, ISharedImages.IMG_TOOL_CUT, ISharedImages.IMG_TOOL_CUT_DISABLED); + makeAction(copyAction, IWorkbenchCommandConstants.EDIT_COPY, ISharedImages.IMG_TOOL_COPY, ISharedImages.IMG_TOOL_COPY_DISABLED); + makeAction(refreshAction, ActionFactory.REFRESH.getCommandId(), null, null); + } + + protected void makeAction(Action action, String id, String imgTool, String imgToolDisabled) { + if(action != null) { + ISharedImages images = PlatformUI.getWorkbench().getSharedImages(); + if(id != null) { + action.setId(id); + action.setActionDefinitionId(id); + } + if(imgTool != null) { + action.setImageDescriptor(images.getImageDescriptor(imgTool)); + } + if(imgToolDisabled != null) { + action.setDisabledImageDescriptor(images.getImageDescriptor(imgToolDisabled)); + } + } + } + + public static class ActionHelper { + + public IStructuredSelection getStructuredSelection(ActionContext context) { + return new StructuredSelection(getSelectedResources(context)); + } + + public List getOneSelectedResources(ActionContext context) { + List selectedResources = getSelectedResources(context); + if(selectedResources.size() > 0) { + for(Iterator i = selectedResources.iterator(); i.hasNext();) { + Object o = i.next(); + if(o instanceof IFile) { + IFile file = (IFile)o; + if(!OneFileUtils.isDi(file)) { + i.remove(); + } + } + } + return selectedResources; + } + return Collections.EMPTY_LIST; + } + + public IStructuredSelection getOneStructuredSelection(ActionContext context) { + List selectedResources = getOneSelectedResources(context); + if(selectedResources.size() > 0) { + return new StructuredSelection(selectedResources); + } + return null; + } + + protected List getSelectedResources(ActionContext context) { + ISelection selec = context.getSelection(); + List resources = new ArrayList(); + if(selec instanceof IStructuredSelection) { + IStructuredSelection struc = (IStructuredSelection)selec; + for(Iterator i = struc.iterator(); i.hasNext();) { + Object o = i.next(); + if(o instanceof IPapyrusFile) { + IPapyrusFile papy = (IPapyrusFile)o; + resources.addAll(Arrays.asList(papy.getAssociatedResources())); + } + } + } + return resources; + } + + public IFile getIFile(ActionContext context) { + ISelection selec = context.getSelection(); + if(selec instanceof IStructuredSelection) { + IStructuredSelection struc = (IStructuredSelection)selec; + Object firstElement = struc.getFirstElement(); + if(firstElement instanceof IFile) { + IFile file = (IFile)firstElement; + return file; + } else if(firstElement instanceof IPapyrusFile) { + return (IFile)((IPapyrusFile)firstElement).getMainFile(); + } + } + return null; + } + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusViewerSorter.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusViewerSorter.java new file mode 100644 index 00000000000..d23d9d1acb5 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/providers/PapyrusViewerSorter.java @@ -0,0 +1,54 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.providers; + +import java.text.Collator; + +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; +import org.eclipse.ui.views.navigator.ResourceComparator; + +/** + * Sort Papyrus Files according to their Main File + * + * @author tristan.faure@atosorigin.com + */ +public class PapyrusViewerSorter extends ViewerSorter { + + /** + * {@link ResourceComparator} for comparison delegation + */ + ResourceComparator comp = new ResourceComparator(ResourceComparator.TYPE); + + public PapyrusViewerSorter() { + super(); + } + + public PapyrusViewerSorter(Collator collator) { + super(collator); + } + + @Override + public int compare(Viewer viewer, Object e1, Object e2) { + if (e1 instanceof IPapyrusFile) { + IPapyrusFile papyrusFile = (IPapyrusFile) e1; + e1 = papyrusFile.getMainFile(); + } + if (e2 instanceof IPapyrusFile) { + IPapyrusFile papyrusFile = (IPapyrusFile) e2; + e2 = papyrusFile.getMainFile(); + } + return comp.compare(viewer, e1, e2); + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/utils/OneFileUtils.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/utils/OneFileUtils.java new file mode 100644 index 00000000000..5362eab6a69 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/utils/OneFileUtils.java @@ -0,0 +1,343 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin Integration. + * + * 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: + * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.onefile.utils; + +import java.util.ArrayList; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel; +import org.eclipse.papyrus.infra.onefile.Activator; +import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; +import org.eclipse.papyrus.infra.onefile.model.ISubResourceFile; +import org.eclipse.papyrus.infra.onefile.model.PapyrusModelHelper; +import org.eclipse.ui.IEditorDescriptor; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorReference; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; +import org.eclipse.ui.part.FileEditorInput; + +/** + * Utility methods + * + * @author tristan.faure@atosorigin.com + * + */ +public class OneFileUtils { + + /** + * Determines if a di exist in the container from a file name + * + * @param fileName + * @param parent + * @return + */ + public static boolean diExists(String fileName, IContainer parent) { + return getDi(fileName, parent) != null; + } + + /** + * Determines if a di exist in the container from a file name + * + * @param fileName + * @param parent + * @return + */ + public static IFile getDi(String fileName, IContainer parent) { + if(parent == null || parent.getType() == IResource.ROOT) { + return null; + } + String substring = fileName; + if(fileName.indexOf('.') > 0) { + substring = fileName.substring(0, fileName.lastIndexOf('.')); + } + IFile file = parent.getFile(new Path(substring + "." + DiModel.DI_FILE_EXTENSION)); + if(file.exists()) { + return file; + } + return null; + } + + /** + * check if the element has children or not + * + * @param element + * @return + */ + public static boolean hasChildren(Object element) { + if(element instanceof IContainer) { + IContainer container = (IContainer)element; + try { + return container.members().length > 0; + } catch (CoreException e) { + } + } + if(element instanceof IPapyrusFile) { + IPapyrusFile iPapyrusFile = (IPapyrusFile)element; + return iPapyrusFile.getMainFile() != null && iPapyrusFile.getAssociatedResources().length > 1; + } + return false; + } + + /** + * Check if the element in parameter is visible or not + * + * @param element + * @return + */ + public static boolean isVisible(Object element) { + boolean typeOk = element instanceof IPapyrusFile || element instanceof IProject || element instanceof IFile || element instanceof IContainer || element instanceof ISubResourceFile; + if(typeOk && element instanceof IFile) { + IFile file = (IFile)element; + typeOk &= !OneFileUtils.diExists(file.getName(), file.getParent()); + } + return typeOk; + } + + /** + * Check if the resource is a Papyrus Di + * + * @param fileName + * @return + */ + public static boolean isDi(IResource fileName) { + return PapyrusModelHelper.getPapyrusModelFactory().isDi(fileName); + } + + /** + * Returns the name without the extension of the file + * + * @param res + * @return + */ + public static String withoutFileExtension(IResource res) { + if(res.getFileExtension() != null && res.getFileExtension().length() > 0) { + return res.getName().substring(0, res.getName().lastIndexOf('.')); + } else { + return res.getName(); + } + } + + /** + * Check if the resource has a DI inside it + * + * @param resource + * @return + */ + public static boolean containsModelFiles(IResource resource) { + if(resource instanceof IContainer) { + IContainer container = (IContainer)resource; + try { + for(IResource m : container.members()) { + if(isDi(m)) { + return true; + } + } + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return false; + } + + /** + * Check if the object is in an already opened editor + * + * @param inputElement + * @return + */ + public static IEditorPart isOpenInEditor(Object inputElement) { + IEditorPart editor = findEditor(inputElement, false); + if(editor != null) { + return editor; + } + IEditorInput input = getEditorInput(inputElement); + if(input != null) { + + IWorkbenchPage p = getActivePage(); + if(p != null) { + return p.findEditor(input); + } + } + return null; + } + + /** + * Find an editor opening the input element + * + * @param inputElement + * @param activate + * , if activate is true, once the editor is found it is + * activated + * @return null if no editor is found + */ + private static IEditorPart findEditor(Object inputElement, boolean activate) { + if(inputElement instanceof IPapyrusFile) { + IPapyrusFile cu = (IPapyrusFile)inputElement; + if(cu != null) { + IWorkbenchPage page = getActivePage(); + for(IEditorReference ref : page.getEditorReferences()) { + IEditorPart editor = ref.getEditor(false); + if(editor != null) { + IEditorInput editorInput; + editorInput = (IEditorInput)editor.getEditorInput(); + if(cu.getMainFile().equals(editorInput.getAdapter(IFile.class))) { + if(activate && page.getActivePart() != editor) { + page.activate(editor); + } + return editor; + } + } + } + } + } + return null; + } + + /** + * Open the editor corresponding to the inpur element + * + * @param inputElement + * @param activate + * @return + * @throws PartInitException + */ + public static IEditorPart openInEditor(Object inputElement, boolean activate) throws PartInitException { + + if(inputElement instanceof IFile) { + return openInEditor((IFile)inputElement, activate); + } + IEditorPart editor = findEditor(inputElement, activate); + if(editor != null) { + return editor; + } + IEditorInput input = getEditorInput(inputElement); + if(input == null) { + throw new PartInitException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "not found")); + } + return openInEditor(input, getEditorID(input), activate); + } + + /** + * Get the editor input for the given element + * + * @param inputElement + * @return + */ + private static IEditorInput getEditorInput(Object inputElement) { + if(inputElement instanceof IFile) { + IFile file = (IFile)inputElement; + return new FileEditorInput(file); + } + return null; + } + + /** + * Get the editor id for an editor input + * + * @param input + * @return + * @throws PartInitException + */ + public static String getEditorID(IEditorInput input) throws PartInitException { + + Assert.isNotNull(input); + + IEditorDescriptor editorDescriptor; + + if(input instanceof IFileEditorInput) + editorDescriptor = IDE.getEditorDescriptor(((IFileEditorInput)input).getFile()); + else { + editorDescriptor = IDE.getEditorDescriptor(input.getName()); + } + return editorDescriptor.getId(); + + } + + /** + * @param file + * @param activate + * @return + * @throws PartInitException + */ + private static IEditorPart openInEditor(IFile file, boolean activate) throws PartInitException { + + if(file == null) { + throw new PartInitException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "not found")); + } + + IWorkbenchPage p = getActivePage(); + + if(p == null) { + throw new PartInitException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "not found")); + } + + IEditorPart editorPart = IDE.openEditor(p, file, activate); + + return editorPart; + + } + + /** + * Get the active Page + * + * @return + */ + public static IWorkbenchPage getActivePage() { + IWorkbench workbench = PlatformUI.getWorkbench(); + if(workbench == null) { + return null; + } + IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); + if(activeWorkbenchWindow == null) { + return null; + } + return activeWorkbenchWindow.getActivePage(); + } + + private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) throws PartInitException { + Assert.isNotNull(input); + Assert.isNotNull(editorID); + IWorkbenchPage p = getActivePage(); + if(p == null) { + throw new PartInitException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "not found")); + } + IEditorPart editorPart = p.openEditor(input, editorID, activate); + return editorPart; + + } + + public static IFile[] getAssociatedFiles(IPapyrusFile papyrusFile) { + ArrayList files = new ArrayList(); + for(IResource res : papyrusFile.getAssociatedResources()) { + if(res instanceof IFile) { + files.add((IFile)res); + } + } + return files.toArray(new IFile[files.size()]); + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/Activator.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/Activator.java deleted file mode 100644 index 8794e7bf4ec..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/Activator.java +++ /dev/null @@ -1,69 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile; - -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.onefile"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext - * ) - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext - * ) - */ - @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; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/matcher/OnlyDiFilter.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/matcher/OnlyDiFilter.java deleted file mode 100644 index a645022d0b7..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/matcher/OnlyDiFilter.java +++ /dev/null @@ -1,55 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.matcher; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.papyrus.onefile.utils.OneFileUtils; - -/** - * Filter hiding di files and associated. the filter enables the content - * provider - * - * @author tfaure - * - */ -public class OnlyDiFilter extends ViewerFilter { - - public static final String FILTER_ID = "org.eclipse.papyrus.onefile.onlyDiFilter"; - - /* - * (non-Javadoc) - * - * @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) { - return OneFileUtils.isVisible(element); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.viewers.ViewerFilter#isFilterProperty(java.lang.Object, - * java.lang.String) - * - * @Override - */ - public boolean isFilterProperty(Object element, String property) { - return true; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusElement.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusElement.java deleted file mode 100644 index 66534e04029..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusElement.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.eclipse.papyrus.onefile.model; - -import org.eclipse.core.resources.IProject; -import org.eclipse.swt.graphics.Image; - -/** - * Basic operations for Papyrus Model Elements - * - * @author tristan.faure@atosorigin.com - * - */ -public interface IPapyrusElement { - /** - * Return the text displayed for the {@link IPapyrusFile} - * - * @return - */ - String getText(); - - /** - * Return the image displayed for the {@link IPapyrusFile} - * - * @return - */ - Image getImage(); - - /** - * Return the project containing the {@link IPapyrusFile} - * - * @return an {@link IProject} - */ - IProject getProject(); - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusFile.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusFile.java deleted file mode 100644 index bceee7730dd..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusFile.java +++ /dev/null @@ -1,56 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.model; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; - -/** - * Contract for Papyrus Files representation - * - * @author tristan.faure@atosorigin.com - * - */ -public interface IPapyrusFile extends IPapyrusElement, IAdaptable { - - /** - * Return the resources associated to the DI, the di must be included in the - * resutl - * - * @return - */ - IResource[] getAssociatedResources(); - - /** - * Return the main file (normally the di) - * - * @return - */ - IFile getMainFile(); - - /** - * Return the parent of the current {@link IPapyrusFile} - * - * @return an IContainer - */ - IContainer getParent(); - - /** - * Return the text displayed for the {@link IPapyrusFile} - * - * @return - */ - String getName(); - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusModelFactory.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusModelFactory.java deleted file mode 100644 index f1b1dd7e27d..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/IPapyrusModelFactory.java +++ /dev/null @@ -1,50 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.model; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; - -/** - * Factory able to create instances of model interfaces - * - * @author tristan.faure@atosorigin.com - * - */ -public interface IPapyrusModelFactory { - - /** - * Create an instance of {@link IPapyrusFile} with the given file - * - * @param file - * @return - */ - IPapyrusFile createIPapyrusFile(IFile file); - - /** - * Create an instanceof {@link IPapyrusFile} with the given file and the - * given {@link IPapyrusFile} - * - * @param papy - * @param r - * @return - */ - ISubResourceFile createISubResourceFile(IPapyrusFile papy, IFile r); - - /** - * Determines if the file in parameter is a di - * - * @param file - * @return - */ - boolean isDi(IResource file); -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/ISubResourceFile.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/ISubResourceFile.java deleted file mode 100644 index 27a14d68728..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/ISubResourceFile.java +++ /dev/null @@ -1,30 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.model; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IAdaptable; - -/** - * Contract for elements bellow an {@link IPapyrusFile} - * - * @author tfaure - * - */ -public interface ISubResourceFile extends IPapyrusElement, IAdaptable { - /** - * Returns the IFile associted to the {@link ISubResourceFile} - * - * @return - */ - IFile getFile(); -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/PapyrusModelHelper.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/PapyrusModelHelper.java deleted file mode 100644 index 10fc49aa819..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/PapyrusModelHelper.java +++ /dev/null @@ -1,111 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.model; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; -import org.eclipse.papyrus.onefile.Activator; -import org.osgi.framework.Bundle; - -/** - * Helper class able to get the correct {@link IPapyrusModelFactory} - * - * @author tfaure - * - */ -public class PapyrusModelHelper { - - private static final String MODEL_FACTORY = "modelFactory"; - static List segments; - - static { - IConfigurationElement[] elements = Platform - .getExtensionRegistry() - .getConfigurationElementsFor(Activator.PLUGIN_ID, MODEL_FACTORY); - segments = new ArrayList(elements.length); - for (IConfigurationElement e : elements) { - Segment s = new PapyrusModelHelper.Segment(); - try { - s.priority = Integer.parseInt(e.getAttribute("priority")); - s.bundle = Platform.getBundle(e.getContributor().getName()); - s.className = e.getAttribute("instance"); - segments.add(s); - } catch (NumberFormatException ex) { - // in case of exception the process continue but the stack is - // traced - ex.printStackTrace(); - } - } - // sort elements according to their priorities - Collections.sort(segments, new Comparator() { - public int compare(Segment o1, Segment o2) { - Integer val1 = 0; - Integer val2 = 0; - if (o1 != null) { - val1 = o1.priority; - } - if (o2 != null) { - val2 = o2.priority; - } - return val1.compareTo(val2); - } - }); - } - - /** - * get the {@link IPapyrusModelFactory} in the current platform - * - * @return a {@link IPapyrusModelFactory} - */ - public static IPapyrusModelFactory getPapyrusModelFactory() { - if (segments == null || segments.size() == 0) { - throw new RuntimeException( - "Initialisation error, please register extension to " - + Activator.PLUGIN_ID + "." + MODEL_FACTORY); - } - // segments are sorted by priorities, the highest is at the end of the - // list - return segments.get(segments.size() - 1).getFactory(); - } - - /** - * Utility class to save extension point information - * - */ - private static class Segment { - public String className; - Bundle bundle; - int priority; - IPapyrusModelFactory instance = null; - - IPapyrusModelFactory getFactory() { - if (instance == null) { - try { - instance = (IPapyrusModelFactory) bundle.loadClass( - className).newInstance(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } - return instance; - } - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/ModelAdapterFactory.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/ModelAdapterFactory.java deleted file mode 100644 index cb1c37f834a..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/ModelAdapterFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.model.adapters; - -import java.util.Arrays; -import java.util.Collection; - -import org.eclipse.core.resources.mapping.ResourceMapping; -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.papyrus.onefile.model.IPapyrusFile; -import org.eclipse.papyrus.onefile.model.mapping.PapyrusResourceMapping; -import org.eclipse.ui.IContributorResourceAdapter; -import org.eclipse.ui.ide.IContributorResourceAdapter2; - -/** - * Adapter factory to adapt {@link IPapyrusFile} - * - * @author tristan.faure@atosorigin.com - */ -@SuppressWarnings("rawtypes") -public class ModelAdapterFactory implements IAdapterFactory { - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, - * java.lang.Class) - */ - public Object getAdapter(Object adaptableObject, Class adapterType) { - if(ResourceMapping.class.equals(adapterType)) { - if(adaptableObject instanceof IPapyrusFile) { - return new PapyrusResourceMapping((IPapyrusFile)adaptableObject); - } - } - if(IContributorResourceAdapter.class.equals(adapterType)) { - return new PapyrusModelContributorResourceAdapter(); - } - if(IContributorResourceAdapter2.class.equals(adapterType)) { - return new PapyrusModelContributorResourceAdapter(); - } - if(Collection.class.equals(adapterType)) { - if(adaptableObject instanceof IPapyrusFile) { - return Arrays.asList(((IPapyrusFile)adaptableObject).getAssociatedResources()); - } - } - return null; - } - - public Class[] getAdapterList() { - return new Class[]{}; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusCommonDropAdapterAssistant.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusCommonDropAdapterAssistant.java deleted file mode 100644 index 76cfb8f4a97..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusCommonDropAdapterAssistant.java +++ /dev/null @@ -1,81 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.model.adapters; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.util.LocalSelectionTransfer; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.papyrus.onefile.model.IPapyrusFile; -import org.eclipse.swt.dnd.DropTargetEvent; -import org.eclipse.swt.dnd.TransferData; -import org.eclipse.ui.navigator.CommonDropAdapter; -import org.eclipse.ui.navigator.resources.ResourceDropAdapterAssistant; - -/** - * Assistant to manage drag and drop of {@link IPapyrusFile} - * {@link IPapyrusFile} are not adapted to {@link IResource} to prevent - * misunderstanding so during transfer the selection is changed - * - * @author tristan.faure@atosorigin.com - * - */ -public class PapyrusCommonDropAdapterAssistant extends - ResourceDropAdapterAssistant { - - @Override - public IStatus validateDrop(Object target, int aDropOperation, - TransferData transferType) { - manageSelection(); - return super.validateDrop(target, aDropOperation, transferType); - } - - @Override - public IStatus handleDrop(CommonDropAdapter aDropAdapter, - DropTargetEvent aDropTargetEvent, Object aTarget) { - manageSelection(); - return super.handleDrop(aDropAdapter, aDropTargetEvent, aTarget); - } - - @Override - protected void doInit() { - super.doInit(); - manageSelection(); - } - - private void manageSelection() { - List elements = new ArrayList(); - ISelection selec = LocalSelectionTransfer.getTransfer().getSelection(); - if (selec instanceof IStructuredSelection) { - IStructuredSelection struc = (IStructuredSelection) selec; - for (Iterator i = struc.iterator(); i.hasNext();) { - Object o = i.next(); - if (o instanceof IPapyrusFile) { - IPapyrusFile papy = (IPapyrusFile) o; - // TODO if a drop assistant is implemented use previous implementation : - // elements.add(papy.getMainFile()); - elements.addAll(Arrays.asList(papy.getAssociatedResources())); - } - } - } - LocalSelectionTransfer.getTransfer().setSelection( - new StructuredSelection(elements)); - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusLinkHelper.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusLinkHelper.java deleted file mode 100644 index cb7ccf737ff..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusLinkHelper.java +++ /dev/null @@ -1,75 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.model.adapters; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.papyrus.onefile.model.IPapyrusFile; -import org.eclipse.papyrus.onefile.model.PapyrusModelHelper; -import org.eclipse.papyrus.onefile.utils.OneFileUtils; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.navigator.ILinkHelper; - -/** - * Link the Papyrus Editor with {@link IPapyrusFile} - * - * @author tristan.faure@atosorigin.com - * - */ -public class PapyrusLinkHelper implements ILinkHelper { - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.navigator.ILinkHelper#findSelection(org.eclipse.ui. - * IEditorInput) - */ - public IStructuredSelection findSelection(IEditorInput anInput) { - List select = new ArrayList(); - if(anInput instanceof IFileEditorInput) { - IFileEditorInput input = (IFileEditorInput)anInput; - IPapyrusFile papy = PapyrusModelHelper.getPapyrusModelFactory().createIPapyrusFile(input.getFile()); - select.add(papy); - IResource res = papy.getMainFile(); - while(res.getParent() != null) { - select.add(0, res.getParent()); - res = res.getParent(); - } - return new StructuredSelection(papy); - } - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.navigator.ILinkHelper#activateEditor(org.eclipse.ui. - * IWorkbenchPage, org.eclipse.jface.viewers.IStructuredSelection) - */ - public void activateEditor(IWorkbenchPage page, IStructuredSelection selection) { - if(selection == null || selection.isEmpty()) - return; - Object element = selection.getFirstElement(); - IEditorPart part = OneFileUtils.isOpenInEditor(element); - if(part != null) { - page.bringToTop(part); - } - - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusModelContributorResourceAdapter.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusModelContributorResourceAdapter.java deleted file mode 100644 index c8af4790309..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/PapyrusModelContributorResourceAdapter.java +++ /dev/null @@ -1,38 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atos.net - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.model.adapters; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.mapping.ResourceMapping; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.ui.ide.IContributorResourceAdapter2; - - -/** - * Another Adapter - * - * @author tfaure - * - */ -public class PapyrusModelContributorResourceAdapter implements IContributorResourceAdapter2 { - - public IResource getAdaptedResource(IAdaptable adaptable) { - IResource res = (IResource)adaptable.getAdapter(IResource.class); - return res; - } - - public ResourceMapping getAdaptedResourceMapping(IAdaptable adaptable) { - ResourceMapping res = (ResourceMapping)adaptable.getAdapter(ResourceMapping.class); - return res; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/SubResourceAdapterFactory.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/SubResourceAdapterFactory.java deleted file mode 100644 index 28d75ecf35c..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/adapters/SubResourceAdapterFactory.java +++ /dev/null @@ -1,56 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.model.adapters; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.mapping.ResourceMapping; -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.papyrus.onefile.model.ISubResourceFile; -import org.eclipse.papyrus.onefile.model.impl.SubResourceFile; -import org.eclipse.papyrus.onefile.model.mapping.SubResourceMapping; -import org.eclipse.ui.IContributorResourceAdapter; - -/** - * Adapter Factory for {@link SubResourceFile} - * - * @author tristan.faure@atosorigin.com - * - */ -public class SubResourceAdapterFactory implements IAdapterFactory { - - public Object getAdapter(Object adaptableObject, Class adapterType) { - if(ResourceMapping.class.equals(adapterType)) { - if(adaptableObject instanceof ISubResourceFile) { - return new SubResourceMapping((ISubResourceFile)adaptableObject); - } - } else if(IFile.class.equals(adapterType)) { - if(adaptableObject instanceof ISubResourceFile) { - return ((ISubResourceFile)adaptableObject).getFile(); - } - } else if(IContributorResourceAdapter.class.equals(adapterType)) { - if(adaptableObject instanceof ISubResourceFile) { - return new PapyrusModelContributorResourceAdapter(); - } - } else if(IResource.class.equals(adapterType)) { - if(adaptableObject instanceof ISubResourceFile) { - return ((ISubResourceFile)adaptableObject).getFile(); - } - } - return null; - } - - public Class[] getAdapterList() { - return new Class[]{}; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusFile.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusFile.java deleted file mode 100644 index 9a2b59d37c6..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusFile.java +++ /dev/null @@ -1,103 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.model.impl; - -import java.util.ArrayList; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.papyrus.core.utils.PapyrusImageUtils; -import org.eclipse.papyrus.onefile.model.IPapyrusFile; -import org.eclipse.papyrus.onefile.utils.OneFileUtils; -import org.eclipse.swt.graphics.Image; - -/** - * Default Implementation of {@link IPapyrusFile} - * - * @author tristan.faure@atosorigin.com - * - */ -public class PapyrusFile implements IPapyrusFile { - - private final IFile file; - - - public PapyrusFile(IFile file) { - this.file = file; - } - - public IFile getMainFile() { - return file; - } - - public IResource[] getAssociatedResources() { - ArrayList files = new ArrayList(); - try { - for(IResource res : file.getParent().members()) { - if(res instanceof IFile && OneFileUtils.withoutFileExtension(file).equals(OneFileUtils.withoutFileExtension(res))) { - files.add((IFile)res); - } - } - } catch (CoreException e) { - } - return files.toArray(new IResource[]{}); - } - - public String getLabel() { - return file.getName(); - } - - - - @Override - public int hashCode() { - return getMainFile().hashCode(); - } - - @Override - public boolean equals(Object obj) { - if(obj instanceof PapyrusFile) { - PapyrusFile papy = (PapyrusFile)obj; - return getMainFile().equals(papy.getMainFile()); - } - return super.equals(obj); - } - - public IProject getProject() { - return file.getProject(); - } - - public IContainer getParent() { - return file.getParent(); - } - - public String getName() { - return file.getName(); - } - - public String getText() { - return getName().substring(0, getName().lastIndexOf('.')); - } - - public Image getImage() { - return PapyrusImageUtils.getDefaultIcon(); - } - - public Object getAdapter(Class adapter) { - return Platform.getAdapterManager().getAdapter(this, adapter); - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusModelFactory.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusModelFactory.java deleted file mode 100644 index cb0dea4719f..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/impl/PapyrusModelFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.model.impl; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.papyrus.onefile.model.IPapyrusFile; -import org.eclipse.papyrus.onefile.model.IPapyrusModelFactory; -import org.eclipse.papyrus.onefile.model.ISubResourceFile; -import org.eclipse.papyrus.resource.sasheditor.DiModel; - -public class PapyrusModelFactory implements IPapyrusModelFactory { - - public IPapyrusFile createIPapyrusFile(IFile file) { - return new PapyrusFile(file); - } - - public ISubResourceFile createISubResourceFile(IPapyrusFile papy, IFile r) { - return new SubResourceFile(papy, r); - } - - public boolean isDi(IResource file) { - return DiModel.DI_FILE_EXTENSION.equals(file.getFileExtension()); - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/impl/SubResourceFile.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/impl/SubResourceFile.java deleted file mode 100644 index 0f7c0006311..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/impl/SubResourceFile.java +++ /dev/null @@ -1,74 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.model.impl; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.papyrus.onefile.model.IPapyrusFile; -import org.eclipse.papyrus.onefile.model.ISubResourceFile; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.PlatformUI; - -/** - * Default implementation of {@link ISubResourceFile} - * - * @author tristan.faure@atosorigin.com - * - */ -public class SubResourceFile implements ISubResourceFile { - @SuppressWarnings("unused") - private IPapyrusFile parent; - private final IFile subResource; - - public SubResourceFile(IPapyrusFile papy, IFile r) { - this.parent = papy; - this.subResource = r; - } - - public IProject getProject() { - return subResource.getProject(); - } - - @Override - public String toString() { - String fileExtension = subResource.getFileExtension(); - return fileExtension != null ? fileExtension : subResource.getName(); - } - - public IFile getFile() { - return subResource; - } - - public Image getImage() { - Image image = JFaceResources.getImage(getFile().getFileExtension()); - if (image == null) { - ImageDescriptor desc = PlatformUI.getWorkbench() - .getEditorRegistry() - .getImageDescriptor(getFile().getName()); - JFaceResources.getImageRegistry().put(getFile().getFileExtension(), - desc); - } - return JFaceResources.getImage(getFile().getFileExtension()); - } - - public String getText() { - return toString(); - } - - public Object getAdapter(Class adapter) { - return Platform.getAdapterManager().getAdapter(this, adapter); - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/mapping/PapyrusResourceMapping.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/mapping/PapyrusResourceMapping.java deleted file mode 100644 index dffb6761d53..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/mapping/PapyrusResourceMapping.java +++ /dev/null @@ -1,84 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.model.mapping; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.resources.mapping.ResourceMapping; -import org.eclipse.core.resources.mapping.ResourceMappingContext; -import org.eclipse.core.resources.mapping.ResourceTraversal; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.papyrus.onefile.model.IPapyrusFile; -import org.eclipse.papyrus.onefile.model.PapyrusModelHelper; -import org.eclipse.papyrus.onefile.providers.OneFileModelProvider; - -/** - * Resource Mapping for Papyrus File - * - */ -public class PapyrusResourceMapping extends ResourceMapping { - - private final IPapyrusFile papyrusFile; - - public PapyrusResourceMapping(IPapyrusFile adaptableObject) { - this.papyrusFile = adaptableObject; - } - - public PapyrusResourceMapping(IFile resource) { - this.papyrusFile = PapyrusModelHelper.getPapyrusModelFactory() - .createIPapyrusFile(resource); - } - - @Override - public Object getModelObject() { - return papyrusFile; - } - - @Override - public String getModelProviderId() { - return OneFileModelProvider.MODEL_PROVIDER_ID; - } - - @Override - public IProject[] getProjects() { - return new IProject[] { papyrusFile.getProject() }; - } - - @Override - public ResourceTraversal[] getTraversals(ResourceMappingContext context, - IProgressMonitor monitor) throws CoreException { - // if (ResourceMappingContext.LOCAL_CONTEXT == context) - // { - // return new ResourceTraversal[]{new ResourceTraversal(new - // IResource[]{papyrusFile.get()}, IResource.DEPTH_ONE, - // IResource.NONE)}; - // } - // else - // { - return new ResourceTraversal[] { new ResourceTraversal( - papyrusFile.getAssociatedResources(), IResource.DEPTH_INFINITE, - IResource.NONE) }; - // } - - } - - @Override - public void accept(ResourceMappingContext context, - IResourceVisitor visitor, IProgressMonitor monitor) - throws CoreException { - super.accept(context, visitor, monitor); - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/mapping/SubResourceMapping.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/mapping/SubResourceMapping.java deleted file mode 100644 index 5eb0ae7de8a..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/model/mapping/SubResourceMapping.java +++ /dev/null @@ -1,71 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.model.mapping; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.resources.mapping.ResourceMapping; -import org.eclipse.core.resources.mapping.ResourceMappingContext; -import org.eclipse.core.resources.mapping.ResourceTraversal; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.papyrus.onefile.model.ISubResourceFile; -import org.eclipse.papyrus.onefile.providers.OneFileModelProvider; - -public class SubResourceMapping extends ResourceMapping { - private final ISubResourceFile file; - - public SubResourceMapping(ISubResourceFile adaptableObject) { - this.file = adaptableObject; - } - - @Override - public Object getModelObject() { - return file; - } - - @Override - public String getModelProviderId() { - return OneFileModelProvider.MODEL_PROVIDER_ID; - } - - @Override - public IProject[] getProjects() { - return new IProject[] { file.getProject() }; - } - - @Override - public ResourceTraversal[] getTraversals(ResourceMappingContext context, - IProgressMonitor monitor) throws CoreException { - // if (ResourceMappingContext.LOCAL_CONTEXT == context) - // { - // return new ResourceTraversal[]{new ResourceTraversal(new - // IResource[]{papyrusFile.get()}, IResource.DEPTH_ONE, - // IResource.NONE)}; - // } - // else - // { - return new ResourceTraversal[] { new ResourceTraversal( - new IResource[] { file.getFile() }, IResource.DEPTH_INFINITE, - IResource.NONE) }; - // } - - } - - @Override - public void accept(ResourceMappingContext context, - IResourceVisitor visitor, IProgressMonitor monitor) - throws CoreException { - super.accept(context, visitor, monitor); - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/ISubresourceFileActionProvider.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/ISubresourceFileActionProvider.java deleted file mode 100644 index 572f3fd52b3..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/ISubresourceFileActionProvider.java +++ /dev/null @@ -1,76 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin) tristan.faure@ato.net - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.providers; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.actions.ActionContext; -import org.eclipse.ui.internal.navigator.resources.actions.EditActionProvider; - - -/** - * An edit action provider to provide Copy/Paste/Delete on sub resources - * - * @author Tristan Faure - * - */ -@SuppressWarnings("restriction") -public class ISubresourceFileActionProvider extends EditActionProvider { - - @Override - public void setContext(ActionContext context) { - // TODO Auto-generated method stub - List resources = new LinkedList(); - if(context.getSelection() instanceof IStructuredSelection) { - IStructuredSelection contextSelec = (IStructuredSelection)context.getSelection(); - for(Iterator i = contextSelec.iterator(); i.hasNext();) { - Object o = i.next(); - IResource res = adapt(o, IResource.class); - if(res != null) { - resources.add(res); - } - } - } - if(!resources.isEmpty()) { - ISelection selec = new StructuredSelection(resources); - super.setContext(new ActionContext(selec)); - } else { - super.setContext(context); - } - } - - @SuppressWarnings("unchecked") - public T adapt(Object o, Class aClass) { - T result = null; - if(aClass.isInstance(o)) { - result = (T)o; - } - if(o instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable)o; - result = (T)adaptable.getAdapter(aClass); - } - if(result == null) { - result = (T)Platform.getAdapterManager().getAdapter(o, aClass); - } - - return result; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/OneFileDecorator.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/OneFileDecorator.java deleted file mode 100644 index f1520787574..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/OneFileDecorator.java +++ /dev/null @@ -1,173 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan FAURE (Atos) tristan.faure@atos.net - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.providers; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IDecoration; -import org.eclipse.jface.viewers.IDecorationContext; -import org.eclipse.jface.viewers.ILightweightLabelDecorator; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.papyrus.onefile.model.IPapyrusFile; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.ui.internal.WorkbenchPlugin; -import org.eclipse.ui.internal.decorators.DecorationBuilder; - - -/** - * This decorator computes decoration of related files - * for each decoration an intersection is made - * and the {@link IPapyrusFile} will have the same decoration of the set - * - * @author tfaure - * - */ -@SuppressWarnings("restriction") -public class OneFileDecorator extends LabelProvider implements ILightweightLabelDecorator { - - public void decorate(Object element, IDecoration decoration) { - if(element instanceof IPapyrusFile) { - IPapyrusFile papy = (IPapyrusFile)element; - IResource[] associatedResources = papy.getAssociatedResources(); - FilteredDecorationBuilder builder = new FilteredDecorationBuilder(decoration.getDecorationContext(), associatedResources.length); - for(IResource r : associatedResources) { - WorkbenchPlugin.getDefault().getDecoratorManager().getLightweightManager().getDecorations(r, builder); - } - builder.handleDecoration(decoration); - } - } - - /** - * The builder which intercepts decoration - * - * @author tfaure - * - */ - protected class FilteredDecorationBuilder extends DecorationBuilder { - - /** overlay, prefix and suffixes can be several so the number of occurences is saved */ - private Map overlay = new HashMap(); - - - private Map prefixString = new HashMap(); - - - private Map suffixString = new HashMap(); - - - private Color bgColor = null; - - private boolean flagBgColor = false; - - private Font newFont = null; - - private boolean flagNewFont = false; - - private Color fgColor = null; - - private boolean flagFgColor = false; - - private final int nbResource; - - public FilteredDecorationBuilder(IDecorationContext context, int nbResource) { - super(context); - this.nbResource = nbResource; - } - - public void addOverlay(ImageDescriptor overlay) { - Integer result = this.overlay.get(overlay); - if(result == null) { - result = 0; - } - result++; - this.overlay.put(overlay, result); - } - - public void addPrefix(String prefixString) { - Integer result = this.prefixString.get(prefixString); - if(result == null) { - result = 0; - } - result++; - this.prefixString.put(prefixString, result); - } - - public void addSuffix(String suffixString) { - Integer result = this.suffixString.get(suffixString); - if(result == null) { - result = 0; - } - result++; - this.suffixString.put(suffixString, result); - } - - public void setBackgroundColor(Color bgColor) { - if(this.bgColor == null && !flagBgColor) { - this.bgColor = bgColor; - flagBgColor = true; - } else if(this.bgColor != null && !this.bgColor.equals(bgColor)) { - this.bgColor = null; - } - } - - public void setFont(Font newFont) { - if(this.newFont == null && !flagNewFont) { - this.newFont = newFont; - flagNewFont = true; - } else if(this.newFont != null && !this.newFont.equals(newFont)) { - this.newFont = null; - } - } - - public void setForegroundColor(Color fgColor) { - if(this.fgColor == null && !flagFgColor) { - this.fgColor = fgColor; - flagFgColor = true; - } else if(this.fgColor != null && !this.fgColor.equals(fgColor)) { - this.fgColor = null; - } - } - - public void handleDecoration(IDecoration decoration) { - if(fgColor != null) { - decoration.setForegroundColor(fgColor); - } - if(bgColor != null) { - decoration.setBackgroundColor(bgColor); - } - if(newFont != null) { - decoration.setFont(newFont); - } - for(ImageDescriptor desc : overlay.keySet()) { - if(overlay.get(desc) == nbResource) { - decoration.addOverlay(desc); - } - } - for(String s : prefixString.keySet()) { - if(prefixString.get(s) == nbResource) { - decoration.addPrefix(s); - } - } - for(String s : suffixString.keySet()) { - if(suffixString.get(s) == nbResource) { - decoration.addSuffix(s); - } - } - } - } - - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/OneFileModelProvider.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/OneFileModelProvider.java deleted file mode 100644 index 128f1f46f97..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/OneFileModelProvider.java +++ /dev/null @@ -1,62 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.providers; - -import org.eclipse.core.internal.resources.mapping.SimpleResourceMapping; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.mapping.ModelProvider; -import org.eclipse.core.resources.mapping.ResourceMapping; -import org.eclipse.core.resources.mapping.ResourceMappingContext; -import org.eclipse.core.resources.mapping.ResourceTraversal; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.papyrus.onefile.model.mapping.PapyrusResourceMapping; -import org.eclipse.papyrus.onefile.utils.OneFileUtils; - -@SuppressWarnings("restriction") -public class OneFileModelProvider extends ModelProvider { - - public static String MODEL_PROVIDER_ID = "org.eclipse.papyrus.onefile.modelProvider"; - - public OneFileModelProvider() { - } - - public ResourceMapping[] getMappings(IResource resource, ResourceMappingContext context, IProgressMonitor monitor) { - if(OneFileUtils.isDi(resource)) { - return new ResourceMapping[]{ new PapyrusResourceMapping((IFile)resource) }; - } - return new ResourceMapping[]{ new SimpleResourceMapping(resource) }; - } - - @Override - public ResourceMapping[] getMappings(IResource[] resources, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { - return super.getMappings(resources, context, monitor); - } - - @Override - public ResourceTraversal[] getTraversals(ResourceMapping[] mappings, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { - return super.getTraversals(mappings, context, monitor); - } - - @Override - public ResourceMapping[] getMappings(ResourceTraversal[] traversals, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { - return super.getMappings(traversals, context, monitor); - } - - @SuppressWarnings("rawtypes") - @Override - public Object getAdapter(Class adapter) { - return super.getAdapter(adapter); - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusContentProvider.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusContentProvider.java deleted file mode 100644 index 49e24dba2e2..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusContentProvider.java +++ /dev/null @@ -1,268 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.providers; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.AbstractTreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.papyrus.onefile.matcher.OnlyDiFilter; -import org.eclipse.papyrus.onefile.model.IPapyrusFile; -import org.eclipse.papyrus.onefile.model.PapyrusModelHelper; -import org.eclipse.papyrus.onefile.utils.OneFileUtils; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.navigator.CommonViewer; - -/** - * Content provider able to retrieve Papyrus children from an {@link IContainer} - * - * @author Tristan FAURE - * - */ -public class PapyrusContentProvider extends WorkbenchContentProvider { - - - private CommonViewer common; - - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - super.inputChanged(viewer, oldInput, newInput); - if(viewer instanceof CommonViewer) { - common = (CommonViewer)viewer; - } - } - - /** - * Determine if the current navigator is filtered or not - * - * @return true if the viewer is filtered - */ - public boolean isFiltered() { - return common != null && common.getNavigatorContentService() != null && common.getNavigatorContentService().getFilterService() != null && common.getNavigatorContentService().getFilterService().isActive(OnlyDiFilter.FILTER_ID); - } - - @Override - public void dispose() { - super.dispose(); - } - - public Object[] getElements(Object inputElement) { - if(inputElement instanceof IWorkspaceRoot) { - return null; - } - List result = new LinkedList(); - try { - if(isFiltered()) { - if(inputElement instanceof IPapyrusFile) { - IPapyrusFile file = (IPapyrusFile)inputElement; - for(IResource r : file.getAssociatedResources()) { - result.add(PapyrusModelHelper.getPapyrusModelFactory().createISubResourceFile(file, (IFile)r)); - } - } else { - IResource[] members = null; - if(inputElement instanceof IContainer) { - members = ((IContainer)inputElement).members(); - } - if(members != null) { - for(IResource r : members) { - if(r instanceof IContainer && !(r instanceof IProject)) { - IContainer cont = (IContainer)r; - result.add(cont); - } else if(r instanceof IFile) { - if(OneFileUtils.isDi(r)) { - IPapyrusFile createIPapyrusFile = PapyrusModelHelper.getPapyrusModelFactory().createIPapyrusFile((IFile)r); - result.add(createIPapyrusFile); - } else { - if(!OneFileUtils.diExists(r.getName(), r.getParent())) { - result.add(r); - } - } - } else { - result.add(r); - } - } - } - } - - } - } catch (CoreException e) { - } - return result.isEmpty() ? null : result.toArray(); - } - - public Object[] getChildren(Object inputElement) { - return getElements(inputElement); - } - - public Object getParent(Object element) { - if(element instanceof IPapyrusFile) { - IPapyrusFile papyFile = (IPapyrusFile)element; - return papyFile.getParent(); - } - return null; - } - - public boolean hasChildren(Object element) { - return OneFileUtils.hasChildren(element); - } - - @Override - protected void processDelta(IResourceDelta delta) { - super.processDelta(delta); - if(!isFiltered()) { - return; - } - Control ctrl = common.getControl(); - if(ctrl == null || ctrl.isDisposed()) { - return; - } - - - final Collection runnables = new ArrayList(); - processPapyrusDelta(delta, runnables); - - if(runnables.isEmpty()) { - return; - } - - //Are we in the UIThread? If so spin it until we are done - ctrl.getDisplay().asyncExec(new Runnable() { - - /* - * (non-Javadoc) - * - * @see java.lang.Runnable#run() - */ - public void run() { - //Abort if this happens after disposes - Control ctrl = common.getControl(); - if(ctrl == null || ctrl.isDisposed()) { - return; - } - runUpdates(runnables); - } - }); - - } - - private void runUpdates(Collection runnables) { - Iterator runnableIterator = runnables.iterator(); - while(runnableIterator.hasNext()) { - ((Runnable)runnableIterator.next()).run(); - } - - } - - protected void processPapyrusDelta(IResourceDelta delta, Collection runnables) { - IResourceDelta[] affectedChildren = delta.getAffectedChildren(IResourceDelta.CHANGED); - - // Handle changed children . - for(int i = 0; i < affectedChildren.length; i++) { - processPapyrusDelta(affectedChildren[i], runnables); - } - - IResourceDelta[] addedChildren = delta.getAffectedChildren(IResourceDelta.ADDED); - - final Object[] addedObjects; - - // Process additions before removals as to not cause selection - // preservation prior to new objects being added - // Handle added children. Issue one update for all insertions. - if(addedChildren.length > 0) { - addedObjects = new Object[addedChildren.length]; - for(int i = 0; i < addedChildren.length; i++) { - addedObjects[i] = addedChildren[i].getResource(); - } - } else { - addedObjects = new Object[0]; - } - - // Handle removed children. Issue one update for all removals. - // heuristic test for items moving within same folder (i.e. renames) - Runnable addAndRemove = new Runnable() { - - public void run() { - if(common instanceof AbstractTreeViewer) { - AbstractTreeViewer treeViewer = (AbstractTreeViewer)common; - // Disable redraw until the operation is finished so we don't - // get a flash of both the new and old item (in the case of - // rename) - // Only do this if we're both adding and removing files (the - // rename case) - try { - // need to handle resource addition - if(addedObjects.length > 0) { - ArrayList elements = new ArrayList(addedObjects.length); - ArrayList toAdd = new ArrayList(addedObjects.length); - for(Object r : addedObjects) { - if(r instanceof IResource) { - IResource current = (IResource)r; - if(OneFileUtils.diExists(current.getName(), current.getParent())) { - elements.add(PapyrusModelHelper.getPapyrusModelFactory().createIPapyrusFile(OneFileUtils.getDi(current.getName(), current.getParent()))); - } - if(OneFileUtils.isDi(current)) { - toAdd.add(PapyrusModelHelper.getPapyrusModelFactory().createIPapyrusFile((IFile)current)); - } - } - } - for(Object o : elements) { - common.refresh(o); - } - for(IPapyrusFile o : toAdd) { - common.add(o.getParent(), o); - } - } - } finally { - - } - } - } - }; - runnables.add(addAndRemove); - } - - // @Override - // protected ITreeContentProvider getDelegateContentProvider() { - // if(provider == null) { - // provider = new WorkbenchContentProvider(); - // } - // return provider; - // } - // - // @Override - // protected String getModelProviderId() { - // return OneFileModelProvider.MODEL_PROVIDER_ID; - // } - // - // @Override - // protected Object getModelRoot() { - // return null; - // } - - // @Override - // protected ResourceTraversal[] getTraversals(ISynchronizationContext context, Object object) { - // return null; - // } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusLabelProvider.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusLabelProvider.java deleted file mode 100644 index d874589462b..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusLabelProvider.java +++ /dev/null @@ -1,67 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.providers; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.papyrus.onefile.model.IPapyrusFile; -import org.eclipse.papyrus.onefile.model.ISubResourceFile; -import org.eclipse.swt.graphics.Image; - -/** - * Label Provider for Papyrus Model Elements - * - * @author tristan.faure@atosorigin.com - * - */ -public class PapyrusLabelProvider implements ILabelProvider { - - public void addListener(ILabelProviderListener listener) { - } - - public void dispose() { - } - - public boolean isLabelProperty(Object element, String property) { - return true; - } - - public void removeListener(ILabelProviderListener listener) { - } - - public Image getImage(Object element) { - if (element instanceof IPapyrusFile) { - IPapyrusFile papyFile = (IPapyrusFile) element; - return papyFile.getImage(); - } - if (element instanceof ISubResourceFile) { - return ((ISubResourceFile) element).getImage(); - } - return null; - } - - public String getText(Object element) { - if (element instanceof IPapyrusFile) { - IPapyrusFile papyFile = (IPapyrusFile) element; - return papyFile.getText(); - } - if (element instanceof ISubResourceFile) { - return ((ISubResourceFile) element).getText(); - } - if (element instanceof IResource) { - return ((IResource) element).getName(); - } - return null; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusModelActionProvider.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusModelActionProvider.java deleted file mode 100644 index c0f27be3527..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusModelActionProvider.java +++ /dev/null @@ -1,316 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.providers; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.papyrus.onefile.model.IPapyrusFile; -import org.eclipse.papyrus.onefile.utils.OneFileUtils; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IWorkbenchCommandConstants; -import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.WorkbenchException; -import org.eclipse.ui.actions.ActionContext; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.actions.CopyResourceAction; -import org.eclipse.ui.actions.DeleteResourceAction; -import org.eclipse.ui.actions.MoveResourceAction; -import org.eclipse.ui.actions.RefreshAction; -import org.eclipse.ui.actions.RenameResourceAction; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; -import org.eclipse.ui.navigator.CommonActionProvider; -import org.eclipse.ui.navigator.ICommonActionConstants; -import org.eclipse.ui.navigator.ICommonActionExtensionSite; -import org.eclipse.ui.navigator.ICommonMenuConstants; -import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite; - -/** - * Actions available through an {@link IPapyrusFile} - * - * @author tfaure - * - */ -@SuppressWarnings({ "restriction", "rawtypes" }) -public class PapyrusModelActionProvider extends CommonActionProvider { - - private boolean fInViewPart = false; - - private ICommonViewerWorkbenchSite workbenchSite; - - private Action openAction; - - private Action deleteAction; - - private Action copyAction; - - private Action renameAction; - - private Action refreshAction; - - private Action moveAction; - - public PapyrusModelActionProvider() { - - } - - @Override - protected boolean filterAction(IAction action) { - return super.filterAction(action); - } - - @Override - public void fillActionBars(IActionBars actionBars) { - if(fInViewPart) { - actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, openAction); - actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction); - actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction); - actionBars.setGlobalActionHandler(ActionFactory.MOVE.getId(), moveAction); - actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction); - actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction); - - } - super.fillActionBars(actionBars); - } - - @Override - public void fillContextMenu(IMenuManager menu) { - super.fillContextMenu(menu); - appendToGroup(menu, openAction, ICommonMenuConstants.GROUP_OPEN); - appendToGroup(menu, deleteAction, ICommonMenuConstants.GROUP_EDIT); - appendToGroup(menu, moveAction, ICommonMenuConstants.GROUP_EDIT); - appendToGroup(menu, copyAction, ICommonMenuConstants.GROUP_EDIT); - appendToGroup(menu, renameAction, ICommonMenuConstants.GROUP_EDIT); - appendToGroup(menu, refreshAction, ICommonMenuConstants.GROUP_EDIT); - } - - private void appendToGroup(IMenuManager menu, IAction action, String id) { - if(action != null && action.isEnabled()) { - menu.appendToGroup(id, action); - } - } - - @Override - public void init(ICommonActionExtensionSite site) { - if(site.getViewSite() instanceof ICommonViewerWorkbenchSite) { - workbenchSite = (ICommonViewerWorkbenchSite)site.getViewSite(); - } - if(workbenchSite != null) { - if(workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) { - fInViewPart = true; - } - makeActions(); - } - } - - private void makeActions() { - final IWorkbenchPartSite provider = workbenchSite.getSite(); - final ActionHelper helper = new ActionHelper(); - openAction = new Action() { - - @Override - public void run() { - if(getIFile() != null) { - try { - IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), getIFile(), true); - } catch (WorkbenchException e) { - } - } - } - - public IFile getIFile() { - return helper.getIFile(getContext()); - } - - @Override - public boolean isEnabled() { - return getIFile() != null; - } - - @Override - public String getText() { - return IDEWorkbenchMessages.OpenFileAction_text; - } - }; - - deleteAction = new DeleteResourceAction(provider) { - - @Override - public boolean isEnabled() { - return getSelectedResources() != null && getSelectedResources().size() > 0 && OneFileUtils.isDi((IResource)getSelectedResources().get(0)); - - } - - @Override - public IStructuredSelection getStructuredSelection() { - return helper.getOneStructuredSelection(getContext()); - } - - @Override - protected List getSelectedResources() { - return helper.getOneSelectedResources(getContext()); - } - }; - - moveAction = new MoveResourceAction(provider) { - - @Override - public IStructuredSelection getStructuredSelection() { - return helper.getStructuredSelection(getContext()); - } - - @Override - protected List getSelectedResources() { - return helper.getSelectedResources(getContext()); - } - }; - - copyAction = new CopyResourceAction(provider) { - - @Override - public IStructuredSelection getStructuredSelection() { - return helper.getStructuredSelection(getContext()); - } - - @Override - protected List getSelectedResources() { - return helper.getSelectedResources(getContext()); - } - }; - - renameAction = new RenameResourceAction(provider) { - - @Override - public IStructuredSelection getStructuredSelection() { - IStructuredSelection selec = helper.getOneStructuredSelection(getContext()); - return selec != null ? selec : super.getStructuredSelection(); - } - - @Override - protected List getSelectedResources() { - return helper.getOneSelectedResources(getContext()); - } - - }; - - refreshAction = new RefreshAction(provider) { - - @Override - public void run() { - super.run(); - } - - }; - - makeAction(openAction, ICommonActionConstants.OPEN, ISharedImages.IMG_TOOL_COPY, ISharedImages.IMG_TOOL_COPY_DISABLED); - makeAction(deleteAction, IWorkbenchCommandConstants.EDIT_DELETE, ISharedImages.IMG_TOOL_DELETE, ISharedImages.IMG_TOOL_DELETE_DISABLED); - makeAction(moveAction, ActionFactory.MOVE.getId(), null, null); - makeAction(copyAction, IWorkbenchCommandConstants.EDIT_CUT, ISharedImages.IMG_TOOL_CUT, ISharedImages.IMG_TOOL_CUT_DISABLED); - makeAction(copyAction, IWorkbenchCommandConstants.EDIT_COPY, ISharedImages.IMG_TOOL_COPY, ISharedImages.IMG_TOOL_COPY_DISABLED); - makeAction(refreshAction, ActionFactory.REFRESH.getCommandId(), null, null); - } - - protected void makeAction(Action action, String id, String imgTool, String imgToolDisabled) { - if(action != null) { - ISharedImages images = PlatformUI.getWorkbench().getSharedImages(); - if(id != null) { - action.setId(id); - action.setActionDefinitionId(id); - } - if(imgTool != null) { - action.setImageDescriptor(images.getImageDescriptor(imgTool)); - } - if(imgToolDisabled != null) { - action.setDisabledImageDescriptor(images.getImageDescriptor(imgToolDisabled)); - } - } - } - - public static class ActionHelper { - - public IStructuredSelection getStructuredSelection(ActionContext context) { - return new StructuredSelection(getSelectedResources(context)); - } - - public List getOneSelectedResources(ActionContext context) { - List selectedResources = getSelectedResources(context); - if(selectedResources.size() > 0) { - for(Iterator i = selectedResources.iterator(); i.hasNext();) { - Object o = i.next(); - if(o instanceof IFile) { - IFile file = (IFile)o; - if(!OneFileUtils.isDi(file)) { - i.remove(); - } - } - } - return selectedResources; - } - return Collections.EMPTY_LIST; - } - - public IStructuredSelection getOneStructuredSelection(ActionContext context) { - List selectedResources = getOneSelectedResources(context); - if(selectedResources.size() > 0) { - return new StructuredSelection(selectedResources); - } - return null; - } - - protected List getSelectedResources(ActionContext context) { - ISelection selec = context.getSelection(); - List resources = new ArrayList(); - if(selec instanceof IStructuredSelection) { - IStructuredSelection struc = (IStructuredSelection)selec; - for(Iterator i = struc.iterator(); i.hasNext();) { - Object o = i.next(); - if(o instanceof IPapyrusFile) { - IPapyrusFile papy = (IPapyrusFile)o; - resources.addAll(Arrays.asList(papy.getAssociatedResources())); - } - } - } - return resources; - } - - public IFile getIFile(ActionContext context) { - ISelection selec = context.getSelection(); - if(selec instanceof IStructuredSelection) { - IStructuredSelection struc = (IStructuredSelection)selec; - Object firstElement = struc.getFirstElement(); - if(firstElement instanceof IFile) { - IFile file = (IFile)firstElement; - return file; - } else if(firstElement instanceof IPapyrusFile) { - return (IFile)((IPapyrusFile)firstElement).getMainFile(); - } - } - return null; - } - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusViewerSorter.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusViewerSorter.java deleted file mode 100644 index 685a6e41802..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/providers/PapyrusViewerSorter.java +++ /dev/null @@ -1,54 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.providers; - -import java.text.Collator; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.papyrus.onefile.model.IPapyrusFile; -import org.eclipse.ui.views.navigator.ResourceComparator; - -/** - * Sort Papyrus Files according to their Main File - * - * @author tristan.faure@atosorigin.com - */ -public class PapyrusViewerSorter extends ViewerSorter { - - /** - * {@link ResourceComparator} for comparison delegation - */ - ResourceComparator comp = new ResourceComparator(ResourceComparator.TYPE); - - public PapyrusViewerSorter() { - super(); - } - - public PapyrusViewerSorter(Collator collator) { - super(collator); - } - - @Override - public int compare(Viewer viewer, Object e1, Object e2) { - if (e1 instanceof IPapyrusFile) { - IPapyrusFile papyrusFile = (IPapyrusFile) e1; - e1 = papyrusFile.getMainFile(); - } - if (e2 instanceof IPapyrusFile) { - IPapyrusFile papyrusFile = (IPapyrusFile) e2; - e2 = papyrusFile.getMainFile(); - } - return comp.compare(viewer, e1, e2); - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/utils/OneFileUtils.java b/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/utils/OneFileUtils.java deleted file mode 100644 index fa339d63a5e..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/onefile/utils/OneFileUtils.java +++ /dev/null @@ -1,343 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin Integration. - * - * 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: - * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.onefile.utils; - -import java.util.ArrayList; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.papyrus.onefile.Activator; -import org.eclipse.papyrus.onefile.model.IPapyrusFile; -import org.eclipse.papyrus.onefile.model.ISubResourceFile; -import org.eclipse.papyrus.onefile.model.PapyrusModelHelper; -import org.eclipse.papyrus.resource.sasheditor.DiModel; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.part.FileEditorInput; - -/** - * Utility methods - * - * @author tristan.faure@atosorigin.com - * - */ -public class OneFileUtils { - - /** - * Determines if a di exist in the container from a file name - * - * @param fileName - * @param parent - * @return - */ - public static boolean diExists(String fileName, IContainer parent) { - return getDi(fileName, parent) != null; - } - - /** - * Determines if a di exist in the container from a file name - * - * @param fileName - * @param parent - * @return - */ - public static IFile getDi(String fileName, IContainer parent) { - if(parent == null || parent.getType() == IResource.ROOT) { - return null; - } - String substring = fileName; - if(fileName.indexOf('.') > 0) { - substring = fileName.substring(0, fileName.lastIndexOf('.')); - } - IFile file = parent.getFile(new Path(substring + "." + DiModel.DI_FILE_EXTENSION)); - if(file.exists()) { - return file; - } - return null; - } - - /** - * check if the element has children or not - * - * @param element - * @return - */ - public static boolean hasChildren(Object element) { - if(element instanceof IContainer) { - IContainer container = (IContainer)element; - try { - return container.members().length > 0; - } catch (CoreException e) { - } - } - if(element instanceof IPapyrusFile) { - IPapyrusFile iPapyrusFile = (IPapyrusFile)element; - return iPapyrusFile.getMainFile() != null && iPapyrusFile.getAssociatedResources().length > 1; - } - return false; - } - - /** - * Check if the element in parameter is visible or not - * - * @param element - * @return - */ - public static boolean isVisible(Object element) { - boolean typeOk = element instanceof IPapyrusFile || element instanceof IProject || element instanceof IFile || element instanceof IContainer || element instanceof ISubResourceFile; - if(typeOk && element instanceof IFile) { - IFile file = (IFile)element; - typeOk &= !OneFileUtils.diExists(file.getName(), file.getParent()); - } - return typeOk; - } - - /** - * Check if the resource is a Papyrus Di - * - * @param fileName - * @return - */ - public static boolean isDi(IResource fileName) { - return PapyrusModelHelper.getPapyrusModelFactory().isDi(fileName); - } - - /** - * Returns the name without the extension of the file - * - * @param res - * @return - */ - public static String withoutFileExtension(IResource res) { - if(res.getFileExtension() != null && res.getFileExtension().length() > 0) { - return res.getName().substring(0, res.getName().lastIndexOf('.')); - } else { - return res.getName(); - } - } - - /** - * Check if the resource has a DI inside it - * - * @param resource - * @return - */ - public static boolean containsModelFiles(IResource resource) { - if(resource instanceof IContainer) { - IContainer container = (IContainer)resource; - try { - for(IResource m : container.members()) { - if(isDi(m)) { - return true; - } - } - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - return false; - } - - /** - * Check if the object is in an already opened editor - * - * @param inputElement - * @return - */ - public static IEditorPart isOpenInEditor(Object inputElement) { - IEditorPart editor = findEditor(inputElement, false); - if(editor != null) { - return editor; - } - IEditorInput input = getEditorInput(inputElement); - if(input != null) { - - IWorkbenchPage p = getActivePage(); - if(p != null) { - return p.findEditor(input); - } - } - return null; - } - - /** - * Find an editor opening the input element - * - * @param inputElement - * @param activate - * , if activate is true, once the editor is found it is - * activated - * @return null if no editor is found - */ - private static IEditorPart findEditor(Object inputElement, boolean activate) { - if(inputElement instanceof IPapyrusFile) { - IPapyrusFile cu = (IPapyrusFile)inputElement; - if(cu != null) { - IWorkbenchPage page = getActivePage(); - for(IEditorReference ref : page.getEditorReferences()) { - IEditorPart editor = ref.getEditor(false); - if(editor != null) { - IEditorInput editorInput; - editorInput = (IEditorInput)editor.getEditorInput(); - if(cu.getMainFile().equals(editorInput.getAdapter(IFile.class))) { - if(activate && page.getActivePart() != editor) { - page.activate(editor); - } - return editor; - } - } - } - } - } - return null; - } - - /** - * Open the editor corresponding to the inpur element - * - * @param inputElement - * @param activate - * @return - * @throws PartInitException - */ - public static IEditorPart openInEditor(Object inputElement, boolean activate) throws PartInitException { - - if(inputElement instanceof IFile) { - return openInEditor((IFile)inputElement, activate); - } - IEditorPart editor = findEditor(inputElement, activate); - if(editor != null) { - return editor; - } - IEditorInput input = getEditorInput(inputElement); - if(input == null) { - throw new PartInitException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "not found")); - } - return openInEditor(input, getEditorID(input), activate); - } - - /** - * Get the editor input for the given element - * - * @param inputElement - * @return - */ - private static IEditorInput getEditorInput(Object inputElement) { - if(inputElement instanceof IFile) { - IFile file = (IFile)inputElement; - return new FileEditorInput(file); - } - return null; - } - - /** - * Get the editor id for an editor input - * - * @param input - * @return - * @throws PartInitException - */ - public static String getEditorID(IEditorInput input) throws PartInitException { - - Assert.isNotNull(input); - - IEditorDescriptor editorDescriptor; - - if(input instanceof IFileEditorInput) - editorDescriptor = IDE.getEditorDescriptor(((IFileEditorInput)input).getFile()); - else { - editorDescriptor = IDE.getEditorDescriptor(input.getName()); - } - return editorDescriptor.getId(); - - } - - /** - * @param file - * @param activate - * @return - * @throws PartInitException - */ - private static IEditorPart openInEditor(IFile file, boolean activate) throws PartInitException { - - if(file == null) { - throw new PartInitException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "not found")); - } - - IWorkbenchPage p = getActivePage(); - - if(p == null) { - throw new PartInitException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "not found")); - } - - IEditorPart editorPart = IDE.openEditor(p, file, activate); - - return editorPart; - - } - - /** - * Get the active Page - * - * @return - */ - public static IWorkbenchPage getActivePage() { - IWorkbench workbench = PlatformUI.getWorkbench(); - if(workbench == null) { - return null; - } - IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); - if(activeWorkbenchWindow == null) { - return null; - } - return activeWorkbenchWindow.getActivePage(); - } - - private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) throws PartInitException { - Assert.isNotNull(input); - Assert.isNotNull(editorID); - IWorkbenchPage p = getActivePage(); - if(p == null) { - throw new PartInitException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "not found")); - } - IEditorPart editorPart = p.openEditor(input, editorID, activate); - return editorPart; - - } - - public static IFile[] getAssociatedFiles(IPapyrusFile papyrusFile) { - ArrayList files = new ArrayList(); - for(IResource res : papyrusFile.getAssociatedResources()) { - if(res instanceof IFile) { - files.add((IFile)res); - } - } - return files.toArray(new IFile[files.size()]); - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/META-INF/MANIFEST.MF b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/META-INF/MANIFEST.MF index 01e7c79878c..4d586056d56 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/META-INF/MANIFEST.MF +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/META-INF/MANIFEST.MF @@ -10,7 +10,7 @@ Bundle-ActivationPolicy: lazy Bundle-Version: 0.9.0.qualifier Bundle-Name: %pluginName Bundle-ManifestVersion: 2 -Bundle-Activator: org.eclipse.papyrus.ui.resources.Activator +Bundle-Activator: org.eclipse.papyrus.infra.ui.resources.Activator Bundle-SymbolicName: org.eclipse.papyrus.infra.ui.resources;singleton:=true Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/OSGI-INF/l10n/bundle.properties b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/OSGI-INF/l10n/bundle.properties index b7cbe34891d..6863156a733 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/OSGI-INF/l10n/bundle.properties +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/OSGI-INF/l10n/bundle.properties @@ -1,4 +1,4 @@ -#Properties file for org.eclipse.papyrus.ui.resources +#Properties file for org.eclipse.papyrus.infra.ui.resources renameParticipant.name = Papyrus Model Renaming deleteParticipant.name = Papyrus Model deleting moveParticipant.name = Papyrus Model Moving \ No newline at end of file diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/build.properties b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/build.properties index b677da13122..78a75fbd49a 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/build.properties +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/build.properties @@ -1,7 +1,23 @@ # #Mon Sep 12 09:30:21 CEST 2011 -bin.includes=META-INF/,.,plugin.properties,plugin.xml,about.html,OSGI-INF/,OSGI-INF/l10n/,OSGI-INF/l10n/bundle.properties,src/org/eclipse/papyrus/ui/resources/refactoring/messages.properties +bin.includes = META-INF/,\ + .,\ + plugin.properties,\ + plugin.xml,\ + about.html,\ + OSGI-INF/,\ + OSGI-INF/l10n/,\ + OSGI-INF/l10n/bundle.properties,\ + src/org/eclipse/papyrus/infra/ui/resources/refactoring/messages.properties output..=bin/ -src.includes=about.html,META-INF/,.,plugin.properties,plugin.xml,OSGI-INF/,OSGI-INF/l10n/,OSGI-INF/l10n/bundle.properties,src/org/eclipse/papyrus/ui/resources/refactoring/messages.properties +src.includes = about.html,\ + META-INF/,\ + .,\ + plugin.properties,\ + plugin.xml,\ + OSGI-INF/,\ + OSGI-INF/l10n/,\ + OSGI-INF/l10n/bundle.properties,\ + src/org/eclipse/papyrus/infra/ui/resources/refactoring/messages.properties source..=src/ bin..=bin/ diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/plugin.xml b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/plugin.xml index f8a0401f551..6fa1c6ef824 100644 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/plugin.xml +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/plugin.xml @@ -4,7 +4,7 @@ @@ -20,7 +20,7 @@ @@ -35,7 +35,7 @@ diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/Activator.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/Activator.java new file mode 100644 index 00000000000..04e8e7c20aa --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/Activator.java @@ -0,0 +1,72 @@ +/***************************************************************************** + * 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.infra.ui.resources; + +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 + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.ui.resources"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** The log service */ + 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; + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/DeleteModelParticipant.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/DeleteModelParticipant.java new file mode 100644 index 00000000000..768162c1aef --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/DeleteModelParticipant.java @@ -0,0 +1,147 @@ +/***************************************************************************** + * 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.infra.ui.resources.refactoring; + +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. + * FIXME Integrate and create register to the extension point + * + * @author Thomas Szadel + * + */ +public class DeleteModelParticipant extends DeleteParticipant { + + /** action name */ + private static final String NAME = "Papyrus Model Deletion"; + + 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 NAME; + } + + /** + * 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/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/DirtyEditorChange.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/DirtyEditorChange.java new file mode 100644 index 00000000000..7375b3b7be9 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/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.infra.ui.resources.refactoring; + +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 Messages.DirtyEditorChange_0; + } + + /** + * @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(), Messages.DirtyEditorChange_1, Messages.DirtyEditorChange_2)) { + status.addFatalError(Messages.DirtyEditorChange_3); + } + } + } + }); + + 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/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/Messages.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/Messages.java new file mode 100644 index 00000000000..e42902e67ce --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/Messages.java @@ -0,0 +1,66 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos Origin. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Arthur Daussy - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.ui.resources.refactoring; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + + private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.ui.resources.refactoring.messages"; //$NON-NLS-1$ + + public static String DirtyEditorChange_0; + + public static String DirtyEditorChange_1; + + public static String DirtyEditorChange_2; + + public static String DirtyEditorChange_3; + + public static String MoveModelParticipant_Name; + + public static String RenameModelChange_0; + + public static String RenameModelChange_5; + + public static String RenameModelChange_6; + + public static String RenameModelChange_7; + + public static String RenameModelChange_8; + + public static String RenameModelChange_Change; + + public static String RenameModelChange_DaveDirtyEditor; + + public static String RenameModelChange_ErrorLoading; + + public static String RenameModelChange_LoadingEMF; + + public static String RenameModelChange_ModifyURI; + + public static String RenameModelChange_Name; + + public static String RenameModelChange_RemoveOldFile; + + public static String RenameModelChange_savingResource; + + public static String RenameModelChange_Unloading; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ModelParticipantHelpers.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ModelParticipantHelpers.java new file mode 100644 index 00000000000..4acaf3f2d5f --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ModelParticipantHelpers.java @@ -0,0 +1,152 @@ +/***************************************************************************** + * 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.infra.ui.resources.refactoring; + +import java.util.ArrayList; +import java.util.Collection; +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.gmf.runtime.notation.Diagram; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel; +import org.eclipse.papyrus.infra.ui.resources.refactoring.ui.RenameParticipantsDialog; +import org.eclipse.swt.widgets.Display; + +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 getResourceToFix(final IFile initialFile) { + + RenameDialogRunnable runnable = new RenameDialogRunnable(initialFile); + Display.getDefault().syncExec(runnable); + return new HashSet(runnable.getFiles()); + } + + /** + * 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(final IFile initialFile) { + + + 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) { + } + } + + Set relatedFiles = new HashSet(); + if(diPath != null) { + IFile diFile = parent.getFile(diPath.makeRelativeTo(parent.getFullPath())); + if(diFile.exists()) { + try { + for(IResource r : diFile.getParent().members()) { + if(r.getFullPath().removeFileExtension().lastSegment().equals(diFile.getFullPath().removeFileExtension().lastSegment())) { + relatedFiles.add(r); + } + } + } catch (CoreException e) { + } + } + } + + // 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; + } + + public static class RenameDialogRunnable implements Runnable { + + private IFile initialFile; + + private RenameParticipantsDialog renameParticipantsDialog; + + public RenameDialogRunnable(IFile file) { + initialFile = file; + } + + public void run() { + renameParticipantsDialog = new RenameParticipantsDialog(Display.getDefault().getActiveShell(), initialFile); + renameParticipantsDialog.open(); + } + + public Collection getFiles() { + return renameParticipantsDialog.getFiles(); + } + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/MoveModelParticipant.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/MoveModelParticipant.java new file mode 100644 index 00000000000..034462bf004 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/MoveModelParticipant.java @@ -0,0 +1,117 @@ +/***************************************************************************** + * 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 + * Arthur Daussy - Correction of the move ( set the destination attribute) + *****************************************************************************/ +package org.eclipse.papyrus.infra.ui.resources.refactoring; + +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. + * FIXME Integrate and create register to the extension point + * + * @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 Messages.MoveModelParticipant_Name; + } + + /** + * 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; + Object _destination = getArguments().getDestination(); + if(_destination instanceof IContainer) { + destination = (IContainer)_destination; + + } + filesToMove = ModelParticipantHelpers.getRelatedFiles(file); + return filesToMove.size() > 0; + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/RenameModelChange.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/RenameModelChange.java new file mode 100644 index 00000000000..643cb35767f --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/RenameModelChange.java @@ -0,0 +1,443 @@ +/***************************************************************************** + * 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.infra.ui.resources.refactoring; + +import static org.eclipse.papyrus.infra.ui.resources.Activator.log; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +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.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature.Setting; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.util.ECrossReferenceAdapter; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +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.modelsetquery.impl.IModelSetQueryAdapter; +import org.eclipse.papyrus.infra.core.modelsetquery.impl.ModelSetQueryAdapter; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.ModelsReader; +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.papyrus.infra.services.controlmode.mm.history.ControledResource; +import org.eclipse.papyrus.infra.services.controlmode.mm.history.historyPackage; +import org.eclipse.papyrus.infra.ui.resources.Activator; +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; + + private final Collection impacted; + + private TransactionalEditingDomain domain; + + private ModelSet resourceSet; + + private List openedEditors; + + private boolean isUndoOperation; + + /** + * Constructor. + * + * @param resourceSet + * The resource set being changed. + * @param oldFile + * The old file. + * @param newFile + * The new file. + * @param impacted + */ + public RenameModelChange(IFile oldFile, IFile newFile, Collection impacted) { + this.oldFile = oldFile; + this.newFile = newFile; + this.impacted = impacted; + + 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 Messages.bind(Messages.RenameModelChange_Name, 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 { + // 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(Messages.RenameModelChange_LoadingEMF); + + // String extension= newFile.getFileExtension(); + // if( extension == null){ + // newFile.getFullPath().addFileExtension(oldFile.getFileExtension()); + // } + pm.subTask(Messages.RenameModelChange_DaveDirtyEditor); + // We need to get the current workbench... so we have to use the UI-Thread! + openedEditors = new ArrayList(); + Display.getDefault().syncExec(new Runnable() { + + public void run() { + IMultiDiagramEditor[] multiEditors = EditorUtils.getRelatedEditors(oldFile); + if(multiEditors != null && multiEditors.length > 0) { + for(IMultiDiagramEditor editor : multiEditors) { + if(editor.isDirty()) { + editor.doSave(new NullProgressMonitor()); + } + openedEditors.add(editor); + } + } + } + }); + pm.worked(10); + + /* + * Load ModelSet + */ + resourceSet = new ModelSet(); + // XMIResourceFactoryImpl value = new XMIResourceFactoryImpl(); + // resourceSet.getResourceFactoryRegistry().getContentTypeToFactoryMap().put(Resource.Factory.Registry.DEFAULT_CONTENT_TYPE_IDENTIFIER, value); + // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, value); + try { + ModelsReader reader = new ModelsReader(); + reader.readModel(resourceSet); + resourceSet.loadModels(oldFile); + for(IResource r : impacted) { + if(r instanceof IFile) { + IFile file = (IFile)r; + try { + resourceSet.getResource(URI.createPlatformResourceURI(file.getFullPath().toString(), true), true); + } catch (Exception e) { + // to avoid load errors + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + // Force EMF resolve and load all the resources + try { + EcoreUtil.resolveAll(resourceSet); + } catch (RuntimeException e) { + // the resolve all does not have to break the operation + } + pm.worked(4); + domain = resourceSet.getTransactionalEditingDomain(); + // TODO improve when impact analysis will be effective + return manageResourceSet(pm, resourceSet); + } + + /** + * 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 = Messages.bind(Messages.RenameModelChange_Change, oldFile.getName(), newFile.getName()); + isUndoOperation = oldFile.exists() && !newFile.exists(); + if(!isUndoOperation) { + newFile.move(oldFile.getFullPath(), true, new SubProgressMonitor(pm, 1)); + } + pm.beginTask(lMsg, 30); + try { + doRun(pm, resourceSet, domain); + // Now, save all the resources + pm.subTask(Messages.RenameModelChange_savingResource); + for(Resource res : resourceSet.getResources()) { + if(res.getURI().isPlatformResource()) { + try { + res.save(null); + } catch (Exception e) { + log.error(Messages.bind(Messages.RenameModelChange_ErrorLoading, res.getURI()), e); + } + } + } + pm.worked(5); + + // Do not forget to unload all the resources to avoid memory leak + pm.subTask(Messages.RenameModelChange_Unloading); + 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(Messages.RenameModelChange_RemoveOldFile); + 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, impacted); + } finally { + pm.done(); + } + } + + private RefactoringStatus manageResourceSet(final IProgressMonitor pm, final ModelSet resourceSet) { + + final Collection readOnlies = new HashSet(); + // for each object of the resources renamed, the refactor will search if a resource is read only or not + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @Override + protected void doExecute() { + for(URI uri : uriMap.keySet()) { + Resource r = resourceSet.getResource(uri, false); + ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(resourceSet); + if(adapter != null) { + adapter = new ECrossReferenceAdapter(); + adapter.setTarget(resourceSet); + } + if(r != null) { + for(Iterator i = EcoreUtil.getAllProperContents(r, false); i.hasNext();) { + EObject e = i.next(); + Collection references = adapter.getInverseReferences(e); + for(Setting s : references) { + EObject eObject = s.getEObject(); + if(eObject != null && eObject.eResource() != null && domain.isReadOnly(eObject.eResource())) { + readOnlies.add(eObject.eResource()); + } + } + } + } + } + + } + }); + // if read only => error to the user + if(!readOnlies.isEmpty()) { + StringBuffer buffer = new StringBuffer("The resources listed are read only, the rename process can not continue : "); + int i = 0; + for(Resource r : readOnlies) { + if(i != 0) { + buffer.append(", "); + } + buffer.append(r.getURI().toString()); + i++; + } + return RefactoringStatus.create(new Status(IStatus.ERROR, Activator.PLUGIN_ID, buffer.toString())); + } + return new RefactoringStatus(); + + } + + private void doRun(final IProgressMonitor pm, final ModelSet resourceSet, final TransactionalEditingDomain domain) { + domain.getCommandStack().execute(new RecordingCommand(domain) { + + @SuppressWarnings("restriction") + @Override + protected void doExecute() { + // Manage Controlled map to ensure consistent history + // TODO change this code when history will be useless + URI modifiedURI = URI.createPlatformResourceURI(oldFile.getFullPath().removeFileExtension().toString(), true); + IModelSetQueryAdapter controledResourcesAdapter = ModelSetQueryAdapter.getExistingTypeCacheAdapter(resourceSet); + if(controledResourcesAdapter != null) { + EObject first = null; + for(Iterator i = resourceSet.getAllContents(); i.hasNext();) { + Notifier n = i.next(); + if(n instanceof EObject) { + first = (EObject)n; + break; + } + } + if(first != null) { + Collection resources = null; + try { + resources = controledResourcesAdapter.getReachableObjectsOfType(first, historyPackage.Literals.CONTROLED_RESOURCE); + } catch (RuntimeException e) { + // in case of errors integrity must be valid + // even performances are bad + resources = new LinkedList(); + for(int i = 0; i < resourceSet.getResources().size(); i++) { + Resource r = resourceSet.getResources().get(i); + for(Iterator it = r.getAllContents(); it.hasNext();) { + EObject tmp = it.next(); + if(tmp instanceof ControledResource) { + ControledResource controled = (ControledResource)tmp; + resources.add(controled); + } + } + } + } + for(EObject e : resources) { + if(e instanceof ControledResource) { + ControledResource controled = (ControledResource)e; + URI baseURI = URI.createURI(e.eResource().getURI().trimSegments(1).trimFragment().toString() + "/"); + URI resolvedURI = URI.createURI(controled.getResourceURL()).resolve(baseURI); + if(resolvedURI.trimFileExtension().equals(modifiedURI.trimFileExtension())) { + String ext = resolvedURI.fileExtension(); + URI newURL = URI.createURI(resolvedURI.trimSegments(1).toString() + "/" + newFile.getFullPath().removeFileExtension().lastSegment().toString() + "." + ext); + controled.setResourceURL(newURL.deresolve(baseURI).toString()); + } + } + } + } + } + } + }); + // Change the uri of the files + pm.subTask(Messages.RenameModelChange_ModifyURI); + for(Resource res : resourceSet.getResources()) { + if(res.getURI().isPlatformResource()) { + URI newURI = uriMap.get(res.getURI()); + if(newURI != null) { + if(log.isDebugEnabled()) { + log.debug(Messages.bind(Messages.RenameModelChange_6, Arrays.asList(res.getURI(), newURI))); + } + res.setURI(newURI); + } + } + + } + pm.worked(5); + + + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/RenameModelParticipant.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/RenameModelParticipant.java new file mode 100644 index 00000000000..c1e6b839da0 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/RenameModelParticipant.java @@ -0,0 +1,142 @@ +/***************************************************************************** + * 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.infra.ui.resources.refactoring; + +import java.util.Collection; + +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; + + private Collection impacted; + + /** + * @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, impacted); + } + + /** + * 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())); + impacted = ModelParticipantHelpers.getResourceToFix(fileToRename); + return true; + } else { + return false; + } + + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/messages.properties b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/messages.properties new file mode 100644 index 00000000000..3b38d28d433 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/messages.properties @@ -0,0 +1,19 @@ +DirtyEditorChange_0=Check opened editors +DirtyEditorChange_1=Confirm saving +DirtyEditorChange_2=The related editor(s) must be saved to continue. +DirtyEditorChange_3=Process can not continue if editors are not saved +MoveModelParticipant_Name=Papyrus Model Move +RenameModelChange_0=The resources listed are read only, the rename process can not continue : +RenameModelChange_5=Warning +RenameModelChange_6=Changing URI {0} into {1} +RenameModelChange_7=The file you are renaming is opened in an editor and has unsaved changes.\nTo continue the process has to save the editor.\nDo you want to continue ? +RenameModelChange_8=The process can not continue with an unsaved editor +RenameModelChange_Change=Rename {0} to {1} +RenameModelChange_DaveDirtyEditor=Saving dirty editors +RenameModelChange_ErrorLoading=Error while loading resource {0} +RenameModelChange_LoadingEMF=Loading EMF model into memory +RenameModelChange_ModifyURI=Modifying resources' URI +RenameModelChange_Name=Update all resources related to {0} +RenameModelChange_RemoveOldFile=Removing old files +RenameModelChange_savingResource=Saving resources +RenameModelChange_Unloading=Unloading model diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/IScopeChooser.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/IScopeChooser.java new file mode 100644 index 00000000000..0b9d02b59b8 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/IScopeChooser.java @@ -0,0 +1,50 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tristan FAURE - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.ui.resources.refactoring.ui; + +import java.util.List; + +import org.eclipse.core.resources.IFile; + + +/** + * Interface for elements getting related files from a file + * + * @author tfaure + * + */ +public interface IScopeChooser { + + /** + * The name or label of the chooser + * + * @return + */ + public String getName(); + + /** + * The description to inform user + * + * @return + */ + public String getDescription(); + + /** + * Return the list of files related to the given parameter + * + * @param f + * @return + */ + public List getRelatedFiles(IFile f); +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/Messages.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/Messages.java new file mode 100644 index 00000000000..52b99539b80 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/Messages.java @@ -0,0 +1,35 @@ +package org.eclipse.papyrus.infra.ui.resources.refactoring.ui; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + + private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.ui.resources.refactoring.ui.messages"; //$NON-NLS-1$ + + public static String RenameParticipantsDialog_DESCRIPTION; + + public static String RenameParticipantsDialog_DESCRIPTION_LABEL; + + public static String RenameParticipantsDialog_DESCRIPTION_NO_ANALYSIS; + + public static String RenameParticipantsDialog_DESCRIPTION_PROJECT; + + public static String RenameParticipantsDialog_DESCRIPTION_WORKSPACE; + + public static String RenameParticipantsDialog_NAME_NO_ANALYSIS; + + public static String RenameParticipantsDialog_NAME_PROJECT; + + public static String RenameParticipantsDialog_NAME_WORKSPACE; + + public static String RenameParticipantsDialog_OPTIONS; + + public static String RenameParticipantsDialog_SELECT_RENAME_OPTION; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/RenameParticipantsDialog.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/RenameParticipantsDialog.java new file mode 100644 index 00000000000..869ee16813b --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/RenameParticipantsDialog.java @@ -0,0 +1,246 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tristan FAURE - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.ui.resources.refactoring.ui; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +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.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.TitleAreaDialog; +import org.eclipse.jface.viewers.ComboViewer; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.papyrus.infra.ui.resources.refactoring.ui.ScopeChooser.ScopeChooserVisitor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.forms.widgets.FormText; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.Section; + + +/** + * Generated by Window Builder + * + * @author tfaure + * + */ +public class RenameParticipantsDialog extends TitleAreaDialog { + + private final FormToolkit formToolkit = new FormToolkit(Display.getDefault()); + + private final IFile context; + + private FormText formDescription; + + protected IScopeChooser currentScope; + + /** + * Create the dialog. + * + * @param parentShell + */ + public RenameParticipantsDialog(Shell parentShell, IFile context) { + super(parentShell); + this.context = context; + } + + /** + * Create contents of the dialog. + * + * @param parent + */ + @Override + protected Control createDialogArea(Composite parent) { + setTitle(Messages.RenameParticipantsDialog_SELECT_RENAME_OPTION); + Composite area = (Composite)super.createDialogArea(parent); + Composite container = new Composite(area, SWT.NONE); + container.setLayout(new GridLayout(1, false)); + container.setLayoutData(new GridData(GridData.FILL_BOTH)); + + Section sctnOptions = formToolkit.createSection(container, Section.EXPANDED | Section.TITLE_BAR); + sctnOptions.setDescription(""); //$NON-NLS-1$ + sctnOptions.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + formToolkit.paintBordersFor(sctnOptions); + sctnOptions.setText(Messages.RenameParticipantsDialog_OPTIONS); + + Composite composite = new Composite(sctnOptions, SWT.NONE); + formToolkit.adapt(composite); + formToolkit.paintBordersFor(composite); + sctnOptions.setClient(composite); + composite.setLayout(new GridLayout(1, false)); + + FormText formText = formToolkit.createFormText(composite, false); + formText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + formToolkit.paintBordersFor(formText); + formText.setText(Messages.RenameParticipantsDialog_DESCRIPTION, true, false); + + ComboViewer comboViewer = new ComboViewer(composite, SWT.READ_ONLY); + comboViewer.setUseHashlookup(true); + comboViewer.setLabelProvider(new ILabelProvider() { + + public void removeListener(ILabelProviderListener listener) { + } + + public boolean isLabelProperty(Object element, String property) { + return true; + } + + public void dispose() { + } + + public void addListener(ILabelProviderListener listener) { + } + + public String getText(Object element) { + if(element instanceof IScopeChooser) { + IScopeChooser scope = (IScopeChooser)element; + return scope.getName(); + } + return null; + } + + public Image getImage(Object element) { + return null; + } + }); + comboViewer.setContentProvider(new IStructuredContentProvider() { + + public Object[] getElements(Object inputElement) { + return (Object[])inputElement; + } + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + + public void dispose() { + } + }); + + Combo combo = comboViewer.getCombo(); + combo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + formToolkit.paintBordersFor(combo); + + Group grpDescription = new Group(composite, SWT.NONE); + grpDescription.setLayout(new GridLayout(1, false)); + grpDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + grpDescription.setText(Messages.RenameParticipantsDialog_DESCRIPTION_LABEL); + formToolkit.adapt(grpDescription); + formToolkit.paintBordersFor(grpDescription); + + formDescription = formToolkit.createFormText(grpDescription, false); + formDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1)); + formToolkit.paintBordersFor(formDescription); + formDescription.setText("", false, false); //$NON-NLS-1$ + + // when the selection changed the description too + comboViewer.addSelectionChangedListener(new ISelectionChangedListener() { + + public void selectionChanged(SelectionChangedEvent event) { + if(event.getSelection() instanceof IStructuredSelection) { + IStructuredSelection selec = (IStructuredSelection)event.getSelection(); + if(selec.getFirstElement() instanceof IScopeChooser) { + IScopeChooser chooser = (IScopeChooser)selec.getFirstElement(); + formDescription.setText(chooser.getDescription(), true, false); + currentScope = chooser; + } + } + } + }); + Object[] input = getInput(); + comboViewer.setInput(input); + comboViewer.setSelection(new StructuredSelection(input[0])); + return area; + } + + /** + * Pre defined list of chooser maybe later an extension point will be creates + * + * @return + */ + private Object[] getInput() { + final ScopeChooserVisitor visitor = new ScopeChooserVisitor(); + return new IScopeChooser[]{ new ScopeChooser(Messages.RenameParticipantsDialog_NAME_PROJECT, Messages.RenameParticipantsDialog_DESCRIPTION_PROJECT) { + + public List getRelatedFiles(IFile f) { + try { + f.getProject().accept(visitor, IResource.DEPTH_INFINITE, IContainer.EXCLUDE_DERIVED); + return visitor.getFiles(); + } catch (CoreException e) { + e.printStackTrace(); + } + return Collections.emptyList(); + } + }, new ScopeChooser(Messages.RenameParticipantsDialog_NAME_WORKSPACE, Messages.RenameParticipantsDialog_DESCRIPTION_WORKSPACE) { + + public List getRelatedFiles(IFile f) { + try { + ResourcesPlugin.getWorkspace().getRoot().accept(visitor, IResource.DEPTH_INFINITE, IContainer.EXCLUDE_DERIVED); + return visitor.getFiles(); + } catch (CoreException e) { + e.printStackTrace(); + } + return Collections.emptyList(); + } + }, new ScopeChooser(Messages.RenameParticipantsDialog_NAME_NO_ANALYSIS, Messages.RenameParticipantsDialog_DESCRIPTION_NO_ANALYSIS) { + + public List getRelatedFiles(IFile f) { + return Arrays.asList(f); + } + } }; + } + + /** + * Create contents of the button bar. + * + * @param parent + */ + @Override + protected void createButtonsForButtonBar(Composite parent) { + createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); + } + + /** + * Return the initial size of the dialog. + */ + @Override + protected Point getInitialSize() { + return new Point(450, 300); + } + + public Collection getFiles() { + return currentScope.getRelatedFiles(context); + } +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/ScopeChooser.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/ScopeChooser.java new file mode 100644 index 00000000000..635ab48cff0 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/ScopeChooser.java @@ -0,0 +1,99 @@ +/***************************************************************************** + * Copyright (c) 2011 Atos. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tristan FAURE - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.ui.resources.refactoring.ui; + +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceVisitor; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.Resource.Factory.Registry; +import org.eclipse.ui.ide.IDE; + + + +/** + * Default Implementation of {@link IScopeChooser} + * + * @author tfaure + */ +public abstract class ScopeChooser implements IScopeChooser { + + private final String description; + + private final String label; + + public ScopeChooser(String label, String formDescription) { + this.label = label; + this.description = formDescription; + + } + + public String getName() { + return label; + } + + public String getDescription() { + return description; + } + + + + public static class ScopeChooserVisitor implements IResourceVisitor { + + private List files = new LinkedList(); + + public boolean visit(IResource resource) throws CoreException { + if(resource instanceof IFile) { + IFile file = (IFile)resource; + if(isXMI(file)) { + files.add(file); + } + return false; + } + return true; + } + + /** + * Determine if the given file is an XMI some specific code has been set for notation and di + * + * @param f + * @return + */ + public boolean isXMI(IFile f) { + URI uri = URI.createPlatformResourceURI(f.getFullPath().toString(), true); + IContentType contentType = IDE.getContentType(f); + Registry instance = Resource.Factory.Registry.INSTANCE; + Object old = instance.getContentTypeToFactoryMap().get(Resource.Factory.Registry.DEFAULT_CONTENT_TYPE_IDENTIFIER); + Object old2 = instance.getExtensionToFactoryMap().get(Resource.Factory.Registry.DEFAULT_EXTENSION); + instance.getContentTypeToFactoryMap().put(Resource.Factory.Registry.DEFAULT_CONTENT_TYPE_IDENTIFIER, null); + instance.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, null); + boolean result = (f != null && contentType != null && (Resource.Factory.Registry.INSTANCE.getFactory(uri, contentType.getId()) != null || "notation".equals(f.getFileExtension()) || "di".equals(f.getFileExtension()))); + instance.getContentTypeToFactoryMap().put(Resource.Factory.Registry.DEFAULT_CONTENT_TYPE_IDENTIFIER, old); + instance.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, old2); + return result; + } + + public List getFiles() { + return files; + } + + } + +} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/messages.properties b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/messages.properties new file mode 100644 index 00000000000..eff43c17e63 --- /dev/null +++ b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/infra/ui/resources/refactoring/ui/messages.properties @@ -0,0 +1,10 @@ +RenameParticipantsDialog_DESCRIPTION=

The rename operation can have several impacts on related files

Please choose the scope of references fixing operation

+RenameParticipantsDialog_DESCRIPTION_LABEL=Description +RenameParticipantsDialog_DESCRIPTION_NO_ANALYSIS=

No analysis is performed, this option is recommended for experimented users

+RenameParticipantsDialog_DESCRIPTION_PROJECT=

The references will be analysed in the project of the renamed file

+RenameParticipantsDialog_DESCRIPTION_WORKSPACE=

The references will be analysed in the whole workspace

This operation can be long

+RenameParticipantsDialog_NAME_NO_ANALYSIS=No Analysis +RenameParticipantsDialog_NAME_PROJECT=Project (default) +RenameParticipantsDialog_NAME_WORKSPACE=Workspace +RenameParticipantsDialog_OPTIONS=Options +RenameParticipantsDialog_SELECT_RENAME_OPTION=Select Rename Options diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/Activator.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/Activator.java deleted file mode 100644 index f153c3ee1ce..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/Activator.java +++ /dev/null @@ -1,72 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Atos Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.ui.resources; - -import org.eclipse.papyrus.log.LogHelper; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.ui.resources"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** The log service */ - 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; - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/DeleteModelParticipant.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/DeleteModelParticipant.java deleted file mode 100644 index b06dffd851e..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/DeleteModelParticipant.java +++ /dev/null @@ -1,147 +0,0 @@ -/***************************************************************************** - * 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.ui.resources.refactoring; - -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. - * FIXME Integrate and create register to the extension point - * - * @author Thomas Szadel - * - */ -public class DeleteModelParticipant extends DeleteParticipant { - - /** action name */ - private static final String NAME = "Papyrus Model Deletion"; - - 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 NAME; - } - - /** - * 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/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/DirtyEditorChange.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/DirtyEditorChange.java deleted file mode 100644 index ecab933cb95..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/DirtyEditorChange.java +++ /dev/null @@ -1,146 +0,0 @@ -/***************************************************************************** - * 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.ui.resources.refactoring; - -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.core.editor.IMultiDiagramEditor; -import org.eclipse.papyrus.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 Messages.DirtyEditorChange_0; - } - - /** - * @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(), Messages.DirtyEditorChange_1, Messages.DirtyEditorChange_2)) { - status.addFatalError(Messages.DirtyEditorChange_3); - } - } - } - }); - - 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/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/Messages.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/Messages.java deleted file mode 100644 index 82a9a40f31f..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/Messages.java +++ /dev/null @@ -1,66 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos Origin. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Arthur Daussy - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.ui.resources.refactoring; - -import org.eclipse.osgi.util.NLS; - -public class Messages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.papyrus.ui.resources.refactoring.messages"; //$NON-NLS-1$ - - public static String DirtyEditorChange_0; - - public static String DirtyEditorChange_1; - - public static String DirtyEditorChange_2; - - public static String DirtyEditorChange_3; - - public static String MoveModelParticipant_Name; - - public static String RenameModelChange_0; - - public static String RenameModelChange_5; - - public static String RenameModelChange_6; - - public static String RenameModelChange_7; - - public static String RenameModelChange_8; - - public static String RenameModelChange_Change; - - public static String RenameModelChange_DaveDirtyEditor; - - public static String RenameModelChange_ErrorLoading; - - public static String RenameModelChange_LoadingEMF; - - public static String RenameModelChange_ModifyURI; - - public static String RenameModelChange_Name; - - public static String RenameModelChange_RemoveOldFile; - - public static String RenameModelChange_savingResource; - - public static String RenameModelChange_Unloading; - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ModelParticipantHelpers.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ModelParticipantHelpers.java deleted file mode 100644 index 3be266874d4..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ModelParticipantHelpers.java +++ /dev/null @@ -1,152 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Thomas Szadel - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.ui.resources.refactoring; - -import java.util.ArrayList; -import java.util.Collection; -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.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.papyrus.resource.sasheditor.DiModel; -import org.eclipse.papyrus.ui.resources.refactoring.ui.RenameParticipantsDialog; -import org.eclipse.swt.widgets.Display; - -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 getResourceToFix(final IFile initialFile) { - - RenameDialogRunnable runnable = new RenameDialogRunnable(initialFile); - Display.getDefault().syncExec(runnable); - return new HashSet(runnable.getFiles()); - } - - /** - * 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(final IFile initialFile) { - - - 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) { - } - } - - Set relatedFiles = new HashSet(); - if(diPath != null) { - IFile diFile = parent.getFile(diPath.makeRelativeTo(parent.getFullPath())); - if(diFile.exists()) { - try { - for(IResource r : diFile.getParent().members()) { - if(r.getFullPath().removeFileExtension().lastSegment().equals(diFile.getFullPath().removeFileExtension().lastSegment())) { - relatedFiles.add(r); - } - } - } catch (CoreException e) { - } - } - } - - // 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; - } - - public static class RenameDialogRunnable implements Runnable { - - private IFile initialFile; - - private RenameParticipantsDialog renameParticipantsDialog; - - public RenameDialogRunnable(IFile file) { - initialFile = file; - } - - public void run() { - renameParticipantsDialog = new RenameParticipantsDialog(Display.getDefault().getActiveShell(), initialFile); - renameParticipantsDialog.open(); - } - - public Collection getFiles() { - return renameParticipantsDialog.getFiles(); - } - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/MoveModelParticipant.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/MoveModelParticipant.java deleted file mode 100644 index 503f8fbef19..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/MoveModelParticipant.java +++ /dev/null @@ -1,117 +0,0 @@ -/***************************************************************************** - * 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 - * Arthur Daussy - Correction of the move ( set the destination attribute) - *****************************************************************************/ -package org.eclipse.papyrus.ui.resources.refactoring; - -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. - * FIXME Integrate and create register to the extension point - * - * @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 Messages.MoveModelParticipant_Name; - } - - /** - * 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; - Object _destination = getArguments().getDestination(); - if(_destination instanceof IContainer) { - destination = (IContainer)_destination; - - } - filesToMove = ModelParticipantHelpers.getRelatedFiles(file); - return filesToMove.size() > 0; - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/RenameModelChange.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/RenameModelChange.java deleted file mode 100644 index e51ac222ef8..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/RenameModelChange.java +++ /dev/null @@ -1,443 +0,0 @@ -/***************************************************************************** - * 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.ui.resources.refactoring; - -import static org.eclipse.papyrus.ui.resources.Activator.log; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -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.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature.Setting; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.util.ECrossReferenceAdapter; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -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.controlmode.mm.history.ControledResource; -import org.eclipse.papyrus.controlmode.mm.history.historyPackage; -import org.eclipse.papyrus.core.editor.IMultiDiagramEditor; -import org.eclipse.papyrus.core.modelsetquery.impl.IModelSetQueryAdapter; -import org.eclipse.papyrus.core.modelsetquery.impl.ModelSetQueryAdapter; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.utils.DiResourceSet; -import org.eclipse.papyrus.core.utils.EditorUtils; -import org.eclipse.papyrus.resource.ModelSet; -import org.eclipse.papyrus.resource.ModelsReader; -import org.eclipse.papyrus.resource.sasheditor.DiModelUtils; -import org.eclipse.papyrus.ui.resources.Activator; -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; - - private final Collection impacted; - - private TransactionalEditingDomain domain; - - private ModelSet resourceSet; - - private List openedEditors; - - private boolean isUndoOperation; - - /** - * Constructor. - * - * @param resourceSet - * The resource set being changed. - * @param oldFile - * The old file. - * @param newFile - * The new file. - * @param impacted - */ - public RenameModelChange(IFile oldFile, IFile newFile, Collection impacted) { - this.oldFile = oldFile; - this.newFile = newFile; - this.impacted = impacted; - - 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 Messages.bind(Messages.RenameModelChange_Name, 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 { - // 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(Messages.RenameModelChange_LoadingEMF); - - // String extension= newFile.getFileExtension(); - // if( extension == null){ - // newFile.getFullPath().addFileExtension(oldFile.getFileExtension()); - // } - pm.subTask(Messages.RenameModelChange_DaveDirtyEditor); - // We need to get the current workbench... so we have to use the UI-Thread! - openedEditors = new ArrayList(); - Display.getDefault().syncExec(new Runnable() { - - public void run() { - IMultiDiagramEditor[] multiEditors = EditorUtils.getRelatedEditors(oldFile); - if(multiEditors != null && multiEditors.length > 0) { - for(IMultiDiagramEditor editor : multiEditors) { - if(editor.isDirty()) { - editor.doSave(new NullProgressMonitor()); - } - openedEditors.add(editor); - } - } - } - }); - pm.worked(10); - - /* - * Load ModelSet - */ - resourceSet = new ModelSet(); - // XMIResourceFactoryImpl value = new XMIResourceFactoryImpl(); - // resourceSet.getResourceFactoryRegistry().getContentTypeToFactoryMap().put(Resource.Factory.Registry.DEFAULT_CONTENT_TYPE_IDENTIFIER, value); - // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, value); - try { - ModelsReader reader = new ModelsReader(); - reader.readModel(resourceSet); - resourceSet.loadModels(oldFile); - for(IResource r : impacted) { - if(r instanceof IFile) { - IFile file = (IFile)r; - try { - resourceSet.getResource(URI.createPlatformResourceURI(file.getFullPath().toString(), true), true); - } catch (Exception e) { - // to avoid load errors - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - // Force EMF resolve and load all the resources - try { - EcoreUtil.resolveAll(resourceSet); - } catch (RuntimeException e) { - // the resolve all does not have to break the operation - } - pm.worked(4); - domain = resourceSet.getTransactionalEditingDomain(); - // TODO improve when impact analysis will be effective - return manageResourceSet(pm, resourceSet); - } - - /** - * 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 = Messages.bind(Messages.RenameModelChange_Change, oldFile.getName(), newFile.getName()); - isUndoOperation = oldFile.exists() && !newFile.exists(); - if(!isUndoOperation) { - newFile.move(oldFile.getFullPath(), true, new SubProgressMonitor(pm, 1)); - } - pm.beginTask(lMsg, 30); - try { - doRun(pm, resourceSet, domain); - // Now, save all the resources - pm.subTask(Messages.RenameModelChange_savingResource); - for(Resource res : resourceSet.getResources()) { - if(res.getURI().isPlatformResource()) { - try { - res.save(null); - } catch (Exception e) { - log.error(Messages.bind(Messages.RenameModelChange_ErrorLoading, res.getURI()), e); - } - } - } - pm.worked(5); - - // Do not forget to unload all the resources to avoid memory leak - pm.subTask(Messages.RenameModelChange_Unloading); - 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(Messages.RenameModelChange_RemoveOldFile); - 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, impacted); - } finally { - pm.done(); - } - } - - private RefactoringStatus manageResourceSet(final IProgressMonitor pm, final ModelSet resourceSet) { - - final Collection readOnlies = new HashSet(); - // for each object of the resources renamed, the refactor will search if a resource is read only or not - domain.getCommandStack().execute(new RecordingCommand(domain) { - - @Override - protected void doExecute() { - for(URI uri : uriMap.keySet()) { - Resource r = resourceSet.getResource(uri, false); - ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(resourceSet); - if(adapter != null) { - adapter = new ECrossReferenceAdapter(); - adapter.setTarget(resourceSet); - } - if(r != null) { - for(Iterator i = EcoreUtil.getAllProperContents(r, false); i.hasNext();) { - EObject e = i.next(); - Collection references = adapter.getInverseReferences(e); - for(Setting s : references) { - EObject eObject = s.getEObject(); - if(eObject != null && eObject.eResource() != null && domain.isReadOnly(eObject.eResource())) { - readOnlies.add(eObject.eResource()); - } - } - } - } - } - - } - }); - // if read only => error to the user - if(!readOnlies.isEmpty()) { - StringBuffer buffer = new StringBuffer("The resources listed are read only, the rename process can not continue : "); - int i = 0; - for(Resource r : readOnlies) { - if(i != 0) { - buffer.append(", "); - } - buffer.append(r.getURI().toString()); - i++; - } - return RefactoringStatus.create(new Status(IStatus.ERROR, Activator.PLUGIN_ID, buffer.toString())); - } - return new RefactoringStatus(); - - } - - private void doRun(final IProgressMonitor pm, final ModelSet resourceSet, final TransactionalEditingDomain domain) { - domain.getCommandStack().execute(new RecordingCommand(domain) { - - @SuppressWarnings("restriction") - @Override - protected void doExecute() { - // Manage Controlled map to ensure consistent history - // TODO change this code when history will be useless - URI modifiedURI = URI.createPlatformResourceURI(oldFile.getFullPath().removeFileExtension().toString(), true); - IModelSetQueryAdapter controledResourcesAdapter = ModelSetQueryAdapter.getExistingTypeCacheAdapter(resourceSet); - if(controledResourcesAdapter != null) { - EObject first = null; - for(Iterator i = resourceSet.getAllContents(); i.hasNext();) { - Notifier n = i.next(); - if(n instanceof EObject) { - first = (EObject)n; - break; - } - } - if(first != null) { - Collection resources = null; - try { - resources = controledResourcesAdapter.getReachableObjectsOfType(first, historyPackage.Literals.CONTROLED_RESOURCE); - } catch (RuntimeException e) { - // in case of errors integrity must be valid - // even performances are bad - resources = new LinkedList(); - for(int i = 0; i < resourceSet.getResources().size(); i++) { - Resource r = resourceSet.getResources().get(i); - for(Iterator it = r.getAllContents(); it.hasNext();) { - EObject tmp = it.next(); - if(tmp instanceof ControledResource) { - ControledResource controled = (ControledResource)tmp; - resources.add(controled); - } - } - } - } - for(EObject e : resources) { - if(e instanceof ControledResource) { - ControledResource controled = (ControledResource)e; - URI baseURI = URI.createURI(e.eResource().getURI().trimSegments(1).trimFragment().toString() + "/"); - URI resolvedURI = URI.createURI(controled.getResourceURL()).resolve(baseURI); - if(resolvedURI.trimFileExtension().equals(modifiedURI.trimFileExtension())) { - String ext = resolvedURI.fileExtension(); - URI newURL = URI.createURI(resolvedURI.trimSegments(1).toString() + "/" + newFile.getFullPath().removeFileExtension().lastSegment().toString() + "." + ext); - controled.setResourceURL(newURL.deresolve(baseURI).toString()); - } - } - } - } - } - } - }); - // Change the uri of the files - pm.subTask(Messages.RenameModelChange_ModifyURI); - for(Resource res : resourceSet.getResources()) { - if(res.getURI().isPlatformResource()) { - URI newURI = uriMap.get(res.getURI()); - if(newURI != null) { - if(log.isDebugEnabled()) { - log.debug(Messages.bind(Messages.RenameModelChange_6, Arrays.asList(res.getURI(), newURI))); - } - res.setURI(newURI); - } - } - - } - pm.worked(5); - - - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/RenameModelParticipant.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/RenameModelParticipant.java deleted file mode 100644 index 0df5f401156..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/RenameModelParticipant.java +++ /dev/null @@ -1,142 +0,0 @@ -/***************************************************************************** - * 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.ui.resources.refactoring; - -import java.util.Collection; - -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; - - private Collection impacted; - - /** - * @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, impacted); - } - - /** - * 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())); - impacted = ModelParticipantHelpers.getResourceToFix(fileToRename); - return true; - } else { - return false; - } - - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/messages.properties b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/messages.properties deleted file mode 100644 index 3b38d28d433..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/messages.properties +++ /dev/null @@ -1,19 +0,0 @@ -DirtyEditorChange_0=Check opened editors -DirtyEditorChange_1=Confirm saving -DirtyEditorChange_2=The related editor(s) must be saved to continue. -DirtyEditorChange_3=Process can not continue if editors are not saved -MoveModelParticipant_Name=Papyrus Model Move -RenameModelChange_0=The resources listed are read only, the rename process can not continue : -RenameModelChange_5=Warning -RenameModelChange_6=Changing URI {0} into {1} -RenameModelChange_7=The file you are renaming is opened in an editor and has unsaved changes.\nTo continue the process has to save the editor.\nDo you want to continue ? -RenameModelChange_8=The process can not continue with an unsaved editor -RenameModelChange_Change=Rename {0} to {1} -RenameModelChange_DaveDirtyEditor=Saving dirty editors -RenameModelChange_ErrorLoading=Error while loading resource {0} -RenameModelChange_LoadingEMF=Loading EMF model into memory -RenameModelChange_ModifyURI=Modifying resources' URI -RenameModelChange_Name=Update all resources related to {0} -RenameModelChange_RemoveOldFile=Removing old files -RenameModelChange_savingResource=Saving resources -RenameModelChange_Unloading=Unloading model diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/IScopeChooser.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/IScopeChooser.java deleted file mode 100644 index db486f7bbba..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/IScopeChooser.java +++ /dev/null @@ -1,50 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tristan FAURE - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.ui.resources.refactoring.ui; - -import java.util.List; - -import org.eclipse.core.resources.IFile; - - -/** - * Interface for elements getting related files from a file - * - * @author tfaure - * - */ -public interface IScopeChooser { - - /** - * The name or label of the chooser - * - * @return - */ - public String getName(); - - /** - * The description to inform user - * - * @return - */ - public String getDescription(); - - /** - * Return the list of files related to the given parameter - * - * @param f - * @return - */ - public List getRelatedFiles(IFile f); -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/Messages.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/Messages.java deleted file mode 100644 index 63c55abcf6e..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/Messages.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.eclipse.papyrus.ui.resources.refactoring.ui; - -import org.eclipse.osgi.util.NLS; - -public class Messages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.papyrus.ui.resources.refactoring.ui.messages"; //$NON-NLS-1$ - - public static String RenameParticipantsDialog_DESCRIPTION; - - public static String RenameParticipantsDialog_DESCRIPTION_LABEL; - - public static String RenameParticipantsDialog_DESCRIPTION_NO_ANALYSIS; - - public static String RenameParticipantsDialog_DESCRIPTION_PROJECT; - - public static String RenameParticipantsDialog_DESCRIPTION_WORKSPACE; - - public static String RenameParticipantsDialog_NAME_NO_ANALYSIS; - - public static String RenameParticipantsDialog_NAME_PROJECT; - - public static String RenameParticipantsDialog_NAME_WORKSPACE; - - public static String RenameParticipantsDialog_OPTIONS; - - public static String RenameParticipantsDialog_SELECT_RENAME_OPTION; - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/RenameParticipantsDialog.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/RenameParticipantsDialog.java deleted file mode 100644 index 3f16b7d3c6a..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/RenameParticipantsDialog.java +++ /dev/null @@ -1,246 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tristan FAURE - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.ui.resources.refactoring.ui; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -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.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.TitleAreaDialog; -import org.eclipse.jface.viewers.ComboViewer; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.papyrus.ui.resources.refactoring.ui.ScopeChooser.ScopeChooserVisitor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.forms.widgets.FormText; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Section; - - -/** - * Generated by Window Builder - * - * @author tfaure - * - */ -public class RenameParticipantsDialog extends TitleAreaDialog { - - private final FormToolkit formToolkit = new FormToolkit(Display.getDefault()); - - private final IFile context; - - private FormText formDescription; - - protected IScopeChooser currentScope; - - /** - * Create the dialog. - * - * @param parentShell - */ - public RenameParticipantsDialog(Shell parentShell, IFile context) { - super(parentShell); - this.context = context; - } - - /** - * Create contents of the dialog. - * - * @param parent - */ - @Override - protected Control createDialogArea(Composite parent) { - setTitle(Messages.RenameParticipantsDialog_SELECT_RENAME_OPTION); - Composite area = (Composite)super.createDialogArea(parent); - Composite container = new Composite(area, SWT.NONE); - container.setLayout(new GridLayout(1, false)); - container.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Section sctnOptions = formToolkit.createSection(container, Section.EXPANDED | Section.TITLE_BAR); - sctnOptions.setDescription(""); //$NON-NLS-1$ - sctnOptions.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); - formToolkit.paintBordersFor(sctnOptions); - sctnOptions.setText(Messages.RenameParticipantsDialog_OPTIONS); - - Composite composite = new Composite(sctnOptions, SWT.NONE); - formToolkit.adapt(composite); - formToolkit.paintBordersFor(composite); - sctnOptions.setClient(composite); - composite.setLayout(new GridLayout(1, false)); - - FormText formText = formToolkit.createFormText(composite, false); - formText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - formToolkit.paintBordersFor(formText); - formText.setText(Messages.RenameParticipantsDialog_DESCRIPTION, true, false); - - ComboViewer comboViewer = new ComboViewer(composite, SWT.READ_ONLY); - comboViewer.setUseHashlookup(true); - comboViewer.setLabelProvider(new ILabelProvider() { - - public void removeListener(ILabelProviderListener listener) { - } - - public boolean isLabelProperty(Object element, String property) { - return true; - } - - public void dispose() { - } - - public void addListener(ILabelProviderListener listener) { - } - - public String getText(Object element) { - if(element instanceof IScopeChooser) { - IScopeChooser scope = (IScopeChooser)element; - return scope.getName(); - } - return null; - } - - public Image getImage(Object element) { - return null; - } - }); - comboViewer.setContentProvider(new IStructuredContentProvider() { - - public Object[] getElements(Object inputElement) { - return (Object[])inputElement; - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - public void dispose() { - } - }); - - Combo combo = comboViewer.getCombo(); - combo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); - formToolkit.paintBordersFor(combo); - - Group grpDescription = new Group(composite, SWT.NONE); - grpDescription.setLayout(new GridLayout(1, false)); - grpDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); - grpDescription.setText(Messages.RenameParticipantsDialog_DESCRIPTION_LABEL); - formToolkit.adapt(grpDescription); - formToolkit.paintBordersFor(grpDescription); - - formDescription = formToolkit.createFormText(grpDescription, false); - formDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1)); - formToolkit.paintBordersFor(formDescription); - formDescription.setText("", false, false); //$NON-NLS-1$ - - // when the selection changed the description too - comboViewer.addSelectionChangedListener(new ISelectionChangedListener() { - - public void selectionChanged(SelectionChangedEvent event) { - if(event.getSelection() instanceof IStructuredSelection) { - IStructuredSelection selec = (IStructuredSelection)event.getSelection(); - if(selec.getFirstElement() instanceof IScopeChooser) { - IScopeChooser chooser = (IScopeChooser)selec.getFirstElement(); - formDescription.setText(chooser.getDescription(), true, false); - currentScope = chooser; - } - } - } - }); - Object[] input = getInput(); - comboViewer.setInput(input); - comboViewer.setSelection(new StructuredSelection(input[0])); - return area; - } - - /** - * Pre defined list of chooser maybe later an extension point will be creates - * - * @return - */ - private Object[] getInput() { - final ScopeChooserVisitor visitor = new ScopeChooserVisitor(); - return new IScopeChooser[]{ new ScopeChooser(Messages.RenameParticipantsDialog_NAME_PROJECT, Messages.RenameParticipantsDialog_DESCRIPTION_PROJECT) { - - public List getRelatedFiles(IFile f) { - try { - f.getProject().accept(visitor, IResource.DEPTH_INFINITE, IContainer.EXCLUDE_DERIVED); - return visitor.getFiles(); - } catch (CoreException e) { - e.printStackTrace(); - } - return Collections.emptyList(); - } - }, new ScopeChooser(Messages.RenameParticipantsDialog_NAME_WORKSPACE, Messages.RenameParticipantsDialog_DESCRIPTION_WORKSPACE) { - - public List getRelatedFiles(IFile f) { - try { - ResourcesPlugin.getWorkspace().getRoot().accept(visitor, IResource.DEPTH_INFINITE, IContainer.EXCLUDE_DERIVED); - return visitor.getFiles(); - } catch (CoreException e) { - e.printStackTrace(); - } - return Collections.emptyList(); - } - }, new ScopeChooser(Messages.RenameParticipantsDialog_NAME_NO_ANALYSIS, Messages.RenameParticipantsDialog_DESCRIPTION_NO_ANALYSIS) { - - public List getRelatedFiles(IFile f) { - return Arrays.asList(f); - } - } }; - } - - /** - * Create contents of the button bar. - * - * @param parent - */ - @Override - protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - } - - /** - * Return the initial size of the dialog. - */ - @Override - protected Point getInitialSize() { - return new Point(450, 300); - } - - public Collection getFiles() { - return currentScope.getRelatedFiles(context); - } -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/ScopeChooser.java b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/ScopeChooser.java deleted file mode 100644 index a9004dd8e99..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/ScopeChooser.java +++ /dev/null @@ -1,99 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2011 Atos. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tristan FAURE - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.ui.resources.refactoring.ui; - -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.Resource.Factory.Registry; -import org.eclipse.ui.ide.IDE; - - - -/** - * Default Implementation of {@link IScopeChooser} - * - * @author tfaure - */ -public abstract class ScopeChooser implements IScopeChooser { - - private final String description; - - private final String label; - - public ScopeChooser(String label, String formDescription) { - this.label = label; - this.description = formDescription; - - } - - public String getName() { - return label; - } - - public String getDescription() { - return description; - } - - - - public static class ScopeChooserVisitor implements IResourceVisitor { - - private List files = new LinkedList(); - - public boolean visit(IResource resource) throws CoreException { - if(resource instanceof IFile) { - IFile file = (IFile)resource; - if(isXMI(file)) { - files.add(file); - } - return false; - } - return true; - } - - /** - * Determine if the given file is an XMI some specific code has been set for notation and di - * - * @param f - * @return - */ - public boolean isXMI(IFile f) { - URI uri = URI.createPlatformResourceURI(f.getFullPath().toString(), true); - IContentType contentType = IDE.getContentType(f); - Registry instance = Resource.Factory.Registry.INSTANCE; - Object old = instance.getContentTypeToFactoryMap().get(Resource.Factory.Registry.DEFAULT_CONTENT_TYPE_IDENTIFIER); - Object old2 = instance.getExtensionToFactoryMap().get(Resource.Factory.Registry.DEFAULT_EXTENSION); - instance.getContentTypeToFactoryMap().put(Resource.Factory.Registry.DEFAULT_CONTENT_TYPE_IDENTIFIER, null); - instance.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, null); - boolean result = (f != null && contentType != null && (Resource.Factory.Registry.INSTANCE.getFactory(uri, contentType.getId()) != null || "notation".equals(f.getFileExtension()) || "di".equals(f.getFileExtension()))); - instance.getContentTypeToFactoryMap().put(Resource.Factory.Registry.DEFAULT_CONTENT_TYPE_IDENTIFIER, old); - instance.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, old2); - return result; - } - - public List getFiles() { - return files; - } - - } - -} diff --git a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/messages.properties b/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/messages.properties deleted file mode 100644 index eff43c17e63..00000000000 --- a/plugins/infra/org.eclipse.papyrus.infra.ui.resources/src/org/eclipse/papyrus/ui/resources/refactoring/ui/messages.properties +++ /dev/null @@ -1,10 +0,0 @@ -RenameParticipantsDialog_DESCRIPTION=

The rename operation can have several impacts on related files

Please choose the scope of references fixing operation

-RenameParticipantsDialog_DESCRIPTION_LABEL=Description -RenameParticipantsDialog_DESCRIPTION_NO_ANALYSIS=

No analysis is performed, this option is recommended for experimented users

-RenameParticipantsDialog_DESCRIPTION_PROJECT=

The references will be analysed in the project of the renamed file

-RenameParticipantsDialog_DESCRIPTION_WORKSPACE=

The references will be analysed in the whole workspace

This operation can be long

-RenameParticipantsDialog_NAME_NO_ANALYSIS=No Analysis -RenameParticipantsDialog_NAME_PROJECT=Project (default) -RenameParticipantsDialog_NAME_WORKSPACE=Workspace -RenameParticipantsDialog_OPTIONS=Options -RenameParticipantsDialog_SELECT_RENAME_OPTION=Select Rename Options -- cgit v1.2.3