Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2013-03-06 09:52:50 +0000
committervlorenzo2013-03-06 09:52:50 +0000
commit8be32fb7c45059308df91e8fbeebdd85d6e937f5 (patch)
treec8b1c3271659933a2a518d2f46df0ea6d618343a
parentf0c66cefd46f073a96179bb768c256500cb74015 (diff)
downloadorg.eclipse.papyrus-8be32fb7c45059308df91e8fbeebdd85d6e937f5.tar.gz
org.eclipse.papyrus-8be32fb7c45059308df91e8fbeebdd85d6e937f5.tar.xz
org.eclipse.papyrus-8be32fb7c45059308df91e8fbeebdd85d6e937f5.zip
290952: [CDO] Support for CDO model repository
https://bugs.eclipse.org/bugs/show_bug.cgi?id=290952 Merge from R9967 to R10361 (CDO Extra-plugins)
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/.classpath8
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/.project28
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF38
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/about.html28
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/build.properties22
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/model/repositories.ecore18
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/model/repositories.ecorediag61
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/model/repositories.genmodel20
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/plugin.properties13
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/plugin.xml83
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/RepositoriesFactory.java61
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/RepositoriesPackage.java303
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/Repository.java115
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/RepositoryRegistry.java52
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoriesFactoryImpl.java116
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoriesPackageImpl.java262
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoryImpl.java281
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoryRegistryImpl.java162
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesAdapterFactory.java148
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesResourceFactoryImpl.java61
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesResourceImpl.java38
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesSwitch.java141
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesXMLProcessor.java60
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/CommitException.java44
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/IPapyrusRepository.java62
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/IPapyrusRepositoryManager.java34
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/IResourceSetDisposalApprover.java34
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelDependentsProvider.java26
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportConfiguration.java53
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportListener.java26
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportMapping.java48
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportMappingListener.java26
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportNode.java32
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportOperation.java28
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImporter.java30
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/ModelImportListenerAdapter.java38
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/ModelImportMappingListenerAdapter.java39
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java216
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSetServiceFactory.java59
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareTransactionalEditingDomain.java74
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareTransactionalEditingDomainProvider.java50
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOReadOnlyHandler.java54
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/PapyrusCDOResourceFactory.java40
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/PapyrusDawnResourceImpl.java57
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/Activator.java49
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CDOUtils.java196
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CompositeResourceSetDisposalApprover.java75
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/ICredentialsProviderFactory.java24
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInteractiveCredentialsProvider.java24
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInternalPapyrusRepository.java31
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInternalPapyrusRepositoryManager.java32
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IRepositoryModelStorage.java46
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java643
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepositoryManager.java283
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepositoryManagerServiceFactory.java57
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/expressions/EObjectPropertyTester.java45
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/AbstractModelImportMapping.java215
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/DefaultModelImportConfigurationFactory.java39
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/DependencyAdapter.java172
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ManyToOneModelImportMapping.java48
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ManyToOneModelImportMappingFactory.java32
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImportConfiguration.java268
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImportNode.java182
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImporter.java358
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImporterFactory.java31
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/OneToOneModelImportMapping.java48
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/OneToOneModelImportMappingFactory.java32
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ReentrantOperationContext.java55
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/WorkspaceDIDependentsProvider.java120
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.classpath7
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.project28
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/META-INF/MANIFEST.MF45
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/about.html28
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/build.properties10
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ctool16/add_repo.gifbin0 -> 592 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ctool16/add_repo.pxmbin0 -> 25053 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ctool16/link_editor.gifbin0 -> 160 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/dlcl16/connect_co.gifbin0 -> 264 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/dlcl16/connect_co.pxmbin0 -> 20871 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/dlcl16/disconnect_co.gifbin0 -> 110 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/connect_co.gifbin0 -> 587 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/connect_co.pxmbin0 -> 20872 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/disconnect_co.gifbin0 -> 114 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/newfolder_co.gifbin0 -> 352 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/papyrus_model.gifbin0 -> 3487 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/repo_closed.gifbin0 -> 258 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/repo_closed.pxmbin0 -> 16668 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/repo_open.gifbin0 -> 594 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/conflicted.gifbin0 -> 3487 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/dependent.gifbin0 -> 3441 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/dependent.pxmbin0 -> 20770 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/other_locked.gifbin0 -> 3453 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/self_locked.gifbin0 -> 3457 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/conflicted.gifbin0 -> 3952 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/conflicted.pxmbin0 -> 24871 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/other_locked.gifbin0 -> 3870 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/other_locked.pxmbin0 -> 20771 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/self_locked.gifbin0 -> 4282 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/self_locked.pxmbin0 -> 24871 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/view16/model_repositories.gifbin0 -> 594 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/view16/model_repositories.pxmbin0 -> 20871 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.properties13
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.xml291
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/Activator.java177
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/SharedImages.java43
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AbstractRepositoryAction.java84
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AddRepositoryAction.java80
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncAction.java88
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncTransactionAction.java89
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/ConnectRepositoryAction.java57
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/CreateFolderAction.java168
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/DeleteModelAction.java122
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/DisconnectRepositoryAction.java75
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/LinkWithEditorAction.java56
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/OpenPapyrusModelAction.java72
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/RemoveRepositoryAction.java79
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/adapters/CDOAdapterFactory.java63
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/adapters/EditorAdapterFactory.java50
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/adapters/PapyrusRepositoryWorkbenchAdapter.java90
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/CDOStateAdapter.java180
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/CDOStateDiagramDecorator.java88
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/CDOStateLabelDecorator.java183
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/DiagramDecoratorProvider.java58
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusConnectionEditPartStylizer.java23
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusEditPartStylizer.java101
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusElementStylizer.java99
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusElementStylizerFactory.java63
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusNodeEditPartStylizer.java23
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/dialogs/AddRepositoryDialog.java103
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/dialogs/RepositoryCredentialsDialog.java129
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/DawnEditorAdapter.java232
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/DawnGraphicalEditorSupport.java168
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/DawnGraphicalEditorSupportServiceFactory.java60
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusCDOEditorInput.java40
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusCDOEditorManager.java249
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFEditorSupport.java283
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFHandler.java187
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFLockingHandler.java35
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusTransactionListener.java176
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/expressions/CDOObjectPropertyTester.java82
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/ImportModelsHandler.java49
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/LockObjectsHandler.java36
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/ResolveConflictsHandler.java45
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/UIHandlerUtil.java63
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/UnlockObjectsHandler.java36
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/markers/CDOMarkerMonitor.java72
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/markers/CDOMarkerProvider.java242
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/markers/CDOPapyrusMarker.java275
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/properties/RepositoryPropertiesBlock.java483
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/properties/RepositoryPropertyPage.java153
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/providers/ModelImportNodeLabelProvider.java106
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/providers/PapyrusElementLabelProvider.java37
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/CompositeLabelProvider.java104
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/DialogCredentialsProviderFactory.java181
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/UIUtil.java223
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/DIModel.java138
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/DIResourceQuery.java274
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/LinkingHelper.java222
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ModelRepositoriesView.java232
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ModelRepositoryItemProvider.java174
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelImportWizard.java294
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelImportWizardPage.java116
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelMappingsPage.java496
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelReferencesPage.java425
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/RepositorySelectionBlock.java223
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/RepositorySelectionPage.java102
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.classpath7
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.project28
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/META-INF/MANIFEST.MF21
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/about.html28
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/build.properties10
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/icons/full/elcl16/newmodel_co.gifbin0 -> 3502 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/icons/full/elcl16/newmodel_co.pxmbin0 -> 24974 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/plugin.properties13
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/plugin.xml68
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/Activator.java52
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/handlers/NewModelHandler.java51
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/wizards/CDONewModelStorageProvider.java256
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/wizards/NewModelPage.java389
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/wizards/RepositorySelectionPart.java80
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/.classpath7
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/.project28
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/META-INF/MANIFEST.MF20
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/about.html28
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/build.properties8
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/plugin.properties13
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/plugin.xml27
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/src/org/eclipse/papyrus/cdo/uml/internal/ui/Activator.java51
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/src/org/eclipse/papyrus/cdo/uml/internal/ui/importsources/CDOPackageImportSource.java219
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.classpath7
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.project28
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/META-INF/MANIFEST.MF16
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/about.html28
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/build.properties20
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/ctool16/CreateEProblemsContainer_problems_EProblem.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/ctool16/CreateEProblemsContainer_subcontainers_EProblemsContainer.gifbin0 -> 223 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/obj16/EProblem.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/obj16/EProblemsContainer.gifbin0 -> 129 bytes
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/plugin.properties49
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/plugin.xml37
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/edit/IProblemTypeProvider.java24
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/edit/ProblemEditUtil.java115
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/edit/ProblemTypeItemProviderAdapter.java33
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/EProblemItemProvider.java285
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/EProblemsContainerItemProvider.java223
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/ProblemsEditPlugin.java97
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/ProblemsItemProviderAdapterFactory.java306
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.classpath7
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.project34
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/META-INF/CDO.MF1
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/META-INF/MANIFEST.MF18
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/about.html28
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/build.properties23
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/model/Problems.ecore90
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/model/Problems.ecorediag237
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/model/Problems.genmodel58
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/plugin.properties13
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/plugin.xml27
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/EProblem.java263
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/EProblemsContainer.java191
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/ESeverity.java300
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/ProblemsFactory.java62
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/ProblemsPackage.java813
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/EProblemImpl.java245
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/EProblemsContainerImpl.java287
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/ProblemsFactoryImpl.java181
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/ProblemsPackageImpl.java560
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/internal/ProblemsPlugin.java100
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsAdapterFactory.java153
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsEvent.java52
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsListener.java25
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsManager.java603
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsSwitch.java150
245 files changed, 22725 insertions, 0 deletions
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/.classpath b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/.classpath
new file mode 100644
index 00000000000..59cf3977c7e
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="src-gen"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/.project b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/.project
new file mode 100644
index 00000000000..7e3c161802a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.cdo.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/.settings/org.eclipse.core.resources.prefs b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000000..b100be5b829
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+encoding//model/repositories.ecore=UTF-8
+encoding//model/repositories.ecorediag=UTF-8
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/.settings/org.eclipse.jdt.core.prefs b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..af0f20f97a5
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/.settings/org.eclipse.jdt.ui.prefs b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 00000000000..86087cd06ce
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.ui.javadoc=true
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*****************************************************************************\n * Copyright (c) ${year} CEA LIST.\n * \n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors\:\n * CEA LIST - Initial API and implementation\n *****************************************************************************/</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * This is the ${type_name} type. Enjoy.\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..1a1e4b27e92
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF
@@ -0,0 +1,38 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.cdo.core;singleton:=true
+Bundle-Version: 0.10.0.qualifier
+Bundle-ClassPath: .
+Bundle-Activator: org.eclipse.papyrus.cdo.internal.core.Activator
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.emf.ecore;visibility:=reexport,
+ org.eclipse.emf.ecore.xmi;visibility:=reexport,
+ org.eclipse.emf.cdo;bundle-version="[4.2.0,5.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.core;bundle-version="0.10.0";visibility:=reexport,
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.services.resourceloading;bundle-version="0.10.0";visibility:=reexport,
+ org.eclipse.papyrus.infra.emf.readonly;bundle-version="0.10.0";visibility:=reexport,
+ org.eclipse.emf.workspace;bundle-version="[1.5.1,2.0.0)",
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="0.10.0",
+ org.eclipse.emf.cdo.dawn;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.emf.cdo.dawn.gmf;bundle-version="[2.1.0,3.0.0)",
+ org.eclipse.emf.transaction;bundle-version="[1.4.0,2.0.0)";visibility:=reexport,
+ org.eclipse.gmf.runtime.notation;bundle-version="[1.5.0,2.0.0)",
+ org.eclipse.equinox.security;bundle-version="[1.1.100,2.0.0)",
+ org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.papyrus.cdo.core,
+ org.eclipse.papyrus.cdo.core.importer,
+ org.eclipse.papyrus.cdo.core.resource,
+ org.eclipse.papyrus.cdo.internal.core,
+ org.eclipse.papyrus.cdo.internal.core.expressions,
+ org.eclipse.papyrus.cdo.internal.core.importer,
+ org.eclipse.papyrus.cdo.internal.core.repositories,
+ org.eclipse.papyrus.cdo.internal.core.repositories.impl,
+ org.eclipse.papyrus.cdo.internal.core.repositories.util
+Bundle-ActivationPolicy: lazy
+Import-Package: com.google.common.base;version="10.0.1",
+ com.google.common.collect;version="10.0.1"
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/about.html b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/about.html
new file mode 100644
index 00000000000..209103075a7
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>November 14, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/build.properties b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/build.properties
new file mode 100644
index 00000000000..10b29360b0b
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/build.properties
@@ -0,0 +1,22 @@
+# Copyright (c) 2013 CEA LIST.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# CEA LIST - Initial API and implementation
+#
+
+bin.includes = .,\
+ model/,\
+ META-INF/,\
+ plugin.xml,\
+ plugin.properties,\
+ about.html
+jars.compile.order = .
+source.. = src/,\
+ src-gen/
+output.. = bin/
+src.includes = about.html
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/model/repositories.ecore b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/model/repositories.ecore
new file mode 100644
index 00000000000..05053b86e0e
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/model/repositories.ecore
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="repositories" nsURI="http://www.eclipse.org/papyrus/repositories/0.10.0"
+ nsPrefix="repositories">
+ <eClassifiers xsi:type="ecore:EClass" name="RepositoryRegistry">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="repositories" upperBound="-1"
+ eType="#//Repository" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Repository">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="uRL" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
+ <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
+ <details key="name" value="url"/>
+ </eAnnotations>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="description" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/model/repositories.ecorediag b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/model/repositories.ecorediag
new file mode 100644
index 00000000000..7e36e89e7d3
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/model/repositories.ecorediag
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmi:id="_DRuIEF5XEeKVz4CWs4rkiA" type="EcoreTools" name="repositories" measurementUnit="Pixel">
+ <children xmi:type="notation:Node" xmi:id="_OS9A4F5XEeKVz4CWs4rkiA" type="1001">
+ <children xmi:type="notation:Node" xmi:id="_OS-2EF5XEeKVz4CWs4rkiA" type="4001"/>
+ <children xmi:type="notation:Node" xmi:id="_OTAEMF5XEeKVz4CWs4rkiA" type="5001">
+ <styles xmi:type="notation:DrawerStyle" xmi:id="_OTAEMV5XEeKVz4CWs4rkiA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_OTAEMl5XEeKVz4CWs4rkiA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_OTAEM15XEeKVz4CWs4rkiA"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_OTArQF5XEeKVz4CWs4rkiA" type="5002">
+ <styles xmi:type="notation:DrawerStyle" xmi:id="_OTArQV5XEeKVz4CWs4rkiA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_OTArQl5XEeKVz4CWs4rkiA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_OTArQ15XEeKVz4CWs4rkiA"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_OS9A4V5XEeKVz4CWs4rkiA" fontColor="4210752" fontName="Lucida Grande" fontHeight="10" fillColor="13761016" lineColor="8421504"/>
+ <element xmi:type="ecore:EClass" href="repositories.ecore#//RepositoryRegistry"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_OS9A4l5XEeKVz4CWs4rkiA" x="104" y="91" width="124"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_P7MKAF5XEeKVz4CWs4rkiA" type="1001">
+ <children xmi:type="notation:Node" xmi:id="_P7MKA15XEeKVz4CWs4rkiA" type="4001"/>
+ <children xmi:type="notation:Node" xmi:id="_P7MKBF5XEeKVz4CWs4rkiA" type="5001">
+ <children xmi:type="notation:Node" xmi:id="_VleMQF5XEeKVz4CWs4rkiA" type="2001">
+ <element xmi:type="ecore:EAttribute" href="repositories.ecore#//Repository/name"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_VleMQV5XEeKVz4CWs4rkiA"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_i4ObwF5XEeKVz4CWs4rkiA" type="2001">
+ <element xmi:type="ecore:EAttribute" href="repositories.ecore#//Repository/description"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_i4ObwV5XEeKVz4CWs4rkiA"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_dScfAF5XEeKVz4CWs4rkiA" type="2001">
+ <element xmi:type="ecore:EAttribute" href="repositories.ecore#//Repository/uRL"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_dScfAV5XEeKVz4CWs4rkiA"/>
+ </children>
+ <styles xmi:type="notation:DrawerStyle" xmi:id="_P7MKBV5XEeKVz4CWs4rkiA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_P7MKBl5XEeKVz4CWs4rkiA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_P7MKB15XEeKVz4CWs4rkiA"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_P7MKCF5XEeKVz4CWs4rkiA" type="5002">
+ <styles xmi:type="notation:DrawerStyle" xmi:id="_P7MKCV5XEeKVz4CWs4rkiA"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_P7MKCl5XEeKVz4CWs4rkiA"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_P7MKC15XEeKVz4CWs4rkiA"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_P7MKAV5XEeKVz4CWs4rkiA" fontColor="4210752" fontName="Lucida Grande" fontHeight="10" fillColor="13761016" lineColor="8421504"/>
+ <element xmi:type="ecore:EClass" href="repositories.ecore#//Repository"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_P7MKAl5XEeKVz4CWs4rkiA" x="99" y="198"/>
+ </children>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_DRuIEV5XEeKVz4CWs4rkiA"/>
+ <element xmi:type="ecore:EPackage" href="repositories.ecore#/"/>
+ <edges xmi:type="notation:Edge" xmi:id="_Rw68kF5XEeKVz4CWs4rkiA" type="3002" source="_OS9A4F5XEeKVz4CWs4rkiA" target="_P7MKAF5XEeKVz4CWs4rkiA">
+ <children xmi:type="notation:Node" xmi:id="_Rw8KsF5XEeKVz4CWs4rkiA" type="4011">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Rw8KsV5XEeKVz4CWs4rkiA" x="-2" y="-42"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_Rw8xwF5XEeKVz4CWs4rkiA" type="4012">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Rw8xwV5XEeKVz4CWs4rkiA" x="-3" y="14"/>
+ </children>
+ <styles xmi:type="notation:ConnectorStyle" xmi:id="_Rw68kV5XEeKVz4CWs4rkiA" lineColor="4210752"/>
+ <styles xmi:type="notation:FontStyle" xmi:id="_Rw68kl5XEeKVz4CWs4rkiA" fontColor="4210752" fontName="Lucida Grande" fontHeight="10"/>
+ <element xmi:type="ecore:EReference" href="repositories.ecore#//RepositoryRegistry/repositories"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_Rw68k15XEeKVz4CWs4rkiA" points="[1, 20, -25, -105]$[-24, 127, -50, 2]"/>
+ </edges>
+</notation:Diagram>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/model/repositories.genmodel b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/model/repositories.genmodel
new file mode 100644
index 00000000000..00d82c4912f
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/model/repositories.genmodel
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
+ xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" copyrightText="Copyright (c) 2013 CEA LIST.&#xA;&#xA;All rights reserved. This program and the accompanying materials&#xA;are made available under the terms of the Eclipse Public License v1.0&#xA;which accompanies this distribution, and is available at&#xA;http://www.eclipse.org/legal/epl-v10.html&#xA;&#xA;Contributors:&#xA; CEA LIST - Initial API and implementation&#xA;"
+ modelDirectory="/org.eclipse.papyrus.cdo.core/src-gen" modelPluginID="org.eclipse.papyrus.cdo.core"
+ modelName="Repositories" nonNLSMarkers="true" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container"
+ importerID="org.eclipse.emf.importer.ecore" complianceLevel="5.0" copyrightFields="false"
+ runtimeVersion="2.8" operationReflection="true" importOrganizing="true">
+ <foreignModel>repositories.ecore</foreignModel>
+ <genPackages prefix="Repositories" basePackage="org.eclipse.papyrus.cdo.internal.core"
+ resource="XML" disposableProviderFactory="true" ecorePackage="repositories.ecore#/">
+ <genClasses ecoreClass="repositories.ecore#//RepositoryRegistry">
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference repositories.ecore#//RepositoryRegistry/repositories"/>
+ </genClasses>
+ <genClasses ecoreClass="repositories.ecore#//Repository">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute repositories.ecore#//Repository/name"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute repositories.ecore#//Repository/uRL"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute repositories.ecore#//Repository/description"/>
+ </genClasses>
+ </genPackages>
+</genmodel:GenModel>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/plugin.properties b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/plugin.properties
new file mode 100644
index 00000000000..0b690a42f75
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/plugin.properties
@@ -0,0 +1,13 @@
+# Copyright (c) 2013 CEA LIST.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# CEA LIST - Initial API and implementation
+#
+
+pluginName = Papyrus CDO Model Repository Core (Incubation)
+providerName = Eclipse Modeling Project
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/plugin.xml b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/plugin.xml
new file mode 100644
index 00000000000..b7ed909af27
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/plugin.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<!--
+ Copyright (c) 2013 CEA LIST.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ CEA LIST - Initial API and implementation
+
+-->
+
+<plugin>
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <!-- @generated repositories -->
+ <package
+ uri="http://www.eclipse.org/papyrus/repositories/0.10.0"
+ class="org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesPackage"
+ genModel="model/repositories.genmodel"/>
+ </extension>
+
+ <extension point="org.eclipse.emf.ecore.extension_parser">
+ <!-- @generated repositories -->
+ <parser
+ type="repositories"
+ class="org.eclipse.papyrus.cdo.internal.core.repositories.util.RepositoriesResourceFactoryImpl"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.papyrus.infra.core.service">
+ <serviceFactory
+ classname="org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManagerServiceFactory"
+ description="A provider of repository managers."
+ id="org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager"
+ priority="5"
+ startKind="startup">
+ </serviceFactory>
+
+ <!-- Priority of OnDemandLoadingModelSet is 5 -->
+ <serviceFactory
+ classname="org.eclipse.papyrus.cdo.core.resource.CDOAwareModelSetServiceFactory"
+ description="A provider of CDO-aware ModelSets."
+ id="org.eclipse.papyrus.infra.core.resource.ModelSet"
+ priority="10"
+ startKind="startup">
+ <dependsOn serviceKeyRef="org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager"/>
+ </serviceFactory>
+ </extension>
+
+ <extension
+ point="org.eclipse.papyrus.infra.core.transactionalEditingDomainProvider">
+ <transactionalEditingDomainProvider
+ class="org.eclipse.papyrus.cdo.core.resource.CDOAwareTransactionalEditingDomainProvider"
+ priority="11">
+ </transactionalEditingDomainProvider>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.emf.readonly.readOnlyHandler">
+
+ <!-- Priority of AppliedProfileReadOnlyHandler is 15 -->
+ <readOnlyHandler
+ class="org.eclipse.papyrus.cdo.core.resource.CDOReadOnlyHandler"
+ priority="16">
+ </readOnlyHandler>
+ </extension>
+
+ <extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.papyrus.cdo.internal.core.expressions.EObjectPropertyTester"
+ id="org.eclipse.papyrus.cdo.eObjectTester"
+ namespace="org.eclipse.papyrus.cdo.core"
+ properties="isCDOObject"
+ type="org.eclipse.emf.ecore.EObject">
+ </propertyTester>
+ </extension>
+
+</plugin>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/RepositoriesFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/RepositoriesFactory.java
new file mode 100644
index 00000000000..95b088898bb
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/RepositoriesFactory.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.cdo.internal.core.repositories;
+
+import org.eclipse.emf.ecore.EFactory;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Factory</b> for the model.
+ * It provides a create method for each non-abstract class of the model.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesPackage
+ * @generated
+ */
+public interface RepositoriesFactory extends EFactory {
+ /**
+ * The singleton instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ RepositoriesFactory eINSTANCE = org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoriesFactoryImpl.init();
+
+ /**
+ * Returns a new object of class '<em>Repository Registry</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Repository Registry</em>'.
+ * @generated
+ */
+ RepositoryRegistry createRepositoryRegistry();
+
+ /**
+ * Returns a new object of class '<em>Repository</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Repository</em>'.
+ * @generated
+ */
+ Repository createRepository();
+
+ /**
+ * Returns the package supported by this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the package supported by this factory.
+ * @generated
+ */
+ RepositoriesPackage getRepositoriesPackage();
+
+} //RepositoriesFactory
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/RepositoriesPackage.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/RepositoriesPackage.java
new file mode 100644
index 00000000000..1bd68949237
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/RepositoriesPackage.java
@@ -0,0 +1,303 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.cdo.internal.core.repositories;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Package</b> for the model.
+ * It contains accessors for the meta objects to represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each operation of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesFactory
+ * @model kind="package"
+ * @generated
+ */
+public interface RepositoriesPackage extends EPackage {
+ /**
+ * The package name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNAME = "repositories"; //$NON-NLS-1$
+
+ /**
+ * The package namespace URI.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_URI = "http://www.eclipse.org/papyrus/repositories/0.10.0"; //$NON-NLS-1$
+
+ /**
+ * The package namespace name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_PREFIX = "repositories"; //$NON-NLS-1$
+
+ /**
+ * The singleton instance of the package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ RepositoriesPackage eINSTANCE = org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoriesPackageImpl.init();
+
+ /**
+ * The meta object id for the '{@link org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoryRegistryImpl <em>Repository Registry</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoryRegistryImpl
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoriesPackageImpl#getRepositoryRegistry()
+ * @generated
+ */
+ int REPOSITORY_REGISTRY = 0;
+
+ /**
+ * The feature id for the '<em><b>Repositories</b></em>' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int REPOSITORY_REGISTRY__REPOSITORIES = 0;
+
+ /**
+ * The number of structural features of the '<em>Repository Registry</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int REPOSITORY_REGISTRY_FEATURE_COUNT = 1;
+
+ /**
+ * The number of operations of the '<em>Repository Registry</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int REPOSITORY_REGISTRY_OPERATION_COUNT = 0;
+
+ /**
+ * The meta object id for the '{@link org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoryImpl <em>Repository</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoryImpl
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoriesPackageImpl#getRepository()
+ * @generated
+ */
+ int REPOSITORY = 1;
+
+ /**
+ * The feature id for the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int REPOSITORY__NAME = 0;
+
+ /**
+ * The feature id for the '<em><b>URL</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int REPOSITORY__URL = 1;
+
+ /**
+ * The feature id for the '<em><b>Description</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int REPOSITORY__DESCRIPTION = 2;
+
+ /**
+ * The number of structural features of the '<em>Repository</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int REPOSITORY_FEATURE_COUNT = 3;
+
+ /**
+ * The number of operations of the '<em>Repository</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int REPOSITORY_OPERATION_COUNT = 0;
+
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.papyrus.cdo.internal.core.repositories.RepositoryRegistry <em>Repository Registry</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Repository Registry</em>'.
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.RepositoryRegistry
+ * @generated
+ */
+ EClass getRepositoryRegistry();
+
+ /**
+ * Returns the meta object for the containment reference list '{@link org.eclipse.papyrus.cdo.internal.core.repositories.RepositoryRegistry#getRepositories <em>Repositories</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the containment reference list '<em>Repositories</em>'.
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.RepositoryRegistry#getRepositories()
+ * @see #getRepositoryRegistry()
+ * @generated
+ */
+ EReference getRepositoryRegistry_Repositories();
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.papyrus.cdo.internal.core.repositories.Repository <em>Repository</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Repository</em>'.
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.Repository
+ * @generated
+ */
+ EClass getRepository();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.papyrus.cdo.internal.core.repositories.Repository#getName <em>Name</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Name</em>'.
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.Repository#getName()
+ * @see #getRepository()
+ * @generated
+ */
+ EAttribute getRepository_Name();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.papyrus.cdo.internal.core.repositories.Repository#getURL <em>URL</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>URL</em>'.
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.Repository#getURL()
+ * @see #getRepository()
+ * @generated
+ */
+ EAttribute getRepository_URL();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.papyrus.cdo.internal.core.repositories.Repository#getDescription <em>Description</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Description</em>'.
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.Repository#getDescription()
+ * @see #getRepository()
+ * @generated
+ */
+ EAttribute getRepository_Description();
+
+ /**
+ * Returns the factory that creates the instances of the model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the factory that creates the instances of the model.
+ * @generated
+ */
+ RepositoriesFactory getRepositoriesFactory();
+
+ /**
+ * <!-- begin-user-doc -->
+ * Defines literals for the meta objects that represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each operation of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ interface Literals {
+ /**
+ * The meta object literal for the '{@link org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoryRegistryImpl <em>Repository Registry</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoryRegistryImpl
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoriesPackageImpl#getRepositoryRegistry()
+ * @generated
+ */
+ EClass REPOSITORY_REGISTRY = eINSTANCE.getRepositoryRegistry();
+
+ /**
+ * The meta object literal for the '<em><b>Repositories</b></em>' containment reference list feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference REPOSITORY_REGISTRY__REPOSITORIES = eINSTANCE.getRepositoryRegistry_Repositories();
+
+ /**
+ * The meta object literal for the '{@link org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoryImpl <em>Repository</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoryImpl
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoriesPackageImpl#getRepository()
+ * @generated
+ */
+ EClass REPOSITORY = eINSTANCE.getRepository();
+
+ /**
+ * The meta object literal for the '<em><b>Name</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute REPOSITORY__NAME = eINSTANCE.getRepository_Name();
+
+ /**
+ * The meta object literal for the '<em><b>URL</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute REPOSITORY__URL = eINSTANCE.getRepository_URL();
+
+ /**
+ * The meta object literal for the '<em><b>Description</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute REPOSITORY__DESCRIPTION = eINSTANCE.getRepository_Description();
+
+ }
+
+} //RepositoriesPackage
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/Repository.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/Repository.java
new file mode 100644
index 00000000000..f7fc49f775b
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/Repository.java
@@ -0,0 +1,115 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.cdo.internal.core.repositories;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Repository</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.papyrus.cdo.internal.core.repositories.Repository#getName <em>Name</em>}</li>
+ * <li>{@link org.eclipse.papyrus.cdo.internal.core.repositories.Repository#getURL <em>URL</em>}</li>
+ * <li>{@link org.eclipse.papyrus.cdo.internal.core.repositories.Repository#getDescription <em>Description</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesPackage#getRepository()
+ * @model
+ * @generated
+ */
+public interface Repository extends EObject {
+ /**
+ * Returns the value of the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Name</em>' attribute.
+ * @see #setName(String)
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesPackage#getRepository_Name()
+ * @model required="true"
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.papyrus.cdo.internal.core.repositories.Repository#getName <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Name</em>' attribute.
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+ /**
+ * Returns the value of the '<em><b>URL</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>URL</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>URL</em>' attribute.
+ * @see #setURL(String)
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesPackage#getRepository_URL()
+ * @model required="true"
+ * extendedMetaData="name='url'"
+ * @generated
+ */
+ String getURL();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.papyrus.cdo.internal.core.repositories.Repository#getURL <em>URL</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>URL</em>' attribute.
+ * @see #getURL()
+ * @generated
+ */
+ void setURL(String value);
+
+ /**
+ * Returns the value of the '<em><b>Description</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Description</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Description</em>' attribute.
+ * @see #setDescription(String)
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesPackage#getRepository_Description()
+ * @model
+ * @generated
+ */
+ String getDescription();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.papyrus.cdo.internal.core.repositories.Repository#getDescription <em>Description</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Description</em>' attribute.
+ * @see #getDescription()
+ * @generated
+ */
+ void setDescription(String value);
+
+} // Repository
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/RepositoryRegistry.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/RepositoryRegistry.java
new file mode 100644
index 00000000000..12749d288d4
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/RepositoryRegistry.java
@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.cdo.internal.core.repositories;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Repository Registry</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.papyrus.cdo.internal.core.repositories.RepositoryRegistry#getRepositories <em>Repositories</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesPackage#getRepositoryRegistry()
+ * @model
+ * @generated
+ */
+public interface RepositoryRegistry extends EObject {
+ /**
+ * Returns the value of the '<em><b>Repositories</b></em>' containment reference list.
+ * The list contents are of type {@link org.eclipse.papyrus.cdo.internal.core.repositories.Repository}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Repositories</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Repositories</em>' containment reference list.
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesPackage#getRepositoryRegistry_Repositories()
+ * @model containment="true"
+ * @generated
+ */
+ EList<Repository> getRepositories();
+
+} // RepositoryRegistry
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoriesFactoryImpl.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoriesFactoryImpl.java
new file mode 100644
index 00000000000..57be4cb0346
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoriesFactoryImpl.java
@@ -0,0 +1,116 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.cdo.internal.core.repositories.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.cdo.internal.core.repositories.*;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Factory</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class RepositoriesFactoryImpl extends EFactoryImpl implements RepositoriesFactory {
+ /**
+ * Creates the default factory implementation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static RepositoriesFactory init() {
+ try {
+ RepositoriesFactory theRepositoriesFactory = (RepositoriesFactory)EPackage.Registry.INSTANCE.getEFactory(RepositoriesPackage.eNS_URI);
+ if (theRepositoriesFactory != null) {
+ return theRepositoriesFactory;
+ }
+ }
+ catch (Exception exception) {
+ EcorePlugin.INSTANCE.log(exception);
+ }
+ return new RepositoriesFactoryImpl();
+ }
+
+ /**
+ * Creates an instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public RepositoriesFactoryImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public EObject create(EClass eClass) {
+ switch (eClass.getClassifierID()) {
+ case RepositoriesPackage.REPOSITORY_REGISTRY: return createRepositoryRegistry();
+ case RepositoriesPackage.REPOSITORY: return createRepository();
+ default:
+ throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public RepositoryRegistry createRepositoryRegistry() {
+ RepositoryRegistryImpl repositoryRegistry = new RepositoryRegistryImpl();
+ return repositoryRegistry;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Repository createRepository() {
+ RepositoryImpl repository = new RepositoryImpl();
+ return repository;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public RepositoriesPackage getRepositoriesPackage() {
+ return (RepositoriesPackage)getEPackage();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @deprecated
+ * @generated
+ */
+ @Deprecated
+ public static RepositoriesPackage getPackage() {
+ return RepositoriesPackage.eINSTANCE;
+ }
+
+} //RepositoriesFactoryImpl
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoriesPackageImpl.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoriesPackageImpl.java
new file mode 100644
index 00000000000..e56eb4db826
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoriesPackageImpl.java
@@ -0,0 +1,262 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.cdo.internal.core.repositories.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.impl.EPackageImpl;
+
+import org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesFactory;
+import org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesPackage;
+import org.eclipse.papyrus.cdo.internal.core.repositories.Repository;
+import org.eclipse.papyrus.cdo.internal.core.repositories.RepositoryRegistry;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Package</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class RepositoriesPackageImpl extends EPackageImpl implements RepositoriesPackage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass repositoryRegistryEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass repositoryEClass = null;
+
+ /**
+ * Creates an instance of the model <b>Package</b>, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
+ * package URI value.
+ * <p>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.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesPackage#eNS_URI
+ * @see #init()
+ * @generated
+ */
+ private RepositoriesPackageImpl() {
+ super(eNS_URI, RepositoriesFactory.eINSTANCE);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
+ *
+ * <p>This method is used to initialize {@link RepositoriesPackage#eINSTANCE} when that field is accessed.
+ * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #eNS_URI
+ * @see #createPackageContents()
+ * @see #initializePackageContents()
+ * @generated
+ */
+ public static RepositoriesPackage init() {
+ if (isInited) return (RepositoriesPackage)EPackage.Registry.INSTANCE.getEPackage(RepositoriesPackage.eNS_URI);
+
+ // Obtain or create and register package
+ RepositoriesPackageImpl theRepositoriesPackage = (RepositoriesPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof RepositoriesPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new RepositoriesPackageImpl());
+
+ isInited = true;
+
+ // Create package meta-data objects
+ theRepositoriesPackage.createPackageContents();
+
+ // Initialize created meta-data
+ theRepositoriesPackage.initializePackageContents();
+
+ // Mark meta-data to indicate it can't be changed
+ theRepositoriesPackage.freeze();
+
+
+ // Update the registry and return the package
+ EPackage.Registry.INSTANCE.put(RepositoriesPackage.eNS_URI, theRepositoriesPackage);
+ return theRepositoriesPackage;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getRepositoryRegistry() {
+ return repositoryRegistryEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getRepositoryRegistry_Repositories() {
+ return (EReference)repositoryRegistryEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getRepository() {
+ return repositoryEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getRepository_Name() {
+ return (EAttribute)repositoryEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getRepository_URL() {
+ return (EAttribute)repositoryEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getRepository_Description() {
+ return (EAttribute)repositoryEClass.getEStructuralFeatures().get(2);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public RepositoriesFactory getRepositoriesFactory() {
+ return (RepositoriesFactory)getEFactoryInstance();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createPackageContents() {
+ if (isCreated) return;
+ isCreated = true;
+
+ // Create classes and their features
+ repositoryRegistryEClass = createEClass(REPOSITORY_REGISTRY);
+ createEReference(repositoryRegistryEClass, REPOSITORY_REGISTRY__REPOSITORIES);
+
+ repositoryEClass = createEClass(REPOSITORY);
+ createEAttribute(repositoryEClass, REPOSITORY__NAME);
+ createEAttribute(repositoryEClass, REPOSITORY__URL);
+ createEAttribute(repositoryEClass, REPOSITORY__DESCRIPTION);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void initializePackageContents() {
+ if (isInitialized) return;
+ isInitialized = true;
+
+ // Initialize package
+ setName(eNAME);
+ setNsPrefix(eNS_PREFIX);
+ setNsURI(eNS_URI);
+
+ // Create type parameters
+
+ // Set bounds for type parameters
+
+ // Add supertypes to classes
+
+ // Initialize classes, features, and operations; add parameters
+ initEClass(repositoryRegistryEClass, RepositoryRegistry.class, "RepositoryRegistry", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
+ initEReference(getRepositoryRegistry_Repositories(), this.getRepository(), null, "repositories", null, 0, -1, RepositoryRegistry.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+
+ initEClass(repositoryEClass, Repository.class, "Repository", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
+ initEAttribute(getRepository_Name(), ecorePackage.getEString(), "name", null, 1, 1, Repository.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEAttribute(getRepository_URL(), ecorePackage.getEString(), "uRL", null, 1, 1, Repository.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEAttribute(getRepository_Description(), ecorePackage.getEString(), "description", null, 0, 1, Repository.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+
+ // Create resource
+ createResource(eNS_URI);
+
+ // Create annotations
+ // http:///org/eclipse/emf/ecore/util/ExtendedMetaData
+ createExtendedMetaDataAnnotations();
+ }
+
+ /**
+ * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void createExtendedMetaDataAnnotations() {
+ String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; //$NON-NLS-1$
+ addAnnotation
+ (getRepository_URL(),
+ source,
+ new String[] {
+ "name", "url" //$NON-NLS-1$ //$NON-NLS-2$
+ });
+ }
+
+} //RepositoriesPackageImpl
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoryImpl.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoryImpl.java
new file mode 100644
index 00000000000..404b6c558e0
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoryImpl.java
@@ -0,0 +1,281 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.cdo.internal.core.repositories.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.MinimalEObjectImpl;
+
+import org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesPackage;
+import org.eclipse.papyrus.cdo.internal.core.repositories.Repository;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Repository</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoryImpl#getName <em>Name</em>}</li>
+ * <li>{@link org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoryImpl#getURL <em>URL</em>}</li>
+ * <li>{@link org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoryImpl#getDescription <em>Description</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class RepositoryImpl extends MinimalEObjectImpl.Container implements Repository {
+ /**
+ * The default value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected static final String NAME_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected String name = NAME_EDEFAULT;
+
+ /**
+ * The default value of the '{@link #getURL() <em>URL</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getURL()
+ * @generated
+ * @ordered
+ */
+ protected static final String URL_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getURL() <em>URL</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getURL()
+ * @generated
+ * @ordered
+ */
+ protected String uRL = URL_EDEFAULT;
+
+ /**
+ * The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getDescription()
+ * @generated
+ * @ordered
+ */
+ protected static final String DESCRIPTION_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getDescription()
+ * @generated
+ * @ordered
+ */
+ protected String description = DESCRIPTION_EDEFAULT;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected RepositoryImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return RepositoriesPackage.Literals.REPOSITORY;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setName(String newName) {
+ String oldName = name;
+ name = newName;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, RepositoriesPackage.REPOSITORY__NAME, oldName, name));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getURL() {
+ return uRL;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setURL(String newURL) {
+ String oldURL = uRL;
+ uRL = newURL;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, RepositoriesPackage.REPOSITORY__URL, oldURL, uRL));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setDescription(String newDescription) {
+ String oldDescription = description;
+ description = newDescription;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, RepositoriesPackage.REPOSITORY__DESCRIPTION, oldDescription, description));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case RepositoriesPackage.REPOSITORY__NAME:
+ return getName();
+ case RepositoriesPackage.REPOSITORY__URL:
+ return getURL();
+ case RepositoriesPackage.REPOSITORY__DESCRIPTION:
+ return getDescription();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case RepositoriesPackage.REPOSITORY__NAME:
+ setName((String)newValue);
+ return;
+ case RepositoriesPackage.REPOSITORY__URL:
+ setURL((String)newValue);
+ return;
+ case RepositoriesPackage.REPOSITORY__DESCRIPTION:
+ setDescription((String)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case RepositoriesPackage.REPOSITORY__NAME:
+ setName(NAME_EDEFAULT);
+ return;
+ case RepositoriesPackage.REPOSITORY__URL:
+ setURL(URL_EDEFAULT);
+ return;
+ case RepositoriesPackage.REPOSITORY__DESCRIPTION:
+ setDescription(DESCRIPTION_EDEFAULT);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case RepositoriesPackage.REPOSITORY__NAME:
+ return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
+ case RepositoriesPackage.REPOSITORY__URL:
+ return URL_EDEFAULT == null ? uRL != null : !URL_EDEFAULT.equals(uRL);
+ case RepositoriesPackage.REPOSITORY__DESCRIPTION:
+ return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String toString() {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (name: "); //$NON-NLS-1$
+ result.append(name);
+ result.append(", uRL: "); //$NON-NLS-1$
+ result.append(uRL);
+ result.append(", description: "); //$NON-NLS-1$
+ result.append(description);
+ result.append(')');
+ return result.toString();
+ }
+
+} //RepositoryImpl
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoryRegistryImpl.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoryRegistryImpl.java
new file mode 100644
index 00000000000..f987b707b83
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/impl/RepositoryRegistryImpl.java
@@ -0,0 +1,162 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.cdo.internal.core.repositories.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.MinimalEObjectImpl;
+
+import org.eclipse.emf.ecore.util.EObjectContainmentEList;
+import org.eclipse.emf.ecore.util.InternalEList;
+
+import org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesPackage;
+import org.eclipse.papyrus.cdo.internal.core.repositories.Repository;
+import org.eclipse.papyrus.cdo.internal.core.repositories.RepositoryRegistry;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Repository Registry</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.eclipse.papyrus.cdo.internal.core.repositories.impl.RepositoryRegistryImpl#getRepositories <em>Repositories</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class RepositoryRegistryImpl extends MinimalEObjectImpl.Container implements RepositoryRegistry {
+ /**
+ * The cached value of the '{@link #getRepositories() <em>Repositories</em>}' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getRepositories()
+ * @generated
+ * @ordered
+ */
+ protected EList<Repository> repositories;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected RepositoryRegistryImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return RepositoriesPackage.Literals.REPOSITORY_REGISTRY;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EList<Repository> getRepositories() {
+ if (repositories == null) {
+ repositories = new EObjectContainmentEList<Repository>(Repository.class, this, RepositoriesPackage.REPOSITORY_REGISTRY__REPOSITORIES);
+ }
+ return repositories;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
+ switch (featureID) {
+ case RepositoriesPackage.REPOSITORY_REGISTRY__REPOSITORIES:
+ return ((InternalEList<?>)getRepositories()).basicRemove(otherEnd, msgs);
+ }
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case RepositoriesPackage.REPOSITORY_REGISTRY__REPOSITORIES:
+ return getRepositories();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case RepositoriesPackage.REPOSITORY_REGISTRY__REPOSITORIES:
+ getRepositories().clear();
+ getRepositories().addAll((Collection<? extends Repository>)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case RepositoriesPackage.REPOSITORY_REGISTRY__REPOSITORIES:
+ getRepositories().clear();
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case RepositoriesPackage.REPOSITORY_REGISTRY__REPOSITORIES:
+ return repositories != null && !repositories.isEmpty();
+ }
+ return super.eIsSet(featureID);
+ }
+
+} //RepositoryRegistryImpl
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesAdapterFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesAdapterFactory.java
new file mode 100644
index 00000000000..52a57e8157b
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesAdapterFactory.java
@@ -0,0 +1,148 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.cdo.internal.core.repositories.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.cdo.internal.core.repositories.*;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Adapter Factory</b> for the model.
+ * It provides an adapter <code>createXXX</code> method for each class of the model.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesPackage
+ * @generated
+ */
+public class RepositoriesAdapterFactory extends AdapterFactoryImpl {
+ /**
+ * The cached model package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected static RepositoriesPackage modelPackage;
+
+ /**
+ * Creates an instance of the adapter factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public RepositoriesAdapterFactory() {
+ if (modelPackage == null) {
+ modelPackage = RepositoriesPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Returns whether this factory is applicable for the type of the object.
+ * <!-- begin-user-doc -->
+ * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model.
+ * <!-- end-user-doc -->
+ * @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 <code>createXXX</code> methods.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected RepositoriesSwitch<Adapter> modelSwitch =
+ new RepositoriesSwitch<Adapter>() {
+ @Override
+ public Adapter caseRepositoryRegistry(RepositoryRegistry object) {
+ return createRepositoryRegistryAdapter();
+ }
+ @Override
+ public Adapter caseRepository(Repository object) {
+ return createRepositoryAdapter();
+ }
+ @Override
+ public Adapter defaultCase(EObject object) {
+ return createEObjectAdapter();
+ }
+ };
+
+ /**
+ * Creates an adapter for the <code>target</code>.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param target the object to adapt.
+ * @return the adapter for the <code>target</code>.
+ * @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.cdo.internal.core.repositories.RepositoryRegistry <em>Repository Registry</em>}'.
+ * <!-- begin-user-doc -->
+ * 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.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.RepositoryRegistry
+ * @generated
+ */
+ public Adapter createRepositoryRegistryAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.cdo.internal.core.repositories.Repository <em>Repository</em>}'.
+ * <!-- begin-user-doc -->
+ * 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.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.Repository
+ * @generated
+ */
+ public Adapter createRepositoryAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for the default case.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @generated
+ */
+ public Adapter createEObjectAdapter() {
+ return null;
+ }
+
+} //RepositoriesAdapterFactory
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesResourceFactoryImpl.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesResourceFactoryImpl.java
new file mode 100644
index 00000000000..dedda946d7f
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesResourceFactoryImpl.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.cdo.internal.core.repositories.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;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Resource Factory</b> associated with the package.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.util.RepositoriesResourceImpl
+ * @generated
+ */
+public class RepositoriesResourceFactoryImpl extends ResourceFactoryImpl {
+ /**
+ * Creates an instance of the resource factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public RepositoriesResourceFactoryImpl() {
+ super();
+ }
+
+ /**
+ * Creates an instance of the resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Resource createResource(URI uri) {
+ XMLResource result = new RepositoriesResourceImpl(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;
+ }
+
+} //RepositoriesResourceFactoryImpl
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesResourceImpl.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesResourceImpl.java
new file mode 100644
index 00000000000..71ce0a89bf8
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesResourceImpl.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.cdo.internal.core.repositories.util;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Resource </b> associated with the package.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.util.RepositoriesResourceFactoryImpl
+ * @generated
+ */
+public class RepositoriesResourceImpl extends XMLResourceImpl {
+ /**
+ * Creates an instance of the resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param uri the URI of the new resource.
+ * @generated
+ */
+ public RepositoriesResourceImpl(URI uri) {
+ super(uri);
+ }
+
+} //RepositoriesResourceImpl
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesSwitch.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesSwitch.java
new file mode 100644
index 00000000000..5e3aa2354e4
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesSwitch.java
@@ -0,0 +1,141 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.cdo.internal.core.repositories.util;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.util.Switch;
+
+import org.eclipse.papyrus.cdo.internal.core.repositories.*;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Switch</b> for the model's inheritance hierarchy.
+ * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
+ * to invoke the <code>caseXXX</code> 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.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesPackage
+ * @generated
+ */
+public class RepositoriesSwitch<T> extends Switch<T> {
+ /**
+ * The cached model package
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected static RepositoriesPackage modelPackage;
+
+ /**
+ * Creates an instance of the switch.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public RepositoriesSwitch() {
+ if (modelPackage == null) {
+ modelPackage = RepositoriesPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Checks whether this is a switch for the given package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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 <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ @Override
+ protected T doSwitch(int classifierID, EObject theEObject) {
+ switch (classifierID) {
+ case RepositoriesPackage.REPOSITORY_REGISTRY: {
+ RepositoryRegistry repositoryRegistry = (RepositoryRegistry)theEObject;
+ T result = caseRepositoryRegistry(repositoryRegistry);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case RepositoriesPackage.REPOSITORY: {
+ Repository repository = (Repository)theEObject;
+ T result = caseRepository(repository);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ default: return defaultCase(theEObject);
+ }
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>Repository Registry</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Repository Registry</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseRepositoryRegistry(RepositoryRegistry object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>Repository</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Repository</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseRepository(Repository object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch, but this is the last case anyway.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject)
+ * @generated
+ */
+ @Override
+ public T defaultCase(EObject object) {
+ return null;
+ }
+
+} //RepositoriesSwitch
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesXMLProcessor.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesXMLProcessor.java
new file mode 100644
index 00000000000..1896f06638b
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src-gen/org/eclipse/papyrus/cdo/internal/core/repositories/util/RepositoriesXMLProcessor.java
@@ -0,0 +1,60 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.cdo.internal.core.repositories.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.cdo.internal.core.repositories.RepositoriesPackage;
+
+/**
+ * This class contains helper methods to serialize and deserialize XML documents
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class RepositoriesXMLProcessor extends XMLProcessor {
+
+ /**
+ * Public constructor to instantiate the helper.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public RepositoriesXMLProcessor() {
+ super((EPackage.Registry.INSTANCE));
+ RepositoriesPackage.eINSTANCE.eClass();
+ }
+
+ /**
+ * Register for "*" and "xml" file extensions the RepositoriesResourceFactoryImpl factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected Map<String, Resource.Factory> getRegistrations() {
+ if (registrations == null) {
+ super.getRegistrations();
+ registrations.put(XML_EXTENSION, new RepositoriesResourceFactoryImpl());
+ registrations.put(STAR_EXTENSION, new RepositoriesResourceFactoryImpl());
+ }
+ return registrations;
+ }
+
+} //RepositoriesXMLProcessor
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/CommitException.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/CommitException.java
new file mode 100644
index 00000000000..be0612ce607
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/CommitException.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.papyrus.cdo.internal.core.Activator;
+
+
+/**
+ * This is the CommitException type. Enjoy.
+ */
+public class CommitException
+ extends CoreException {
+
+ private static final long serialVersionUID = 1L;
+
+ public CommitException() {
+ this("Commit failed.");
+ }
+
+ public CommitException(String message) {
+ super(new Status(IStatus.ERROR, Activator.PLUGIN_ID, message));
+ }
+
+ public CommitException(Throwable cause) {
+ this("Commit failed.", cause);
+ }
+
+ public CommitException(String message, Throwable cause) {
+ super(new Status(IStatus.ERROR, Activator.PLUGIN_ID, message, cause));
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/IPapyrusRepository.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/IPapyrusRepository.java
new file mode 100644
index 00000000000..2a99bf5a2c4
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/IPapyrusRepository.java
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+
+/**
+ * Protocol for a CDO repository in the Papyrus system.
+ */
+public interface IPapyrusRepository {
+ String getName();
+
+ void setName(String name);
+
+ String getURL();
+
+ String getUsername();
+
+ void setUsername(String username);
+
+ String getPassword();
+
+ void setPassword(String password);
+
+ void clearCredentials();
+
+ boolean isConnected();
+
+ void connect();
+
+ void disconnect() throws CommitException;
+
+ Collection<ResourceSet> getTransactions();
+
+ Collection<ResourceSet> getReadOnlyViews();
+
+ ResourceSet createReadOnlyView(ResourceSet resourceSet);
+
+ ResourceSet createTransaction(ResourceSet resourceSet);
+
+ void commit(ResourceSet transaction) throws CommitException;
+
+ void rollback(ResourceSet transaction);
+
+ void close(ResourceSet view);
+
+ void addResourceSetDisposalApprover(IResourceSetDisposalApprover approver);
+
+ void removeResourceSetDisposalApprover(IResourceSetDisposalApprover approver);
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/IPapyrusRepositoryManager.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/IPapyrusRepositoryManager.java
new file mode 100644
index 00000000000..3834c666219
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/IPapyrusRepositoryManager.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.util.URI;
+
+/**
+ * This is the IPapyrusRepositoryManager type. Enjoy.
+ */
+public interface IPapyrusRepositoryManager {
+
+ Collection<? extends IPapyrusRepository> getRepositories();
+
+ IPapyrusRepository createRepository(String url);
+
+ void removeRepository(IPapyrusRepository repository);
+
+ IPapyrusRepository getRepository(String url);
+
+ IPapyrusRepository getRepositoryForURI(URI uri);
+
+ void saveRepositories();
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/IResourceSetDisposalApprover.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/IResourceSetDisposalApprover.java
new file mode 100644
index 00000000000..2bf1dfb60f1
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/IResourceSetDisposalApprover.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * A protocol for objects that an {@link IPapyrusRepository} may consult to
+ * approve the closure of resource sets that have uncommitted changes.
+ */
+public interface IResourceSetDisposalApprover {
+
+ DisposeAction disposalRequested(IPapyrusRepository repository,
+ Collection<ResourceSet> resourceSets);
+
+ //
+ // Nested types
+ //
+
+ enum DisposeAction {
+ NONE, SAVE, CLOSE;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelDependentsProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelDependentsProvider.java
new file mode 100644
index 00000000000..b2bb973c29e
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelDependentsProvider.java
@@ -0,0 +1,26 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.importer;
+
+import java.util.Collection;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+
+/**
+ * This is the IModelDependentsProvider type. Enjoy.
+ */
+public interface IModelDependentsProvider {
+
+ Collection<URI> getDependents(Resource resource, IProgressMonitor monitor);
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportConfiguration.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportConfiguration.java
new file mode 100644
index 00000000000..736c3066ba3
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportConfiguration.java
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.importer;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.cdo.internal.core.importer.DefaultModelImportConfigurationFactory;
+
+/**
+ * This is the IModelImportConfiguration type. Enjoy.
+ */
+public interface IModelImportConfiguration {
+
+ Collection<IModelImportNode> getModelsToImport();
+
+ IModelImportNode addModelToImport(URI resourceURI);
+
+ void removeModelToImport(IModelImportNode node);
+
+ ResourceSet getResourceSet();
+
+ void addModelDependentsProvider(IModelDependentsProvider provider);
+
+ IModelImportOperation.Context getOperationContext();
+
+ Diagnostic validate();
+
+ void dispose();
+
+ void addModelImportListener(IModelImportListener listener);
+
+ void removeModelImportListener(IModelImportListener listener);
+
+ interface Factory {
+
+ Factory DEFAULT = new DefaultModelImportConfigurationFactory();
+
+ IModelImportConfiguration create(
+ IModelImportOperation.Context operationContext);
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportListener.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportListener.java
new file mode 100644
index 00000000000..25ca33ec2a0
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportListener.java
@@ -0,0 +1,26 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.importer;
+
+import org.eclipse.emf.common.util.Diagnostic;
+
+/**
+ * This is the IModelImportListener type. Enjoy.
+ */
+public interface IModelImportListener {
+
+ void modelsToImportChanged(IModelImportConfiguration configuration);
+
+ void modelDependentsChanged(IModelImportNode node);
+
+ void modelImportProblemsOccurred(Diagnostic problems);
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportMapping.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportMapping.java
new file mode 100644
index 00000000000..2bc7b51490e
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportMapping.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.importer;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.core.importer.ManyToOneModelImportMappingFactory;
+import org.eclipse.papyrus.cdo.internal.core.importer.OneToOneModelImportMappingFactory;
+
+/**
+ * This is the IModelImportMapping type. Enjoy.
+ */
+public interface IModelImportMapping {
+
+ IModelImportConfiguration getConfiguration();
+
+ IPapyrusRepository getRepository();
+
+ void setRepository(IPapyrusRepository repository);
+
+ void mapTo(IModelImportNode source, IPath path);
+
+ IPath getMapping(IModelImportNode node);
+
+ Diagnostic validate();
+
+ void addModelImportMappingListener(IModelImportMappingListener listener);
+
+ void removeModelImportMappingListener(IModelImportMappingListener listener);
+
+ interface Factory {
+ Factory ONE_TO_ONE = new OneToOneModelImportMappingFactory();
+
+ Factory MANY_TO_ONE = new ManyToOneModelImportMappingFactory();
+
+ IModelImportMapping create(IModelImportConfiguration configuration);
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportMappingListener.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportMappingListener.java
new file mode 100644
index 00000000000..7d44d0b8de4
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportMappingListener.java
@@ -0,0 +1,26 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.importer;
+
+import org.eclipse.emf.common.util.Diagnostic;
+
+/**
+ * This is the IModelImportMappingListener type. Enjoy.
+ */
+public interface IModelImportMappingListener {
+
+ void modelImportRepositoryChanged(IModelImportMapping mapping);
+
+ void modelImportMappingChanged(IModelImportNode node);
+
+ void modelImportMappingProblemsOccurred(Diagnostic problems);
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportNode.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportNode.java
new file mode 100644
index 00000000000..3fe4dd47624
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportNode.java
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.importer;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.util.URI;
+
+/**
+ * This is the IModelImportNode type. Enjoy.
+ */
+public interface IModelImportNode {
+
+ String getName();
+
+ URI getPrimaryResourceURI();
+
+ Collection<URI> getResourceURIs();
+
+ Collection<IModelImportNode> getDependencies();
+
+ Collection<IModelImportNode> getDependents();
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportOperation.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportOperation.java
new file mode 100644
index 00000000000..8bdb59148a1
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImportOperation.java
@@ -0,0 +1,28 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.importer;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.Diagnostic;
+
+/**
+ * This is the IModelImportOperation type. Enjoy.
+ */
+public interface IModelImportOperation {
+
+ Diagnostic run(IProgressMonitor monitor);
+
+ interface Context {
+
+ Diagnostic run(IModelImportOperation operation);
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImporter.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImporter.java
new file mode 100644
index 00000000000..7b374b57c74
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/IModelImporter.java
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.importer;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.papyrus.cdo.internal.core.importer.ModelImporterFactory;
+
+/**
+ * This is the IModelImporter type. Enjoy.
+ */
+public interface IModelImporter {
+
+ Diagnostic importModels(IModelImportMapping mapping);
+
+ interface Factory {
+
+ Factory DEFAULT = new ModelImporterFactory();
+
+ IModelImporter create();
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/ModelImportListenerAdapter.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/ModelImportListenerAdapter.java
new file mode 100644
index 00000000000..ed43c15fe23
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/ModelImportListenerAdapter.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.importer;
+
+import org.eclipse.emf.common.util.Diagnostic;
+
+/**
+ * This is the ModelImportListenerAdapter type. Enjoy.
+ */
+public class ModelImportListenerAdapter
+ implements IModelImportListener {
+
+ public ModelImportListenerAdapter() {
+ super();
+ }
+
+ public void modelsToImportChanged(IModelImportConfiguration configuration) {
+ // pass
+ }
+
+ public void modelDependentsChanged(IModelImportNode node) {
+ // pass
+ }
+
+ public void modelImportProblemsOccurred(Diagnostic problems) {
+ // pass
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/ModelImportMappingListenerAdapter.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/ModelImportMappingListenerAdapter.java
new file mode 100644
index 00000000000..18679a3f213
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/importer/ModelImportMappingListenerAdapter.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.importer;
+
+import org.eclipse.emf.common.util.Diagnostic;
+
+/**
+ * This is the ModelImportMappingListenerAdapter type. Enjoy.
+ */
+public class ModelImportMappingListenerAdapter
+ implements IModelImportMappingListener {
+
+ public ModelImportMappingListenerAdapter() {
+ super();
+ }
+
+ public void modelImportRepositoryChanged(
+ IModelImportMapping mapping) {
+ // pass
+ }
+
+ public void modelImportMappingChanged(IModelImportNode node) {
+ // pass
+ }
+
+ public void modelImportMappingProblemsOccurred(Diagnostic problems) {
+ // pass
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java
new file mode 100644
index 00000000000..e43d60b3f2b
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java
@@ -0,0 +1,216 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.resource;
+
+import java.io.IOException;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.dawn.gmf.util.DawnDiagramUpdater;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
+import org.eclipse.emf.cdo.view.CDOViewSet;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+import org.eclipse.papyrus.infra.core.resource.ModelMultiException;
+import org.eclipse.papyrus.infra.services.resourceloading.OnDemandLoadingModelSet;
+
+import com.google.common.collect.Iterables;
+
+/**
+ * This is the CDOAwareModelSet type. Enjoy.
+ */
+public class CDOAwareModelSet
+ extends OnDemandLoadingModelSet {
+
+ private final ThreadLocal<Boolean> inGetResource = new ThreadLocal<Boolean>();
+
+ private final IPapyrusRepositoryManager repositoryManager;
+
+ private IPapyrusRepository repository;
+
+ private IListener invalidationListener;
+
+ public CDOAwareModelSet(IPapyrusRepositoryManager repositoryManager) {
+ super();
+
+ this.repositoryManager = repositoryManager;
+ }
+
+ @Override
+ public EObject getEObject(URI uri, boolean loadOnDemand) {
+ return CDOUtils.isCDOURI(uri)
+ ? basicGetEObject(uri, loadOnDemand)
+ : super.getEObject(uri, loadOnDemand);
+ }
+
+ protected EObject basicGetEObject(URI uri, boolean loadOnDemand) {
+ Resource resource = getResource(uri.trimFragment(), loadOnDemand);
+
+ return (resource == null)
+ ? null
+ : resource.getEObject(uri.fragment());
+ }
+
+ @Override
+ public Resource getResource(URI uri, boolean loadOnDemand) {
+ Boolean oldValue = inGetResource.get();
+ inGetResource.set(Boolean.TRUE);
+
+ try {
+ return super.getResource(uri, loadOnDemand);
+ } finally {
+ inGetResource.set(oldValue);
+ }
+ }
+
+ boolean isInGetResource() {
+ return inGetResource.get() == Boolean.TRUE;
+ }
+
+ @Override
+ public Resource createResource(URI uri, String contentType) {
+ initTransaction(uri);
+ return super.createResource(uri, contentType);
+ }
+
+ @Override
+ protected void demandLoad(Resource resource)
+ throws IOException {
+
+ if (CDOUtils.isCDOURI(resource.getURI())) {
+ // XML options not applicable to CDO resources
+ resource.load(null);
+
+ resourceLoadedHook(resource);
+ } else {
+ super.demandLoad(resource);
+ }
+ }
+
+ protected void resourceLoadedHook(Resource resource) {
+ for (Diagram next : Iterables.filter(resource.getContents(),
+ Diagram.class)) {
+
+ DawnDiagramUpdater.initializeElement(next);
+ }
+ }
+
+ public CDOView getCDOView() {
+ CDOViewSet viewSet = CDOUtil.getViewSet(this);
+ CDOView[] views = (viewSet == null)
+ ? null
+ : viewSet.getViews();
+
+ return ((views != null) && (views.length > 0))
+ ? views[0]
+ : null;
+ }
+
+ @Override
+ public void createModels(URI newURI) {
+ initTransaction(newURI);
+ super.createModels(newURI);
+ }
+
+ @Override
+ public void loadModels(URI uri)
+ throws ModelMultiException {
+
+ initTransaction(uri);
+ super.loadModels(uri);
+ }
+
+ protected void initTransaction(URI uri) {
+ if (getCDOView() == null) {
+ // get the repository and start a transaction on it
+
+ if (repository == null) {
+ repository = repositoryManager.getRepositoryForURI(uri);
+ }
+
+ if (repository != null) {
+ repository.createTransaction(this);
+ CDOView view = getCDOView();
+ if (view != null) {
+ view.addListener(getInvalidationListener());
+ }
+ }
+ }
+ }
+
+ @Override
+ public void unload() {
+ if ((repository != null) && (getCDOView() != null)) {
+ CDOView view = getCDOView();
+ if (view != null) {
+ view.removeListener(getInvalidationListener());
+ }
+ invalidationListener = null;
+
+ // dispose the transaction
+ repository.close(this);
+ }
+
+ repository = null;
+
+ super.unload();
+ }
+
+ protected final IListener getInvalidationListener() {
+ if (invalidationListener == null) {
+ invalidationListener = createInvalidationListener();
+ }
+ return invalidationListener;
+ }
+
+ protected IListener createInvalidationListener() {
+ return new IListener() {
+
+ public void notifyEvent(IEvent event) {
+ if (event instanceof CDOViewInvalidationEvent) {
+ if (hasTransactionalEditingDomain()) {
+ TransactionalEditingDomain domain = getTransactionalEditingDomain();
+ if (domain instanceof CDOAwareTransactionalEditingDomain) {
+ ((CDOAwareTransactionalEditingDomain) domain)
+ .fireResourceSetChanged((CDOViewInvalidationEvent) event);
+ }
+ }
+ }
+ }
+ };
+ }
+
+ @Override
+ public boolean isReadOnly(EObject eObject) {
+ boolean result;
+
+ CDOObject cdo = CDOUtils.getCDOObject(eObject);
+
+ if (cdo != null) {
+ // TODO: Check user permissions
+ result = CDOUtils.isLocked(cdo, true);
+ } else {
+ result = super.isReadOnly(eObject);
+ }
+
+ return result;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSetServiceFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSetServiceFactory.java
new file mode 100644
index 00000000000..e872f077cd5
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSetServiceFactory.java
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.resource;
+
+import org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager;
+import org.eclipse.papyrus.infra.core.services.IServiceFactory;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+
+/**
+ * This is the CDOAwareModelSetServiceFactory type. Enjoy.
+ */
+public class CDOAwareModelSetServiceFactory
+ implements IServiceFactory {
+
+ private IPapyrusRepositoryManager repositoryManager;
+
+ private CDOAwareModelSet modelSet;
+
+ public void init(ServicesRegistry servicesRegistry)
+ throws ServiceException {
+
+ repositoryManager = servicesRegistry
+ .getService(IPapyrusRepositoryManager.class);
+ }
+
+ public void startService()
+ throws ServiceException {
+
+ // pass
+ }
+
+ public void disposeService()
+ throws ServiceException {
+
+ if (modelSet != null) {
+ try {
+ modelSet.unload();
+ } catch (Exception e) {
+ throw new ServiceException("Failed to unload CDO-aware ModelSet.", e);
+ }
+ }
+ }
+
+ public Object createServiceInstance() {
+ modelSet = new CDOAwareModelSet(repositoryManager);
+ return modelSet;
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareTransactionalEditingDomain.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareTransactionalEditingDomain.java
new file mode 100644
index 00000000000..214843dcc2a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareTransactionalEditingDomain.java
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.resource;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.cdo.dawn.transaction.DawnTransactionChangeRecorder;
+import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.transaction.ResourceSetChangeEvent;
+import org.eclipse.emf.transaction.ResourceSetListener;
+import org.eclipse.emf.transaction.Transaction;
+import org.eclipse.emf.transaction.TransactionalCommandStack;
+import org.eclipse.emf.transaction.impl.TransactionChangeRecorder;
+import org.eclipse.emf.transaction.impl.TransactionImpl;
+import org.eclipse.papyrus.cdo.internal.core.Activator;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+import org.eclipse.papyrus.infra.emf.readonly.PapyrusROTransactionalEditingDomain;
+
+/**
+ * This is the CDOAwareTransactionalEditingDomain type. Enjoy.
+ */
+public class CDOAwareTransactionalEditingDomain
+ extends PapyrusROTransactionalEditingDomain {
+
+ public CDOAwareTransactionalEditingDomain(AdapterFactory adapterFactory,
+ TransactionalCommandStack stack, ResourceSet resourceSet) {
+ super(adapterFactory, stack, resourceSet);
+ }
+
+ @Override
+ protected TransactionChangeRecorder createChangeRecorder(ResourceSet rset) {
+ return new DawnTransactionChangeRecorder(this, rset);
+ }
+
+ protected void fireResourceSetChanged(CDOViewInvalidationEvent event) {
+ final ResourceSetListener[] listeners = getPostcommitListeners();
+ final Transaction transaction = new TransactionImpl(this, false);
+
+ // TODO: Compute notifications from the revision deltas? Model Explorer
+ // doesn't need any, and this is here primarily to kick the explorer.
+ final List<Notification> notifications = Collections.emptyList();
+
+ CDOUtils.notify(this, new Runnable() {
+
+ public void run() {
+ for (ResourceSetListener element : listeners) {
+ try {
+ element.resourceSetChanged(new ResourceSetChangeEvent(
+ CDOAwareTransactionalEditingDomain.this,
+ transaction, notifications));
+ } catch (Exception e) {
+ Activator.log
+ .error(
+ "Uncaught exception in resource set change listener.",
+ e);
+ }
+ }
+ }
+ });
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareTransactionalEditingDomainProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareTransactionalEditingDomainProvider.java
new file mode 100644
index 00000000000..1e9cda798da
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareTransactionalEditingDomainProvider.java
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.resource;
+
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.IResourceUndoContextPolicy;
+import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
+import org.eclipse.papyrus.commands.CheckedOperationHistory;
+import org.eclipse.papyrus.commands.NotifyingWorkspaceCommandStack;
+import org.eclipse.papyrus.infra.emf.readonly.PapyrusROTransactionalEditingDomainProvider;
+
+/**
+ * This is the CDOAwareTransactionalEditingDomainProvider type. Enjoy.
+ */
+public class CDOAwareTransactionalEditingDomainProvider
+ extends PapyrusROTransactionalEditingDomainProvider {
+
+ public CDOAwareTransactionalEditingDomainProvider() {
+ super();
+ }
+
+ @Override
+ public TransactionalEditingDomain createTransactionalEditingDomain(
+ ResourceSet resourceSet) {
+
+ NotifyingWorkspaceCommandStack stack = new NotifyingWorkspaceCommandStack(
+ CheckedOperationHistory.getInstance());
+ stack.setResourceUndoContextPolicy(IResourceUndoContextPolicy.DEFAULT);
+
+ TransactionalEditingDomain result = new CDOAwareTransactionalEditingDomain(
+ new ComposedAdapterFactory(
+ ComposedAdapterFactory.Descriptor.Registry.INSTANCE), stack,
+ resourceSet);
+
+ WorkspaceEditingDomainFactory.INSTANCE.mapResourceSet(result);
+
+ return result;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOReadOnlyHandler.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOReadOnlyHandler.java
new file mode 100644
index 00000000000..34b8f13deb5
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOReadOnlyHandler.java
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.resource;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+import org.eclipse.papyrus.infra.emf.readonly.IReadOnlyHandler2;
+
+
+/**
+ * This is the CDOReadOnlyHandler type. Enjoy.
+ */
+public class CDOReadOnlyHandler
+ implements IReadOnlyHandler2 {
+
+ public CDOReadOnlyHandler() {
+ super();
+ }
+
+ public boolean handlesURIs(URI[] uris, EditingDomain editingDomain) {
+ boolean result = false;
+
+ if ((uris.length > 0) && CDOUtils.isCDOEditingDomain(editingDomain)) {
+ for (int i = 0; !result && (i < uris.length); i++) {
+ if (CDOUtils.isCDOURI(uris[i])) {
+ result = true;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public boolean isReadOnly(URI[] uris, EditingDomain editingDomain) {
+ // TODO Support CDO permissions
+ return false;
+ }
+
+ public boolean enableWrite(URI[] uris, EditingDomain editingDomain) {
+ // TODO Support CDO permissions
+ return true;
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/PapyrusCDOResourceFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/PapyrusCDOResourceFactory.java
new file mode 100644
index 00000000000..95871cf546f
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/PapyrusCDOResourceFactory.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.resource;
+
+import org.eclipse.emf.cdo.dawn.resources.impl.DawnResourceFactoryImpl;
+import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
+import org.eclipse.emf.common.util.URI;
+
+/**
+ * This is the PapyrusCDOResourceFactory type. Enjoy.
+ */
+public class PapyrusCDOResourceFactory
+ extends DawnResourceFactoryImpl {
+
+ private final CDOAwareModelSet modelSet;
+
+ public PapyrusCDOResourceFactory(CDOAwareModelSet modelSet) {
+ super();
+
+ this.modelSet = modelSet;
+ }
+
+ protected CDOResourceImpl createCDOResource(URI uri) {
+ return new PapyrusDawnResourceImpl(uri);
+ }
+
+ @Override
+ protected boolean isGetResource() {
+ return modelSet.isInGetResource() || super.isGetResource();
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/PapyrusDawnResourceImpl.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/PapyrusDawnResourceImpl.java
new file mode 100644
index 00000000000..92bb19525dc
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/PapyrusDawnResourceImpl.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.core.resource;
+
+import org.eclipse.emf.cdo.dawn.resources.impl.DawnWrapperResourceImpl;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+
+
+/**
+ * This is the PapyrusDawnResourceImpl type. Enjoy.
+ */
+public class PapyrusDawnResourceImpl
+ extends DawnWrapperResourceImpl {
+
+ private URI uri;
+
+ public PapyrusDawnResourceImpl(URI uri) {
+ super(uri);
+
+ this.uri = uri;
+ }
+
+ @Override
+ public URI getURI() {
+ // cache the URI locally to read it without synchronization, to prevent
+ // deadlocks on the URI thread with the ReadOnlyManager
+ return (uri != null) ? uri : super.getURI();
+ }
+
+ @Override
+ public void setURI(URI newURI) {
+ super.setURI(newURI);
+
+ this.uri = super.getURI();
+ }
+
+ @Override
+ public String toString() {
+ return String.format("%s{uri: %s}", super.toString(), getURI());
+ }
+
+ @Override
+ public void setID(EObject eObject, String id) {
+ // profile migration expects to be able to do this, but it has
+ // no meaning. Just don't throw as the super implementation does
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/Activator.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/Activator.java
new file mode 100644
index 00000000000..076c7941ce0
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/Activator.java
@@ -0,0 +1,49 @@
+package org.eclipse.papyrus.cdo.internal.core;
+
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.osgi.framework.BundleContext;
+
+public class Activator extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.cdo.core";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /** Logging helper */
+ public static LogHelper log = new LogHelper();
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+
+ // register the log helper
+ log.setPlugin(plugin);
+ }
+
+ @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/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CDOUtils.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CDOUtils.java
new file mode 100644
index 00000000000..2ecb5fee2ca
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CDOUtils.java
@@ -0,0 +1,196 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core;
+
+import java.util.Set;
+import java.util.concurrent.Executor;
+
+import org.eclipse.emf.cdo.CDOLock;
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.dawn.spi.DawnState;
+import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
+import org.eclipse.emf.cdo.view.CDOViewSet;
+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.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.ResourceSetChangeEvent;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.cdo.core.resource.CDOAwareTransactionalEditingDomain;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * This is the CDOUtils type. Enjoy.
+ */
+public class CDOUtils {
+
+ private static final Set<String> CDO_URI_SCHEMES = ImmutableSet.of("cdo",
+ "dawn");
+
+ private static Executor broadcastExecutor = new DirectExecutor();
+
+ /**
+ * Not instantiable by clients.
+ */
+ private CDOUtils() {
+ super();
+ }
+
+ public static boolean isCDOURI(URI uri) {
+ return CDO_URI_SCHEMES.contains(uri.scheme());
+ }
+
+ public static boolean isCDOEditingDomain(EditingDomain domain) {
+ return domain instanceof CDOAwareTransactionalEditingDomain;
+ }
+
+ public static ResourceSet getResourceSet(Notifier notifier) {
+ ResourceSet result = null;
+
+ if (notifier instanceof CDOViewSet) {
+ result = ((CDOViewSet) notifier).getResourceSet();
+ } else if (notifier instanceof ResourceSet) {
+ result = (ResourceSet) notifier;
+ } else if (notifier instanceof Resource) {
+ result = ((Resource) notifier).getResourceSet();
+ } else if (notifier instanceof CDOResourceNode) {
+ // folders (resource nodes that aren't resources) are not in a
+ // resource set, so get the associated view's resource set
+ CDOView view = ((CDOResourceNode) notifier).cdoView();
+ if (view != null) {
+ result = view.getResourceSet();
+ }
+ } else if (notifier instanceof EObject) {
+ result = getResourceSet(((EObject) notifier).eResource());
+ }
+
+ return result;
+ }
+
+ public static boolean isCDOObject(EObject object) {
+ ResourceSet resourceSet = getResourceSet(object);
+
+ return (resourceSet != null)
+ && (CDOUtil.getViewSet(resourceSet) != null);
+ }
+
+ public static CDOObject getCDOObject(EObject object) {
+ CDOObject result = null;
+
+ if (isCDOObject(object)) {
+ result = CDOUtil.getCDOObject(object);
+ }
+
+ return result;
+ }
+
+ public static boolean isLockable(CDOObject object) {
+ // transient objects do not have lock states
+ return object.cdoLockState() != null;
+ }
+
+ public static boolean isLocked(CDOObject object, boolean remotely) {
+ CDOLock lock = isLockable(object)
+ ? object.cdoWriteLock()
+ : null;
+
+ return (lock != null) && (remotely
+ ? lock.isLockedByOthers()
+ : lock.isLocked());
+ }
+
+ public static void lock(CDOObject object) {
+ object.cdoWriteLock().lock();
+ }
+
+ public static void unlock(CDOObject object) {
+ object.cdoWriteLock().unlock();
+ }
+
+ public static DawnState computeState(EObject object) {
+ DawnState result = DawnState.CLEAN;
+
+ CDOObject cdo = getCDOObject(object);
+ if (cdo != null) {
+ if (cdo.cdoConflict()) {
+ result = DawnState.CONFLICT;
+ } else if (isLocked(cdo, true)) {
+ result = DawnState.LOCKED_REMOTELY;
+ } else if (isLocked(cdo, false)) {
+ result = DawnState.LOCKED_LOCALLY;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * <p>
+ * Runs a code block that broadcasts notification of
+ * {@link ResourceSetChangeEvent}s, {@link CDOViewInvalidationEvent}s, etc.
+ * to listeners using the most appropriate
+ * {@linkplain #setBroadcastExecutor() executor} available. This allows a
+ * UI-safe execution to be injected if necessary.
+ * </p>
+ * <p>
+ * <strong>Note</strong> that there is no assurance that this block will be
+ * executed either synchronously or asynchronously.
+ * </p>
+ *
+ * @param broadcastCommand
+ * the notification command to execute
+ */
+ public static void notify(Runnable broadcastCommand) {
+ broadcastExecutor.execute(broadcastCommand);
+ }
+
+ public static void notify(final TransactionalEditingDomain domain,
+ final Runnable broadcastCommand) {
+
+ broadcastExecutor.execute(new Runnable() {
+
+ public void run() {
+ try {
+ domain.runExclusive(broadcastCommand);
+ } catch (Exception e) {
+ Activator.log.error(
+ "Exception in execution of notification broadcast.", e);
+ }
+ }
+ });
+ }
+
+ public static void setBroadcastExecutor(Executor executor) {
+ broadcastExecutor = (executor == null)
+ ? new DirectExecutor()
+ : executor;
+ }
+
+ //
+ // Nested types
+ //
+
+ private static final class DirectExecutor
+ implements Executor {
+
+ public void execute(Runnable command) {
+ command.run();
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CompositeResourceSetDisposalApprover.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CompositeResourceSetDisposalApprover.java
new file mode 100644
index 00000000000..0ecbfbf9c4c
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CompositeResourceSetDisposalApprover.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.core.IResourceSetDisposalApprover;
+
+import com.google.common.collect.Lists;
+
+/**
+ * This is the CompositeResourceSetDisposalApprover type. Enjoy.
+ */
+class CompositeResourceSetDisposalApprover
+ implements IResourceSetDisposalApprover {
+
+ private final List<IResourceSetDisposalApprover> approvers = Lists
+ .newArrayListWithExpectedSize(1);
+
+ CompositeResourceSetDisposalApprover() {
+ super();
+ }
+
+ public DisposeAction disposalRequested(IPapyrusRepository repository,
+ Collection<ResourceSet> resourceSets) {
+
+ DisposeAction result = DisposeAction.CLOSE;
+
+ if (!resourceSets.isEmpty() && !approvers.isEmpty()) {
+ for (IResourceSetDisposalApprover next : approvers) {
+ DisposeAction action = wrapNull(next
+ .disposalRequested(repository, resourceSets));
+
+ result = result.compareTo(action) > 0
+ ? action
+ : result;
+
+ if (result == DisposeAction.NONE) {
+ // no need to consult anyone else
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private DisposeAction wrapNull(DisposeAction action) {
+ return (action == null)
+ ? DisposeAction.NONE
+ : action;
+ }
+
+ void addApprover(IResourceSetDisposalApprover approver) {
+ if (!approvers.contains(approver)) {
+ approvers.add(approver);
+ }
+ }
+
+ void removeApprover(IResourceSetDisposalApprover approver) {
+ approvers.remove(approver);
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/ICredentialsProviderFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/ICredentialsProviderFactory.java
new file mode 100644
index 00000000000..0f8599f41b0
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/ICredentialsProviderFactory.java
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core;
+
+import org.eclipse.net4j.util.security.IPasswordCredentialsProvider2;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+
+/**
+ * This is the ICredentialsProviderFactory type. Enjoy.
+ */
+public interface ICredentialsProviderFactory {
+
+ IPasswordCredentialsProvider2 createCredentialsProvider(
+ IPapyrusRepository repository);
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInteractiveCredentialsProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInteractiveCredentialsProvider.java
new file mode 100644
index 00000000000..842328d5823
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInteractiveCredentialsProvider.java
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core;
+
+import org.eclipse.net4j.util.security.IPasswordCredentialsProvider2;
+
+
+/**
+ * This is the IInteractiveCredentialsProvider type. Enjoy.
+ */
+public interface IInteractiveCredentialsProvider
+ extends IPasswordCredentialsProvider2 {
+
+ void reportCredentialsFailure(SecurityException e);
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInternalPapyrusRepository.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInternalPapyrusRepository.java
new file mode 100644
index 00000000000..bbb406d10d0
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInternalPapyrusRepository.java
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core;
+
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+
+
+/**
+ * This is the IInternalPapyrusRepository type. Enjoy.
+ */
+public interface IInternalPapyrusRepository
+ extends IPapyrusRepository {
+
+ CDOSession getCDOSession();
+
+ CDOView getMasterView();
+
+ CDOView getCDOView(ResourceSet resourceSet);
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInternalPapyrusRepositoryManager.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInternalPapyrusRepositoryManager.java
new file mode 100644
index 00000000000..9eca5f81caf
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IInternalPapyrusRepositoryManager.java
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core;
+
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager;
+
+/**
+ * This is the IInternalPapyrusRepositoryManager type. Enjoy.
+ */
+public interface IInternalPapyrusRepositoryManager
+ extends IPapyrusRepositoryManager {
+
+ IManagedContainer getSessionsContainer();
+
+ void setURL(IPapyrusRepository repository, String url);
+
+ ICredentialsProviderFactory getCredentialsProviderFactory();
+
+ void setCredentialsProviderFactory(
+ ICredentialsProviderFactory credentialsProviderFactory);
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IRepositoryModelStorage.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IRepositoryModelStorage.java
new file mode 100644
index 00000000000..4b4e847fb84
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/IRepositoryModelStorage.java
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * This is the IRepositoryModelStorage type. Enjoy.
+ */
+public interface IRepositoryModelStorage {
+
+ /**
+ * Obtains an input stream on the repository model storage, if any.
+ *
+ * @return an input stream, or {@code null} if there is no repository model
+ * currently stored
+ *
+ * @throws IOException
+ * on any failure to get an input stream that is not simply that
+ * the storage doesn't yet exist
+ */
+ InputStream createInputStream()
+ throws IOException;
+
+ /**
+ * Obtains an output stream on the repository model storage.
+ *
+ * @return an output stream (may not be {@code null})
+ *
+ * @throws IOException
+ * on any failure to get an output stream
+ */
+ OutputStream createOutputStream()
+ throws IOException;
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java
new file mode 100644
index 00000000000..972236bb641
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java
@@ -0,0 +1,643 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.model.CDOPackageRegistryPopulator;
+import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.common.util.NotAuthenticatedException;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+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.spi.cdo.CDOMergingConflictResolver;
+import org.eclipse.equinox.security.storage.EncodingUtils;
+import org.eclipse.equinox.security.storage.ISecurePreferences;
+import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
+import org.eclipse.equinox.security.storage.StorageException;
+import org.eclipse.net4j.util.container.Container;
+import org.eclipse.net4j.util.container.ContainerEvent;
+import org.eclipse.net4j.util.container.IContainerDelta;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
+import org.eclipse.net4j.util.security.CredentialsProviderFactory;
+import org.eclipse.net4j.util.security.ICredentialsProvider2;
+import org.eclipse.papyrus.cdo.core.CommitException;
+import org.eclipse.papyrus.cdo.core.IResourceSetDisposalApprover;
+import org.eclipse.papyrus.cdo.core.resource.CDOAwareModelSet;
+import org.eclipse.papyrus.cdo.core.resource.PapyrusCDOResourceFactory;
+import org.eclipse.papyrus.cdo.internal.core.repositories.Repository;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Strings;
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+
+/**
+ * This is the PapyrusRepository type. Enjoy.
+ */
+public class PapyrusRepository
+ extends Container<CDOResourceNode>
+ implements IInternalPapyrusRepository, IAdaptable {
+
+ private static final String SECURE_STORE_PATH = "/" + Activator.PLUGIN_ID
+ + "/repositories";
+
+ private static final CDOResourceNode[] NO_RESOURCE_NODES = new CDOResourceNode[0];
+
+ private final IManagedContainer container;
+
+ private final Repository model;
+
+ private CDOSession session;
+
+ private BiMap<ResourceSet, CDOView> readOnlyViews = HashBiMap.create();
+
+ private BiMap<ResourceSet, CDOTransaction> transactions = HashBiMap
+ .create();
+
+ private IListener viewListener;
+
+ private CDOView masterView;
+
+ private volatile CDOResourceNode[] topResourceNodes;
+
+ private IListener masterViewListener;
+
+ private final CompositeResourceSetDisposalApprover approvers = new CompositeResourceSetDisposalApprover();
+
+ public PapyrusRepository(IManagedContainer container, Repository model) {
+ this.container = container;
+ this.model = model;
+
+ activate();
+ }
+
+ public String getName() {
+ return model.getName();
+ }
+
+ public void setName(String name) {
+ if (Strings.isNullOrEmpty(name)) {
+ throw new IllegalArgumentException("null or empty name");
+ }
+
+ model.setName(name);
+ }
+
+ public String getURL() {
+ return model.getURL();
+ }
+
+ public String getUsername() {
+ return getSecureStorageValue("username");
+ }
+
+ public void setUsername(String username) {
+ if (username != null) {
+ username = username.trim();
+ if (username.length() == 0) {
+ username = null;
+ }
+ }
+
+ setSecureStorageValue("username", username, false);
+ }
+
+ public String getPassword() {
+ return getSecureStorageValue("password");
+ }
+
+ private String getSecureStorageValue(String key) {
+ String result = null;
+
+ ISecurePreferences store = SecurePreferencesFactory.getDefault();
+ String path = getSecureStorePath();
+ if (store.nodeExists(path)) {
+ store = store.node(path);
+
+ try {
+ result = store.get(key, null);
+ } catch (StorageException e) {
+ Activator.log.error(String.format(
+ "Failed to load repository %s from secure storage.", key),
+ e);
+ }
+ }
+
+ return result;
+ }
+
+ private String getSecureStorePath() {
+ return String.format("%s/%s", SECURE_STORE_PATH,
+ EncodingUtils.encodeSlashes(getURL()));
+ }
+
+ public void setPassword(String password) {
+ setSecureStorageValue("password", password, true);
+ }
+
+ private void setSecureStorageValue(String key, String value, boolean encrypt) {
+ ISecurePreferences store = SecurePreferencesFactory.getDefault().node(
+ getSecureStorePath());
+ try {
+ if (value == null) {
+ store.remove(key);
+ } else {
+ store.put(key, value, encrypt);
+ }
+ } catch (StorageException e) {
+ Activator.log.error(String.format(
+ "Failed to store repository %s in secure storage.", key), e);
+ }
+ }
+
+ public void clearCredentials() {
+ ISecurePreferences store = SecurePreferencesFactory.getDefault();
+ String path = getSecureStorePath();
+ if (store.nodeExists(path)) {
+ store.node(path).removeNode();
+ }
+ }
+
+ public boolean isConnected() {
+ return (session != null) && !session.isClosed();
+ }
+
+ public void connect() {
+ if (!isConnected()) {
+ ICredentialsProvider2 creds = getCredentialsProvider();
+ Object oldCreds = null;
+ if (creds != null) {
+ oldCreds = container.putElement(
+ CredentialsProviderFactory.PRODUCT_GROUP, "interactive",
+ null, creds);
+ }
+
+ try {
+ for (;;) {
+ try {
+ session = (CDOSession) container.getElement(
+ "org.eclipse.emf.cdo.sessions", "cdo", getURL());
+ CDOUtil.setLegacyModeDefault(true);
+ } catch (NotAuthenticatedException e) {
+ // user cancelled the credentials dialog. That's OK
+ break;
+ } catch (SecurityException e) {
+ // wrong credentials. If the user stored them, purge and
+ // try again
+ clearCredentials();
+
+ if (creds instanceof IInteractiveCredentialsProvider) {
+ ((IInteractiveCredentialsProvider) creds)
+ .reportCredentialsFailure(e);
+ }
+
+ continue;
+ }
+ break;
+ }
+
+ if (session != null) {
+ configure(session);
+
+ // open the master view for the UI
+ createReadOnlyView(new ResourceSetImpl());
+ }
+ } finally {
+ if (creds != null) {
+ if (oldCreds != null) {
+ container.putElement(
+ CredentialsProviderFactory.PRODUCT_GROUP,
+ "interactive", null, oldCreds);
+ } else {
+ container/* IPluginContainer.INSTANCE */.removeElement(
+ CredentialsProviderFactory.PRODUCT_GROUP,
+ "interactive", null);
+ }
+ }
+ }
+ }
+ }
+
+ private ICredentialsProvider2 getCredentialsProvider() {
+ ICredentialsProvider2 result = null;
+
+ ICredentialsProviderFactory factory = PapyrusRepositoryManager.INSTANCE
+ .getCredentialsProviderFactory();
+ if (factory != null) {
+ result = factory.createCredentialsProvider(this);
+ }
+
+ return result;
+ }
+
+ public void disconnect()
+ throws CommitException {
+
+ if (isConnected()) {
+ ImmutableList<ResourceSet> dirty = ImmutableList.copyOf(Iterables
+ .filter(transactions.keySet(), new Predicate<ResourceSet>() {
+
+ public boolean apply(ResourceSet input) {
+ return transactions.get(input).isDirty();
+ }
+ }));
+
+ switch (approvers.disposalRequested(this, dirty)) {
+ case SAVE :
+ for (ResourceSet next : dirty) {
+ commit(next);
+ }
+
+ // intentional fall-through (save then close)
+ case CLOSE :
+ for (CDOView next : ImmutableList.copyOf(transactions
+ .values())) {
+
+ doClose(next);
+ }
+ for (CDOView next : ImmutableList.copyOf(readOnlyViews
+ .values())) {
+
+ doClose(next);
+ }
+
+ session.close();
+ session = null;
+ break;
+ default : // NONE
+ break;
+ }
+ }
+ }
+
+ protected void checkConnected() {
+ if (!isConnected()) {
+ throw new IllegalStateException("not connected");
+ }
+ }
+
+ public Collection<ResourceSet> getReadOnlyViews() {
+ return Collections.unmodifiableCollection(readOnlyViews.keySet());
+ }
+
+ public ResourceSet createReadOnlyView(ResourceSet resourceSet) {
+ checkConnected();
+
+ CDOUtil.setLegacyModeDefault(true); // legacy mode is per-thread
+ CDOView view = session.openView(resourceSet);
+ configure(view);
+ ResourceSet result = view.getResourceSet();
+ readOnlyViews.put(result, view);
+
+ if (masterView == null) {
+ masterView = view;
+ topResourceNodes = getElements();
+ adaptMasterView(view);
+
+ if (topResourceNodes.length > 0) {
+ fireElementsAddedEvent(topResourceNodes);
+ } else {
+ fireEvent(); // just refresh my presentation
+ }
+ }
+
+ return result;
+ }
+
+ public Collection<ResourceSet> getTransactions() {
+ return Collections.unmodifiableCollection(transactions.keySet());
+ }
+
+ public ResourceSet createTransaction(ResourceSet resourceSet) {
+ checkConnected();
+
+ CDOUtil.setLegacyModeDefault(true); // legacy mode is per-thread
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+ configure(transaction);
+ ResourceSet result = transaction.getResourceSet();
+ transactions.put(result, transaction);
+
+ return result;
+ }
+
+ public CDOSession getCDOSession() {
+ return session;
+ }
+
+ public CDOView getMasterView() {
+ return masterView;
+ }
+
+ public CDOView getCDOView(ResourceSet resourceSet) {
+ CDOView result = readOnlyViews.get(resourceSet);
+
+ if (result == null) {
+ result = transactions.get(resourceSet);
+ }
+
+ return result;
+ }
+
+ protected void removeCDOView(ResourceSet resourceSet) {
+ readOnlyViews.remove(resourceSet);
+ transactions.remove(resourceSet);
+ }
+
+ CDOTransaction checkTransaction(CDOView view) {
+ if (!(view instanceof CDOTransaction)) {
+ throw new IllegalArgumentException("not a transaction");
+ }
+
+ return (CDOTransaction) view;
+ }
+
+ public void commit(ResourceSet transaction)
+ throws CommitException {
+ CDOView cdoView = getCDOView(transaction);
+
+ try {
+ checkTransaction(cdoView).commit();
+ } catch (org.eclipse.emf.cdo.util.CommitException e) {
+ throw new CommitException(e);
+ }
+ }
+
+ public void rollback(ResourceSet transaction) {
+ CDOView cdoView = getCDOView(transaction);
+ checkTransaction(cdoView).rollback();
+ }
+
+ public void close(ResourceSet view) {
+ CDOView cdoView = getCDOView(view);
+
+ if (cdoView != null) {
+ doClose(cdoView);
+ }
+ }
+
+ protected void doClose(CDOView view) {
+ try {
+ if (view == masterView) {
+ unadaptMasterView(view);
+ masterView = null;
+ CDOResourceNode[] removedNodes = topResourceNodes;
+ topResourceNodes = null;
+ if ((removedNodes != null) && (removedNodes.length > 0)) {
+ fireElementsRemovedEvent(removedNodes);
+ } else {
+ fireEvent(); // just refresh my presentation
+ }
+ }
+ } finally {
+ unadaptView(view);
+ removeCDOView(view.getResourceSet());
+ view.close();
+ }
+ }
+
+ public Repository getModel() {
+ return model;
+ }
+
+ protected void configure(CDOSession newSession) {
+ CDOUtil.setLegacyModeDefault(true);
+ CDOPackageRegistryPopulator.populate(newSession.getPackageRegistry());
+ }
+
+ protected void configure(CDOView newReadOnlyView) {
+ adaptView(newReadOnlyView);
+
+ commonViewConfiguration(newReadOnlyView);
+
+ // TODO: Do we need to set any other options?
+ }
+
+ protected void commonViewConfiguration(CDOView newView) {
+ // CDO's default resource factory inspects the current thread's stack
+ // trace to see whether the getResource(...) method of a set of known
+ // ResourceSet implementation classes is in progress. We have a
+ // ResourceSet implementation that CDO doesn't know about, so we need
+ // our own factory
+ ResourceSet rset = newView.getResourceSet();
+ if (rset instanceof CDOAwareModelSet) {
+ rset.getResourceFactoryRegistry()
+ .getProtocolToFactoryMap()
+ .put(CDOProtocolConstants.PROTOCOL_NAME,
+ new PapyrusCDOResourceFactory((CDOAwareModelSet) rset));
+ }
+ }
+
+ protected void configure(CDOTransaction newTransaction) {
+ adaptView(newTransaction);
+
+ commonViewConfiguration(newTransaction);
+
+ newTransaction.options().addConflictResolver(
+ new CDOMergingConflictResolver());
+ // TODO: Do we need to set any other options?
+ }
+
+ private IListener getViewListener() {
+ if (viewListener == null) {
+ viewListener = new LifecycleEventAdapter() {
+
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle) {
+ readOnlyViews.inverse().remove(lifecycle);
+ transactions.inverse().remove(lifecycle);
+ }
+ };
+ }
+
+ return viewListener;
+ }
+
+ private void adaptView(CDOView view) {
+ view.addListener(getViewListener());
+ }
+
+ private void unadaptView(CDOView view) {
+ view.removeListener(getViewListener());
+ }
+
+ private IListener getMasterViewListener() {
+ if (masterViewListener == null) {
+ masterViewListener = new IListener() {
+
+ public void notifyEvent(IEvent event) {
+ if (event instanceof CDOViewInvalidationEvent) {
+ CDOViewInvalidationEvent inval = (CDOViewInvalidationEvent) event;
+ translateMasterViewInvalidationEvent(inval);
+ }
+ }
+ };
+ }
+
+ return masterViewListener;
+ }
+
+ private void adaptMasterView(CDOView view) {
+ view.addListener(getMasterViewListener());
+ }
+
+ private void unadaptMasterView(CDOView view) {
+ view.removeListener(getMasterViewListener());
+ }
+
+ public void addResourceSetDisposalApprover(
+ IResourceSetDisposalApprover approver) {
+
+ approvers.addApprover(approver);
+ }
+
+ public void removeResourceSetDisposalApprover(
+ IResourceSetDisposalApprover approver) {
+
+ approvers.removeApprover(approver);
+ }
+
+ //
+ // IContainer protocol
+ //
+
+ @Override
+ public boolean isEmpty() {
+ return !isActive() || !isConnected() || (masterView == null)
+ || masterView.isEmpty();
+ }
+
+ public CDOResourceNode[] getElements() {
+ CDOResourceNode[] result = NO_RESOURCE_NODES;
+
+ if (masterView != null) {
+ if (topResourceNodes == null) {
+ topResourceNodes = masterView.getElements();
+ }
+ result = topResourceNodes;
+ }
+
+ return result;
+ }
+
+ @Override
+ protected void doAfterActivate()
+ throws Exception {
+
+ super.doAfterActivate();
+
+ model.eAdapters().add(new AdapterImpl() {
+
+ @Override
+ public void notifyChanged(Notification msg) {
+ fireEvent();
+ }
+
+ @Override
+ public boolean isAdapterForType(Object type) {
+ return type == PapyrusRepository.class;
+ }
+ });
+ }
+
+ @Override
+ protected void doBeforeDeactivate()
+ throws Exception {
+
+ Adapter adapter = EcoreUtil.getExistingAdapter(model,
+ PapyrusRepository.class);
+ if (adapter != null) {
+ model.eAdapters().remove(adapter);
+ }
+
+ super.doBeforeDeactivate();
+ }
+
+ private void translateMasterViewInvalidationEvent(
+ CDOViewInvalidationEvent event) {
+
+ for (Map.Entry<CDOObject, CDORevisionDelta> next : event
+ .getRevisionDeltas().entrySet()) {
+
+ if (next.getKey() instanceof CDOResourceNode) {
+ CDOResourceNode resNode = (CDOResourceNode) next.getKey();
+
+ if (resNode.isRoot()) {
+ // the event doesn't provide a revision delta, so calculate
+ // a delta
+
+ Set<CDOResourceNode> currentNodes = Sets
+ .newLinkedHashSet(Arrays.asList(getElements()));
+ Set<CDOResourceNode> newNodes = Sets
+ .newLinkedHashSet(Iterables.filter(
+ ((CDOResource) resNode).getContents(),
+ CDOResourceNode.class));
+
+ Set<CDOResourceNode> removed = Sets.difference(
+ currentNodes, newNodes);
+ Set<CDOResourceNode> added = Sets.difference(newNodes,
+ currentNodes);
+
+ ContainerEvent<CDOResourceNode> cEvent = new ContainerEvent<CDOResourceNode>(
+ this);
+ for (CDOResourceNode r : removed) {
+ cEvent.addDelta(r, IContainerDelta.Kind.REMOVED);
+ }
+ for (CDOResourceNode a : added) {
+ cEvent.addDelta(a, IContainerDelta.Kind.ADDED);
+ }
+
+ // re-calculate elements from the view
+ topResourceNodes = resNode.cdoView().getElements();
+
+ fireEvent(cEvent);
+ break;
+ }
+ }
+ }
+
+ }
+
+ //
+ // IAdaptable protocol
+ //
+
+ public Object getAdapter(@SuppressWarnings("rawtypes")
+ Class adapter) {
+ return Platform.getAdapterManager().getAdapter(this, adapter);
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepositoryManager.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepositoryManager.java
new file mode 100644
index 00000000000..35a2a1b02dd
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepositoryManager.java
@@ -0,0 +1,283 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.util.CDOURIUtil;
+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.impl.XMLResourceFactoryImpl;
+import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
+import org.eclipse.net4j.util.container.Container;
+import org.eclipse.net4j.util.container.ContainerUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesFactory;
+import org.eclipse.papyrus.cdo.internal.core.repositories.RepositoriesPackage;
+import org.eclipse.papyrus.cdo.internal.core.repositories.Repository;
+import org.eclipse.papyrus.cdo.internal.core.repositories.RepositoryRegistry;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
+
+/**
+ * This is the PapyrusRepositoryManager type. Enjoy.
+ */
+public class PapyrusRepositoryManager
+ extends Container<IPapyrusRepository>
+ implements IInternalPapyrusRepositoryManager {
+
+ public static final PapyrusRepositoryManager INSTANCE = new PapyrusRepositoryManager();
+
+ private final IRepositoryModelStorage storage;
+
+ private final IManagedContainer container;
+
+ private final RepositoryRegistry repositoryRegistry;
+
+ private final Map<String, IInternalPapyrusRepository> repositories;
+
+ private ICredentialsProviderFactory credentialsProviderFactory;
+
+ public PapyrusRepositoryManager() {
+ this(null);
+ }
+
+ public PapyrusRepositoryManager(IRepositoryModelStorage storage) {
+ this.storage = storage;
+ this.container = createContainer();
+ this.repositoryRegistry = loadRepositories();
+ this.repositories = initializeRepositories();
+
+ activate();
+ }
+
+ public void dispose() {
+ deactivate();
+ }
+
+ private static IManagedContainer createContainer() {
+ IManagedContainer result = ContainerUtil.createPluginContainer();
+
+ result.activate();
+
+ return result;
+ }
+
+ public IManagedContainer getSessionsContainer() {
+ return container;
+ }
+
+ public Collection<? extends IPapyrusRepository> getRepositories() {
+ return Collections.unmodifiableCollection(repositories.values());
+ }
+
+ public IPapyrusRepository createRepository(String url) {
+ if (getRepository(url) != null) {
+ throw new IllegalArgumentException("repository already exists");
+ }
+
+ Repository repository = RepositoriesFactory.eINSTANCE
+ .createRepository();
+ repository.setURL(url);
+ repositoryRegistry.getRepositories().add(repository);
+
+ PapyrusRepository result = new PapyrusRepository(container, repository);
+ repositories.put(url, result);
+
+ fireElementAddedEvent(result);
+
+ return result;
+ }
+
+ public void setURL(IPapyrusRepository repository, String url) {
+ if (!Objects.equal(repository.getURL(), url)) {
+ if (getRepository(url) != null) {
+ throw new IllegalArgumentException("repository already exists");
+ }
+
+ if (repository.isConnected()) {
+ throw new IllegalStateException("repository is connected");
+ }
+
+ PapyrusRepository internalRepository = (PapyrusRepository) repository;
+ repositories.remove(internalRepository.getURL());
+ internalRepository.getModel().setURL(url);
+ repositories.put(url, internalRepository);
+ }
+ }
+
+ public void removeRepository(IPapyrusRepository repository) {
+ if (repository.isConnected()) {
+ throw new IllegalArgumentException("repository is still connected");
+ }
+
+ repositories.remove(repository.getURL());
+ EcoreUtil.delete(((PapyrusRepository) repository).getModel());
+
+ fireElementRemovedEvent(repository);
+ }
+
+ public IPapyrusRepository getRepository(String url) {
+ return repositories.get(url);
+ }
+
+ public IPapyrusRepository getRepositoryForURI(URI uri) {
+ IPapyrusRepository result = null;
+
+ if (CDOUtils.isCDOURI(uri)) {
+ String uuid = CDOURIUtil.extractRepositoryUUID(uri);
+
+ for (IInternalPapyrusRepository next : repositories.values()) {
+ CDOSession session = next.getCDOSession();
+ if ((session != null)
+ && Objects.equal(uuid, session.getRepositoryInfo().getUUID())) {
+
+ result = next;
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public void saveRepositories() {
+ if (storage != null) {
+ try {
+ OutputStream output = storage.createOutputStream();
+ try {
+ repositoryRegistry.eResource().save(output, null);
+ } finally {
+ if (output != null) {
+ IOUtil.closeSilent(output);
+ }
+ }
+ } catch (IOException e) {
+ Activator.log.error(
+ "Failed to save model repositories to custom storage.", e);
+ }
+ } else {
+ try {
+ repositoryRegistry.eResource().save(null);
+ } catch (IOException e) {
+ Activator.log.error("Failed to save model repositories.", e);
+ }
+ }
+
+ // save passwords, if any
+ try {
+ SecurePreferencesFactory.getDefault().flush();
+ } catch (IOException e) {
+ Activator.log.error(
+ "Failed to save repository passwords to secure storage.", e);
+ }
+ }
+
+ private RepositoryRegistry loadRepositories() {
+ ResourceSet rset = new ResourceSetImpl();
+ rset.getResourceFactoryRegistry().getExtensionToFactoryMap()
+ .put("xml", new XMLResourceFactoryImpl());
+
+ File repositoriesFile = new File(Activator.getDefault()
+ .getStateLocation().toFile(), "repositories.xml");
+ URI uri = URI.createFileURI(repositoriesFile.getAbsolutePath());
+ Resource resource = rset.createResource(uri);
+
+ if (storage != null) {
+ try {
+ InputStream input = storage.createInputStream();
+ if (input != null) {
+ try {
+ resource.load(input, null);
+ } finally {
+ IOUtil.closeSilent(input);
+ }
+ }
+ } catch (Exception e) {
+ Activator.log.error(
+ "Failed to load repository registry from custom storage.",
+ e);
+ }
+ } else {
+ if (repositoriesFile.exists()) {
+ try {
+ resource.load(null);
+ } catch (Exception e) {
+ Activator.log.error("Failed to load repository registry.",
+ e);
+ // if there's any junk, clear it out
+ resource.getContents().clear();
+ }
+ } else {
+ resource = rset.createResource(uri);
+ }
+ }
+
+ RepositoryRegistry result = (RepositoryRegistry) EcoreUtil
+ .getObjectByType(resource.getContents(),
+ RepositoriesPackage.Literals.REPOSITORY_REGISTRY);
+
+ if (result == null) {
+ result = RepositoriesFactory.eINSTANCE.createRepositoryRegistry();
+ resource.getContents().add(result);
+ }
+
+ return result;
+ }
+
+ private Map<String, IInternalPapyrusRepository> initializeRepositories() {
+ Map<String, IInternalPapyrusRepository> result = Maps.newHashMap();
+
+ for (Repository next : repositoryRegistry.getRepositories()) {
+ result.put(next.getURL(), new PapyrusRepository(container, next));
+ }
+
+ return result;
+ }
+
+ public ICredentialsProviderFactory getCredentialsProviderFactory() {
+ return credentialsProviderFactory;
+ }
+
+ public void setCredentialsProviderFactory(
+ ICredentialsProviderFactory credentialsProviderFactory) {
+
+ this.credentialsProviderFactory = credentialsProviderFactory;
+ }
+
+ //
+ // IContainer protocol
+ //
+
+ public boolean isEmpty() {
+ return !isActive() || repositories.isEmpty();
+ }
+
+ public IPapyrusRepository[] getElements() {
+ return Iterables.toArray(repositories.values(),
+ IPapyrusRepository.class);
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepositoryManagerServiceFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepositoryManagerServiceFactory.java
new file mode 100644
index 00000000000..b574127a41d
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepositoryManagerServiceFactory.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core;
+
+import org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager;
+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 for {@link IPapyrusRepositoryManager}s.
+ */
+public class PapyrusRepositoryManagerServiceFactory
+ implements IServiceFactory {
+
+ private IPapyrusRepositoryManager service;
+
+ public PapyrusRepositoryManagerServiceFactory() {
+ super();
+ }
+
+ public void init(ServicesRegistry servicesRegistry)
+ throws ServiceException {
+
+ // pass
+ }
+
+ public void startService()
+ throws ServiceException {
+
+ // pass
+ }
+
+ public void disposeService()
+ throws ServiceException {
+
+ // nothing to dispose (the repository manager is a shared instance)
+ }
+
+ public Object createServiceInstance()
+ throws ServiceException {
+
+ service = PapyrusRepositoryManager.INSTANCE;
+ return service;
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/expressions/EObjectPropertyTester.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/expressions/EObjectPropertyTester.java
new file mode 100644
index 00000000000..edd0c216c1b
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/expressions/EObjectPropertyTester.java
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.expressions;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+
+/**
+ * This is the EObjectPropertyTester type. Enjoy.
+ */
+public class EObjectPropertyTester
+ extends PropertyTester {
+
+ public static final String IS_CDO_OBJECT = "isCDOObject";
+
+ public EObjectPropertyTester() {
+ super();
+ }
+
+ public boolean test(Object receiver, String property, Object[] args,
+ Object expectedValue) {
+
+ boolean result = false;
+
+ CDOObject cdoObject = CDOUtils.getCDOObject((EObject) receiver);
+ if (cdoObject != null) {
+ if (IS_CDO_OBJECT.equals(property)) {
+ result = true;
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/AbstractModelImportMapping.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/AbstractModelImportMapping.java
new file mode 100644
index 00000000000..31e217e4393
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/AbstractModelImportMapping.java
@@ -0,0 +1,215 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer;
+
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.DiagnosticChain;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportListener;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportMapping;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportMappingListener;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportNode;
+import org.eclipse.papyrus.cdo.core.importer.ModelImportListenerAdapter;
+import org.eclipse.papyrus.cdo.internal.core.Activator;
+import org.eclipse.papyrus.cdo.internal.core.IInternalPapyrusRepository;
+
+/**
+ * This is the AbstractModelImportMapping type. Enjoy.
+ */
+abstract class AbstractModelImportMapping
+ implements IModelImportMapping {
+
+ private final IModelImportConfiguration config;
+
+ private IPapyrusRepository repository;
+
+ private final CopyOnWriteArrayList<IModelImportMappingListener> listeners = new CopyOnWriteArrayList<IModelImportMappingListener>();
+
+ public AbstractModelImportMapping(IModelImportConfiguration config) {
+ super();
+
+ this.config = config;
+
+ config.addModelImportListener(createConfigurationListener());
+ }
+
+ public IModelImportConfiguration getConfiguration() {
+ return config;
+ }
+
+ public IPapyrusRepository getRepository() {
+ return repository;
+ }
+
+ public void setRepository(IPapyrusRepository repository) {
+ if (repository != this.repository) {
+ this.repository = repository;
+
+ fireRepositoryChanged();
+ }
+ }
+
+ public Diagnostic validate() {
+ BasicDiagnostic result = new BasicDiagnostic();
+
+ if (validateRepository(result)) {
+ for (IModelImportNode node : getConfiguration().getModelsToImport()) {
+ validateMapping(node, result);
+ }
+ }
+
+ fireProblemsEvent(result);
+
+ return result;
+ }
+
+ protected boolean validateRepository(DiagnosticChain diagnostics) {
+ boolean result = true;
+
+ if (getRepository() == null) {
+ diagnostics.add(new BasicDiagnostic(Diagnostic.ERROR,
+ Activator.PLUGIN_ID, 0, "No repository specified for import.",
+ null));
+ result = false;
+ } else if (!getRepository().isConnected()) {
+ diagnostics.add(new BasicDiagnostic(Diagnostic.ERROR,
+ Activator.PLUGIN_ID, 0, NLS.bind(
+ "Repository \"{0}\" is not connected.",
+ repository.getName()), new Object[]{repository}));
+ result = false;
+ }
+
+ return result;
+ }
+
+ protected boolean validateMapping(IModelImportNode node,
+ DiagnosticChain diagnostics) {
+
+ boolean result = true;
+
+ IPath mapping = getMapping(node);
+ if (mapping == null) {
+ diagnostics.add(new BasicDiagnostic(Diagnostic.ERROR,
+ Activator.PLUGIN_ID, 0, NLS.bind(
+ "No mapping specified for {0}", node.getName()),
+ new Object[]{node}));
+ result = false;
+ } else {
+ for (URI next : node.getResourceURIs()) {
+ String resourcePath = mapping.removeFileExtension()
+ .addFileExtension(next.fileExtension()).toString();
+
+ if (getView().hasResource(resourcePath)) {
+ diagnostics
+ .add(new BasicDiagnostic(
+ Diagnostic.ERROR,
+ Activator.PLUGIN_ID,
+ 0,
+ NLS.bind(
+ "Resource already exists at mapping \"{0}\" for {1}",
+ mapping, node.getName()), new Object[]{node}));
+ result = false;
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public void addModelImportMappingListener(
+ IModelImportMappingListener listener) {
+
+ listeners.addIfAbsent(listener);
+ }
+
+ public void removeModelImportMappingListener(
+ IModelImportMappingListener listener) {
+
+ listeners.remove(listener);
+ }
+
+ protected CDOView getView() {
+ IInternalPapyrusRepository repo = (IInternalPapyrusRepository) getRepository();
+
+ return (repo == null)
+ ? null
+ : repo.getMasterView();
+ }
+
+ protected void fireRepositoryChanged() {
+ for (IModelImportMappingListener next : listeners) {
+ try {
+ next.modelImportRepositoryChanged(this);
+ } catch (Exception e) {
+ Activator.log.error(
+ "Uncaught exception in model import mapping listener.", e);
+ }
+ }
+ }
+
+ protected void fireProblemsEvent(Diagnostic problems) {
+ if (problems.getSeverity() > Diagnostic.OK) {
+ for (IModelImportMappingListener next : listeners) {
+ try {
+ next.modelImportMappingProblemsOccurred(problems);
+ } catch (Exception e) {
+ Activator.log.error(
+ "Uncaught exception in model import mapping listener.",
+ e);
+ }
+ }
+ }
+ }
+
+ protected void fireMappingChanged(IModelImportNode node) {
+ for (IModelImportMappingListener next : listeners) {
+ try {
+ next.modelImportMappingChanged(node);
+ } catch (Exception e) {
+ Activator.log.error(
+ "Uncaught exception in model import mapping listener.", e);
+ }
+ }
+ }
+
+ private IModelImportListener createConfigurationListener() {
+ return new ModelImportListenerAdapter() {
+
+ @Override
+ public void modelsToImportChanged(
+ IModelImportConfiguration configuration) {
+
+ computeDefaultMappings(configuration);
+ }
+ };
+ }
+
+ protected void computeDefaultMappings(
+ IModelImportConfiguration configuration) {
+
+ for (IModelImportNode next : configuration.getModelsToImport()) {
+ if (getMapping(next) == null) {
+ mapTo(next, new Path(next.getName()));
+ }
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/DefaultModelImportConfigurationFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/DefaultModelImportConfigurationFactory.java
new file mode 100644
index 00000000000..5ac7f657d49
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/DefaultModelImportConfigurationFactory.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer;
+
+import org.eclipse.papyrus.cdo.core.importer.IModelImportConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportConfiguration.Factory;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportOperation;
+
+/**
+ * This is the DefaultModelImportConfigurationFactory type. Enjoy.
+ */
+public class DefaultModelImportConfigurationFactory
+ implements Factory {
+
+ public DefaultModelImportConfigurationFactory() {
+ super();
+ }
+
+ public IModelImportConfiguration create(
+ IModelImportOperation.Context operationContext) {
+
+ ModelImportConfiguration result = new ModelImportConfiguration(
+ operationContext);
+
+ result.addModelDependentsProvider(new WorkspaceDIDependentsProvider());
+
+ return result;
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/DependencyAdapter.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/DependencyAdapter.java
new file mode 100644
index 00000000000..63915221362
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/DependencyAdapter.java
@@ -0,0 +1,172 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+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.sasheditor.DiModel;
+import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Sets;
+
+/**
+ * This is the DependencyAdapter type. Enjoy.
+ */
+public class DependencyAdapter
+ extends AdapterImpl {
+
+ private Set<Resource> dependencies = Sets.newLinkedHashSet();
+
+ private Set<Resource> dependents = Sets.newLinkedHashSet();
+
+ private DependencyAdapter() {
+ super();
+ }
+
+ static DependencyAdapter getInstance(Resource resource) {
+ DependencyAdapter result = null;
+
+ for (Object next : resource.eAdapters()) {
+ if (next instanceof DependencyAdapter) {
+ result = (DependencyAdapter) next;
+ break;
+ }
+ }
+
+ if (result == null) {
+ result = new DependencyAdapter();
+ resource.eAdapters().add(Math.min(1, resource.eAdapters().size()),
+ result);
+
+ result.analyze(resource);
+ }
+
+ return result;
+ }
+
+ public Set<Resource> getDependencies() {
+ return dependencies;
+ }
+
+ public static Set<Resource> getDependencies(Resource resource) {
+ return getInstance(resource).getDependencies();
+ }
+
+ public Set<Resource> getDependents() {
+ return dependents;
+ }
+
+ public static Set<Resource> getDependents(Resource resource) {
+ return getInstance(resource).getDependents();
+ }
+
+ private void analyze(Resource resource) {
+ for (Iterator<EObject> iter = resource.getAllContents(); iter.hasNext();) {
+ for (EObject xref : iter.next().eCrossReferences()) {
+ Resource xrefRes = xref.eResource();
+ if ((xrefRes != null)
+ && (isUserModelResource(xrefRes.getURI()))) {
+
+ addDependency(xrefRes);
+ }
+ }
+ }
+
+ if (isDIResource(resource)) {
+ // find implicit dependencies, being the other components of the
+ // logical Papyrus model. Note that this iteration over new
+ // members depends on the set being a LinkedHashSet (retaining
+ // the order of insertion)
+ int size, oldSize = 0;
+ do {
+ size = dependencies.size();
+
+ for (Resource firstOrder : ImmutableList.copyOf(dependencies)
+ .subList(oldSize, size)) {
+
+ for (Resource next : getDependencies(firstOrder)) {
+ if (getDIResource(next) == resource) {
+ addDependency(next);
+ }
+ }
+ }
+
+ oldSize = size;
+ } while (oldSize < dependencies.size());
+ }
+ }
+
+ private Resource getResource() {
+ return (Resource) getTarget();
+ }
+
+ private void addDependency(Resource resource) {
+ Resource self = getResource();
+
+ if ((resource != self) && dependencies.add(resource)) {
+ getInstance(resource).addDependent(self);
+ }
+ }
+
+ private void addDependent(Resource resource) {
+ if (resource != getResource()) {
+ dependents.add(resource);
+ }
+ }
+
+ boolean isUserModelResource(URI uri) {
+ return // config.hasResource(uri) &&
+ (uri.isPlatformResource() || uri.isFile()) && !uri.isArchive();
+ }
+
+ static boolean isDIResource(Resource resource) {
+ boolean result = false;
+
+ for (EObject next : resource.getContents()) {
+ if (next instanceof SashWindowsMngr) {
+ result = true;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ static Resource getDIResource(Resource resource) {
+ Resource result = null;
+
+ if (isDIResource(resource)) {
+ result = resource;
+ } else {
+ // find the the DI resource
+ ResourceSet rset = resource.getResourceSet();
+ URI uri = resource.getURI().trimFileExtension()
+ .appendFileExtension(DiModel.DI_FILE_EXTENSION);
+ if (rset.getURIConverter().exists(uri, null)) {
+ Resource di = rset.getResource(uri, true);
+
+ if ((di != null) && isDIResource(di)) {
+ result = di;
+ }
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ManyToOneModelImportMapping.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ManyToOneModelImportMapping.java
new file mode 100644
index 00000000000..665a97aff92
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ManyToOneModelImportMapping.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportNode;
+
+import com.google.common.base.Objects;
+
+/**
+ * This is the ManyToOneModelImportMapping type. Enjoy.
+ */
+public class ManyToOneModelImportMapping
+ extends AbstractModelImportMapping {
+
+ private IPath mapping;
+
+ public ManyToOneModelImportMapping(IModelImportConfiguration config) {
+ super(config);
+
+ computeDefaultMappings(config);
+ }
+
+ public void mapTo(IModelImportNode source, IPath path) {
+ if (!Objects.equal(this.mapping, path)) {
+ this.mapping = path;
+
+ for (IModelImportNode next : getConfiguration().getModelsToImport()) {
+ fireMappingChanged(next);
+ }
+ }
+ }
+
+ public IPath getMapping(IModelImportNode node) {
+ return mapping;
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ManyToOneModelImportMappingFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ManyToOneModelImportMappingFactory.java
new file mode 100644
index 00000000000..5be39ff8136
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ManyToOneModelImportMappingFactory.java
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer;
+
+import org.eclipse.papyrus.cdo.core.importer.IModelImportConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportMapping;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportMapping.Factory;
+
+/**
+ * This is the ManyToOneModelImportMappingFactory type. Enjoy.
+ */
+public class ManyToOneModelImportMappingFactory
+ implements Factory {
+
+ public ManyToOneModelImportMappingFactory() {
+ super();
+ }
+
+ public IModelImportMapping create(IModelImportConfiguration configuration) {
+ return new ManyToOneModelImportMapping(configuration);
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImportConfiguration.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImportConfiguration.java
new file mode 100644
index 00000000000..d4cdfcb6893
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImportConfiguration.java
@@ -0,0 +1,268 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.DiagnosticChain;
+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.osgi.util.NLS;
+import org.eclipse.papyrus.cdo.core.importer.IModelDependentsProvider;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportListener;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportNode;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportOperation;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportOperation.Context;
+import org.eclipse.papyrus.cdo.internal.core.Activator;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+/**
+ * This is the ModelImportConfiguration type. Enjoy.
+ */
+public class ModelImportConfiguration
+ implements IModelImportConfiguration {
+
+ private Map<URI, Resource> resources = Maps.newHashMap();
+
+ private ResourceSet resourceSet;
+
+ private IModelImportOperation.Context operationContext;
+
+ private Map<Resource, IModelImportNode> importNodes = Maps.newHashMap();
+
+ private Set<IModelImportNode> modelsToImport = Sets.newHashSet();
+
+ private Collection<IModelDependentsProvider> dependentsProviders = Lists
+ .newArrayList();
+
+ private CopyOnWriteArrayList<IModelImportListener> listeners = new CopyOnWriteArrayList<IModelImportListener>();
+
+ public ModelImportConfiguration(
+ IModelImportOperation.Context operationContext) {
+
+ super();
+
+ this.resourceSet = new ResourceSetImpl();
+ ((ResourceSetImpl) this.resourceSet).setURIResourceMap(resources);
+ this.operationContext = new ReentrantOperationContext(operationContext);
+ }
+
+ public void dispose() {
+ if (resourceSet != null) {
+ for (Resource next : resourceSet.getResources()) {
+ next.unload();
+ next.eAdapters().clear();
+ }
+
+ resourceSet.getResources().clear();
+ resourceSet.eAdapters().clear();
+ resourceSet = null;
+
+ resources.clear();
+ resources = null;
+ }
+
+ listeners.clear();
+ }
+
+ public ResourceSet getResourceSet() {
+ return resourceSet;
+ }
+
+ public Context getOperationContext() {
+ return operationContext;
+ }
+
+ public Collection<IModelImportNode> getModelsToImport() {
+ return Collections.unmodifiableSet(modelsToImport);
+ }
+
+ public IModelImportNode addModelToImport(URI resourceURI) {
+ IModelImportNode result = getNode(resourceURI);
+
+ if (modelsToImport.add(result)) {
+ fireModelsToImportChanged();
+ }
+
+ return result;
+ }
+
+ protected IModelImportNode getNode(URI resourceURI) {
+ IModelImportNode result = null;
+
+ Resource resource = resourceSet.getResource(resourceURI, true);
+ if (resource != null) {
+ result = importNodes.get(resource);
+ if (result == null) {
+ final ModelImportNode newNode = new ModelImportNode(this,
+ resource);
+ importNodes.put(resource, newNode);
+
+ newNode.initialize(getOperationContext());
+
+ Diagnostic problems = getOperationContext().run(
+ new IModelImportOperation() {
+
+ public Diagnostic run(IProgressMonitor monitor) {
+ SubMonitor sub = SubMonitor.convert(monitor,
+ "Calculating model dependents ...",
+ dependentsProviders.size());
+
+ for (IModelDependentsProvider next : dependentsProviders) {
+ for (URI uri : next.getDependents(
+ newNode.getPrimaryResource(), monitor)) {
+
+ newNode.addDependent(getNode(uri));
+ }
+ sub.worked(1);
+ }
+
+ sub.done();
+ return Diagnostic.OK_INSTANCE;
+ }
+ });
+
+ fireModelDependentsChanged(newNode);
+ fireProblemsEvent(problems);
+
+ result = newNode;
+ }
+ }
+
+ return result;
+ }
+
+ public void removeModelToImport(IModelImportNode node) {
+ if (modelsToImport.remove(node)) {
+ fireModelsToImportChanged();
+ }
+ }
+
+ public void addModelDependentsProvider(IModelDependentsProvider provider) {
+ if (!dependentsProviders.contains(provider)) {
+ dependentsProviders.add(provider);
+ }
+ }
+
+ public Diagnostic validate() {
+ BasicDiagnostic result = new BasicDiagnostic();
+
+ Set<IModelImportNode> toImport = ImmutableSet
+ .copyOf(getModelsToImport());
+ for (IModelImportNode node : toImport) {
+ checkDependents(node, toImport, result);
+ checkDependencies(node, toImport, result);
+ }
+
+ fireProblemsEvent(result);
+
+ return result;
+ }
+
+ protected void checkDependents(IModelImportNode node,
+ Set<IModelImportNode> toImport, DiagnosticChain diagnostics) {
+
+ Set<IModelImportNode> dependents = ImmutableSet.copyOf(node
+ .getDependents());
+ Set<IModelImportNode> leftOut = Sets.difference(dependents, toImport);
+ if (!leftOut.isEmpty()) {
+ diagnostics
+ .add(new BasicDiagnostic(
+ Diagnostic.WARNING,
+ Activator.PLUGIN_ID,
+ 0,
+ NLS.bind(
+ "Not all models that reference {0} are selected for import.",
+ node.getName()), new Object[]{node, leftOut}));
+ }
+ }
+
+ protected void checkDependencies(IModelImportNode node,
+ Set<IModelImportNode> toImport, DiagnosticChain diagnostics) {
+
+ Set<IModelImportNode> dependencies = ImmutableSet.copyOf(node
+ .getDependencies());
+ Set<IModelImportNode> leftOut = Sets.difference(dependencies, toImport);
+ if (!leftOut.isEmpty()) {
+ diagnostics
+ .add(new BasicDiagnostic(
+ Diagnostic.INFO,
+ Activator.PLUGIN_ID,
+ 0,
+ NLS.bind(
+ "Not all models that are referenced by {0} are selected for import.",
+ node.getName()), new Object[]{node, leftOut}));
+ }
+ }
+
+ public void addModelImportListener(IModelImportListener listener) {
+ listeners.addIfAbsent(listener);
+ }
+
+ public void removeModelImportListener(IModelImportListener listener) {
+ listeners.remove(listener);
+ }
+
+ void fireProblemsEvent(Diagnostic problems) {
+ if (problems.getSeverity() > Diagnostic.OK) {
+ for (IModelImportListener next : listeners) {
+ try {
+ next.modelImportProblemsOccurred(problems);
+ } catch (Exception e) {
+ Activator.log.error(
+ "Uncaught exception in model import listener.", e);
+ }
+ }
+ }
+ }
+
+ void fireModelsToImportChanged() {
+ for (IModelImportListener next : listeners) {
+ try {
+ next.modelsToImportChanged(this);
+ } catch (Exception e) {
+ Activator.log.error(
+ "Uncaught exception in model import listener.", e);
+ }
+ }
+ }
+
+ void fireModelDependentsChanged(IModelImportNode node) {
+ for (IModelImportListener next : listeners) {
+ try {
+ next.modelDependentsChanged(node);
+ } catch (Exception e) {
+ Activator.log.error(
+ "Uncaught exception in model import listener.", e);
+ }
+ }
+ }
+
+ boolean hasResource(URI uri) {
+ return resources.containsKey(uri);
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImportNode.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImportNode.java
new file mode 100644
index 00000000000..4962008b295
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImportNode.java
@@ -0,0 +1,182 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
+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.URIConverter;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportNode;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportOperation;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+
+/**
+ * This is the ModelImportNode type. Enjoy.
+ */
+public class ModelImportNode
+ implements IModelImportNode {
+
+ private final ModelImportConfiguration config;
+
+ private Resource resource;
+
+ private String name;
+
+ private Set<Resource> components = Sets.newLinkedHashSet();
+
+ private Set<IModelImportNode> dependencies = Sets.newLinkedHashSet();
+
+ private Set<IModelImportNode> dependents = Sets.newLinkedHashSet();
+
+ public ModelImportNode(ModelImportConfiguration config, Resource resource) {
+ super();
+
+ this.config = config;
+ this.resource = resource;
+ }
+
+ void initialize(IModelImportOperation.Context context) {
+
+ context.run(new IModelImportOperation() {
+
+ public Diagnostic run(IProgressMonitor monitor) {
+
+ SubMonitor sub = SubMonitor.convert(monitor,
+ "Calculating model dependencies ...", 2);
+
+ components.add(resource);
+ scanForComponents();
+ sub.worked(1);
+
+ scanForDependencies();
+ sub.worked(1);
+
+ sub.done();
+
+ return Diagnostic.OK_INSTANCE;
+ }
+ });
+ }
+
+ public String getName() {
+ if (name == null) {
+ URI uri = getPrimaryResourceURI();
+
+ String path = uri.path();
+ if (uri.isPlatformResource()) {
+ // trim the project segment
+ path = path.substring(("/" + uri.segment(0)).length());
+ } // else a file: URI's path does not include the device, so it's OK
+
+ this.name = path;
+ }
+
+ return name;
+ }
+
+ Resource getPrimaryResource() {
+ return resource;
+ }
+
+ public URI getPrimaryResourceURI() {
+ return resource.getURI();
+ }
+
+ public Collection<URI> getResourceURIs() {
+ ImmutableSet.Builder<URI> result = ImmutableSet.builder();
+
+ for (Resource next : components) {
+ result.add(next.getURI());
+ }
+
+ return result.build();
+ }
+
+ public Collection<IModelImportNode> getDependencies() {
+ return Collections.unmodifiableSet(dependencies);
+ }
+
+ public Collection<IModelImportNode> getDependents() {
+ return Collections.unmodifiableSet(dependents);
+ }
+
+ void addDependent(IModelImportNode node) {
+ dependents.add(node);
+ }
+
+ @Override
+ public int hashCode() {
+ return getPrimaryResourceURI().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return (obj instanceof IModelImportNode)
+ && getPrimaryResourceURI().equals(
+ ((IModelImportNode) obj).getPrimaryResourceURI());
+ }
+
+ @Override
+ public String toString() {
+ return String.format("ModelImportNode(%s)", getName());
+ }
+
+ private void scanForComponents() {
+ Resource self = getPrimaryResource();
+ for (Resource next : DependencyAdapter.getDependencies(self)) {
+ if (DependencyAdapter.getDIResource(next) == self) {
+ components.add(next);
+ }
+ }
+ }
+
+ private void scanForDependencies() {
+ // for each component resource, find the external resources that it
+ // references and, for any that seems to have a primary resource, get
+ // its node
+
+ URIConverter converter = resource.getResourceSet().getURIConverter();
+
+ for (Resource component : components) {
+ for (Resource xref : DependencyAdapter.getDependencies(component)) {
+ URI primary = findPrimaryResource(xref.getURI(), converter);
+ if ((primary != null) && converter.exists(primary, null)) {
+ IModelImportNode node = config.getNode(primary);
+ if ((node != null) && !node.equals(this)) {
+ dependencies.add(node);
+ }
+ }
+ }
+ }
+ }
+
+ private URI findPrimaryResource(URI componentURI, URIConverter converter) {
+ URI result = null;
+
+ URI candidate = componentURI.trimFileExtension().appendFileExtension(
+ DiModel.DI_FILE_EXTENSION);
+ if (converter.exists(candidate, null)) {
+ result = candidate;
+ }
+
+ return result;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImporter.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImporter.java
new file mode 100644
index 00000000000..d1ab9413a1f
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImporter.java
@@ -0,0 +1,358 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.DiagnosticChain;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+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.papyrus.cdo.core.importer.IModelImportConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportMapping;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportNode;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportOperation;
+import org.eclipse.papyrus.cdo.core.importer.IModelImporter;
+import org.eclipse.papyrus.cdo.internal.core.Activator;
+import org.eclipse.papyrus.cdo.internal.core.IInternalPapyrusRepository;
+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;
+
+import com.google.common.collect.Sets;
+
+/**
+ * This is the ModelImporter type. Enjoy.
+ */
+public class ModelImporter
+ implements IModelImporter {
+
+ protected static final ContentType DI_CONTENT = new ContentType("DI");
+
+ protected static final ContentType UML_CONTENT = new ContentType("UML");
+
+ protected static final ContentType NOTATION_CONTENT = new ContentType(
+ "Notation");
+
+ protected static final ContentType UNKNOWN_CONTENT = new ContentType(
+ "unknown");
+
+ public ModelImporter() {
+ super();
+ }
+
+ public Diagnostic importModels(final IModelImportMapping mapping) {
+
+ BasicDiagnostic result = new BasicDiagnostic();
+
+ add(result, mapping.getConfiguration().validate());
+ add(result, mapping.validate());
+
+ if (result.getSeverity() < Diagnostic.ERROR) {
+ add(result,
+ mapping.getConfiguration().getOperationContext()
+ .run(new IModelImportOperation() {
+
+ public Diagnostic run(IProgressMonitor monitor) {
+ return doImport(mapping, monitor);
+ }
+ }));
+ }
+
+ return result;
+ }
+
+ protected Diagnostic doImport(IModelImportMapping mapping,
+ IProgressMonitor monitor) {
+
+ BasicDiagnostic result = new BasicDiagnostic();
+ IModelImportConfiguration configuration = mapping.getConfiguration();
+
+ // by the time the configuration has analyzed every model to be
+ // imported, all proxies have been resolved that can be. So,
+ // there's no need for a further EcoreUtil.resolveAll() or such
+
+ // 1 for transaction commit, 1 for saving affected non-imported
+ // models, and 1 for clean-up
+ SubMonitor sub = SubMonitor.convert(monitor, "Importing models",
+ configuration.getModelsToImport().size() + 3);
+
+ IInternalPapyrusRepository repository = (IInternalPapyrusRepository) mapping
+ .getRepository();
+ ResourceSet destination = repository
+ .createTransaction(new ResourceSetImpl());
+ CDOTransaction transaction = (CDOTransaction) repository
+ .getCDOView(destination);
+
+ for (IModelImportNode model : configuration.getModelsToImport()) {
+ add(result,
+ importModel(model, configuration.getResourceSet(),
+ mapping.getMapping(model), transaction, sub.newChild(1)));
+ }
+
+ try {
+ try {
+ transaction.commit(sub.newChild(1));
+ } catch (CommitException e) {
+ result.add(new BasicDiagnostic(IStatus.ERROR,
+ Activator.PLUGIN_ID, 0,
+ "Failed to commit import transaction.", new Object[]{e}));
+ }
+
+ try {
+ saveNonimportedModels(mapping, transaction, sub.newChild(1));
+ } catch (Exception e) {
+ result.add(new BasicDiagnostic(IStatus.ERROR,
+ Activator.PLUGIN_ID, 0,
+ "Failed to save affected models in the workspace.",
+ new Object[]{e}));
+ }
+ } finally {
+ cleanUp(configuration.getResourceSet());
+ cleanUp(destination);
+ repository.close(destination);
+ sub.worked(1);
+ }
+
+ sub.done();
+
+ return result;
+ }
+
+ protected Diagnostic importModel(IModelImportNode model, ResourceSet rset,
+ IPath toPath, CDOTransaction transaction, IProgressMonitor monitor) {
+
+ BasicDiagnostic result = new BasicDiagnostic();
+
+ IPath basePath = toPath.removeFileExtension();
+
+ SubMonitor sub = SubMonitor.convert(monitor, model.getName(), model
+ .getResourceURIs().size());
+
+ for (URI next : model.getResourceURIs()) {
+ Resource destination = transaction.getOrCreateResource(basePath
+ .addFileExtension(next.fileExtension()).toString());
+
+ add(result,
+ importResource(rset.getResource(next, true), destination));
+ monitor.worked(1);
+ }
+
+ sub.done();
+
+ return result;
+ }
+
+ protected Diagnostic importResource(Resource source, Resource destination) {
+ if (!destination.getContents().isEmpty()) {
+ ContentType contentType = getContentType(source);
+ if (contentType == DI_CONTENT) {
+ mergeDIContent(source, destination);
+ } else {
+ // just append the additional content
+ destination.getContents().addAll(source.getContents());
+ }
+ } else {
+ destination.getContents().addAll(source.getContents());
+ }
+
+ return Diagnostic.OK_INSTANCE;
+ }
+
+ /**
+ * Determines the content-type of a resource for the purpose of combining
+ * content.
+ *
+ * @param resource
+ * a resource to be combined with existing content
+ *
+ * @return the content type
+ */
+ protected ContentType getContentType(Resource resource) {
+ ContentType result = UNKNOWN_CONTENT;
+
+ for (EObject next : resource.getContents()) {
+ EPackage ePackage = next.eClass().getEPackage();
+ if (ePackage == DiPackage.eINSTANCE) {
+ result = DI_CONTENT;
+ break;
+ }
+ if (ePackage.getName().equalsIgnoreCase("uml")) {
+ result = UML_CONTENT;
+ break;
+ }
+ if (ePackage.getName().equalsIgnoreCase("notation")) {
+ result = NOTATION_CONTENT;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ protected void mergeDIContent(Resource source, Resource destination) {
+ // snip out the source window manager and get its counterpart
+ SashWindowsMngr srcMngr = (SashWindowsMngr) EcoreUtil.getObjectByType(
+ source.getContents(), DiPackage.Literals.SASH_WINDOWS_MNGR);
+ EcoreUtil.remove(srcMngr);
+ SashWindowsMngr dstMngr = (SashWindowsMngr) EcoreUtil.getObjectByType(
+ destination.getContents(), DiPackage.Literals.SASH_WINDOWS_MNGR);
+
+ // merge the window manager contents
+ if (dstMngr == null) {
+ destination.getContents().add(0, srcMngr);
+ } else {
+ SashModel dstModel = dstMngr.getSashModel();
+ SashModel srcModel = srcMngr.getSashModel();
+
+ if (dstModel == null) {
+ dstMngr.setSashModel(srcModel);
+ } else {
+ dstModel.getWindows().addAll(srcModel.getWindows());
+ if (dstModel.getCurrentSelection() == null) {
+ dstModel
+ .setCurrentSelection(srcModel.getCurrentSelection());
+ }
+ }
+
+ PageList dstPages = dstMngr.getPageList();
+ PageList srcPages = srcMngr.getPageList();
+
+ if (dstPages == null) {
+ dstMngr.setPageList(srcPages);
+ } else {
+ dstPages.getAvailablePage().addAll(srcPages.getAvailablePage());
+ }
+ }
+
+ // and add all of the tables and other content
+ destination.getContents().addAll(source.getContents());
+ }
+
+ protected Diagnostic saveNonimportedModels(IModelImportMapping mapping,
+ CDOTransaction transaction, IProgressMonitor monitor) {
+
+ IModelImportConfiguration configuration = mapping.getConfiguration();
+
+ BasicDiagnostic result = new BasicDiagnostic();
+
+ Collection<IModelImportNode> imported = configuration
+ .getModelsToImport();
+ Set<IModelImportNode> nonImported = Sets.newHashSet();
+
+ for (IModelImportNode next : configuration.getModelsToImport()) {
+ for (IModelImportNode dependent : next.getDependents()) {
+ if (!imported.contains(dependent)) {
+ nonImported.add(dependent);
+ }
+ }
+ }
+
+ if (!nonImported.isEmpty()) {
+ SubMonitor sub = SubMonitor.convert(monitor,
+ "Saving workspace models...", nonImported.size());
+
+ ResourceSet rset = configuration.getResourceSet();
+
+ try {
+ for (IModelImportNode next : nonImported) {
+ for (URI uri : next.getResourceURIs()) {
+ Resource resource = rset.getResource(uri, false);
+
+ // if the resource is modified, then we imported it, so
+ // don't save
+ if ((resource != null) && !resource.isModified()) {
+ try {
+ resource.save(null);
+ } catch (Exception e) {
+ add(result,
+ new BasicDiagnostic(
+ IStatus.ERROR,
+ Activator.PLUGIN_ID,
+ 0,
+ "Failed to save workspace dependent of imported model.",
+ new Object[]{e}));
+ }
+ }
+ }
+
+ sub.worked(1);
+ }
+ } finally {
+ sub.done();
+ }
+ }
+
+ return result;
+ }
+
+ private void cleanUp(ResourceSet resourceSet) {
+ for (Resource next : resourceSet.getResources()) {
+ next.unload();
+ next.eAdapters().clear();
+ }
+ resourceSet.getResources().clear();
+ }
+
+ private static void add(DiagnosticChain diagnostics, Diagnostic diagnostic) {
+ if (diagnostic.getSeverity() > Diagnostic.OK) {
+ diagnostics.merge(diagnostic);
+ }
+ }
+
+ //
+ // Nested types
+ //
+
+ protected static class ContentType {
+
+ private final String name;
+
+ protected ContentType(String name) {
+ this.name = name;
+ }
+
+ public final String getName() {
+ return name;
+ }
+
+ @Override
+ public int hashCode() {
+ return getName().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return (obj instanceof ContentType)
+ && ((ContentType) obj).getName().equals(getName());
+ }
+
+ @Override
+ public String toString() {
+ return getName() + " content";
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImporterFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImporterFactory.java
new file mode 100644
index 00000000000..b85865f27bd
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImporterFactory.java
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer;
+
+import org.eclipse.papyrus.cdo.core.importer.IModelImporter;
+import org.eclipse.papyrus.cdo.core.importer.IModelImporter.Factory;
+
+/**
+ * This is the ModelImporterFactory type. Enjoy.
+ */
+public class ModelImporterFactory
+ implements Factory {
+
+ public ModelImporterFactory() {
+ super();
+ }
+
+ public IModelImporter create() {
+ return new ModelImporter();
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/OneToOneModelImportMapping.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/OneToOneModelImportMapping.java
new file mode 100644
index 00000000000..76ed4ca85ec
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/OneToOneModelImportMapping.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportNode;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.Maps;
+
+/**
+ * This is the ManyToOneModelImportMapping type. Enjoy.
+ */
+public class OneToOneModelImportMapping
+ extends AbstractModelImportMapping {
+
+ private Map<IModelImportNode, IPath> mappings = Maps.newHashMap();
+
+ public OneToOneModelImportMapping(IModelImportConfiguration config) {
+ super(config);
+
+ computeDefaultMappings(config);
+ }
+
+ public void mapTo(IModelImportNode source, IPath path) {
+ if (!Objects.equal(getMapping(source), path)) {
+ mappings.put(source, path);
+
+ fireMappingChanged(source);
+ }
+ }
+
+ public IPath getMapping(IModelImportNode node) {
+ return mappings.get(node);
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/OneToOneModelImportMappingFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/OneToOneModelImportMappingFactory.java
new file mode 100644
index 00000000000..08819d2d4d5
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/OneToOneModelImportMappingFactory.java
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer;
+
+import org.eclipse.papyrus.cdo.core.importer.IModelImportConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportMapping;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportMapping.Factory;
+
+/**
+ * This is the OneToOneModelImportMappingFactory type. Enjoy.
+ */
+public class OneToOneModelImportMappingFactory
+ implements Factory {
+
+ public OneToOneModelImportMappingFactory() {
+ super();
+ }
+
+ public IModelImportMapping create(IModelImportConfiguration configuration) {
+ return new OneToOneModelImportMapping(configuration);
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ReentrantOperationContext.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ReentrantOperationContext.java
new file mode 100644
index 00000000000..94f4cfa79b2
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ReentrantOperationContext.java
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportOperation;
+
+/**
+ * This is the ReentrantOperationContext type. Enjoy.
+ */
+public class ReentrantOperationContext
+ implements IModelImportOperation.Context {
+
+ private final IModelImportOperation.Context delegate;
+
+ private AtomicInteger depth = new AtomicInteger();
+
+ public ReentrantOperationContext(IModelImportOperation.Context delegate) {
+ super();
+
+ this.delegate = delegate;
+ }
+
+ public Diagnostic run(IModelImportOperation operation) {
+ Diagnostic result;
+
+ try {
+ if (depth.getAndIncrement() == 0) {
+ // let the delegate run it
+ result = delegate.run(operation);
+ } else {
+ // run it directly, assuming we are still in the context of the
+ // delegate
+ result = operation.run(new NullProgressMonitor());
+ }
+ } finally {
+ depth.decrementAndGet();
+ }
+
+ return result;
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/WorkspaceDIDependentsProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/WorkspaceDIDependentsProvider.java
new file mode 100644
index 00000000000..5fb99c85f69
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/WorkspaceDIDependentsProvider.java
@@ -0,0 +1,120 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.core.importer;
+
+import static org.eclipse.papyrus.cdo.internal.core.importer.DependencyAdapter.getDIResource;
+import static org.eclipse.papyrus.cdo.internal.core.importer.DependencyAdapter.isDIResource;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.papyrus.cdo.core.importer.IModelDependentsProvider;
+import org.eclipse.papyrus.cdo.internal.core.Activator;
+
+import com.google.common.collect.Sets;
+
+/**
+ * This is the WorkspaceDIDependentsProvider type. Enjoy.
+ */
+public class WorkspaceDIDependentsProvider
+ implements IModelDependentsProvider {
+
+ private boolean completedScan;
+
+ public WorkspaceDIDependentsProvider() {
+ super();
+ }
+
+ public Collection<URI> getDependents(Resource resource,
+ IProgressMonitor monitor) {
+
+ if (!completedScan) {
+ scanWorkspace(resource.getResourceSet());
+ }
+
+ Set<URI> result = Sets.newHashSet();
+
+ // if it's a DI resource, get its dependencies' dependents and find
+ // their dependents that are unique DIs
+ Resource di = getDIResource(resource);
+ if (di != null) {
+ // the DI's dependencies are the model components
+ for (Resource component : DependencyAdapter.getDependencies(di)) {
+ // the components' dependents in other models are what we are
+ // interested in
+ for (Resource next : DependencyAdapter.getDependents(component)) {
+ Resource dependentDI = getDIResource(next);
+ if ((dependentDI != null) && (dependentDI != di)) {
+ result.add(dependentDI.getURI());
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private void scanWorkspace(final ResourceSet resourceSet) {
+ completedScan = true;
+
+ IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
+
+ public boolean visit(IResourceProxy proxy)
+ throws CoreException {
+
+ if ((proxy.getType() == IResource.FILE)
+ && proxy.getName().endsWith(".di")) {
+
+ String path = proxy.requestFullPath().toString();
+
+ try {
+ Resource resource = resourceSet.getResource(
+ URI.createPlatformResourceURI(path, true), true);
+
+ if ((resource != null) && isDIResource(resource)) {
+ // it's a Papyrus model. Initialize the
+ // dependencies
+ DependencyAdapter.getInstance(resource);
+ }
+ } catch (Exception e) {
+ // not a valid model resource. That's OK.
+ Resource resource = resourceSet.getResource(
+ URI.createPlatformResourceURI(path, true), false);
+ if (resource != null) {
+ resource.unload();
+ resourceSet.getResources().remove(resource);
+ resource.eAdapters().clear();
+ }
+ }
+ }
+
+ return true;
+ }
+ };
+
+ try {
+ ResourcesPlugin.getWorkspace().getRoot().accept(visitor, 0);
+ } catch (CoreException e) {
+ // TODO: report to user?
+ Activator.log.error(e);
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.classpath b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.classpath
new file mode 100644
index 00000000000..64c5e31b7a2
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.project b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.project
new file mode 100644
index 00000000000..e78851d5007
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.cdo.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.settings/org.eclipse.jdt.core.prefs b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..af0f20f97a5
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.settings/org.eclipse.jdt.ui.prefs b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 00000000000..86087cd06ce
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.ui.javadoc=true
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*****************************************************************************\n * Copyright (c) ${year} CEA LIST.\n * \n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors\:\n * CEA LIST - Initial API and implementation\n *****************************************************************************/</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * This is the ${type_name} type. Enjoy.\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/META-INF/MANIFEST.MF b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..8ff2eb5cfd3
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,45 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.cdo.ui;singleton:=true
+Bundle-Version: 0.10.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.cdo.internal.ui.Activator
+Bundle-Vendor: %providerName
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.ui.ide;bundle-version="[3.8.0,4.0.0)",
+ org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0",
+ org.eclipse.ui.workbench,
+ org.eclipse.papyrus.cdo.core;bundle-version="0.10.0";visibility:=reexport,
+ org.eclipse.emf.cdo.ui;bundle-version="[4.2.0,5.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="0.10.0",
+ org.eclipse.emf.cdo.dawn;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.emf.cdo.dawn.gmf;bundle-version="[2.1.0,3.0.0)",
+ org.eclipse.emf.cdo.dawn.ui;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.papyrus.infra.emf;bundle-version="0.10.0",
+ org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.3.0",
+ org.eclipse.papyrus.infra.onefile;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.services.markerlistener;bundle-version="0.10.0",
+ org.eclipse.papyrus.cdo.validation.problems;bundle-version="0.10.0",
+ org.eclipse.papyrus.cdo.validation.problems.edit;bundle-version="0.10.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Import-Package: com.google.common.base;version="10.0.1",
+ com.google.common.cache;version="10.0.1",
+ com.google.common.collect;version="10.0.1",
+ com.google.common.eventbus;version="10.0.1"
+Export-Package: org.eclipse.papyrus.cdo.internal.ui,
+ org.eclipse.papyrus.cdo.internal.ui.actions,
+ org.eclipse.papyrus.cdo.internal.ui.adapters,
+ org.eclipse.papyrus.cdo.internal.ui.decorators,
+ org.eclipse.papyrus.cdo.internal.ui.dialogs,
+ org.eclipse.papyrus.cdo.internal.ui.editors,
+ org.eclipse.papyrus.cdo.internal.ui.expressions,
+ org.eclipse.papyrus.cdo.internal.ui.handlers,
+ org.eclipse.papyrus.cdo.internal.ui.markers,
+ org.eclipse.papyrus.cdo.internal.ui.properties,
+ org.eclipse.papyrus.cdo.internal.ui.providers,
+ org.eclipse.papyrus.cdo.internal.ui.util,
+ org.eclipse.papyrus.cdo.internal.ui.views,
+ org.eclipse.papyrus.cdo.internal.ui.wizards
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/about.html b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/about.html
new file mode 100644
index 00000000000..209103075a7
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>November 14, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/build.properties b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/build.properties
new file mode 100644
index 00000000000..64cd39d55da
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/build.properties
@@ -0,0 +1,10 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties,\
+ plugin.xml,\
+ icons/,\
+ about.html
+bin.excludes = icons/**/*.pxm
+src.includes = about.html
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ctool16/add_repo.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ctool16/add_repo.gif
new file mode 100644
index 00000000000..7fd983bc94e
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ctool16/add_repo.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ctool16/add_repo.pxm b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ctool16/add_repo.pxm
new file mode 100644
index 00000000000..29e89b652f4
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ctool16/add_repo.pxm
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ctool16/link_editor.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ctool16/link_editor.gif
new file mode 100644
index 00000000000..870934b6934
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ctool16/link_editor.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/dlcl16/connect_co.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/dlcl16/connect_co.gif
new file mode 100644
index 00000000000..2bc98a38f61
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/dlcl16/connect_co.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/dlcl16/connect_co.pxm b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/dlcl16/connect_co.pxm
new file mode 100644
index 00000000000..a785bfa3978
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/dlcl16/connect_co.pxm
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/dlcl16/disconnect_co.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/dlcl16/disconnect_co.gif
new file mode 100644
index 00000000000..587f8c98f9a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/dlcl16/disconnect_co.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/connect_co.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/connect_co.gif
new file mode 100644
index 00000000000..a028be50aa7
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/connect_co.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/connect_co.pxm b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/connect_co.pxm
new file mode 100644
index 00000000000..4e8b0646540
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/connect_co.pxm
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/disconnect_co.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/disconnect_co.gif
new file mode 100644
index 00000000000..d8fdd8a0849
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/disconnect_co.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/newfolder_co.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/newfolder_co.gif
new file mode 100644
index 00000000000..6fb9345b2a8
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/elcl16/newfolder_co.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/papyrus_model.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/papyrus_model.gif
new file mode 100644
index 00000000000..55aa23df78c
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/papyrus_model.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/repo_closed.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/repo_closed.gif
new file mode 100644
index 00000000000..f92c642187f
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/repo_closed.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/repo_closed.pxm b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/repo_closed.pxm
new file mode 100644
index 00000000000..1ba54dad20f
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/repo_closed.pxm
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/repo_open.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/repo_open.gif
new file mode 100644
index 00000000000..686395292bf
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/obj16/repo_open.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/conflicted.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/conflicted.gif
new file mode 100644
index 00000000000..874d661377a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/conflicted.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/dependent.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/dependent.gif
new file mode 100644
index 00000000000..9ae7df1e18c
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/dependent.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/dependent.pxm b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/dependent.pxm
new file mode 100644
index 00000000000..53ee535df9c
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/dependent.pxm
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/other_locked.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/other_locked.gif
new file mode 100644
index 00000000000..0cc1dac56c0
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/other_locked.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/self_locked.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/self_locked.gif
new file mode 100644
index 00000000000..3b2797b1c67
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr16/self_locked.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/conflicted.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/conflicted.gif
new file mode 100644
index 00000000000..b82a28db10d
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/conflicted.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/conflicted.pxm b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/conflicted.pxm
new file mode 100644
index 00000000000..5e5c606262f
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/conflicted.pxm
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/other_locked.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/other_locked.gif
new file mode 100644
index 00000000000..91dfb98795d
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/other_locked.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/other_locked.pxm b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/other_locked.pxm
new file mode 100644
index 00000000000..693787ea9e0
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/other_locked.pxm
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/self_locked.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/self_locked.gif
new file mode 100644
index 00000000000..b958b6881c4
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/self_locked.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/self_locked.pxm b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/self_locked.pxm
new file mode 100644
index 00000000000..998ff2cf525
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/ovr24/self_locked.pxm
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/view16/model_repositories.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/view16/model_repositories.gif
new file mode 100644
index 00000000000..686395292bf
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/view16/model_repositories.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/view16/model_repositories.pxm b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/view16/model_repositories.pxm
new file mode 100644
index 00000000000..8b2e5da0724
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/icons/full/view16/model_repositories.pxm
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.properties b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.properties
new file mode 100644
index 00000000000..f367b98634a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.properties
@@ -0,0 +1,13 @@
+# Copyright (c) 2013 CEA LIST.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# CEA LIST - Initial API and implementation
+#
+
+pluginName = Papyrus CDO Model Repository UI (Incubation)
+providerName = Eclipse Modeling Project
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.xml b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.xml
new file mode 100644
index 00000000000..9b24d13530c
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/plugin.xml
@@ -0,0 +1,291 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+
+<!--
+ Copyright (c) 2013 CEA LIST.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ CEA LIST - Initial API and implementation
+
+-->
+
+<plugin>
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ category="org.eclipse.papyrus.views.category"
+ class="org.eclipse.papyrus.cdo.internal.ui.views.ModelRepositoriesView"
+ icon="icons/full/view16/model_repositories.gif"
+ id="org.eclipse.papyrus.cdo.ui.ModelRepositoriesView"
+ name="Model Repositories"
+ restorable="true">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.core.service">
+ <serviceFactory
+ classname="org.eclipse.papyrus.cdo.internal.ui.editors.DawnGraphicalEditorSupportServiceFactory"
+ description="The Dawn-based CDO-aware diagram editor support implementation."
+ id="org.eclipse.papyrus.infra.gmfdiag.common.IGraphicalEditorSupport"
+ priority="10"
+ startKind="lazy">
+ </serviceFactory>
+ </extension>
+ <extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+ class="org.eclipse.papyrus.cdo.internal.ui.properties.RepositoryPropertyPage"
+ id="org.eclipse.papyrus.cdo.ui.repositoryProperties"
+ name="CDO Repository Connection">
+ <enabledWhen>
+ <adapt
+ type="org.eclipse.papyrus.cdo.core.IPapyrusRepository">
+ </adapt>
+ </enabledWhen>
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.papyrus.cdo.core.IPapyrusRepository"
+ class="org.eclipse.papyrus.cdo.internal.ui.adapters.PapyrusRepositoryWorkbenchAdapter$Factory">
+ <adapter
+ type="org.eclipse.ui.model.IWorkbenchAdapter">
+ </adapter>
+ </factory>
+ <factory
+ adaptableType="org.eclipse.ui.IEditorPart"
+ class="org.eclipse.papyrus.cdo.internal.ui.adapters.EditorAdapterFactory">
+ <adapter
+ type="org.eclipse.emf.cdo.dawn.editors.IDawnEditor">
+ </adapter>
+ </factory>
+ </extension>
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="org.eclipse.papyrus.infra.core.perspective">
+ <viewShortcut
+ id="org.eclipse.papyrus.cdo.ui.ModelRepositoriesView">
+ </viewShortcut>
+ <view
+ id="org.eclipse.papyrus.cdo.ui.ModelRepositoriesView"
+ minimized="false"
+ relationship="stack"
+ relative="org.eclipse.ui.navigator.ProjectExplorer">
+ </view>
+ </perspectiveExtension>
+ </extension>
+
+ <extension
+ point="org.eclipse.emf.cdo.dawn.elementstylizerfactory">
+ <DawnElementStylizerFactory
+ factory="org.eclipse.papyrus.cdo.internal.ui.decorators.PapyrusElementStylizerFactory"
+ priority="2 - Low">
+ </DawnElementStylizerFactory>
+ </extension>
+
+ <extension
+ point="org.eclipse.gmf.runtime.diagram.ui.decoratorProviders">
+ <decoratorProvider
+ class="org.eclipse.papyrus.cdo.internal.ui.decorators.DiagramDecoratorProvider">
+ <Priority
+ name="Low">
+ </Priority>
+ </decoratorProvider>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.decorators">
+ <decorator
+ class="org.eclipse.papyrus.cdo.internal.ui.decorators.CDOStateLabelDecorator"
+ id="org.eclipse.papyrus.cdo.ui.cdoStateDecorator"
+ label="CDO State Decorations"
+ state="true">
+ <description>
+ Decorates elements in Papyrus model repositories with CDO lock and conflict states.
+ </description>
+ <enablement>
+ <or>
+ <objectClass
+ name="org.eclipse.emf.ecore.EObject">
+ </objectClass>
+ <objectClass
+ name="org.eclipse.emf.facet.infra.browser.uicore.internal.model.ITreeElement">
+ </objectClass>
+ </or>
+ </enablement>
+ </decorator>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.ui.popup.any?after=additions">
+ <menu
+ label="Locks/Conflicts">
+ <visibleWhen
+ checkEnabled="false">
+ <and>
+ <with
+ variable="activeEditorId">
+ <equals
+ value="org.eclipse.papyrus.infra.core.papyrusEditor">
+ </equals>
+ </with>
+ <with variable="selection">
+ <iterate ifEmpty="false" operator="and">
+ <adapt type="org.eclipse.emf.cdo.CDOObject" />
+ </iterate>
+ </with>
+ </and>
+ </visibleWhen>
+ <command
+ commandId="org.eclipse.papyrus.cdo.ui.commands.lock"
+ label="Lock">
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.cdo.ui.commands.unlock"
+ label="Unlock">
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.cdo.ui.commands.resolveConflicts"
+ label="Resolve Conflicts">
+ </command>
+ </menu>
+ </menuContribution>
+ <menuContribution
+ locationURI="popup:org.eclipse.ui.popup.any?after=additions">
+ <command
+ commandId="org.eclipse.papyrus.cdo.ui.commands.importModels"
+ label="Import into Repository...">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ id="org.eclipse.papyrus.cdo.ui.commands.lock"
+ name="Lock objects">
+ </command>
+ <command
+ id="org.eclipse.papyrus.cdo.ui.commands.unlock"
+ name="Unlock objects">
+ </command>
+ <command
+ id="org.eclipse.papyrus.cdo.ui.commands.resolveConflicts"
+ name="Resolve conflicts">
+ </command>
+ <command
+ id="org.eclipse.papyrus.cdo.ui.commands.importModels"
+ name="Import Models into Repository">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.papyrus.cdo.internal.ui.handlers.LockObjectsHandler"
+ commandId="org.eclipse.papyrus.cdo.ui.commands.lock">
+ <enabledWhen>
+ <iterate operator="and" ifEmpty="false">
+ <adapt
+ type="org.eclipse.emf.cdo.CDOObject">
+ <test
+ property="org.eclipse.papyrus.cdo.ui.canLock">
+ </test>
+ </adapt>
+ </iterate>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.papyrus.cdo.internal.ui.handlers.UnlockObjectsHandler"
+ commandId="org.eclipse.papyrus.cdo.ui.commands.unlock">
+ <enabledWhen>
+ <iterate operator="and" ifEmpty="false">
+ <adapt
+ type="org.eclipse.emf.cdo.CDOObject">
+ <test
+ property="org.eclipse.papyrus.cdo.ui.isLockedLocally" >
+ </test>
+ </adapt>
+ </iterate>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.papyrus.cdo.internal.ui.handlers.ResolveConflictsHandler"
+ commandId="org.eclipse.papyrus.cdo.ui.commands.resolveConflicts">
+ <enabledWhen>
+ <iterate operator="and" ifEmpty="false">
+ <adapt
+ type="org.eclipse.emf.cdo.CDOObject">
+ <test
+ property="org.eclipse.papyrus.cdo.ui.isConflicted">
+ </test>
+ </adapt>
+ </iterate>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.papyrus.cdo.internal.ui.handlers.ImportModelsHandler"
+ commandId="org.eclipse.papyrus.cdo.ui.commands.importModels">
+ <enabledWhen>
+ <iterate operator="and" ifEmpty="false">
+ <adapt
+ type="org.eclipse.papyrus.infra.onefile.model.IPapyrusFile">
+ </adapt>
+ </iterate>
+ </enabledWhen>
+ </handler>
+ </extension>
+
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.gef.EditPart"
+ class="org.eclipse.papyrus.cdo.internal.ui.adapters.CDOAdapterFactory">
+ <adapter
+ type="org.eclipse.emf.cdo.CDOObject">
+ </adapter>
+ </factory>
+ <factory
+ adaptableType="org.eclipse.emf.facet.infra.browser.uicore.internal.model.ITreeElement"
+ class="org.eclipse.papyrus.cdo.internal.ui.adapters.CDOAdapterFactory">
+ <adapter
+ type="org.eclipse.emf.cdo.CDOObject">
+ </adapter>
+ </factory>
+ </extension>
+ <extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.papyrus.cdo.internal.ui.expressions.CDOObjectPropertyTester"
+ id="org.eclipse.papyrus.cdo.ui.cdoObjectTester"
+ namespace="org.eclipse.papyrus.cdo.ui"
+ properties="canLock,isLockedLocally,isLockedRemotely,isConflicted"
+ type="org.eclipse.emf.cdo.CDOObject">
+ </propertyTester>
+ </extension>
+
+ <extension
+ point="org.eclipse.papyrus.infra.services.markerlistener.markerproviders">
+ <provider
+ class="org.eclipse.papyrus.cdo.internal.ui.markers.CDOMarkerProvider">
+ <enablement>
+ <instanceof
+ value="org.eclipse.emf.cdo.eresource.CDOResource">
+ </instanceof>
+ </enablement>
+ </provider>
+ <monitor class="org.eclipse.papyrus.cdo.internal.ui.markers.CDOMarkerMonitor">
+ </monitor>
+ </extension>
+
+</plugin>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/Activator.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/Activator.java
new file mode 100644
index 00000000000..3b66e695a7b
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/Activator.java
@@ -0,0 +1,177 @@
+package org.eclipse.papyrus.cdo.internal.ui;
+
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.ui.util.DialogCredentialsProviderFactory;
+import org.eclipse.papyrus.cdo.internal.ui.util.UIUtil;
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class Activator
+ extends AbstractUIPlugin {
+
+ public static final String ICON_ADD_REPOSITORY = "add_repository";
+
+ public static final String ICON_OPEN_REPOSITORY = "open_repository";
+
+ public static final String ICON_CLOSED_REPOSITORY = "closed_repository";
+
+ public static final String ICON_CONNECT_REPOSITORY_ENABLED = "connect_repo_ena";
+
+ public static final String ICON_CONNECT_REPOSITORY_DISABLED = "connect_repo_dis";
+
+ public static final String ICON_DISCONNECT_REPOSITORY_ENABLED = "disconnect_repo_ena";
+
+ public static final String ICON_DISCONNECT_REPOSITORY_DISABLED = "disconnect_repo_dis";
+
+ public static final String ICON_CONFLICTED_OVERLAY24 = "conflicted_ovr24";
+
+ public static final String ICON_CONFLICTED_OVERLAY16 = "conflicted_ovr16";
+
+ public static final String ICON_OTHER_LOCKED_OVERLAY24 = "other_locked_ovr24";
+
+ public static final String ICON_OTHER_LOCKED_OVERLAY16 = "other_locked_ovr16";
+
+ public static final String ICON_SELF_LOCKED_OVERLAY24 = "self_locked_ovr24";
+
+ public static final String ICON_SELF_LOCKED_OVERLAY16 = "self_locked_ovr16";
+
+ public static final String ICON_PAPYRUS_MODEL = "papyrus_model";
+
+ public static final String ICON_CREATE_FOLDER = "create_folder";
+
+ public static final String ICON_DEPENDENT_OVERLAY16 = "dependent_ovr16";
+
+ public static final String ICON_LINK_WITH_EDITOR = "link_editor";
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.cdo.ui";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /** Logging helper */
+ public static LogHelper log = new LogHelper();
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ super();
+ }
+
+ @Override
+ public void start(BundleContext context)
+ throws Exception {
+ super.start(context);
+ plugin = this;
+
+ // register the log helper
+ log.setPlugin(plugin);
+
+ CDOUtils.setBroadcastExecutor(UIUtil.uiSafeExecutor());
+
+ PapyrusRepositoryManager.INSTANCE
+ .setCredentialsProviderFactory(new DialogCredentialsProviderFactory());
+ }
+
+ @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;
+ }
+
+ protected ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, "$nl$/icons/" + path);
+ }
+
+ @Override
+ protected void initializeImageRegistry(ImageRegistry reg) {
+ super.initializeImageRegistry(reg);
+
+ reg.put(ICON_ADD_REPOSITORY,
+ getImageDescriptor("full/ctool16/add_repo.gif"));
+
+ reg.put(ICON_OPEN_REPOSITORY,
+ getImageDescriptor("full/obj16/repo_open.gif"));
+
+ reg.put(ICON_CLOSED_REPOSITORY,
+ getImageDescriptor("full/obj16/repo_closed.gif"));
+
+ reg.put(ICON_CONNECT_REPOSITORY_ENABLED,
+ getImageDescriptor("full/elcl16/connect_co.gif"));
+
+ reg.put(ICON_CONNECT_REPOSITORY_DISABLED,
+ getImageDescriptor("full/dlcl16/connect_co.gif"));
+
+ reg.put(ICON_DISCONNECT_REPOSITORY_ENABLED,
+ getImageDescriptor("full/elcl16/disconnect_co.gif"));
+
+ reg.put(ICON_DISCONNECT_REPOSITORY_DISABLED,
+ getImageDescriptor("full/dlcl16/disconnect_co.gif"));
+
+ reg.put(ICON_CONFLICTED_OVERLAY24,
+ getImageDescriptor("full/ovr24/conflicted.gif"));
+
+ reg.put(ICON_CONFLICTED_OVERLAY16,
+ getImageDescriptor("full/ovr16/conflicted.gif"));
+
+ reg.put(ICON_OTHER_LOCKED_OVERLAY24,
+ getImageDescriptor("full/ovr24/other_locked.gif"));
+
+ reg.put(ICON_OTHER_LOCKED_OVERLAY16,
+ getImageDescriptor("full/ovr16/other_locked.gif"));
+
+ reg.put(ICON_SELF_LOCKED_OVERLAY24,
+ getImageDescriptor("full/ovr24/self_locked.gif"));
+
+ reg.put(ICON_SELF_LOCKED_OVERLAY16,
+ getImageDescriptor("full/ovr16/self_locked.gif"));
+
+ reg.put(ICON_PAPYRUS_MODEL,
+ getImageDescriptor("full/obj16/papyrus_model.gif"));
+
+ reg.put(ICON_CREATE_FOLDER,
+ getImageDescriptor("full/elcl16/newfolder_co.gif"));
+
+ reg.put(ICON_DEPENDENT_OVERLAY16,
+ getImageDescriptor("full/ovr16/dependent.gif"));
+
+ reg.put(ICON_LINK_WITH_EDITOR,
+ getImageDescriptor("full/ctool16/link_editor.gif"));
+ }
+
+ public static ImageDescriptor getIcon(String key) {
+ return getDefault().getImageRegistry().getDescriptor(key);
+ }
+
+ public static IDawnEditor getActiveDawnEditor() {
+ IDawnEditor result = null;
+ IEditorPart editor = DawnEditorHelper.getActiveEditor();
+
+ if (editor instanceof IDawnEditor) {
+ result = (IDawnEditor) editor;
+ } else {
+ result = (IDawnEditor) editor.getAdapter(IDawnEditor.class);
+ }
+
+ return result;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/SharedImages.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/SharedImages.java
new file mode 100644
index 00000000000..ce15c14542e
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/SharedImages.java
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * This is the SharedImages type. Enjoy.
+ */
+public class SharedImages {
+ private static final ImageRegistry REGISTRY = new ImageRegistry(Display.getDefault());
+
+ private SharedImages() {
+ super();
+ }
+
+ public static Image getImage(String key) {
+ Image result = REGISTRY.get(key);
+
+ if (result == null) {
+ ImageDescriptor desc = Activator.getIcon(key);
+ if (desc != null) {
+ REGISTRY.put(key, desc);
+ result = REGISTRY.get(key);
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AbstractRepositoryAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AbstractRepositoryAction.java
new file mode 100644
index 00000000000..a80189eaa07
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AbstractRepositoryAction.java
@@ -0,0 +1,84 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.actions;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+
+import com.google.common.collect.Iterators;
+
+/**
+ * This is the AbstractRepositoryAction type. Enjoy.
+ */
+public abstract class AbstractRepositoryAction
+ extends BaseSelectionListenerAction {
+
+ private IPapyrusRepository repository;
+
+ private IWorkbenchPart part;
+
+ public AbstractRepositoryAction(String text, ImageDescriptor enabledIcon,
+ ImageDescriptor disabledIcon, IWorkbenchPart part) {
+ super(text);
+
+ this.part = part;
+
+ setImageDescriptor(enabledIcon);
+ setDisabledImageDescriptor(disabledIcon);
+ }
+
+ public AbstractRepositoryAction(String text, String sharedEnabledIcon,
+ String sharedDisabledIcon, IWorkbenchPart part) {
+ this(text, getSharedImage(part, sharedEnabledIcon), getSharedImage(
+ part, sharedDisabledIcon), part);
+ }
+
+ public AbstractRepositoryAction(String text, IWorkbenchPart part) {
+ this(text, (ImageDescriptor) null, null, part);
+ }
+
+ static ImageDescriptor getSharedImage(IWorkbenchPart part, String imageKey) {
+ return ImageDescriptor.createFromImage(part.getSite()
+ .getWorkbenchWindow().getWorkbench().getSharedImages()
+ .getImage(imageKey));
+ }
+
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ boolean result = super.updateSelection(selection);
+
+ repository = Iterators.getNext(
+ Iterators.filter(selection.iterator(), IPapyrusRepository.class),
+ null);
+ result = result && (repository != null) && isEnabledFor(repository);
+
+ return result;
+ }
+
+ protected IWorkbenchPart getPart() {
+ return part;
+ }
+
+ protected abstract boolean isEnabledFor(IPapyrusRepository repository);
+
+ protected abstract void run(IPapyrusRepository repository);
+
+ @Override
+ public void run() {
+ if (repository != null) {
+ run(repository);
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AddRepositoryAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AddRepositoryAction.java
new file mode 100644
index 00000000000..4c23cd5e6ed
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AddRepositoryAction.java
@@ -0,0 +1,80 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.actions;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.internal.ui.dialogs.AddRepositoryDialog;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * This is the AddRepositoryAction type. Enjoy.
+ */
+public class AddRepositoryAction
+ extends Action {
+
+ private IWorkbenchPart part;
+
+ public AddRepositoryAction(IWorkbenchPart part) {
+ super("Add Repository...", Activator
+ .getIcon(Activator.ICON_ADD_REPOSITORY));
+
+ this.part = part;
+ }
+
+ @Override
+ public void run() {
+ AddRepositoryDialog dlg = new AddRepositoryDialog(part.getSite()
+ .getShell());
+ if (dlg.open() == Window.OK) {
+ IPapyrusRepositoryManager mgr = PapyrusRepositoryManager.INSTANCE;
+ String url = dlg.getURL();
+
+ IPapyrusRepository repository = mgr.getRepository(url);
+
+ if (repository == null) {
+ repository = mgr.createRepository(url);
+ repository.setName(dlg.getName());
+ }
+
+ mgr.saveRepositories();
+
+ if (!repository.isConnected()) {
+ final IPapyrusRepository _repository = repository;
+ try {
+ part.getSite().getWorkbenchWindow()
+ .run(true, false, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException,
+ InterruptedException {
+
+ _repository.connect();
+ }
+ });
+ } catch (Exception e) {
+ Activator.log.error(
+ "Unexpected exception in async repository connection.",
+ e);
+ }
+ }
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncAction.java
new file mode 100644
index 00000000000..81858f48455
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncAction.java
@@ -0,0 +1,88 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.actions;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+
+/**
+ * This is the AsyncAction type. Enjoy.
+ */
+public abstract class AsyncAction<T>
+ extends BaseSelectionListenerAction {
+
+ protected final Class<? extends T> type;
+
+ private T selection;
+
+ public AsyncAction(Class<? extends T> type, String text, String icon) {
+ this(type, text, Activator.getIcon(icon));
+ }
+
+ public AsyncAction(Class<? extends T> type, String text,
+ ImageDescriptor icon) {
+
+ super(text);
+
+ this.type = type;
+
+ setImageDescriptor(icon);
+ }
+
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ this.selection = coerce(selection.getFirstElement());
+
+ return (this.selection != null) && super.updateSelection(selection);
+ }
+
+ protected T coerce(Object selection) {
+ T result = null;
+
+ if (type.isInstance(selection)) {
+ result = type.cast(selection);
+ } else if (selection instanceof IAdaptable) {
+ result = type.cast(((IAdaptable) selection).getAdapter(type));
+ }
+
+ return result;
+ }
+
+ @Override
+ public void run() {
+ if (selection != null) {
+ if (gatherInput(selection)) {
+ new Job(getText()) {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ doRun(selection, monitor);
+ return Status.OK_STATUS;
+ }
+ }.schedule();
+ }
+ }
+ }
+
+ protected boolean gatherInput(T selection) {
+ return true;
+ }
+
+ protected abstract void doRun(T selection, IProgressMonitor monitor);
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncTransactionAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncTransactionAction.java
new file mode 100644
index 00000000000..cbe28289947
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/AsyncTransactionAction.java
@@ -0,0 +1,89 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.actions;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.ui.statushandlers.StatusManager;
+
+/**
+ * This is the AsyncTransactionAction type. Enjoy.
+ */
+public abstract class AsyncTransactionAction<T>
+ extends AsyncAction<T> {
+
+ public AsyncTransactionAction(Class<? extends T> type, String text,
+ String icon) {
+
+ super(type, text, icon);
+ }
+
+ public AsyncTransactionAction(Class<? extends T> type, String text,
+ ImageDescriptor icon) {
+
+ super(type, text, icon);
+ }
+
+ protected CDOView getView(T selection) {
+ if (!(selection instanceof CDOObject)) {
+ throw new IllegalArgumentException("selection is not a CDOObject");
+ }
+ return ((CDOObject) selection).cdoView();
+ }
+
+ @Override
+ protected void doRun(T selection, IProgressMonitor monitor) {
+ CDOView view = getView(selection);
+
+ if (view instanceof CDOTransaction) {
+ doRun(selection, (CDOTransaction) view, monitor);
+ } else {
+ CDOUtil.setLegacyModeDefault(true);
+
+ final CDOID oid = (selection instanceof CDOObject)
+ ? ((CDOObject) selection).cdoID()
+ : null;
+
+ CDOTransaction transaction = view.getSession().openTransaction();
+
+ try {
+ // get the image of the CDOObject in the new transaction
+ T localSelection = (oid == null)
+ ? selection
+ : type.cast(transaction.getObject(oid));
+
+ doRun(localSelection, transaction, monitor);
+ } finally {
+ try {
+ transaction.commit();
+ } catch (CommitException e) {
+ StatusManager.getManager().handle(
+ new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ "Action failed: " + getText(), e),
+ StatusManager.SHOW);
+ }
+ }
+ }
+ }
+
+ protected abstract void doRun(T selection, CDOTransaction transaction,
+ IProgressMonitor monitor);
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/ConnectRepositoryAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/ConnectRepositoryAction.java
new file mode 100644
index 00000000000..8b22902ab7b
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/ConnectRepositoryAction.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.actions;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * This is the ConnectRepositoryAction type. Enjoy.
+ */
+public class ConnectRepositoryAction
+ extends AbstractRepositoryAction {
+
+ public ConnectRepositoryAction(IWorkbenchPart part) {
+ super("Connect", Activator
+ .getIcon(Activator.ICON_CONNECT_REPOSITORY_ENABLED), Activator
+ .getIcon(Activator.ICON_CONNECT_REPOSITORY_DISABLED), part);
+ }
+
+ @Override
+ protected boolean isEnabledFor(IPapyrusRepository repository) {
+ return !repository.isConnected();
+ }
+
+ @Override
+ protected void run(final IPapyrusRepository repository) {
+ try {
+ getPart().getSite().getWorkbenchWindow()
+ .run(true, false, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException,
+ InterruptedException {
+
+ repository.connect();
+ }
+ });
+ } catch (Exception e) {
+ Activator.log.error(
+ "Unexpected exception in async repository connection.", e);
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/CreateFolderAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/CreateFolderAction.java
new file mode 100644
index 00000000000..91bf6236011
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/CreateFolderAction.java
@@ -0,0 +1,168 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.actions;
+
+import java.util.Collections;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+import org.eclipse.emf.cdo.eresource.EresourceFactory;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.cdo.internal.core.IInternalPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.ui.IWorkbenchPart;
+
+import com.google.common.collect.Iterables;
+
+/**
+ * This is the CreateFolderAction type. Enjoy.
+ */
+public class CreateFolderAction
+ extends AsyncTransactionAction<CDOResourceNode> {
+
+ private final IWorkbenchPart part;
+
+ private String folderName;
+
+ public CreateFolderAction(IWorkbenchPart part) {
+ super(CDOResourceNode.class, "Create Folder...",
+ Activator.ICON_CREATE_FOLDER);
+
+ this.part = part;
+ }
+
+ @Override
+ protected CDOResourceNode coerce(Object selection) {
+ CDOResourceNode result = super.coerce(selection);
+
+ if ((result == null)
+ && (selection instanceof IInternalPapyrusRepository)) {
+
+ IInternalPapyrusRepository repository = (IInternalPapyrusRepository) selection;
+
+ if (repository.isConnected()) {
+ CDOView view = repository.getMasterView();
+ if (view != null) {
+ result = view.getRootResource();
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ protected boolean gatherInput(CDOResourceNode selection) {
+ boolean result = false;
+
+ InputDialog dialog = new InputDialog(part.getSite().getShell(),
+ "Create New Folder", "Enter a name for the new folder.",
+ getDefaultFolderName(selection), createInputValidator(selection));
+
+ if (dialog.open() == Window.OK) {
+ folderName = dialog.getValue().trim();
+ result = true;
+ }
+
+ return result;
+ }
+
+ private Iterable<CDOResourceNode> getChildren(CDOResourceNode node) {
+ Iterable<CDOResourceNode> result;
+
+ if (node instanceof CDOResourceFolder) {
+ result = ((CDOResourceFolder) node).getNodes();
+ } else if ((node instanceof CDOResource)
+ && ((CDOResource) node).isRoot()) {
+ result = Iterables.filter(((CDOResource) node).getContents(),
+ CDOResourceNode.class);
+ } else {
+ result = Collections.emptyList();
+ }
+
+ return result;
+ }
+
+ boolean nameExists(Iterable<CDOResourceNode> existingNodes, String name) {
+ boolean result = false;
+
+ for (CDOResourceNode next : existingNodes) {
+ if (name.equals(next.getName())) {
+ result = true;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ private String getDefaultFolderName(CDOResourceNode parent) {
+ Iterable<CDOResourceNode> existing = getChildren(parent);
+ String result = null;
+
+ for (int i = 1; result == null; i++) {
+ result = "folder" + i;
+
+ if (nameExists(existing, result)) {
+ result = null;
+ }
+ }
+
+ return result;
+ }
+
+ private IInputValidator createInputValidator(CDOResourceNode parent) {
+ final Iterable<CDOResourceNode> existing = getChildren(parent);
+
+ return new IInputValidator() {
+
+ public String isValid(String newText) {
+ String result;
+ String name = (newText == null)
+ ? ""
+ : newText.trim();
+
+ if (name.length() == 0) {
+ result = "Name may not be empty";
+ } else if (nameExists(existing, name)) {
+ result = "A resource or folder of that name already exists";
+ } else {
+ result = null;
+ }
+
+ return result;
+ }
+ };
+ }
+
+ @Override
+ protected void doRun(CDOResourceNode selection, CDOTransaction transaction,
+ IProgressMonitor monitor) {
+
+ CDOResourceFolder folder = EresourceFactory.eINSTANCE
+ .createCDOResourceFolder();
+ folder.setName(folderName);
+
+ if (selection instanceof CDOResourceFolder) {
+ ((CDOResourceFolder) selection).getNodes().add(folder);
+ } else if (selection instanceof CDOResource) {
+ ((CDOResource) selection).getContents().add(folder);
+ }
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/DeleteModelAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/DeleteModelAction.java
new file mode 100644
index 00000000000..244607d5faa
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/DeleteModelAction.java
@@ -0,0 +1,122 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.actions;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.internal.ui.editors.PapyrusCDOEditorInput;
+import org.eclipse.papyrus.cdo.internal.ui.views.DIModel;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.statushandlers.StatusManager;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+/**
+ * This is the DeleteModelAction type. Enjoy.
+ */
+public class DeleteModelAction
+ extends AsyncTransactionAction<DIModel> {
+
+ private final IWorkbenchPart part;
+
+ public DeleteModelAction(IWorkbenchPart part) {
+ super(DIModel.class, "Delete", ImageDescriptor.createFromImage(part
+ .getSite().getWorkbenchWindow().getWorkbench().getSharedImages()
+ .getImage(ISharedImages.IMG_TOOL_DELETE)));
+
+ this.part = part;
+
+ setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);
+ }
+
+ @Override
+ protected CDOView getView(DIModel selection) {
+ return selection.getResource().cdoView();
+ }
+
+ @Override
+ protected boolean gatherInput(DIModel selection) {
+ boolean result = false;
+
+ if (MessageDialog
+ .openQuestion(
+ part.getSite().getShell(),
+ "Delete Model",
+ NLS.bind(
+ "Are you sure you want to delete the model \"{0}\"? This action cannot be undone.",
+ selection.getName()))) {
+
+ IWorkbenchPage page = part.getSite().getPage();
+ URI uri = selection.getResource().getURI();
+ PapyrusCDOEditorInput input = new PapyrusCDOEditorInput(uri);
+ IEditorPart openEditor = page.findEditor(input);
+ if (openEditor != null) {
+ page.closeEditor(openEditor, false);
+ }
+
+ result = true;
+ }
+
+ return result;
+ }
+
+ @Override
+ protected void doRun(DIModel selection, CDOTransaction transaction,
+ IProgressMonitor monitor) {
+
+ List<IStatus> failures = Lists.newArrayListWithExpectedSize(1);
+ for (Object next : selection.getChildren()) {
+ if (next instanceof CDOResource) {
+ // get the resource local to this transaction
+
+ CDOID oid = ((CDOResource) next).cdoID();
+ CDOResource toDelete = (CDOResource) transaction.getObject(oid);
+ if (toDelete != null) {
+ try {
+ toDelete.delete(null);
+ } catch (Exception e) {
+ failures.add(new Status(IStatus.ERROR,
+ Activator.PLUGIN_ID, "Failed to delete resource "
+ + toDelete.getPath(), e));
+ }
+ }
+ }
+ }
+
+ if (!failures.isEmpty()) {
+ StatusManager.getManager().handle(
+ new MultiStatus(Activator.PLUGIN_ID, 0, Iterables.toArray(
+ failures, IStatus.class),
+ "Errors occurred in deleting model.", null),
+ StatusManager.SHOW);
+ }
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/DisconnectRepositoryAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/DisconnectRepositoryAction.java
new file mode 100644
index 00000000000..e0cd821cd4f
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/DisconnectRepositoryAction.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.actions;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.papyrus.cdo.core.CommitException;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.statushandlers.IStatusAdapterConstants;
+import org.eclipse.ui.statushandlers.StatusAdapter;
+import org.eclipse.ui.statushandlers.StatusManager;
+
+/**
+ * This is the ConnectRepositoryAction type. Enjoy.
+ */
+public class DisconnectRepositoryAction
+ extends AbstractRepositoryAction {
+
+ public DisconnectRepositoryAction(IWorkbenchPart part) {
+ super("Disconnect", Activator
+ .getIcon(Activator.ICON_DISCONNECT_REPOSITORY_ENABLED), Activator
+ .getIcon(Activator.ICON_DISCONNECT_REPOSITORY_DISABLED), part);
+ }
+
+ @Override
+ protected boolean isEnabledFor(IPapyrusRepository repository) {
+ return repository.isConnected();
+ }
+
+ @Override
+ protected void run(final IPapyrusRepository repository) {
+ final CommitException[] commitFailure = new CommitException[1];
+
+ try {
+ getPart().getSite().getWorkbenchWindow()
+ .run(true, false, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException,
+ InterruptedException {
+
+ try {
+ repository.disconnect();
+ } catch (CommitException e) {
+ commitFailure[0] = e;
+ }
+ }
+ });
+ } catch (Exception e) {
+ Activator.log.error(
+ "Unexpected exception in async repository connection.", e);
+ }
+
+ if (commitFailure[0] != null) {
+ StatusAdapter adapter = new StatusAdapter(
+ commitFailure[0].getStatus());
+ adapter.setProperty(IStatusAdapterConstants.TITLE_PROPERTY,
+ "Disconnect failed");
+ StatusManager.getManager().handle(adapter, StatusManager.SHOW);
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/LinkWithEditorAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/LinkWithEditorAction.java
new file mode 100644
index 00000000000..ece856ec244
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/LinkWithEditorAction.java
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.internal.ui.views.ModelRepositoriesView;
+import org.eclipse.ui.IPropertyListener;
+
+/**
+ * This is the AddRepositoryAction type. Enjoy.
+ */
+public class LinkWithEditorAction
+ extends Action {
+
+ private ModelRepositoriesView part;
+
+ public LinkWithEditorAction(ModelRepositoriesView part) {
+ super("Link with Editor", IAction.AS_CHECK_BOX);
+
+ this.part = part;
+ part.addPropertyListener(new IPropertyListener() {
+
+ public void propertyChanged(Object source, int propId) {
+ switch (propId) {
+ case ModelRepositoriesView.LINK_WITH_EDITOR_PROPERTY :
+ updateToggleState();
+ break;
+ }
+ }
+ });
+
+ setImageDescriptor(Activator.getIcon(Activator.ICON_LINK_WITH_EDITOR));
+
+ setChecked(part.isLinkWithEditor());
+ }
+
+ @Override
+ public void run() {
+ part.setLinkWithEditor(!part.isLinkWithEditor());
+ }
+
+ void updateToggleState() {
+ setChecked(part.isLinkWithEditor());
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/OpenPapyrusModelAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/OpenPapyrusModelAction.java
new file mode 100644
index 00000000000..57efd81fbd8
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/OpenPapyrusModelAction.java
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.actions;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.cdo.internal.ui.editors.PapyrusCDOEditorManager;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+import org.eclipse.ui.statushandlers.StatusManager;
+
+/**
+ * This is the AddRepositoryAction type. Enjoy.
+ */
+public class OpenPapyrusModelAction
+ extends BaseSelectionListenerAction {
+
+ private final IWorkbenchPart part;
+
+ public OpenPapyrusModelAction(IWorkbenchPart part) {
+ super("Open in Papyrus Editor");
+
+ this.part = part;
+ }
+
+ @Override
+ public void run() {
+ IStructuredSelection sel = getStructuredSelection();
+
+ if ((sel != null) && !sel.isEmpty()) {
+ CDOResource res = getResource(sel.getFirstElement());
+
+ if (res != null) {
+ try {
+ URI uri = res.getURI();
+ String name = uri.trimFileExtension().lastSegment();
+
+ PapyrusCDOEditorManager.INSTANCE.openEditor(part.getSite()
+ .getPage(), uri, name);
+ } catch (PartInitException e) {
+ StatusManager.getManager().handle(e.getStatus(),
+ StatusManager.SHOW);
+ }
+ }
+ }
+ }
+
+ private CDOResource getResource(Object object) {
+ CDOResource result = null;
+
+ if (object instanceof CDOResource) {
+ result = (CDOResource) object;
+ } else if (object instanceof IAdaptable) {
+ result = (CDOResource) ((IAdaptable) object)
+ .getAdapter(CDOResource.class);
+ }
+
+ return result;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/RemoveRepositoryAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/RemoveRepositoryAction.java
new file mode 100644
index 00000000000..9490ce758d6
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/actions/RemoveRepositoryAction.java
@@ -0,0 +1,79 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.actions;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.cdo.core.CommitException;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.statushandlers.IStatusAdapterConstants;
+import org.eclipse.ui.statushandlers.StatusAdapter;
+import org.eclipse.ui.statushandlers.StatusManager;
+
+/**
+ * This is the RemoveRepositoryAction type. Enjoy.
+ */
+public class RemoveRepositoryAction
+ extends AbstractRepositoryAction {
+
+ public RemoveRepositoryAction(IWorkbenchPart part) {
+ super("Remove", ISharedImages.IMG_TOOL_DELETE,
+ ISharedImages.IMG_TOOL_DELETE_DISABLED, part);
+
+ setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);
+ }
+
+ @Override
+ protected boolean isEnabledFor(IPapyrusRepository repository) {
+ return true;
+ }
+
+ @Override
+ protected void run(IPapyrusRepository repository) {
+ boolean connected = repository.isConnected();
+
+ String message = connected
+ ? "The repository \"{0}\" is currently connected. Are you sure you want to disconnect and remove it?"
+ : "Are you sure you want to remove the repository \"{0}\"?";
+
+ if (MessageDialog.openQuestion(getPart().getSite().getShell(),
+ "Remove Repository", NLS.bind(message, repository.getName()))) {
+ IPapyrusRepositoryManager mgr = PapyrusRepositoryManager.INSTANCE;
+
+ if (!connected) {
+ // just remove it. Easy
+ mgr.removeRepository(repository);
+ mgr.saveRepositories();
+ } else {
+ try {
+ repository.disconnect();
+
+ // don't proceed with removing the repository if disconnect
+ // failed
+ mgr.removeRepository(repository);
+ mgr.saveRepositories();
+ } catch (CommitException e) {
+ StatusAdapter adapter = new StatusAdapter(e.getStatus());
+ adapter.setProperty(IStatusAdapterConstants.TITLE_PROPERTY,
+ "Disconnect failed");
+ StatusManager.getManager().handle(adapter,
+ StatusManager.SHOW);
+ }
+ }
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/adapters/CDOAdapterFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/adapters/CDOAdapterFactory.java
new file mode 100644
index 00000000000..5ea1b6fe245
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/adapters/CDOAdapterFactory.java
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.adapters;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+
+/**
+ * This is the CDOAdapterFactory type. Enjoy.
+ */
+@SuppressWarnings("rawtypes")
+public class CDOAdapterFactory
+ implements IAdapterFactory {
+
+ private final Class[] supported = {CDOObject.class};
+
+ public CDOAdapterFactory() {
+ super();
+ }
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ EObject eObject = null;
+ if (adaptableObject instanceof EditPart) {
+ // notation views are important as CDOObjects for locking and
+ // conflict purposes, so do not defer to the semantic element
+ eObject = (EObject) ((EditPart) adaptableObject).getModel();
+ } else if (adaptableObject instanceof EObject) {
+ eObject = (EObject) adaptableObject;
+ } else {
+ // try really hard to get an EObject
+ if (adaptableObject instanceof IAdaptable) {
+ eObject = (EObject) ((IAdaptable) adaptableObject)
+ .getAdapter(EObject.class);
+ }
+ if (eObject == null) {
+ eObject = (EObject) Platform.getAdapterManager()
+ .getAdapter(adaptableObject, EObject.class);
+ }
+ }
+
+ // get the CDOObject from the EObject (if possible)
+ return CDOUtils.getCDOObject(eObject);
+ }
+
+ public Class[] getAdapterList() {
+ return supported;
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/adapters/EditorAdapterFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/adapters/EditorAdapterFactory.java
new file mode 100644
index 00000000000..6d353de823b
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/adapters/EditorAdapterFactory.java
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.adapters;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.papyrus.cdo.internal.ui.editors.DawnEditorAdapter;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * This is the EditorAdapterFactory type. Enjoy.
+ */
+@SuppressWarnings("rawtypes")
+public class EditorAdapterFactory
+ implements IAdapterFactory {
+
+ private final Class[] supported = {IDawnEditor.class};
+
+ public EditorAdapterFactory() {
+ super();
+ }
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ Object result = null;
+
+ if (adapterType == IDawnEditor.class) {
+ if (adaptableObject instanceof IEditorPart) {
+ IEditorPart editor = (IEditorPart) adaptableObject;
+
+ result = DawnEditorAdapter.getDawnEditor(editor);
+ }
+ }
+
+ return result;
+ }
+
+ public Class[] getAdapterList() {
+ return supported;
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/adapters/PapyrusRepositoryWorkbenchAdapter.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/adapters/PapyrusRepositoryWorkbenchAdapter.java
new file mode 100644
index 00000000000..c6869ff0002
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/adapters/PapyrusRepositoryWorkbenchAdapter.java
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.adapters;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+/**
+ * This is the PapyrusRepositoryWorkbenchAdapter type. Enjoy.
+ */
+public class PapyrusRepositoryWorkbenchAdapter
+ implements IWorkbenchAdapter {
+
+ private static final Object[] NOTHING = {};
+
+ public PapyrusRepositoryWorkbenchAdapter() {
+ super();
+ }
+
+ public Object[] getChildren(Object o) {
+ return (o instanceof IContainer<?>)
+ ? ((IContainer<?>) o).getElements()
+ : NOTHING;
+ }
+
+ public ImageDescriptor getImageDescriptor(Object object) {
+ ImageDescriptor result = null;
+
+ if (object instanceof IPapyrusRepository) {
+ boolean open = ((IPapyrusRepository) object).isConnected();
+ result = Activator.getIcon(open
+ ? Activator.ICON_OPEN_REPOSITORY
+ : Activator.ICON_CLOSED_REPOSITORY);
+ }
+
+ return result;
+ }
+
+ public String getLabel(Object o) {
+ String result = null;
+
+ if (o instanceof IPapyrusRepository) {
+ result = ((IPapyrusRepository) o).getName();
+ }
+
+ return result;
+ }
+
+ public Object getParent(Object o) {
+ return null;
+ }
+
+ //
+ // Nested types
+ //
+
+ @SuppressWarnings("rawtypes")
+ public static class Factory
+ implements IAdapterFactory {
+
+ private final Class[] supported = {IWorkbenchAdapter.class};
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ Object result = null;
+
+ if (adaptableObject instanceof IPapyrusRepository) {
+ result = new PapyrusRepositoryWorkbenchAdapter();
+ }
+
+ return result;
+ }
+
+ public Class[] getAdapterList() {
+ return supported;
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/CDOStateAdapter.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/CDOStateAdapter.java
new file mode 100644
index 00000000000..0715611b01e
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/CDOStateAdapter.java
@@ -0,0 +1,180 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.decorators;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.eclipse.emf.cdo.dawn.spi.DawnState;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+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.EcoreUtil;
+
+import com.google.common.collect.Sets;
+
+/**
+ * An adapter that caches the current Dawn
+ */
+public class CDOStateAdapter
+ extends AdapterImpl {
+
+ private DawnState state = DawnState.CLEAN;
+
+ CDOStateAdapter() {
+ super();
+ }
+
+ public static CDOStateAdapter require(Notifier notifier) {
+ CDOStateAdapter result = get(notifier);
+
+ if (result == null) {
+ result = new CDOStateAdapter();
+ notifier.eAdapters().add(result);
+ }
+
+ return result;
+ }
+
+ public static CDOStateAdapter get(Notifier notifier) {
+ return (CDOStateAdapter) EcoreUtil.getExistingAdapter(notifier,
+ DawnState.class);
+ }
+
+ public static DawnState getState(Notifier notifier) {
+ CDOStateAdapter adapter = get(notifier);
+
+ return (adapter == null)
+ ? DawnState.CLEAN
+ : adapter.getState();
+ }
+
+ public static void setState(Notifier notifier, DawnState state) {
+ if (state == DawnState.CLEAN) {
+ CDOStateAdapter adapter = get(notifier);
+ if (adapter != null) {
+ notifier.eAdapters().remove(adapter);
+ }
+ } else {
+ require(notifier).setState(state);
+ }
+ }
+
+ public static Iterable<CDOStateAdapter> getAll(ResourceSet resourceSet) {
+ Iterable<CDOStateAdapter> result;
+
+ Tracker tracker = Tracker.get(resourceSet);
+ if (tracker == null) {
+ result = Collections.emptySet();
+ } else {
+ result = tracker.getStateAdapters();
+ }
+
+ return result;
+ }
+
+ @Override
+ public boolean isAdapterForType(Object type) {
+ return type == DawnState.class;
+ }
+
+ public DawnState getState() {
+ return state;
+ }
+
+ public void setState(DawnState state) {
+ this.state = (state == null)
+ ? DawnState.CLEAN
+ : state;
+ }
+
+ @Override
+ public void setTarget(Notifier newTarget) {
+ super.setTarget(newTarget);
+
+ if (newTarget instanceof EObject) {
+ Resource res = ((EObject) newTarget).eResource();
+ if (res != null) {
+ ResourceSet rset = res.getResourceSet();
+ if (rset != null) {
+ Tracker.require(rset).add(this);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void unsetTarget(Notifier oldTarget) {
+ if (oldTarget instanceof EObject) {
+ Resource res = ((EObject) oldTarget).eResource();
+ if (res != null) {
+ ResourceSet rset = res.getResourceSet();
+ if (rset != null) {
+ Tracker tracker = Tracker.get(rset);
+ if (tracker != null) {
+ tracker.remove(this);
+ }
+ }
+ }
+ }
+
+ super.unsetTarget(oldTarget);
+ }
+
+ //
+ // Nested types
+ //
+
+ private static final class Tracker
+ extends AdapterImpl {
+
+ private final Set<CDOStateAdapter> stateAdapters = Sets.newHashSet();
+
+ static Tracker get(ResourceSet resourceSet) {
+ Tracker result = null;
+
+ for (Object next : resourceSet.eAdapters()) {
+ if (next instanceof Tracker) {
+ result = (Tracker) next;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ static Tracker require(ResourceSet resourceSet) {
+ Tracker result = get(resourceSet);
+
+ if (result == null) {
+ result = new Tracker();
+ resourceSet.eAdapters().add(result);
+ }
+
+ return result;
+ }
+
+ void add(CDOStateAdapter stateAdapter) {
+ stateAdapters.add(stateAdapter);
+ }
+
+ void remove(CDOStateAdapter stateAdapter) {
+ stateAdapters.remove(stateAdapter);
+ }
+
+ Iterable<CDOStateAdapter> getStateAdapters() {
+ return stateAdapters;
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/CDOStateDiagramDecorator.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/CDOStateDiagramDecorator.java
new file mode 100644
index 00000000000..a4db5789bf2
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/CDOStateDiagramDecorator.java
@@ -0,0 +1,88 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.decorators;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer;
+import org.eclipse.emf.cdo.dawn.spi.DawnState;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.AbstractDecorator;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget.Direction;
+import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * A GMF-based label decorator for diagram views, to annotate them to indicate
+ * CDO locking and transaction conflict states.
+ */
+public class CDOStateDiagramDecorator
+ extends AbstractDecorator {
+
+ private DawnElementStylizer stylizer;
+
+ public CDOStateDiagramDecorator(IDecoratorTarget decoratorTarget,
+ DawnElementStylizer stylizer) {
+ super(decoratorTarget);
+
+ this.stylizer = stylizer;
+ }
+
+ public void activate() {
+ // pass
+ }
+
+ public void refresh() {
+ removeDecoration();
+
+ View view = (View) getDecoratorTarget().getAdapter(View.class);
+ EObject element = ((view == null) || !view.isSetElement())
+ ? null
+ : view.getElement();
+ CDOObject cdo = (element == null)
+ ? null
+ : CDOUtils.getCDOObject(element);
+ if (cdo != null) {
+ EditPart editPart = (EditPart) getDecoratorTarget().getAdapter(
+ EditPart.class);
+
+ // does the view, itself, have a conflict or lock state?
+ DawnState state = CDOStateAdapter.getState(view);
+ if (state == DawnState.CLEAN) {
+ // infer a state from the semantic element, then
+ state = CDOStateAdapter.getState(element);
+ }
+
+ Image image = stylizer.getImage(editPart, state);
+
+ if (image != null) {
+ if (editPart instanceof ShapeEditPart) {
+ int margin = MapModeUtil.getMapMode(
+ ((GraphicalEditPart) editPart).getFigure()).DPtoLP(-1);
+ setDecoration(getDecoratorTarget().addShapeDecoration(
+ image, Direction.SOUTH_EAST, margin, true));
+ } else if (view instanceof Edge) {
+ int percent = 50;
+ setDecoration(getDecoratorTarget().addConnectionDecoration(
+ image, percent, true));
+ }
+ }
+ }
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/CDOStateLabelDecorator.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/CDOStateLabelDecorator.java
new file mode 100644
index 00000000000..b28390ad56c
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/CDOStateLabelDecorator.java
@@ -0,0 +1,183 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.decorators;
+
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer;
+import org.eclipse.emf.cdo.dawn.spi.DawnState;
+import org.eclipse.emf.cdo.dawn.ui.stylizer.DawnElementStylizerRegistry;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.resource.LocalResourceManager;
+import org.eclipse.jface.resource.ResourceManager;
+import org.eclipse.jface.viewers.DecorationOverlayIcon;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.progress.UIJob;
+
+/**
+ * This is the CDOStateLabelDecorator type. Enjoy.
+ */
+public class CDOStateLabelDecorator
+ implements ILabelDecorator {
+
+ private static Set<CDOStateLabelDecorator> instances = new CopyOnWriteArraySet<CDOStateLabelDecorator>();
+
+ private final ResourceManager manager = new LocalResourceManager(
+ JFaceResources.getResources());
+
+ private final ListenerList listeners = new ListenerList();
+
+ private static LabelUpdateJob labelUpdateJob = new LabelUpdateJob();
+
+ public CDOStateLabelDecorator() {
+ super();
+
+ instances.add(this);
+ }
+
+ public void dispose() {
+ manager.dispose();
+
+ instances.remove(this);
+ }
+
+ public Image decorateImage(Image image, Object element) {
+ EObject eObject = EMFHelper.getEObject(element);
+
+ if (eObject != null) {
+ DawnState state = CDOStateAdapter.getState(eObject);
+ if (state != DawnState.CLEAN) {
+ DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance
+ .getStylizer(eObject);
+
+ if (stylizer != null) {
+ ImageDescriptor decoration = ImageDescriptor
+ .createFromImage(stylizer.getImage(eObject, state));
+
+ if (decoration != null) {
+ ImageDescriptor desc = new DecorationOverlayIcon(image,
+ decoration, IDecoration.BOTTOM_RIGHT);
+
+ return (Image) manager.get(desc);
+ }
+ }
+ }
+ }
+
+ return image;
+ }
+
+ public String decorateText(String text, Object element) {
+ return text;
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ listeners.remove(listener);
+ }
+
+ public static void fireLabelUpdates() {
+ labelUpdateJob.poke();
+ }
+
+ private void fireUpdates() {
+ Object[] listeners = this.listeners.getListeners();
+
+ if (listeners.length > 0) {
+ LabelProviderChangedEvent event = new LabelProviderChangedEvent(
+ this);
+
+ for (int i = 0; i < listeners.length; i++) {
+ try {
+ ((ILabelProviderListener) listeners[i])
+ .labelProviderChanged(event);
+ } catch (Exception e) {
+ Activator.log.error(
+ "Uncaught exception in label provider listener.", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * A label-updating job that aggregates multiple requests to update labels,
+ * in order to avoid redundant updates.
+ */
+ private static class LabelUpdateJob
+ extends UIJob {
+
+ private final Object lock = new Object();
+
+ private boolean pending;
+
+ LabelUpdateJob() {
+ super("Update CDO state label decorations");
+
+ setSystem(true);
+ }
+
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+
+ for (;;) {
+ synchronized (lock) {
+ pending = false;
+ }
+
+ for (CDOStateLabelDecorator next : instances) {
+ next.fireUpdates();
+ }
+
+ synchronized (lock) {
+ if (!pending) {
+ break;
+ }
+ }
+ };
+
+ return Status.OK_STATUS;
+ }
+
+ void poke() {
+ synchronized (lock) {
+ if (!pending) {
+ pending = true;
+
+ if (getState() != Job.RUNNING) {
+ schedule();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/DiagramDecoratorProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/DiagramDecoratorProvider.java
new file mode 100644
index 00000000000..1b4f4e708ec
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/DiagramDecoratorProvider.java
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.decorators;
+
+import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer;
+import org.eclipse.emf.cdo.dawn.ui.stylizer.DawnElementStylizerRegistry;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.CreateDecoratorsOperation;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorProvider;
+import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
+
+/**
+ * This is the DiagramDecoratorProvider type. Enjoy.
+ */
+public class DiagramDecoratorProvider
+ extends AbstractProvider
+ implements IDecoratorProvider {
+
+ public DiagramDecoratorProvider() {
+ super();
+ }
+
+ public boolean provides(IOperation operation) {
+ if (!(operation instanceof CreateDecoratorsOperation)) {
+ return false;
+ }
+ IDecoratorTarget decoratorTarget = ((CreateDecoratorsOperation) operation)
+ .getDecoratorTarget();
+ EditPart editPart = (EditPart) decoratorTarget
+ .getAdapter(EditPart.class);
+ return editPart instanceof IPapyrusEditPart;
+ }
+
+ public void createDecorators(IDecoratorTarget decoratorTarget) {
+ EditPart editPart = (EditPart) decoratorTarget
+ .getAdapter(EditPart.class);
+
+ DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance
+ .getStylizer(editPart);
+ if (stylizer != null) {
+ decoratorTarget.installDecorator("cdoState", new CDOStateDiagramDecorator(
+ decoratorTarget, stylizer));
+ }
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusConnectionEditPartStylizer.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusConnectionEditPartStylizer.java
new file mode 100644
index 00000000000..7a6bb5a8610
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusConnectionEditPartStylizer.java
@@ -0,0 +1,23 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.decorators;
+
+/**
+ * This is the PapyrusConnectionEditPartStylizer type. Enjoy.
+ */
+public class PapyrusConnectionEditPartStylizer
+ extends PapyrusEditPartStylizer {
+
+ public PapyrusConnectionEditPartStylizer() {
+ super();
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusEditPartStylizer.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusEditPartStylizer.java
new file mode 100644
index 00000000000..3f4210289aa
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusEditPartStylizer.java
@@ -0,0 +1,101 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.decorators;
+
+import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
+import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnEditPartStylizer;
+import org.eclipse.emf.cdo.dawn.spi.DawnState;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.common.ui.util.DisplayUtils;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.internal.ui.SharedImages;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This is the PapyrusEditPartStylizer type. Enjoy.
+ */
+abstract class PapyrusEditPartStylizer
+ extends DawnEditPartStylizer {
+
+ public PapyrusEditPartStylizer() {
+ super();
+ }
+
+ @Override
+ public Image getImage(Object element, DawnState state) {
+ Image result;
+
+ switch (state) {
+ case LOCKED_LOCALLY :
+ result = SharedImages
+ .getImage(Activator.ICON_SELF_LOCKED_OVERLAY24);
+ break;
+ case LOCKED_REMOTELY :
+ result = SharedImages
+ .getImage(Activator.ICON_OTHER_LOCKED_OVERLAY24);
+ break;
+ case CONFLICT :
+ result = SharedImages
+ .getImage(Activator.ICON_CONFLICTED_OVERLAY24);
+ break;
+ default :
+ result = super.getImage(element, state);
+ break;
+ }
+
+ return result;
+ }
+
+ @Override
+ public void setDefault(EditPart editPart) {
+ setState(editPart, DawnState.CLEAN);
+ }
+
+ @Override
+ public void setLocked(EditPart editPart, int type) {
+ DawnState state;
+
+ switch (type) {
+ case DawnAppearancer.TYPE_LOCKED_GLOBALLY :
+ state = DawnState.LOCKED_REMOTELY;
+ break;
+ case DawnAppearancer.TYPE_LOCKED_LOCALLY :
+ state = DawnState.LOCKED_LOCALLY;
+ break;
+ default :
+ state = DawnState.LOCKED_REMOTELY;
+ break;
+ }
+
+ setState(editPart, state);
+ }
+
+ @Override
+ public void setConflicted(EditPart editPart, int type) {
+ setState(editPart, DawnState.CONFLICT);
+ }
+
+ protected void setState(final EditPart editPart, DawnState state) {
+ View view = (View) editPart.getModel();
+
+ CDOStateAdapter.setState(view, state);
+
+ // post refresh of the edit-part later to let the decorator catch up
+ DisplayUtils.getDisplay().asyncExec(new Runnable() {
+
+ public void run() {
+ editPart.refresh();
+ }
+ });
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusElementStylizer.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusElementStylizer.java
new file mode 100644
index 00000000000..5d96bb95d40
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusElementStylizer.java
@@ -0,0 +1,99 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.decorators;
+
+import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
+import org.eclipse.emf.cdo.dawn.spi.DawnState;
+import org.eclipse.emf.cdo.dawn.ui.stylizer.DawnDefaultElementStylizer;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.internal.ui.SharedImages;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This is the PapyrusNodeEditPartStylizer type. Enjoy.
+ */
+public class PapyrusElementStylizer
+ extends DawnDefaultElementStylizer {
+
+ public PapyrusElementStylizer() {
+ super();
+ }
+
+ @Override
+ public Image getImage(Object element, DawnState state) {
+ Image result;
+
+ switch (state) {
+ case LOCKED_LOCALLY :
+ result = SharedImages
+ .getImage(Activator.ICON_SELF_LOCKED_OVERLAY16);
+ break;
+ case LOCKED_REMOTELY :
+ result = SharedImages
+ .getImage(Activator.ICON_OTHER_LOCKED_OVERLAY16);
+ break;
+ case CONFLICT :
+ result = SharedImages
+ .getImage(Activator.ICON_CONFLICTED_OVERLAY16);
+ break;
+ default :
+ result = super.getImage(element, state);
+ break;
+ }
+
+ return result;
+ }
+
+ @Override
+ public void setDefault(Object element) {
+ if (element instanceof EObject) {
+ EObject eObject = (EObject) element;
+ setState(eObject, DawnState.CLEAN);
+ }
+ }
+
+ @Override
+ public void setConflicted(Object element, final int type) {
+ if (element instanceof EObject) {
+ EObject eObject = (EObject) element;
+ setState(eObject, DawnState.CONFLICT);
+ }
+ }
+
+ @Override
+ public void setLocked(Object element, int type) {
+ if (element instanceof EObject) {
+ EObject eObject = (EObject) element;
+
+ DawnState state;
+ switch (type) {
+ case DawnAppearancer.TYPE_LOCKED_GLOBALLY :
+ state = DawnState.LOCKED_REMOTELY;
+ break;
+ case DawnAppearancer.TYPE_LOCKED_LOCALLY :
+ state = DawnState.LOCKED_LOCALLY;
+ break;
+ default :
+ state = DawnState.LOCKED_REMOTELY;
+ break;
+ }
+
+ setState(eObject, state);
+ }
+ }
+
+ protected void setState(EObject object, DawnState state) {
+ CDOStateAdapter.setState(object, state);
+ CDOStateLabelDecorator.fireLabelUpdates();
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusElementStylizerFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusElementStylizerFactory.java
new file mode 100644
index 00000000000..c9f492221a8
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusElementStylizerFactory.java
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.decorators;
+
+import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer;
+import org.eclipse.emf.cdo.dawn.appearance.IDawnElementStylizerFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPart;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
+
+/**
+ * This is the PapyrusElementStylizerFactory type. Enjoy.
+ */
+public class PapyrusElementStylizerFactory
+ implements IDawnElementStylizerFactory {
+
+ public PapyrusElementStylizerFactory() {
+ super();
+ }
+
+ public DawnElementStylizer getElementStylizer(Object object) {
+ DawnElementStylizer result = null;
+
+ if (isPapyrusEditPart(object)) {
+ if (object instanceof ConnectionEditPart) {
+ result = new PapyrusConnectionEditPartStylizer();
+ } else {
+ result = new PapyrusNodeEditPartStylizer();
+ }
+ } else if (object instanceof EObject) {
+ result = new PapyrusElementStylizer();
+ }
+
+ return result;
+ }
+
+ protected boolean isPapyrusEditPart(Object object) {
+ boolean result = object instanceof IPapyrusEditPart;
+
+ if (!result && (object instanceof EditPart)) {
+ EditPart editPart = ((EditPart) object).getRoot().getContents();
+ Object model = editPart.getModel();
+
+ if (model instanceof EObject) {
+ result = CDOUtils.getResourceSet((EObject) model) instanceof ModelSet;
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusNodeEditPartStylizer.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusNodeEditPartStylizer.java
new file mode 100644
index 00000000000..6781827061a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/decorators/PapyrusNodeEditPartStylizer.java
@@ -0,0 +1,23 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.decorators;
+
+/**
+ * This is the PapyrusNodeEditPartStylizer type. Enjoy.
+ */
+public class PapyrusNodeEditPartStylizer
+ extends PapyrusEditPartStylizer {
+
+ public PapyrusNodeEditPartStylizer() {
+ super();
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/dialogs/AddRepositoryDialog.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/dialogs/AddRepositoryDialog.java
new file mode 100644
index 00000000000..da439b96d92
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/dialogs/AddRepositoryDialog.java
@@ -0,0 +1,103 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.dialogs;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.papyrus.cdo.internal.ui.properties.RepositoryPropertiesBlock;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * This is the AddRepositoryDialog type. Enjoy.
+ */
+public class AddRepositoryDialog
+ extends TitleAreaDialog {
+
+ private static final String TITLE = "Add Repository";
+
+ private static final String MESSAGE = "Enter the repository name and location.";
+
+ private RepositoryPropertiesBlock block;
+
+ public AddRepositoryDialog(Shell parentShell) {
+ super(parentShell);
+ setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL | SWT.TITLE
+ | SWT.RESIZE);
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(TITLE);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ setTitle(TITLE);
+ setMessage(MESSAGE);
+
+ Composite result = (Composite) super.createDialogArea(parent);
+
+ block = new RepositoryPropertiesBlock();
+ block.createControl(result);
+
+ block
+ .addListener(new RepositoryPropertiesBlock.StatusChangedMessageProviderAdapter() {
+
+ @Override
+ protected void handleMessageChange(String message,
+ int messageSeverity) {
+
+ Button okButton = getButton(IDialogConstants.OK_ID);
+ okButton
+ .setEnabled(messageSeverity == IMessageProvider.NONE);
+
+ if (message == null) {
+ setMessage(MESSAGE);
+ } else {
+ setMessage(message, messageSeverity);
+ }
+ }
+ });
+
+ return result;
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Control result = super.createContents(parent);
+
+ block.update();
+
+ return result;
+ }
+
+ @Override
+ protected void okPressed() {
+ block.finish();
+
+ super.okPressed();
+ }
+
+ public String getName() {
+ return block.getName();
+ }
+
+ public String getURL() {
+ return block.getURL();
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/dialogs/RepositoryCredentialsDialog.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/dialogs/RepositoryCredentialsDialog.java
new file mode 100644
index 00000000000..ec8fc02a900
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/dialogs/RepositoryCredentialsDialog.java
@@ -0,0 +1,129 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.dialogs;
+
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.net4j.util.security.IPasswordCredentials;
+import org.eclipse.net4j.util.security.PasswordCredentials;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * This is the AddRepositoryDialog type. Enjoy.
+ */
+public class RepositoryCredentialsDialog
+ extends TitleAreaDialog {
+
+ private static final String TITLE = "Repository Login";
+
+ private static final String MESSAGE = "Enter your credentials for the repository \"{0}\".";
+
+ private final IPapyrusRepository repository;
+
+ private final String message;
+
+ private Text usernameText;
+
+ private Text passwordText;
+
+ private Button rememberCheckbox;
+
+ private IPasswordCredentials credentials;
+
+ public RepositoryCredentialsDialog(Shell parentShell,
+ IPapyrusRepository repository) {
+ super(parentShell);
+ setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL | SWT.TITLE);
+
+ this.repository = repository;
+ message = NLS.bind(MESSAGE, repository.getName());
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(TITLE);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ setTitle(TITLE);
+ setMessage(message);
+
+ Composite result = (Composite) super.createDialogArea(parent);
+
+ Composite main = new Composite(result, SWT.NONE);
+ main.setLayout(new GridLayout(2, false));
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
+
+ new Label(main, SWT.NONE).setText("User name:");
+ usernameText = new Text(main, SWT.BORDER);
+ GridDataFactory.fillDefaults().applyTo(usernameText);
+
+ new Label(main, SWT.NONE).setText("Password:");
+ passwordText = new Text(main, SWT.BORDER | SWT.PASSWORD);
+ GridDataFactory.fillDefaults().applyTo(passwordText);
+
+ rememberCheckbox = new Button(main, SWT.CHECK);
+ rememberCheckbox.setText("Remember login for this repository");
+ GridDataFactory.fillDefaults().span(2, 1).applyTo(rememberCheckbox);
+
+ if (repository.getUsername() != null) {
+ usernameText.setText(repository.getUsername());
+ }
+
+ if (repository.getPassword() != null) {
+ passwordText.setText(repository.getPassword());
+ }
+
+ return result;
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Control result = super.createContents(parent);
+
+ // the shell is bigger than it needs to be, by default (in English)
+ getShell().pack();
+
+ return result;
+ }
+
+ @Override
+ protected void okPressed() {
+ String username = usernameText.getText().trim();
+ String password = passwordText.getText().trim();
+ credentials = new PasswordCredentials(username, password.toCharArray());
+
+ if (rememberCheckbox.getSelection()) {
+ repository.setUsername(username);
+ repository.setPassword(password);
+ PapyrusRepositoryManager.INSTANCE.saveRepositories();
+ }
+
+ super.okPressed();
+ }
+
+ public IPasswordCredentials getCredentials() {
+ return credentials;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/DawnEditorAdapter.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/DawnEditorAdapter.java
new file mode 100644
index 00000000000..a2184f48480
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/DawnEditorAdapter.java
@@ -0,0 +1,232 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.editors;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditorSupport;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.PartInitException;
+
+import com.google.common.collect.Maps;
+
+/**
+ * This is the DawnEditorAdapter type. Enjoy.
+ */
+public class DawnEditorAdapter
+ implements IDawnEditor {
+
+ private static Map<IEditorPart, IDawnEditor> ADAPTERS = Maps.newHashMap();
+
+ private final DiagramDocumentEditor diagramEditor;
+
+ private IDawnEditorSupport editorSupport;
+
+ private CDOView view;
+
+ private String contributorID;
+
+ public DawnEditorAdapter(DiagramDocumentEditor diagramEditor) {
+ this.diagramEditor = diagramEditor;
+
+ ADAPTERS.put(diagramEditor, this);
+ }
+
+ DiagramDocumentEditor getDiagramEditor() {
+ return diagramEditor;
+ }
+
+ public static IDawnEditor getDawnEditor(IEditorPart editor) {
+ return ADAPTERS.get(editor);
+ }
+
+ static void removeAdapter(IEditorPart editor) {
+ ADAPTERS.remove(editor);
+ }
+
+ public CDOView getView() {
+ return view;
+ }
+
+ void setView(CDOView view) {
+ this.view = view;
+ }
+
+ public String getContributorID() {
+ if (contributorID == null) {
+ contributorID = determineEditorID(diagramEditor);
+ }
+
+ return contributorID;
+ }
+
+ public void setDirty() {
+ IDocumentProvider documentProvider = diagramEditor
+ .getDocumentProvider();
+ if (documentProvider != null) {
+ documentProvider.setCanSaveDocument(getEditorInput());
+ }
+ }
+
+ public Object getAdapter(@SuppressWarnings("rawtypes")
+ Class adapter) {
+ if ((adapter == DiagramDocumentEditor.class)
+ || (adapter == DiagramEditor.class)) {
+ return diagramEditor;
+ }
+
+ return diagramEditor.getAdapter(adapter);
+ }
+
+ private String determineEditorID(DiagramDocumentEditor editor) {
+ String result = null;
+
+ // look for the generated ID constant
+ for (Class<?> clazz = editor.getClass(); (clazz != null)
+ && (clazz != Object.class); clazz = clazz.getSuperclass()) {
+
+ try {
+ Field idField = clazz.getField("ID");
+ int modifiers = idField.getModifiers();
+ if ((idField.getType() == String.class)
+ && Modifier.isStatic(modifiers)
+ && Modifier.isFinal(modifiers)
+ && Modifier.isPublic(modifiers)) {
+
+ result = (String) idField.get(null);
+ }
+ } catch (Exception e) {
+ // it's OK. No such field, that's fine. Try the superclass
+ }
+ }
+
+ if (result == null) {
+ // this is the default ID pattern generated for Papyrus editors
+ result = editor.getClass().getName() + "ID";
+ }
+
+ return result;
+ }
+
+ public void doSave(IProgressMonitor monitor) {
+ CDOView view = getView();
+
+ // the Papyrus diagram editors don't save; the multi-editor does.
+ // But, we know that save is commit, so do that
+ if (view instanceof CDOTransaction) {
+ try {
+ ((CDOTransaction) view).commit(monitor);
+ } catch (CommitException e) {
+ Activator.log.error(
+ "Failed to commit transaction to save editor.", e);
+ }
+ } else {
+ diagramEditor.doSave(monitor);
+ }
+ }
+
+ //
+ // Delegation methods
+ //
+
+ public boolean isDirty() {
+ return diagramEditor.isDirty();
+ }
+
+ public IDawnEditorSupport getDawnEditorSupport() {
+ return editorSupport;
+ }
+
+ void setEditorSupport(IDawnEditorSupport editorSupport) {
+ this.editorSupport = editorSupport;
+ }
+
+ public IEditorInput getEditorInput() {
+ return diagramEditor.getEditorInput();
+ }
+
+ public IEditorSite getEditorSite() {
+ return diagramEditor.getEditorSite();
+ }
+
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
+
+ diagramEditor.init(site, input);
+ }
+
+ public void addPropertyListener(IPropertyListener listener) {
+ diagramEditor.addPropertyListener(listener);
+ }
+
+ public void createPartControl(Composite parent) {
+ diagramEditor.createPartControl(parent);
+ }
+
+ public void dispose() {
+ diagramEditor.dispose();
+ }
+
+ public IWorkbenchPartSite getSite() {
+ return diagramEditor.getSite();
+ }
+
+ public String getTitle() {
+ return diagramEditor.getTitle();
+ }
+
+ public Image getTitleImage() {
+ return diagramEditor.getTitleImage();
+ }
+
+ public String getTitleToolTip() {
+ return diagramEditor.getTitleToolTip();
+ }
+
+ public void removePropertyListener(IPropertyListener listener) {
+ diagramEditor.removePropertyListener(listener);
+ }
+
+ public void setFocus() {
+ diagramEditor.setFocus();
+ }
+
+ public void doSaveAs() {
+ diagramEditor.doSaveAs();
+ }
+
+ public boolean isSaveAsAllowed() {
+ return diagramEditor.isSaveAsAllowed();
+ }
+
+ public boolean isSaveOnCloseNeeded() {
+ return diagramEditor.isSaveOnCloseNeeded();
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/DawnGraphicalEditorSupport.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/DawnGraphicalEditorSupport.java
new file mode 100644
index 00000000000..094e46c2855
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/DawnGraphicalEditorSupport.java
@@ -0,0 +1,168 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.editors;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.dawn.gmf.editors.impl.DawnGMFEditorSupport;
+import org.eclipse.emf.cdo.dawn.gmf.synchronize.DawnConflictHelper;
+import org.eclipse.emf.cdo.dawn.gmf.util.DawnDiagramUpdater;
+import org.eclipse.emf.cdo.dawn.spi.DawnState;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.ui.parts.GraphicalEditor;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.cdo.core.resource.CDOAwareModelSet;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.internal.ui.decorators.CDOStateAdapter;
+import org.eclipse.papyrus.cdo.internal.ui.util.UIUtil;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.gmfdiag.common.DefaultGraphicalEditorSupport;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IConflictingEditPartFilter;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusDiagramEditPart;
+
+import com.google.common.collect.Maps;
+
+/**
+ * This is the DawnGraphicalEditorSupport type. Enjoy.
+ */
+public class DawnGraphicalEditorSupport
+ extends DefaultGraphicalEditorSupport {
+
+ private final ServicesRegistry registry;
+
+ public DawnGraphicalEditorSupport(ServicesRegistry registry) {
+ super();
+
+ this.registry = registry;
+ }
+
+ public void initialize(GraphicalEditor editor) {
+ if (editor instanceof DiagramDocumentEditor) {
+ CDOView view = getCDOView();
+ if (view != null) {
+ DiagramDocumentEditor diagramEditor = (DiagramDocumentEditor) editor;
+
+ initialize(diagramEditor, view);
+ }
+ }
+
+ super.initialize(editor);
+ }
+
+ protected void initialize(final DiagramDocumentEditor diagramEditor,
+ CDOView view) {
+ DawnEditorAdapter adapter = new DawnEditorAdapter(diagramEditor);
+ final DawnGMFEditorSupport dawnSupport = new PapyrusGMFEditorSupport(
+ adapter);
+
+ adapter.setEditorSupport(dawnSupport);
+ adapter.setView(getCDOView());
+ dawnSupport.setView(adapter.getView());
+
+ // after the root edit part has been created, inject a conflicting edit
+ // part filter
+ UIUtil.later(new Runnable() {
+
+ public void run() {
+ DiagramEditPart diagramEP = diagramEditor.getDiagramEditPart();
+ if (diagramEP instanceof PapyrusDiagramEditPart) {
+ ((PapyrusDiagramEditPart) diagramEP)
+ .setConflictingEditPartFilter(createConflictingEditPartFilter());
+ }
+ }
+ });
+
+ dawnSupport.registerListeners();
+
+ // find and process objects locked remotely
+ final Map<Object, DawnState> remoteLocks = getRemoteLocks(diagramEditor);
+ if (!remoteLocks.isEmpty()) {
+ // post for later because the editor isn't yet connected to its
+ // editor site in the workbench
+ UIUtil.later(new Runnable() {
+
+ public void run() {
+ dawnSupport.handleRemoteLockChanges(remoteLocks);
+
+ for (Object next : remoteLocks.keySet()) {
+ final EObject element = CDOUtil
+ .getEObject((CDOObject) next);
+ View view = DawnDiagramUpdater
+ .findViewByContainer(element);
+
+ CDOStateAdapter.setState(view, remoteLocks.get(next));
+ }
+ }
+ });
+ }
+ }
+
+ CDOView getCDOView() {
+ CDOView result = null;
+
+ try {
+ ModelSet modelSet = registry.getService(ModelSet.class);
+ if (modelSet instanceof CDOAwareModelSet) {
+ result = ((CDOAwareModelSet) modelSet).getCDOView();
+ }
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ }
+
+ return result;
+ }
+
+ private Map<Object, DawnState> getRemoteLocks(
+ DiagramDocumentEditor diagramEditor) {
+
+ Map<Object, DawnState> result = Maps.newHashMap();
+
+ Diagram diagram = diagramEditor.getDiagram();
+ if (diagram != null) {
+ Iterator<EObject> iter = EcoreUtil.getAllProperContents(
+ Collections.singleton(diagram), false);
+
+ while (iter.hasNext()) {
+ CDOObject next = CDOUtils.getCDOObject(iter.next());
+ if ((next != null) && CDOUtils.isLocked(next, true)) {
+ result.put(next, DawnState.LOCKED_REMOTELY);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private IConflictingEditPartFilter createConflictingEditPartFilter() {
+ return new IConflictingEditPartFilter() {
+
+ public boolean isConflicting(EditPart editPart) {
+ Object model = editPart.getModel();
+ return (model instanceof EObject)
+ && DawnConflictHelper.isConflicted((EObject) model);
+ }
+ };
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/DawnGraphicalEditorSupportServiceFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/DawnGraphicalEditorSupportServiceFactory.java
new file mode 100644
index 00000000000..929410149a8
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/DawnGraphicalEditorSupportServiceFactory.java
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.editors;
+
+import org.eclipse.papyrus.infra.core.services.IServiceFactory;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+
+
+/**
+ * This is the DawnGraphicalEditorSupportServiceFactory type. Enjoy.
+ */
+public class DawnGraphicalEditorSupportServiceFactory
+ implements IServiceFactory {
+
+ private ServicesRegistry registry;
+
+ private DawnGraphicalEditorSupport service;
+
+ public DawnGraphicalEditorSupportServiceFactory() {
+ super();
+ }
+
+ public void init(ServicesRegistry servicesRegistry)
+ throws ServiceException {
+
+ this.registry = servicesRegistry;
+ }
+
+ public void startService()
+ throws ServiceException {
+
+ // pass
+ }
+
+ public void disposeService()
+ throws ServiceException {
+
+ if (service == null) {
+ // TODO clean up?
+ }
+ }
+
+ public Object createServiceInstance()
+ throws ServiceException {
+
+ service = new DawnGraphicalEditorSupport(registry);
+ return service;
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusCDOEditorInput.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusCDOEditorInput.java
new file mode 100644
index 00000000000..02a7bb58d91
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusCDOEditorInput.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.editors;
+
+import org.eclipse.emf.common.ui.URIEditorInput;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.ui.IPersistableElement;
+
+/**
+ * This is the PapyrusCDOEditorInput type. Enjoy.
+ */
+public class PapyrusCDOEditorInput
+ extends URIEditorInput {
+
+ public PapyrusCDOEditorInput(URI uri) {
+ super(uri);
+ }
+
+ public PapyrusCDOEditorInput(URI uri, String name) {
+ super(uri, name);
+ }
+
+ /**
+ * Editors on CDO resources cannot be re-opened without re-connecting the
+ * repository, so return {@code null}.
+ */
+ @Override
+ public IPersistableElement getPersistable() {
+ return null;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusCDOEditorManager.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusCDOEditorManager.java
new file mode 100644
index 00000000000..fa89e816b7b
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusCDOEditorManager.java
@@ -0,0 +1,249 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.editors;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.core.IResourceSetDisposalApprover;
+import org.eclipse.papyrus.cdo.internal.core.IInternalPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.internal.ui.util.UIUtil;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+/**
+ * This is the PapyrusCDOEditorManager type. Enjoy.
+ */
+public class PapyrusCDOEditorManager {
+
+ public static final PapyrusCDOEditorManager INSTANCE = new PapyrusCDOEditorManager();
+
+ private BiMap<IEditorPart, CDOView> editors = HashBiMap.create();
+
+ private Cache<IWorkbenchPage, EditorListener> editorListeners = CacheBuilder
+ .newBuilder().weakKeys()
+ .build(new CacheLoader<IWorkbenchPage, EditorListener>() {
+
+ @Override
+ public EditorListener load(IWorkbenchPage key) {
+ EditorListener result = new EditorListener();
+ key.addPartListener(result);
+ return result;
+ }
+ });
+
+ private IResourceSetDisposalApprover disposalApprover;
+
+ private PapyrusCDOEditorManager() {
+ super();
+ }
+
+ public IEditorPart openEditor(IWorkbenchPage page, URI uri, String name)
+ throws PartInitException {
+
+ IInternalPapyrusRepository repository = getRepository(uri);
+ repository.addResourceSetDisposalApprover(getDisposalApprover());
+
+ IEditorPart result = page.openEditor(new PapyrusCDOEditorInput(uri,
+ name), "org.eclipse.papyrus.infra.core.papyrusEditor");
+
+ EditingDomain domain = (EditingDomain) result
+ .getAdapter(EditingDomain.class);
+ ResourceSet resourceSet = domain.getResourceSet();
+
+ CDOView view = repository.getCDOView(resourceSet);
+ add(view, result);
+
+ if (view instanceof CDOTransaction) {
+ view.addListener(new PapyrusTransactionListener());
+ }
+
+ return result;
+ }
+
+ private IResourceSetDisposalApprover getDisposalApprover() {
+ if (disposalApprover == null) {
+ disposalApprover = new ResourceSetDisposalApprover();
+ }
+
+ return disposalApprover;
+ }
+
+ IInternalPapyrusRepository getRepository(URI uri) {
+ return (IInternalPapyrusRepository) PapyrusRepositoryManager.INSTANCE
+ .getRepositoryForURI(uri);
+ }
+
+ void add(CDOView view, IEditorPart editor) {
+ editors.put(editor, view);
+
+ view.addListener(new CDOViewListener(editor));
+ try {
+ editorListeners.get(editor.getSite().getPage()).addEditor(editor);
+ } catch (Exception e) {
+ // this should be impossible with our cache loader
+ Activator.log.error(e);
+ }
+ }
+
+ void closed(IEditorPart editor) {
+ editors.remove(editor);
+ DawnEditorAdapter.removeAdapter(editor);
+ }
+
+ //
+ // Nested types
+ //
+
+ private class CDOViewListener
+ extends LifecycleEventAdapter {
+
+ private final IEditorPart editor;
+
+ CDOViewListener(IEditorPart editor) {
+ this.editor = editor;
+ }
+
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle) {
+ UIUtil.later(new Runnable() {
+
+ public void run() {
+ if (editors.containsKey(editor)) {
+ editor.getSite().getPage().closeEditor(editor, false);
+ }
+ }
+ });
+
+ lifecycle.removeListener(this);
+ }
+ }
+
+ private class EditorListener
+ implements IPartListener {
+
+ private Set<IEditorPart> editors = Sets.newHashSet();
+
+ void addEditor(IEditorPart editor) {
+ editors.add(editor);
+ }
+
+ public void partClosed(IWorkbenchPart part) {
+ if (editors.remove(part)) {
+ IEditorPart editor = (IEditorPart) part;
+ closed(editor);
+ }
+ }
+
+ public void partActivated(IWorkbenchPart part) {
+ // pass
+ }
+
+ public void partBroughtToTop(IWorkbenchPart part) {
+ // pass
+ }
+
+ public void partDeactivated(IWorkbenchPart part) {
+ // pass
+ }
+
+ public void partOpened(IWorkbenchPart part) {
+ // pass
+ }
+ }
+
+ private class ResourceSetDisposalApprover
+ implements IResourceSetDisposalApprover {
+
+ public DisposeAction disposalRequested(IPapyrusRepository repository,
+ Collection<ResourceSet> resourceSets) {
+
+ DisposeAction result = DisposeAction.CLOSE;
+ IInternalPapyrusRepository internal = (IInternalPapyrusRepository) repository;
+ final List<IEditorPart> dirty = Lists.newArrayList();
+
+ for (ResourceSet next : resourceSets) {
+ CDOView view = internal.getCDOView(next);
+ IEditorPart editor = editors.inverse().get(view);
+
+ if ((editor != null) && editor.isDirty()) {
+ dirty.add(editor);
+ }
+ }
+
+ if (!dirty.isEmpty()) {
+ Future<Integer> dlgResult = UIUtil
+ .call(new Callable<Integer>() {
+
+ public Integer call() {
+ MessageDialog dlg = new MessageDialog(
+ dirty.get(0).getSite().getShell(),
+ "Unsaved Model Editors",
+ null,
+ "There are unsaved model editors using this repository. Save them first?",
+ MessageDialog.QUESTION_WITH_CANCEL, //
+ new String[]{"Yes", "No", "Cancel"}, 2);
+
+ return dlg.open();
+ }
+ });
+
+ try {
+ switch (dlgResult.get()) {
+ case 0 : // Yes
+ result = DisposeAction.SAVE;
+ break;
+ case 1 : // No
+ result = DisposeAction.CLOSE;
+ break;
+ case 2 : // Cancel
+ result = DisposeAction.NONE;
+ break;
+ default :
+ break;
+ }
+ } catch (Exception e) {
+ // shouldn't happen because the UIUtil doesn't support
+ // interruption as it runs stuff on the UI thread
+ Activator.log.error(e);
+ }
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFEditorSupport.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFEditorSupport.java
new file mode 100644
index 00000000000..ff46dfd5fbc
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFEditorSupport.java
@@ -0,0 +1,283 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.editors;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer;
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
+import org.eclipse.emf.cdo.dawn.gmf.editors.impl.DawnGMFEditorSupport;
+import org.eclipse.emf.cdo.dawn.gmf.notifications.impl.DawnGMFHandler;
+import org.eclipse.emf.cdo.dawn.gmf.util.DawnDiagramUpdater;
+import org.eclipse.emf.cdo.dawn.notifications.BasicDawnListener;
+import org.eclipse.emf.cdo.dawn.spi.DawnState;
+import org.eclipse.emf.cdo.dawn.ui.stylizer.DawnElementStylizerRegistry;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+import org.eclipse.papyrus.cdo.internal.ui.util.UIUtil;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
+
+/**
+ * This is the PapyrusGMFEditorSupport type. Enjoy.
+ */
+public class PapyrusGMFEditorSupport
+ extends DawnGMFEditorSupport {
+
+ private static final Predicate<EStructuralFeature.Setting> IS_VIEW_REFERENCE = new Predicate<EStructuralFeature.Setting>() {
+
+ public boolean apply(EStructuralFeature.Setting input) {
+ return input.getEStructuralFeature() == NotationPackage.Literals.VIEW__ELEMENT;
+ }
+ };
+
+ private static final Function<EStructuralFeature.Setting, View> OWNER_VIEW = new Function<EStructuralFeature.Setting, View>() {
+
+ public View apply(EStructuralFeature.Setting input) {
+ return (View) input.getEObject();
+ }
+ };
+
+ /**
+ * @param editor
+ */
+ public PapyrusGMFEditorSupport(IDawnEditor editor) {
+ super(editor);
+ }
+
+ @Override
+ protected DawnGMFHandler createDawnGMFHandler(IDawnEditor editor) {
+ return new PapyrusGMFHandler(editor);
+ }
+
+ @Override
+ protected BasicDawnListener getLockingHandler() {
+ return new PapyrusGMFLockingHandler(getEditor());
+ }
+
+ @Override
+ public void lockObject(Object objectToBeLocked) {
+ if (objectToBeLocked instanceof EditPart) {
+ super.lockObject(objectToBeLocked);
+
+ // the super implementation locked the semantic element, so update
+ // its presentation
+ CDOObject cdo = CDOUtils
+ .getCDOObject(getSemanticElement((EditPart) objectToBeLocked));
+ if (cdo != null) {
+ updateAppearance(cdo);
+ }
+ } else {
+ EObject element = EMFHelper.getEObject(objectToBeLocked);
+ CDOObject cdo = (element == null)
+ ? null
+ : CDOUtils.getCDOObject(element);
+
+ if (element != null) {
+ CDOUtils.lock(cdo);
+
+ updateAppearance(cdo);
+
+ // and update any views in my diagram
+ for (View next : getViewsOfElement(element)) {
+ cdo = CDOUtils.getCDOObject(next);
+ if (cdo != null) {
+ CDOUtils.lock(cdo);
+ updateAppearance(cdo);
+ }
+ }
+
+ refresh();
+ }
+ }
+ }
+
+ private void updateAppearance(CDOObject cdoObject) {
+ EObject element = CDOUtil.getEObject(cdoObject);
+ DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance
+ .getStylizer(element);
+
+ if (stylizer != null) {
+ if (cdoObject.cdoConflict()) {
+ stylizer.setConflicted(element,
+ DawnAppearancer.TYPE_CONFLICT_REMOTELY_AND_LOCALLY_CHANGED);
+ } else if (CDOUtils.isLocked(cdoObject, true)) {
+ stylizer.setLocked(element,
+ DawnAppearancer.TYPE_LOCKED_GLOBALLY);
+ } else if (CDOUtils.isLocked(cdoObject, false)) {
+ stylizer
+ .setLocked(element, DawnAppearancer.TYPE_LOCKED_LOCALLY);
+ } else {
+ stylizer.setDefault(element);
+ }
+ }
+ }
+
+ @Override
+ public void unlockObject(Object objectToBeUnlocked) {
+ if (objectToBeUnlocked instanceof EditPart) {
+ super.unlockObject(objectToBeUnlocked);
+
+ // the super implementation unlocked the semantic element, so update
+ // its presentation
+ CDOObject cdo = CDOUtils
+ .getCDOObject(getSemanticElement((EditPart) objectToBeUnlocked));
+ if (cdo != null) {
+ updateAppearance(cdo);
+ }
+ } else {
+ EObject element = EMFHelper.getEObject(objectToBeUnlocked);
+ CDOObject cdo = (element == null)
+ ? null
+ : CDOUtils.getCDOObject(element);
+
+ if (element != null) {
+ CDOUtils.unlock(cdo);
+
+ updateAppearance(cdo);
+
+ // and update any views in my diagram
+ for (View next : getViewsOfElement(element)) {
+ cdo = CDOUtils.getCDOObject(next);
+ if (cdo != null) {
+ CDOUtils.unlock(cdo);
+ updateAppearance(cdo);
+ }
+ }
+
+ refresh();
+ }
+ }
+ }
+
+ @Override
+ public void handleRemoteLockChanges(Map<Object, DawnState> changedObjects) {
+ if (UIUtil.ensureUIThread(this, changedObjects)) {
+ // filter the event to cover only the objects that are views in or
+ // have views in my diagram
+ Map<Object, DawnState> filtered = filter(changedObjects);
+ if (filtered != null) {
+ super.handleRemoteLockChanges(filtered);
+ }
+ }
+ }
+
+ protected Map<Object, DawnState> filter(
+ Map<Object, DawnState> changedObjects) {
+
+ Map<Object, DawnState> result = Maps.newHashMap(changedObjects);
+
+ if (filter(result.keySet(), getDiagramEditor(getEditor()))) {
+ if (result.isEmpty()) {
+ result = null;
+ }
+ }
+
+ return result;
+ }
+
+ public static View findView(DiagramDocumentEditor diagramEditor,
+ EObject element) {
+
+ View result = null;
+
+ Diagram diagram = diagramEditor.getDiagram();
+ View view = DawnDiagramUpdater.findViewByContainer(element);
+
+ if (view != null) {
+ if (EcoreUtil.isAncestor(diagram, view)) {
+ result = view;
+ }
+ } else {
+ // find the view of the element that is in my diagram
+ for (View next : getViewsOfElement(element)) {
+ if (EcoreUtil.isAncestor(diagram, next)) {
+ result = next;
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public static Iterable<View> getViewsOfElement(EObject element) {
+ Iterable<View> result = Collections.emptyList();
+
+ ECrossReferenceAdapter xrefs = ECrossReferenceAdapter
+ .getCrossReferenceAdapter(element);
+ if (xrefs != null) {
+ Collection<EStructuralFeature.Setting> settings = xrefs
+ .getNonNavigableInverseReferences(element);
+ result = Iterables.transform(
+ Iterables.filter(settings, IS_VIEW_REFERENCE), OWNER_VIEW);
+ }
+
+ return result;
+
+ }
+
+ static boolean filter(Collection<?> objects,
+ DiagramDocumentEditor diagramEditor) {
+
+ boolean result = false;
+
+ for (Iterator<?> iter = objects.iterator(); iter.hasNext();) {
+ Object next = iter.next();
+
+ if (next instanceof CDOObject) {
+ EObject element = CDOUtil.getEObject((CDOObject) next);
+
+ // get the view of this element in the current diagram
+ View view = findView(diagramEditor, element);
+ if (view == null) {
+ iter.remove();
+ result = true;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public static EObject getSemanticElement(EditPart editPart) {
+ EObject result = null;
+
+ Object model = editPart.getModel();
+ if (model instanceof EObject) {
+ View view = DawnDiagramUpdater.findViewByContainer((EObject) model);
+ if (view != null) {
+ result = view.getElement();
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFHandler.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFHandler.java
new file mode 100644
index 00000000000..d1f5e00a9ab
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFHandler.java
@@ -0,0 +1,187 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.editors;
+
+import static org.eclipse.emf.cdo.dawn.gmf.editors.impl.DawnGMFEditorSupport.getDiagramEditor;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.gmf.notifications.impl.DawnGMFHandler;
+import org.eclipse.emf.cdo.dawn.gmf.util.DawnDiagramUpdater;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
+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.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.cdo.internal.ui.util.UIUtil;
+
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+/**
+ * This is the PapyrusGMFHandler type. Enjoy.
+ */
+public class PapyrusGMFHandler
+ extends DawnGMFHandler {
+
+ public PapyrusGMFHandler(IDawnEditor editor) {
+ super(editor);
+ }
+
+ @Override
+ public void handleViewInvalidationEvent(CDOViewInvalidationEvent event) {
+ if (UIUtil.ensureUIThread(this, event)) {
+ // filter the event to cover only the objects that are views in or
+ // have views in my diagram
+ CDOViewInvalidationEvent filtered = filter(event);
+ if (filtered != null) {
+ super.handleViewInvalidationEvent(filtered);
+ }
+ }
+ }
+
+ @Override
+ public void handleTransactionConflictEvent(CDOTransactionConflictEvent event) {
+ if (UIUtil.ensureUIThread(this, event)) {
+ // filter the event to cover only the objects that are views in or
+ // have views in my diagram
+ CDOTransactionConflictEvent filtered = filter(event);
+ if (filtered != null) {
+ super.handleTransactionConflictEvent(filtered);
+ }
+ }
+ }
+
+ protected CDOViewInvalidationEvent filter(
+ final CDOViewInvalidationEvent event) {
+
+ CDOViewInvalidationEvent result = event;
+
+ boolean filtered = false;
+
+ final Set<CDOObject> dirty = Sets.newHashSet(event.getDirtyObjects());
+ final Set<CDOObject> detached = Sets.newHashSet(event
+ .getDetachedObjects());
+ final Map<CDOObject, CDORevisionDelta> deltas = Maps.newHashMap(event
+ .getRevisionDeltas());
+
+ filtered = filter(dirty) || filtered;
+ filtered = filter(detached) || filtered;
+ filtered = filter(deltas.keySet()) || filtered;
+
+ if (filtered) {
+ if (dirty.isEmpty() && detached.isEmpty() && deltas.isEmpty()) {
+ result = null;
+ } else {
+ result = new CDOViewInvalidationEvent() {
+
+ public CDOView getSource() {
+ return event.getSource();
+ }
+
+ public long getTimeStamp() {
+ return event.getTimeStamp();
+ }
+
+ public Map<CDOObject, CDORevisionDelta> getRevisionDeltas() {
+ return deltas;
+ }
+
+ public Set<CDOObject> getDirtyObjects() {
+ return dirty;
+ }
+
+ public Set<CDOObject> getDetachedObjects() {
+ return detached;
+ }
+ };
+ }
+ }
+
+ return result;
+ }
+
+ protected boolean filter(Collection<?> objects) {
+ return PapyrusGMFEditorSupport
+ .filter(objects, getDiagramEditor(editor));
+ }
+
+ protected CDOTransactionConflictEvent filter(
+ CDOTransactionConflictEvent event) {
+
+ CDOObject cdoObject = event.getConflictingObject();
+ EObject element = CDOUtil.getEObject(cdoObject);
+ DiagramDocumentEditor diagramEditor = getDiagramEditor(editor);
+
+ // get the view of this element in the current diagram
+ View view = PapyrusGMFEditorSupport.findView(diagramEditor, element);
+
+ return (view == null)
+ ? null
+ : event;
+ }
+
+ @Override
+ public void modifyingObject(CDOTransaction transaction,
+ final CDOObject object, CDOFeatureDelta featureDelta) {
+
+ if (object instanceof Resource) {
+ // GMF doesn't need to refresh a resource
+ return;
+ }
+
+ refresh(object);
+ editor.setDirty();
+ object.eAdapters().add(new Adapter() {
+
+ public void notifyChanged(Notification notification) {
+ // removal of adapters doesn't require refresh, especially if
+ // the adapter that is removed is the CDO legacy adapter! (which
+ // then results in issues)
+ if (notification.getEventType() != Notification.REMOVING_ADAPTER) {
+ if (UIUtil.ensureUIThread(this, notification)) {
+ DiagramDocumentEditor diagramEditor = getDiagramEditor(editor);
+ DawnDiagramUpdater.refreshEditPart(
+ diagramEditor.getDiagramEditPart(), diagramEditor);
+ object.eAdapters().remove(this);
+ }
+ }
+ }
+
+ public boolean isAdapterForType(Object type) {
+ return false;
+ }
+
+ public void setTarget(Notifier newTarget) {
+ // pass
+ }
+
+ public Notifier getTarget() {
+ return null;
+ }
+ });
+
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFLockingHandler.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFLockingHandler.java
new file mode 100644
index 00000000000..6c58788142e
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFLockingHandler.java
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.editors;
+
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.gmf.notifications.impl.DawnGMFLockingHandler;
+import org.eclipse.emf.cdo.view.CDOViewLocksChangedEvent;
+import org.eclipse.papyrus.cdo.internal.ui.util.UIUtil;
+
+/**
+ * This is the PapyrusGMFLockingHandler type. Enjoy.
+ */
+public class PapyrusGMFLockingHandler
+ extends DawnGMFLockingHandler {
+
+ public PapyrusGMFLockingHandler(IDawnEditor editor) {
+ super(editor);
+ }
+
+ @Override
+ public void handleLocksChangedEvent(CDOViewLocksChangedEvent event) {
+ if (UIUtil.ensureUIThread(this, event)) {
+ super.handleLocksChangedEvent(event);
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusTransactionListener.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusTransactionListener.java
new file mode 100644
index 00000000000..f82255faa0a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusTransactionListener.java
@@ -0,0 +1,176 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.editors;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
+import org.eclipse.emf.cdo.dawn.gmf.util.DawnDiagramUpdater;
+import org.eclipse.emf.cdo.dawn.spi.DawnState;
+import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent;
+import org.eclipse.emf.cdo.transaction.CDOTransactionFinishedEvent;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
+import org.eclipse.emf.cdo.view.CDOViewLocksChangedEvent;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+import org.eclipse.papyrus.cdo.internal.ui.decorators.CDOStateAdapter;
+import org.eclipse.papyrus.cdo.internal.ui.decorators.CDOStateLabelDecorator;
+import org.eclipse.papyrus.cdo.internal.ui.util.UIUtil;
+
+import com.google.common.collect.Maps;
+
+/**
+ * This is the PapyrusTransactionListener type. Enjoy.
+ */
+public class PapyrusTransactionListener
+ implements IListener {
+
+ public PapyrusTransactionListener() {
+ super();
+ }
+
+ public void notifyEvent(IEvent event) {
+ if (event instanceof CDOViewInvalidationEvent) {
+ handleViewInvalidationEvent((CDOViewInvalidationEvent) event);
+ } else if (event instanceof CDOTransactionConflictEvent) {
+ handleTransactionConflictEvent((CDOTransactionConflictEvent) event);
+ } else if (event instanceof CDOViewLocksChangedEvent) {
+ handleLocksChangedEvent((CDOViewLocksChangedEvent) event);
+ } else if (event instanceof CDOTransactionFinishedEvent) {
+ handleTransactionFinishedEvent((CDOTransactionFinishedEvent) event);
+ } else {
+ handleEvent(event);
+ }
+ }
+
+ protected void handleTransactionConflictEvent(
+ CDOTransactionConflictEvent event) {
+
+ if (UIUtil.ensureUIThread(this, event)) {
+ CDOObject cdoObject = event.getConflictingObject();
+ EObject element = CDOUtil.getEObject(cdoObject);
+ View view = DawnDiagramUpdater.findViewByContainer(element);
+
+ if (view == null) {
+ // it's not actually a view that is conflicted, but a model
+ // element
+ if (cdoObject.cdoConflict()) {
+ CDOStateAdapter.setState(element, DawnState.CONFLICT);
+
+ CDOStateLabelDecorator.fireLabelUpdates();
+ }
+ }
+ }
+ }
+
+ protected void handleLocksChangedEvent(CDOViewLocksChangedEvent event) {
+ if (UIUtil.ensureUIThread(this, event)) {
+ Map<EObject, DawnState> changedObjects = new HashMap<EObject, DawnState>();
+ CDOView cdoView = event.getSource();
+
+ for (CDOLockState state : event.getLockStates()) {
+ Object lockedObject = state.getLockedObject();
+
+ CDOID id;
+ if (lockedObject instanceof CDOID) {
+ id = (CDOID) lockedObject;
+ } else if (lockedObject instanceof CDOIDAndBranch) {
+ id = ((CDOIDAndBranch) lockedObject).getID();
+ } else {
+ throw new RuntimeException("Unexpected object type: "
+ + lockedObject);
+ }
+
+ if (id != null) {
+ CDOObject object = cdoView.getObject(id);
+ EObject element = CDOUtil.getEObject(object);
+
+ View view = DawnDiagramUpdater.findViewByContainer(element);
+
+ if (view == null) {
+ // it's not actually a view that is locked, but a model
+ // element
+
+ if (CDOUtils.isLocked(object, false)) {
+ throw new IllegalStateException(
+ "Locally locked objects should not occur.");
+ } else if (CDOUtils.isLocked(object, true)) {
+ changedObjects.put(element,
+ DawnState.LOCKED_REMOTELY);
+ } else {
+ changedObjects.put(element, DawnState.CLEAN);
+ }
+ }
+ }
+ }
+
+ handleLocks(changedObjects);
+ }
+ }
+
+ /**
+ * @precondition The current thread is the UI thread
+ */
+ void handleLocks(Map<EObject, DawnState> changedObjects) {
+ if (!changedObjects.isEmpty()) {
+ for (Map.Entry<EObject, DawnState> next : changedObjects.entrySet()) {
+
+ EObject element = next.getKey();
+ DawnState state = next.getValue();
+
+ CDOStateAdapter.setState(element, state);
+ }
+
+ CDOStateLabelDecorator.fireLabelUpdates();
+ }
+ }
+
+ protected void handleViewInvalidationEvent(CDOViewInvalidationEvent event) {
+ // pass
+ }
+
+ protected void handleTransactionFinishedEvent(
+ CDOTransactionFinishedEvent event) {
+
+ // review all conflicts and locks
+ Map<EObject, DawnState> stateUpdates = Maps.newHashMap();
+
+ for (CDOStateAdapter next : CDOStateAdapter.getAll(event.getSource()
+ .getResourceSet())) {
+
+ Object target = next.getTarget();
+ if (target instanceof EObject) {
+ EObject object = (EObject) target;
+ stateUpdates.put(object, CDOUtils.computeState(object));
+ }
+ }
+
+ for (Map.Entry<EObject, DawnState> next : stateUpdates.entrySet()) {
+ CDOStateAdapter.setState(next.getKey(), next.getValue());
+ }
+
+ CDOStateLabelDecorator.fireLabelUpdates();
+ }
+
+ protected void handleEvent(IEvent event) {
+ // pass
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/expressions/CDOObjectPropertyTester.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/expressions/CDOObjectPropertyTester.java
new file mode 100644
index 00000000000..85aeab893ef
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/expressions/CDOObjectPropertyTester.java
@@ -0,0 +1,82 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.expressions;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.dawn.spi.DawnState;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+import org.eclipse.papyrus.cdo.internal.ui.decorators.CDOStateAdapter;
+
+/**
+ * This is the EObjectPropertyTester type. Enjoy.
+ */
+public class CDOObjectPropertyTester
+ extends PropertyTester {
+
+ public static final String CAN_LOCK = "canLock";
+
+ public static final String IS_LOCKED_LOCALLY = "isLockedLocally";
+
+ public static final String IS_LOCKED_REMOTELY = "isLockedRemotely";
+
+ public static final String IS_CONFLICTED = "isConflicted";
+
+ public CDOObjectPropertyTester() {
+ super();
+ }
+
+ public boolean test(Object receiver, String property, Object[] args,
+ Object expectedValue) {
+
+ boolean result = false;
+
+ CDOObject cdoObject = (CDOObject) receiver;
+ if (cdoObject != null) {
+ if (CAN_LOCK.equals(property)) {
+ result = canLock(cdoObject);
+ } else if (IS_LOCKED_LOCALLY.equals(property)) {
+ result = isLockedLocally(cdoObject);
+ } else if (IS_LOCKED_REMOTELY.equals(property)) {
+ result = isLockedRemotely(cdoObject);
+ } else if (IS_CONFLICTED.equals(property)) {
+ result = isConflicted(cdoObject);
+ }
+ }
+
+ return result;
+ }
+
+ private boolean canLock(CDOObject object) {
+ boolean result = CDOUtils.isLockable(object);
+
+ if (result) {
+ DawnState state = CDOStateAdapter.getState(object);
+ result = (state != DawnState.LOCKED_LOCALLY)
+ && (state != DawnState.LOCKED_REMOTELY);
+ }
+
+ return result;
+ }
+
+ private boolean isLockedLocally(CDOObject object) {
+ return CDOStateAdapter.getState(object) == DawnState.LOCKED_LOCALLY;
+ }
+
+ private boolean isLockedRemotely(CDOObject object) {
+ return CDOStateAdapter.getState(object) == DawnState.LOCKED_REMOTELY;
+ }
+
+ private boolean isConflicted(CDOObject object) {
+ return CDOStateAdapter.getState(object) == DawnState.CONFLICT;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/ImportModelsHandler.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/ImportModelsHandler.java
new file mode 100644
index 00000000000..dcd4c4db720
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/ImportModelsHandler.java
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.papyrus.cdo.internal.ui.wizards.ModelImportWizard;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * This is the ImportModelsHandler type. Enjoy.
+ */
+public class ImportModelsHandler
+ extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event)
+ throws ExecutionException {
+
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection instanceof IStructuredSelection) {
+ IWorkbenchWindow window = HandlerUtil
+ .getActiveWorkbenchWindow(event);
+
+ if (window != null) {
+ ModelImportWizard wizard = new ModelImportWizard();
+ wizard.init(window.getWorkbench(),
+ (IStructuredSelection) selection);
+
+ new WizardDialog(window.getShell(), wizard).open();
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/LockObjectsHandler.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/LockObjectsHandler.java
new file mode 100644
index 00000000000..dea0d426f67
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/LockObjectsHandler.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.handlers;
+
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+
+/**
+ * This is the LockObjectsHandler type. Enjoy.
+ */
+public class LockObjectsHandler
+ extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event)
+ throws ExecutionException {
+
+ List<Object> selected = UIHandlerUtil.getSelection(event);
+ Activator.getActiveDawnEditor().getDawnEditorSupport()
+ .lockObjects(selected);
+
+ return null;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/ResolveConflictsHandler.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/ResolveConflictsHandler.java
new file mode 100644
index 00000000000..dc32f736468
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/ResolveConflictsHandler.java
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * This is the ResolveConflictsHandler type. Enjoy.
+ */
+public class ResolveConflictsHandler
+ extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event)
+ throws ExecutionException {
+ IDawnEditor activeEditor = Activator.getActiveDawnEditor();
+
+ if (activeEditor != null) {
+ // TODO: Implement real conflict resolution
+
+ if (MessageDialog
+ .openQuestion(HandlerUtil.getActiveShellChecked(event),
+ "Resolve Conflicts",
+ "Are you sure you want to roll back all pending changes to resolve conflicts?")) {
+ activeEditor.getDawnEditorSupport().rollback();
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/UIHandlerUtil.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/UIHandlerUtil.java
new file mode 100644
index 00000000000..728e0b6c0d5
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/UIHandlerUtil.java
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.handlers;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.cdo.dawn.spi.IDawnEditingSupport;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+
+/**
+ * This is the UIHandlerUtil type. Enjoy.
+ */
+public class UIHandlerUtil {
+
+ private UIHandlerUtil() {
+ super();
+ }
+
+ public static <T> Collection<T> getSelection(ExecutionEvent event,
+ Class<T> type)
+ throws ExecutionException {
+
+ ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
+ Collection<T> result = Collections.emptyList();
+
+ if (selection instanceof IStructuredSelection) {
+ Collection<?> selected = ((IStructuredSelection) selection)
+ .toList();
+ result = ImmutableList.copyOf(Iterables.filter(selected, type));
+ }
+
+ return result;
+ }
+
+ /**
+ * The return type is {@code List<Object>} because that is the type required
+ * by the Dawn {@link IDawnEditingSupport#lockObjects(java.util.List)} API.
+ */
+ public static List<Object> getSelection(ExecutionEvent event)
+ throws ExecutionException {
+
+ return (List<Object>) getSelection(event, Object.class);
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/UnlockObjectsHandler.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/UnlockObjectsHandler.java
new file mode 100644
index 00000000000..3945eabbda0
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/handlers/UnlockObjectsHandler.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.handlers;
+
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+
+/**
+ * This is the UnlockObjectsHandler type. Enjoy.
+ */
+public class UnlockObjectsHandler
+ extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event)
+ throws ExecutionException {
+
+ List<Object> selected = UIHandlerUtil.getSelection(event);
+ Activator.getActiveDawnEditor().getDawnEditorSupport()
+ .unlockObjects(selected);
+
+ return null;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/markers/CDOMarkerMonitor.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/markers/CDOMarkerMonitor.java
new file mode 100644
index 00000000000..a779269e3a8
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/markers/CDOMarkerMonitor.java
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.markers;
+
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.papyrus.cdo.validation.problems.edit.ProblemEditUtil;
+import org.eclipse.papyrus.cdo.validation.problems.util.ProblemsEvent;
+import org.eclipse.papyrus.cdo.validation.problems.util.ProblemsListener;
+import org.eclipse.papyrus.cdo.validation.problems.util.ProblemsManager;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.services.markerlistener.providers.AbstractMarkerMonitor;
+
+/**
+ * This is the CDOMarkerMonitor type. Enjoy.
+ */
+public class CDOMarkerMonitor
+ extends AbstractMarkerMonitor {
+
+ private ProblemEditUtil util;
+
+ private ProblemsListener problemsListener;
+
+ public CDOMarkerMonitor() {
+ super();
+ }
+
+ @Override
+ public void initialize(ModelSet modelSet) {
+ super.initialize(modelSet);
+
+ this.util = new ProblemEditUtil(
+ ((AdapterFactoryEditingDomain) modelSet
+ .getTransactionalEditingDomain()).getAdapterFactory());
+ this.problemsListener = createProblemsListener();
+ ProblemsManager.getProblemsManager(modelSet).addProblemsListener(
+ problemsListener);
+ }
+
+ @Override
+ public void dispose() {
+ if (problemsListener != null) {
+ ProblemsManager.getProblemsManager(getModelSet())
+ .removeProblemsListener(problemsListener);
+ problemsListener = null;
+ }
+
+ super.dispose();
+ }
+
+ protected ProblemsListener createProblemsListener() {
+ return new ProblemsListener() {
+
+ public void problemAdded(ProblemsEvent event) {
+ fireMarkerAdded(new CDOPapyrusMarker(event.getProblem(), util));
+ }
+
+ public void problemRemoved(ProblemsEvent event) {
+ fireMarkerRemoved(new CDOPapyrusMarker(event.getProblem(), util));
+ }
+
+ };
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/markers/CDOMarkerProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/markers/CDOMarkerProvider.java
new file mode 100644
index 00000000000..77448d0e7c2
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/markers/CDOMarkerProvider.java
@@ -0,0 +1,242 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.markers;
+
+import java.util.Collection;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.validation.problems.EProblem;
+import org.eclipse.papyrus.cdo.validation.problems.edit.ProblemEditUtil;
+import org.eclipse.papyrus.cdo.validation.problems.util.ProblemsManager;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+import org.eclipse.papyrus.infra.services.markerlistener.providers.AbstractMarkerProvider;
+
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
+
+/**
+ * This is the CDOMarkerProvider type. Enjoy.
+ */
+public class CDOMarkerProvider
+ extends AbstractMarkerProvider {
+
+ private final ProblemEditUtil defaultUtil = new ProblemEditUtil(
+ new ComposedAdapterFactory(
+ ComposedAdapterFactory.Descriptor.Registry.INSTANCE));
+
+ public CDOMarkerProvider() {
+ super();
+ }
+
+ public boolean canProvideMarkersFor(Resource resource) {
+ return resource instanceof CDOResource;
+ }
+
+ public Collection<? extends IPapyrusMarker> getMarkers(
+ final Resource resource, String type, boolean includeSubtypes)
+ throws CoreException {
+
+ // run in a read-only transaction because the problems manager accesses
+ // a cross-reference adapter
+ return run(
+ resource,
+ CoreException.class,
+ new RunnableWithResult.Impl<Collection<? extends IPapyrusMarker>>() {
+
+ public void run() {
+ setResult(Lists.newArrayList(Iterators.transform(
+ getProblemsManager(resource).getAllProblems(resource),
+ CDOPapyrusMarker.wrap(getProblemEditUtil(resource)))));
+ }
+ });
+ }
+
+ @Override
+ public void createMarkers(final Resource resource,
+ final Diagnostic diagnostic, final IProgressMonitor monitor)
+ throws CoreException {
+
+ // run in a read-only transaction because the problems manager accesses
+ // a cross-reference adapter. Note that a read/write transaction is not
+ // needed because we aren't modifying the contents of the resource set
+ // (the problems model is not stored in a resource)
+ run(resource, CoreException.class, new Runnable() {
+
+ public void run() {
+ try {
+ basicCreateMarkers(resource, diagnostic, monitor);
+ } catch (CoreException e) {
+ throw new WrappedException(e);
+ }
+ }
+ });
+ }
+
+ final void basicCreateMarkers(Resource resource, Diagnostic diagnostic,
+ IProgressMonitor monitor)
+ throws CoreException {
+
+ super.createMarkers(resource, diagnostic, monitor);
+ }
+
+ @Override
+ protected void doCreateMarker(Resource resource, Diagnostic diagnostic)
+ throws CoreException {
+
+ ProblemsManager mgr = getProblemsManager(resource);
+ EProblem problem = mgr.createProblem(diagnostic);
+ if (problem != null) {
+ mgr.addProblem(problem);
+ }
+ }
+
+ @Override
+ protected void batchCreated(Resource resource) {
+ super.batchCreated(resource);
+
+ ResourceSet rset = resource.getResourceSet();
+ if (rset instanceof ModelSet) {
+ // yield the resource set to any other threads that might
+ // be waiting to read it
+ ((ModelSet) rset).getTransactionalEditingDomain().yield();
+ }
+ }
+
+ @Override
+ public void deleteMarkers(final EObject object,
+ final IProgressMonitor monitor)
+ throws CoreException {
+
+ // run in a read-only transaction because the problems manager accesses
+ // a cross-reference adapter. Note that a read/write transaction is not
+ // needed because we aren't modifying the contents of the resource set
+ // (the problems model is not stored in a resource)
+ run(object.eResource(), CoreException.class, new Runnable() {
+
+ public void run() {
+ try {
+ basicDeleteMarkers(object, monitor);
+ } catch (CoreException e) {
+ throw new WrappedException(e);
+ }
+ }
+ });
+ }
+
+ protected final void basicDeleteMarkers(EObject object,
+ IProgressMonitor monitor)
+ throws CoreException {
+
+ super.deleteMarkers(object, monitor);
+ }
+
+ public void deleteMarkers(final Resource resource, IProgressMonitor monitor) {
+ SubMonitor sub = SubMonitor.convert(monitor, IProgressMonitor.UNKNOWN);
+
+ // run in a read-only transaction because the problems manager accesses
+ // a cross-reference adapter. Note that a read/write transaction is not
+ // needed because we aren't modifying the contents of the resource set
+ // (the problems model is not stored in a resource)
+ run(resource, new Runnable() {
+
+ public void run() {
+ getProblemsManager(resource).purgeProblems(resource);
+ }
+ });
+
+ sub.done();
+ }
+
+ private ProblemsManager getProblemsManager(Resource resource) {
+ return ProblemsManager.getProblemsManager(resource.getResourceSet());
+ }
+
+ private ProblemEditUtil getProblemEditUtil(Resource resource) {
+ ProblemEditUtil result = defaultUtil;
+
+ ResourceSet rset = resource.getResourceSet();
+ if (rset instanceof ModelSet) {
+ AdapterFactory factory = ((AdapterFactoryEditingDomain) ((ModelSet) rset)
+ .getTransactionalEditingDomain()).getAdapterFactory();
+ result = new ProblemEditUtil(factory);
+ }
+
+ return result;
+ }
+
+ static <X extends Throwable> void run(Resource context, Runnable runnable) {
+ run(context, RuntimeException.class, runnable);
+ }
+
+ static <X extends Throwable> void run(Resource context,
+ Class<X> exceptionType, Runnable runnable)
+ throws X {
+
+ ResourceSet rset = context.getResourceSet();
+ if (rset instanceof ModelSet) {
+ try {
+ ((ModelSet) rset).getTransactionalEditingDomain().runExclusive(
+ runnable);
+ } catch (WrappedException e) {
+ throw exceptionType.cast(e.exception());
+ } catch (InterruptedException e) {
+ Activator.log.error(
+ "CDO problem markers runnable interrupted.", e);
+ }
+ } else {
+ runnable.run();
+ }
+ }
+
+ static <T, X extends Throwable> T run(Resource context,
+ Class<X> exceptionType, RunnableWithResult<T> runnable)
+ throws X {
+
+ T result;
+
+ ResourceSet rset = context.getResourceSet();
+ if (rset instanceof ModelSet) {
+ try {
+ result = TransactionUtil
+ .runExclusive(
+ ((ModelSet) rset).getTransactionalEditingDomain(),
+ runnable);
+ } catch (WrappedException e) {
+ throw exceptionType.cast(e.exception());
+ } catch (InterruptedException e) {
+ Activator.log.error(
+ "CDO problem markers runnable interrupted.", e);
+ result = null;
+ }
+ } else {
+ runnable.run();
+ result = runnable.getResult();
+ }
+
+ return result;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/markers/CDOPapyrusMarker.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/markers/CDOPapyrusMarker.java
new file mode 100644
index 00000000000..e24dca5570e
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/markers/CDOPapyrusMarker.java
@@ -0,0 +1,275 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.markers;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EValidator;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.validation.problems.EProblem;
+import org.eclipse.papyrus.cdo.validation.problems.ESeverity;
+import org.eclipse.papyrus.cdo.validation.problems.edit.ProblemEditUtil;
+import org.eclipse.papyrus.cdo.validation.problems.util.ProblemsManager;
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.collect.Maps;
+
+/**
+ * This is the CDOPapyrusMarker type. Enjoy.
+ */
+public class CDOPapyrusMarker
+ implements IPapyrusMarker {
+
+ private final ProblemEditUtil util;
+
+ private final Resource resource;
+
+ private final EProblem problem;
+
+ CDOPapyrusMarker(EProblem problem, ProblemEditUtil util) {
+ super();
+
+ this.util = util;
+ this.resource = problem.getElement().eResource();
+ this.problem = problem;
+ }
+
+ public static Function<EProblem, CDOPapyrusMarker> wrap(
+ final ProblemEditUtil util) {
+
+ return new Function<EProblem, CDOPapyrusMarker>() {
+
+ public CDOPapyrusMarker apply(EProblem input) {
+ return new CDOPapyrusMarker(input, util);
+ }
+ };
+ }
+
+ public Resource getResource() {
+ return resource;
+ }
+
+ public EObject getEObject() {
+ return problem.getElement();
+ }
+
+ public boolean exists() {
+ EObject element = getEObject();
+ return (element != null) && (element.eResource() != null);
+ }
+
+ public String getType() {
+ return EValidator.MARKER;
+ }
+
+ public String getTypeLabel()
+ throws CoreException {
+
+ return util.getProblemType(problem);
+ }
+
+ public void delete() {
+ ProblemsManager.delete(problem);
+ }
+
+ public Object getAttribute(String name)
+ throws CoreException {
+
+ Object result = null;
+
+ if (name.equals(EValidator.URI_ATTRIBUTE)) {
+ result = EcoreUtil.getURI(getEObject()).toString();
+ } else if (name.equals(SEVERITY)) {
+ result = getMarkerSeverity();
+ } else if (name.equals(MESSAGE)) {
+ result = problem.getMessage();
+ } else {
+ throw new CoreException(error("No such marker attribute: " + name));
+ }
+
+ return result;
+ }
+
+ protected final IStatus error(String message) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, message);
+ }
+
+ protected int getMarkerSeverity() {
+ int result;
+
+ switch (problem.getSeverity()) {
+ case OK :
+ case INFO :
+ result = SEVERITY_INFO;
+ break;
+ case WARNING :
+ result = SEVERITY_WARNING;
+ break;
+ default :
+ result = SEVERITY_ERROR;
+ break;
+ }
+
+ return result;
+ }
+
+ public String getAttribute(String name, String defaultValue) {
+ String result = null;
+
+ if (name.equals(EValidator.URI_ATTRIBUTE)) {
+ result = EcoreUtil.getURI(getEObject()).toString();
+ } else if (name.equals(MESSAGE)) {
+ result = problem.getMessage();
+ } else {
+ result = defaultValue;
+ }
+
+ return (result != null)
+ ? result
+ : defaultValue;
+ }
+
+ public boolean getAttribute(String name, boolean defaultValue) {
+ // we don't have any boolean attributes, yet
+ return defaultValue;
+ }
+
+ public int getAttribute(String name, int defaultValue) {
+ int result;
+
+ if (name.equals(SEVERITY)) {
+ result = getMarkerSeverity();
+ } else {
+ result = defaultValue;
+ }
+
+ return result;
+ }
+
+ public Map<String, ?> getAttributes()
+ throws CoreException {
+
+ Map<String, Object> result = Maps.newHashMap();
+
+ result.put(EValidator.URI_ATTRIBUTE, EcoreUtil.getURI(getEObject())
+ .toString());
+ result.put(SEVERITY, getMarkerSeverity());
+ result.put(MESSAGE, problem.getMessage());
+
+ return result;
+
+ }
+
+ public void setAttribute(String name, Object value)
+ throws CoreException {
+
+ if (name.equals(EValidator.URI_ATTRIBUTE)) {
+ throw new CoreException(
+ error("Cannot set URI of a CDOPapyrusMarker."));
+ } else if (name.equals(SEVERITY)) {
+ setMarkerSeverity(((Number) value).intValue());
+ } else if (name.equals(MESSAGE)) {
+ problem.setMessage((String) value);
+ } else {
+ throw new CoreException(error("No such marker attribute: " + name));
+ }
+ }
+
+ protected void setMarkerSeverity(int severity)
+ throws CoreException {
+ switch (severity) {
+ case SEVERITY_INFO :
+ problem.setSeverity(ESeverity.INFO);
+ break;
+ case SEVERITY_WARNING :
+ problem.setSeverity(ESeverity.WARNING);
+ break;
+ case SEVERITY_ERROR :
+ problem.setSeverity(ESeverity.ERROR);
+ break;
+ default :
+ throw new CoreException(error("Invalid marker severity: "
+ + severity));
+ }
+ }
+
+ public void setAttribute(String name, String value)
+ throws CoreException {
+
+ if (name.equals(EValidator.URI_ATTRIBUTE)) {
+ throw new CoreException(
+ error("Cannot set URI of a CDOPapyrusMarker."));
+ } else if (name.equals(MESSAGE)) {
+ problem.setMessage(value);
+ } else {
+ throw new CoreException(error("No such marker attribute: " + name));
+ }
+ }
+
+ public void setAttribute(String name, boolean value)
+ throws CoreException {
+
+ throw new CoreException(error("No such marker attribute: " + name));
+ }
+
+ public void setAttribute(String name, int value)
+ throws CoreException {
+
+ if (name.equals(SEVERITY)) {
+ setMarkerSeverity(value);
+ } else {
+ throw new CoreException(error("No such marker attribute: " + name));
+ }
+ }
+
+ public void setAttributes(Map<String, ?> attributes)
+ throws CoreException {
+
+ for (Map.Entry<String, ?> next : attributes.entrySet()) {
+ String name = next.getKey();
+ Object value = next.getValue();
+
+ if (name.equals(EValidator.URI_ATTRIBUTE)) {
+ throw new CoreException(
+ error("Cannot set URI of a CDOPapyrusMarker."));
+ } else if (name.equals(SEVERITY)) {
+ setMarkerSeverity(((Number) value).intValue());
+ } else if (name.equals(MESSAGE)) {
+ problem.setMessage((String) value);
+ }
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return (obj instanceof CDOPapyrusMarker)
+ && Objects.equal(((CDOPapyrusMarker) obj).problem, problem);
+ }
+
+ @Override
+ public int hashCode() {
+ return (problem == null) ? 0 : problem.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return String.format("CDOPapyrusMarker:%s:%s", getResource(), hashCode());
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/properties/RepositoryPropertiesBlock.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/properties/RepositoryPropertiesBlock.java
new file mode 100644
index 00000000000..f2ecae4cf07
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/properties/RepositoryPropertiesBlock.java
@@ -0,0 +1,483 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.properties;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.cdo.util.CDOURIUtil;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.net4j.util.event.Event;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.event.Notifier;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import com.google.common.base.Objects;
+
+/**
+ * This is the RepositoryPropertiesBlock type. Enjoy.
+ */
+public class RepositoryPropertiesBlock
+ extends Notifier {
+
+ private Text nameText;
+
+ private ComboViewer protocolCombo;
+
+ private Button defaultPort;
+
+ private Text portText;
+
+ private Text hostText;
+
+ private Text repoText;
+
+ private String name;
+
+ private String url;
+
+ private IStatus status = Status.OK_STATUS;
+
+ private IPapyrusRepository repository;
+
+ private boolean createMode;
+
+ private boolean editable = true;
+
+ public RepositoryPropertiesBlock() {
+ this(null, true);
+ }
+
+ public RepositoryPropertiesBlock(IPapyrusRepository repository) {
+ this(repository, false);
+ }
+
+ private RepositoryPropertiesBlock(IPapyrusRepository repository,
+ boolean createMode) {
+ this.repository = repository;
+ this.createMode = createMode;
+ }
+
+ public Control createControl(Composite parent) {
+ Composite result = new Composite(parent, SWT.NONE);
+ result.setLayout(new GridLayout(2, false));
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(result);
+
+ new Label(result, SWT.NONE).setText("Name:");
+ nameText = new Text(result, SWT.BORDER);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText);
+
+ new Label(result, SWT.NONE).setText("Protocol:");
+ protocolCombo = new ComboViewer(result);
+ protocolCombo.setContentProvider(new ArrayContentProvider());
+ protocolCombo.setInput(Protocol.values());
+
+ defaultPort = new Button(result, SWT.CHECK);
+ defaultPort.setText("Use default port");
+ GridDataFactory.swtDefaults().span(2, 1).applyTo(defaultPort);
+
+ Label label = new Label(result, SWT.NONE);
+ label.setText("Port:");
+ GridDataFactory.swtDefaults().indent(15, 0).applyTo(label);
+ portText = new Text(result, SWT.BORDER);
+ GridDataFactory.fillDefaults().applyTo(portText);
+
+ new Label(result, SWT.NONE).setText("Host:");
+ hostText = new Text(result, SWT.BORDER);
+ GridDataFactory.fillDefaults().applyTo(hostText);
+
+ new Label(result, SWT.NONE).setText("Repository:");
+ repoText = new Text(result, SWT.BORDER);
+ GridDataFactory.fillDefaults().applyTo(repoText);
+
+ reset();
+
+ defaultPort.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ portText.setEnabled(!defaultPort.getSelection());
+ if (defaultPort.getSelection()) {
+ updatePortForProtocol();
+ recalculateURL();
+ }
+ }
+ });
+ protocolCombo
+ .addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ if (defaultPort.getSelection()) {
+ updatePortForProtocol();
+ recalculateURL();
+ }
+ }
+ });
+
+ ModifyListener modifyListener = new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ recalculateURL();
+ }
+ };
+ nameText.addModifyListener(modifyListener);
+ portText.addModifyListener(modifyListener);
+ hostText.addModifyListener(modifyListener);
+ repoText.addModifyListener(modifyListener);
+
+ updateEditable();
+
+ return result;
+ }
+
+ public void dispose() {
+ // pass
+ }
+
+ public void reset() {
+ if (nameText == null) {
+ return;
+ }
+
+ String name = (repository == null)
+ ? (createMode
+ ? "My Repository"
+ : "")
+ : repository.getName();
+ String url = (repository == null)
+ ? (createMode
+ ? "tcp://localhost?repositoryName=repo1"
+ : null)
+ : repository.getURL();
+ URI uri = (url == null)
+ ? null
+ : URI.createURI(url);
+ String host = (uri == null)
+ ? ""
+ : parseHost(uri);
+ String repo = (uri == null)
+ ? ""
+ : parseRepositoryName(uri);
+ Protocol protocol = Protocol.TCP;
+ String portString = "";
+ boolean isDefaultPort = true;
+ if (uri != null) {
+ protocol = Protocol.valueOf(uri.scheme().toUpperCase());
+ int port = parsePort(uri);
+ if (port < 0) {
+ port = getSelectedProtocol().defaultPort();
+ }
+ portString = Integer.toString(port);
+ isDefaultPort = port == getSelectedProtocol().defaultPort();
+ }
+ nameText.setText(name);
+ protocolCombo.setSelection(new StructuredSelection(protocol));
+ hostText.setText(host);
+ repoText.setText(repo);
+ defaultPort.setSelection(isDefaultPort);
+ portText.setEnabled(editable && !isDefaultPort);
+ portText.setText(portString);
+ updatePortForProtocol();
+
+ recalculateURL();
+ }
+
+ public void setRepository(IPapyrusRepository repository) {
+ if (this.repository != repository) {
+ this.repository = repository;
+ reset();
+ }
+ }
+
+ public void setEditable(boolean editable) {
+ if (this.editable != editable) {
+ this.editable = editable;
+
+ updateEditable();
+ }
+ }
+
+ Protocol getSelectedProtocol() {
+ Protocol result = Protocol.TCP;
+
+ IStructuredSelection sel = (IStructuredSelection) protocolCombo
+ .getSelection();
+ if (!sel.isEmpty()) {
+ result = (Protocol) sel.getFirstElement();
+ }
+
+ return result;
+ }
+
+ void updatePortForProtocol() {
+ portText.setText(String.valueOf(getSelectedProtocol().defaultPort()));
+ }
+
+ public void finish() {
+ this.name = nameText.getText();
+ }
+
+ public void update() {
+ recalculateURL();
+ }
+
+ void recalculateURL() {
+ try {
+ if (Integer.parseInt(portText.getText().trim()) <= 0) {
+ throw new IllegalArgumentException();
+ }
+ } catch (Exception e) {
+ setStatus(error("Port must be a positive integer."));
+ return;
+ }
+
+ if (hostText.getText().trim().length() == 0) {
+ setStatus(error("The host name is required."));
+ return;
+ }
+
+ if (repoText.getText().trim().length() == 0) {
+ setStatus(error("The repository identifier is required."));
+ return;
+ }
+
+ if (nameText.getText().trim().length() == 0) {
+ setStatus(error("A name for the repository configuration is required."));
+ return;
+ }
+
+ name = nameText.getText().trim();
+ url = computeURL();
+
+ IPapyrusRepository existing = PapyrusRepositoryManager.INSTANCE
+ .getRepository(url);
+ if ((existing != null) && (existing != repository)) {
+ setStatus(error(NLS.bind(
+ "A repository \"{0}\" already exists at this location.",
+ existing.getName())));
+ return;
+ }
+
+ for (IPapyrusRepository next : PapyrusRepositoryManager.INSTANCE
+ .getRepositories()) {
+
+ if ((next != repository) && Objects.equal(next.getName(), name)) {
+ setStatus(warning(NLS
+ .bind(
+ "A repository named \"{0}\" already exists at a different location.",
+ next.getName())));
+ return;
+ }
+ }
+
+ setStatus(Status.OK_STATUS);
+ }
+
+ private IStatus error(String reason) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, reason);
+ }
+
+ private IStatus warning(String reason) {
+ return new Status(IStatus.WARNING, Activator.PLUGIN_ID, reason);
+ }
+
+ private String computeURL() {
+ StringBuilder result = new StringBuilder();
+
+ result.append(getSelectedProtocol().scheme).append(":");
+
+ result.append("//");
+ result.append(hostText.getText().trim());
+
+ result.append(":").append(portText.getText().trim());
+
+ result.append("?repositoryName=").append(repoText.getText().trim());
+
+ return result.toString();
+ }
+
+ private int parsePort(URI uri) {
+ String result = uri.port();
+ return (result == null)
+ ? -1
+ : Integer.parseInt(result);
+ }
+
+ private String parseHost(URI uri) {
+ String result = uri.authority();
+
+ if (result != null) {
+ int colon = result.lastIndexOf(':');
+ if (colon >= 0) {
+ result = result.substring(0, colon);
+ }
+ }
+
+ return result;
+ }
+
+ private String parseRepositoryName(URI uri) {
+ return CDOURIUtil.getParameters(uri.query()).get("repositoryName");
+ }
+
+ public IStatus getStatus() {
+ return status;
+ }
+
+ void setStatus(final IStatus status) {
+ class StatusChangedEvent
+ extends Event
+ implements IStatusChangedEvent {
+
+ private static final long serialVersionUID = 1L;
+
+ StatusChangedEvent() {
+ super(RepositoryPropertiesBlock.this);
+ }
+
+ public IStatus getStatus() {
+ return status;
+ }
+ }
+
+ this.status = status;
+ fireEvent(new StatusChangedEvent());
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getURL() {
+ return url;
+ }
+
+ private void updateEditable() {
+ if (nameText == null) {
+ return;
+ }
+
+ nameText.setEnabled(editable);
+ protocolCombo.getControl().setEnabled(editable);
+ defaultPort.setEnabled(editable);
+ portText.setEnabled(editable && !defaultPort.getSelection());
+ hostText.setEnabled(editable);
+ repoText.setEnabled(editable);
+ }
+
+ public static enum Protocol {
+ TCP("tcp", 2036), HTTP("http", 80);
+
+ private final String scheme;
+
+ private final int defaultPort;
+
+ Protocol(String scheme, int defaultPort) {
+ this.scheme = scheme;
+ this.defaultPort = defaultPort;
+ }
+
+ public String scheme() {
+ return scheme;
+ }
+
+ public int defaultPort() {
+ return defaultPort;
+ }
+ }
+
+ public static interface IStatusChangedEvent
+ extends IEvent {
+
+ IStatus getStatus();
+ }
+
+ public static class StatusChangedEventAdapter
+ implements IListener {
+
+ public void notifyEvent(IEvent event) {
+ if (event instanceof IStatusChangedEvent) {
+ handleStatusChanged(
+ (RepositoryPropertiesBlock) event.getSource(),
+ ((IStatusChangedEvent) event).getStatus());
+ } else {
+ handleOtherEvent(event);
+ }
+ }
+
+ protected void handleStatusChanged(RepositoryPropertiesBlock source,
+ IStatus newStatus) {
+
+ // pass
+ }
+
+ protected void handleOtherEvent(IEvent event) {
+ // pass
+ }
+ }
+
+ public static class StatusChangedMessageProviderAdapter
+ extends StatusChangedEventAdapter {
+
+ @Override
+ protected void handleStatusChanged(RepositoryPropertiesBlock source,
+ IStatus newStatus) {
+
+ int messageSeverity;
+
+ switch (newStatus.getSeverity()) {
+ case IStatus.OK :
+ messageSeverity = IMessageProvider.NONE;
+ break;
+ case IStatus.INFO :
+ messageSeverity = IMessageProvider.INFORMATION;
+ break;
+ case IStatus.WARNING :
+ messageSeverity = IMessageProvider.WARNING;
+ break;
+ default :
+ messageSeverity = IMessageProvider.ERROR;
+ break;
+ }
+
+ handleMessageChange(newStatus.isOK()
+ ? null
+ : newStatus.getMessage(), messageSeverity);
+ }
+
+ protected void handleMessageChange(String message, int messageSeverity) {
+ // pass
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/properties/RepositoryPropertyPage.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/properties/RepositoryPropertyPage.java
new file mode 100644
index 00000000000..3c51606c10c
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/properties/RepositoryPropertyPage.java
@@ -0,0 +1,153 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.properties;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.papyrus.cdo.core.CommitException;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.core.IInternalPapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.eclipse.ui.statushandlers.IStatusAdapterConstants;
+import org.eclipse.ui.statushandlers.StatusAdapter;
+import org.eclipse.ui.statushandlers.StatusManager;
+
+import com.google.common.base.Objects;
+
+/**
+ * This is the RepositoryPropertyPage type. Enjoy.
+ */
+public class RepositoryPropertyPage
+ extends PropertyPage {
+
+ private static final String MESSAGE = "Edit the repository name and location.";
+
+ private RepositoryPropertiesBlock block;
+
+ private Button forgetCredsButton;
+
+ @Override
+ protected Control createContents(Composite parent) {
+ setMessage(MESSAGE);
+
+ Composite result = new Composite(parent, SWT.NONE);
+ result.setLayout(new GridLayout(1, false));
+
+ block = new RepositoryPropertiesBlock(getRepository());
+ block.createControl(result);
+ block
+ .addListener(new RepositoryPropertiesBlock.StatusChangedMessageProviderAdapter() {
+
+ @Override
+ protected void handleMessageChange(String message,
+ int messageSeverity) {
+
+ setValid(messageSeverity < IMessageProvider.ERROR);
+
+ if (message == null) {
+ setMessage(MESSAGE);
+ } else {
+ setMessage(message, messageSeverity);
+ }
+ }
+ });
+
+ forgetCredsButton = new Button(result, SWT.PUSH);
+ forgetCredsButton.setText("Clear stored password");
+ forgetCredsButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ getRepository().clearCredentials();
+ }
+ });
+
+ return result;
+ }
+
+ protected IPapyrusRepository getRepository() {
+ IAdaptable element = getElement();
+ IPapyrusRepository result = (element instanceof IPapyrusRepository)
+ ? (IPapyrusRepository) element
+ : (IPapyrusRepository) element.getAdapter(IPapyrusRepository.class);
+
+ return result;
+ }
+
+ @Override
+ public boolean performOk() {
+ boolean result = false;
+
+ block.finish();
+
+ if (block.getStatus().isOK()) {
+ IPapyrusRepository repository = getRepository();
+
+ if (!repository.isConnected()
+ || Objects.equal(repository.getURL(), block.getURL())
+ || MessageDialog
+ .openQuestion(
+ getShell(),
+ "Repository Connected",
+ "The repository will have to be disconnected in order to apply these changes. Proceed?")) {
+
+ updateRepository(repository);
+
+ result = super.performOk();
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ protected void performDefaults() {
+ block.reset();
+ }
+
+ private void updateRepository(IPapyrusRepository repository) {
+ boolean reconnect = repository.isConnected()
+ && !Objects.equal(repository.getURL(), block.getURL());
+
+ IInternalPapyrusRepositoryManager mgr = PapyrusRepositoryManager.INSTANCE;
+ String url = block.getURL();
+
+ try {
+ if (reconnect) {
+ repository.disconnect();
+ }
+
+ repository.setName(block.getName());
+ mgr.setURL(repository, url);
+
+ mgr.saveRepositories();
+
+ if (reconnect) {
+ // if it was connected, re-connect
+ repository.connect();
+ }
+ } catch (CommitException e) {
+ StatusAdapter adapter = new StatusAdapter(e.getStatus());
+ adapter.setProperty(IStatusAdapterConstants.TITLE_PROPERTY,
+ "Disconnect failed");
+ StatusManager.getManager().handle(adapter, StatusManager.SHOW);
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/providers/ModelImportNodeLabelProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/providers/ModelImportNodeLabelProvider.java
new file mode 100644
index 00000000000..e1971e6816a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/providers/ModelImportNodeLabelProvider.java
@@ -0,0 +1,106 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.providers;
+
+import static org.eclipse.papyrus.infra.onefile.model.PapyrusModelHelper.getPapyrusModelFactory;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportNode;
+import org.eclipse.papyrus.cdo.internal.ui.util.CompositeLabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+/**
+ * This is the ModelImportNodeLabelProvider type. Enjoy.
+ */
+public class ModelImportNodeLabelProvider
+ implements ILabelProvider {
+
+ private ILabelProvider delegate = new CompositeLabelProvider(
+ new PapyrusElementLabelProvider(), new WorkbenchLabelProvider());
+
+ public ModelImportNodeLabelProvider() {
+ super();
+ }
+
+ public Image getImage(Object element) {
+ Image result = null;
+ IModelImportNode model = getModelImportNode(element);
+
+ if (model != null) {
+ result = delegate.getImage(getWorkbenchObject(model));
+ }
+
+ return result;
+ }
+
+ protected IModelImportNode getModelImportNode(Object element) {
+ return (element instanceof IModelImportNode)
+ ? (IModelImportNode) element
+ : null;
+ }
+
+ public String getText(Object element) {
+ String result = null;
+ IModelImportNode model = getModelImportNode(element);
+
+ if (model != null) {
+ result = delegate.getText(getWorkbenchObject(model));
+
+ if (result == null) {
+ result = model.getPrimaryResourceURI().trimFileExtension()
+ .lastSegment();
+ }
+ }
+
+ return result;
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void dispose() {
+ delegate.dispose();
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ delegate.addListener(listener);
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ delegate.removeListener(listener);
+ }
+
+ Object getWorkbenchObject(IModelImportNode element) {
+ Object result = element;
+
+ URI uri = element.getPrimaryResourceURI();
+ if (uri.isPlatformResource()) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot()
+ .getFile(new Path(uri.toPlatformString(true)));
+
+ if ((file != null) && getPapyrusModelFactory().isDi(file)) {
+ result = getPapyrusModelFactory().createIPapyrusFile(file);
+ } else {
+ result = file;
+ }
+ }
+
+ return result;
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/providers/PapyrusElementLabelProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/providers/PapyrusElementLabelProvider.java
new file mode 100644
index 00000000000..ed5a34542df
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/providers/PapyrusElementLabelProvider.java
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.providers;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.papyrus.infra.onefile.model.IPapyrusElement;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This is the PapyrusElementLabelProvider type. Enjoy.
+ */
+public class PapyrusElementLabelProvider
+ extends LabelProvider {
+
+ @Override
+ public Image getImage(Object element) {
+ return (element instanceof IPapyrusElement)
+ ? ((IPapyrusElement) element).getImage()
+ : null;
+ }
+
+ @Override
+ public String getText(Object element) {
+ return (element instanceof IPapyrusElement)
+ ? ((IPapyrusElement) element).getText()
+ : null;
+ }
+} \ No newline at end of file
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/CompositeLabelProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/CompositeLabelProvider.java
new file mode 100644
index 00000000000..a6fe97cb758
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/CompositeLabelProvider.java
@@ -0,0 +1,104 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.util;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.swt.graphics.Image;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+/**
+ * This is the CompositeLabelProvider type. Enjoy.
+ */
+public class CompositeLabelProvider
+ implements ILabelProvider {
+
+ private List<ILabelProvider> labelProviders = Lists.newArrayList();
+
+ public CompositeLabelProvider() {
+ super();
+ }
+
+ public CompositeLabelProvider(ILabelProvider provider,
+ ILabelProvider... more) {
+ this(Lists.asList(provider, more));
+ }
+
+ public CompositeLabelProvider(Iterable<? extends ILabelProvider> providers) {
+ this();
+
+ Iterables.addAll(this.labelProviders, providers);
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ for (ILabelProvider next : labelProviders) {
+ next.addListener(listener);
+ }
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ for (ILabelProvider next : labelProviders) {
+ next.removeListener(listener);
+ }
+ }
+
+ public void dispose() {
+ for (ILabelProvider next : labelProviders) {
+ next.dispose();
+ }
+
+ labelProviders.clear();
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ for (ILabelProvider next : labelProviders) {
+ if (next.isLabelProperty(element, property)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public Image getImage(Object element) {
+ Image result = null;
+
+ for (ILabelProvider next : labelProviders) {
+ result = next.getImage(element);
+
+ if (result != null) {
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ public String getText(Object element) {
+ String result = null;
+
+ for (ILabelProvider next : labelProviders) {
+ result = next.getText(element);
+
+ if (result != null) {
+ break;
+ }
+ }
+
+ return result;
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/DialogCredentialsProviderFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/DialogCredentialsProviderFactory.java
new file mode 100644
index 00000000000..85409e972c0
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/DialogCredentialsProviderFactory.java
@@ -0,0 +1,181 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.util;
+
+import java.util.concurrent.Callable;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.net4j.util.security.IPasswordCredentials;
+import org.eclipse.net4j.util.security.IPasswordCredentialsProvider2;
+import org.eclipse.net4j.util.security.PasswordCredentials;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.core.ICredentialsProviderFactory;
+import org.eclipse.papyrus.cdo.internal.core.IInteractiveCredentialsProvider;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.internal.ui.dialogs.RepositoryCredentialsDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWindowListener;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import com.google.common.base.Strings;
+
+/**
+ * This is the DialogCredentialsProviderFactory type. Enjoy.
+ */
+public class DialogCredentialsProviderFactory
+ implements ICredentialsProviderFactory {
+
+ private volatile IWorkbenchWindow activeWindow;
+
+ public DialogCredentialsProviderFactory() {
+ super();
+
+ PlatformUI.getWorkbench().addWindowListener(new IWindowListener() {
+
+ public void windowActivated(IWorkbenchWindow window) {
+ activeWindow = window;
+ }
+
+ public void windowClosed(IWorkbenchWindow window) {
+ if (activeWindow == window) {
+ activeWindow = null;
+ }
+ }
+
+ public void windowOpened(IWorkbenchWindow window) {
+ // pass
+ }
+
+ public void windowDeactivated(IWorkbenchWindow window) {
+ // pass
+ }
+
+ });
+ }
+
+ public IPasswordCredentialsProvider2 createCredentialsProvider(
+ IPapyrusRepository repository) {
+
+ return new CredentialsProvider(repository);
+ }
+
+ //
+ // Nested types
+ //
+
+ private class CredentialsProvider
+ implements IInteractiveCredentialsProvider {
+
+ private IPapyrusRepository repository;
+
+ CredentialsProvider(IPapyrusRepository repository) {
+ super();
+
+ this.repository = repository;
+ }
+
+ public boolean isInteractive() {
+ return true;
+ }
+
+ public IPasswordCredentials getCredentials() {
+ return getCredentials(null);
+ }
+
+ public IPasswordCredentials getCredentials(String realm) {
+ IPasswordCredentials result;
+
+ String username = repository.getUsername();
+ String password = repository.getPassword();
+
+ if (!Strings.isNullOrEmpty(username)
+ && !Strings.isNullOrEmpty(password)) {
+ // use stored creds
+ result = new PasswordCredentials(username,
+ password.toCharArray());
+ } else {
+ // OK, prompt the user, then
+ result = call(new Callable<IPasswordCredentials>() {
+
+ public IPasswordCredentials call() {
+ return openDialog();
+ }
+ });
+ }
+
+ return result;
+ }
+
+ private Shell getCurrentShell() {
+ return (activeWindow != null)
+ ? activeWindow.getShell()
+ : Display.getDefault().getActiveShell();
+ }
+
+ private IPasswordCredentials openDialog() {
+ IPasswordCredentials result = null;
+
+ RepositoryCredentialsDialog dlg = new RepositoryCredentialsDialog(
+ getCurrentShell(), repository);
+ if (dlg.open() == Window.OK) {
+ result = dlg.getCredentials();
+ }
+
+ return result;
+ }
+
+ public void reportCredentialsFailure(final SecurityException e) {
+ call(new Callable<Void>() {
+
+ public Void call() {
+ MessageDialog.openWarning(getCurrentShell(),
+ "Login Failed", e.getLocalizedMessage());
+ return null;
+ }
+ });
+ }
+
+ private <T> T call(final Callable<T> callable) {
+ final Object[] result = new Object[1];
+
+ final Shell parentShell = getCurrentShell();
+
+ if (parentShell.getDisplay() == Display.getCurrent()) {
+ try {
+ result[0] = (T) callable.call();
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ } else {
+ parentShell.getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ result[0] = callable.call();
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+ });
+ }
+
+ // this is safe according to the 'callable' type
+ @SuppressWarnings("unchecked")
+ T resultAsT = (T) result[0];
+
+ return resultAsT;
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/UIUtil.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/UIUtil.java
new file mode 100644
index 00000000000..973b4ea811a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/util/UIUtil.java
@@ -0,0 +1,223 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.util;
+
+import java.lang.reflect.Method;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Future;
+import java.util.concurrent.FutureTask;
+
+import org.eclipse.gmf.runtime.common.ui.util.DisplayUtils;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * This is the UIUtil type. Enjoy.
+ */
+public class UIUtil {
+
+ /**
+ * Not instantiable by clients.
+ */
+ private UIUtil() {
+ super();
+ }
+
+ public static Executor uiSafeExecutor() {
+ return UISafeExecutor.INSTANCE;
+ }
+
+ /**
+ * Posts a runnable to run later on the UI thread, whether the current
+ * thread is the UI or not. In fact, the name "later" suggests that usually
+ * this method is useful in code that is on the UI thread but needs to
+ * ensure that some block runs later, after other events have been
+ * processed.
+ *
+ * @param runnable
+ * a block of code to run later
+ */
+ public static void later(Runnable runnable) {
+ DisplayUtils.getDisplay().asyncExec(runnable);
+ }
+
+ /**
+ * Posts a callable that needs access to the UI to run asynchronously on the
+ * specified {@code display} thread.
+ *
+ * @param display
+ * the display on which to post a computation asynchronously
+ * @param callable
+ * a computation to run asynchronously on the UI thread
+ * @return the future result of the {@code callable}
+ */
+ public static <T> Future<T> asyncCall(Display display, Callable<T> callable) {
+ final FutureTask<T> result = new FutureTask<T>(callable);
+ display.asyncExec(result);
+ return result;
+ }
+
+ /**
+ * A UI-safe execution of a {@code callable} that needs access to the UI. If
+ * the current thread is the UI thread, then the result will be available
+ * immediately. Otherwise, the {@code callable} will be invoked
+ * asynchronously and the result will be available some time later.
+ *
+ * @param callable
+ * a computation to run on the UI thread
+ * @return the future result of the {@code callable}
+ */
+ public static <T> Future<T> call(Callable<T> callable) {
+ final FutureTask<T> result = new FutureTask<T>(callable);
+
+ Display display = Display.getCurrent();
+ if (display != null) {
+ result.run();
+ } else {
+ DisplayUtils.getDisplay().asyncExec(result);
+ }
+
+ return result;
+ }
+
+ /**
+ * <p>
+ * Queries whether the current thread is the UI thread and, if not, posts an
+ * runnable to re-dispatch the calling method asynchronously on the UI
+ * thread.
+ * </p>
+ * <p>
+ * The intended usage pattern is thus:
+ * </p>
+ *
+ * <pre>
+ * public void doSomethingToTheUI(Object arg1, String arg2) {
+ * if (UIUtil.ensureUIThread(this, arg1, arg2) {
+ * // do stuff here with arg1 and arg2 that requires
+ * // the UI thread
+ * }
+ * }
+ * </pre>
+ *
+ * @param receiver
+ * the receiver of the method to be (potentially) re-dispatched.
+ * This is the object calling the {@code ensureUIThread()}
+ * utility
+ * @param arguments
+ * the arguments passed in the method invocation to be
+ * re-dispatched
+ *
+ * @return {@code true} if the current thread is the UI thread and the
+ * calling method may proceed; {@code false} if the method
+ * invocation was re-dispatched asynchronously and the calling
+ * method must not proceed
+ */
+ public static boolean ensureUIThread(final Object receiver,
+ final Object... arguments) {
+
+ final Display display = DisplayUtils.getDisplay();
+ boolean result = Display.getCurrent() == display;
+
+ if (!result) {
+ // find the calling method and post its invocation asynchronously
+ String callingMethodName = null;
+ StackTraceElement[] stack = Thread.currentThread().getStackTrace();
+ for (int i = 0; i < stack.length; i++) {
+ StackTraceElement next = stack[i];
+ if (UIUtil.class.getName().equals(next.getClassName())
+ && "ensureUIThread".equals(next.getMethodName())) {
+
+ callingMethodName = stack[i + 1].getMethodName();
+ break;
+ }
+ }
+
+ if (callingMethodName == null) {
+ throw new IllegalStateException("Invalid stack trace");
+ }
+
+ final Method method = findMethod(receiver.getClass(),
+ callingMethodName, arguments);
+ if (method == null) {
+ throw new IllegalStateException("Could not find calling method");
+ }
+
+ method.setAccessible(true);
+
+ display.asyncExec(new Runnable() {
+
+ public void run() {
+ try {
+ method.invoke(receiver, arguments);
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+ });
+ }
+
+ return result;
+ }
+
+ private static Method findMethod(Class<?> owner, String name,
+ Object[] arguments) {
+ Method result = null;
+
+ Class<?>[] actual = new Class<?>[arguments.length];
+ for (int i = 0; i < arguments.length; i++) {
+ actual[i] = (arguments[i] == null)
+ ? null
+ : arguments[i].getClass();
+ }
+
+ Method[] declared = owner.getDeclaredMethods();
+ out : for (int i = 0; i < declared.length; i++) {
+ Method next = declared[i];
+ if (name.equals(next.getName())) {
+ Class<?>[] parameters = next.getParameterTypes();
+
+ for (int j = 0; j < parameters.length; j++) {
+ if ((actual[j] != null)
+ && !parameters[j].isAssignableFrom(actual[j])) {
+ continue out;
+ }
+ }
+
+ result = next;
+ break out;
+ }
+ }
+
+ return result;
+ }
+
+ //
+ // Nested types
+ //
+
+ private static final class UISafeExecutor
+ implements Executor {
+
+ static final UISafeExecutor INSTANCE = new UISafeExecutor();
+
+ public void execute(Runnable command) {
+ Display workbenchDisplay = PlatformUI.getWorkbench().getDisplay();
+ if (Display.getCurrent() == workbenchDisplay) {
+ command.run();
+ } else {
+ workbenchDisplay.asyncExec(command);
+ }
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/DIModel.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/DIModel.java
new file mode 100644
index 00000000000..2a3a48b60e7
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/DIModel.java
@@ -0,0 +1,138 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.views;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+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.util.EcoreUtil;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.internal.ui.SharedImages;
+import org.eclipse.swt.graphics.Image;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+/**
+ * This is the DIModel type. Enjoy.
+ */
+public class DIModel
+ extends PlatformObject
+ implements Adapter {
+
+ private final CDOResource resource;
+
+ public DIModel(CDOResource resource) {
+ this.resource = resource;
+
+ // ensure that I am the only adapter
+ for (Iterator<Adapter> iter = resource.eAdapters().iterator(); iter
+ .hasNext();) {
+
+ if (iter.next() instanceof DIModel) {
+ iter.remove();
+ }
+ }
+ resource.eAdapters().add(this);
+ }
+
+ public final CDOResource getResource() {
+ return resource;
+ }
+
+ public static DIModel getInstance(CDOResource resource, boolean create) {
+ DIModel result = (DIModel) EcoreUtil.getExistingAdapter(resource, DIModel.class);
+
+ if ((result == null) && create) {
+ result = new DIModel(resource);
+ }
+
+ return result;
+ }
+
+ @Override
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Class adapter) {
+ if ((adapter == CDOResourceNode.class)
+ || (adapter == CDOResource.class) || (adapter == CDOObject.class)) {
+
+ return getResource();
+ }
+
+ return super.getAdapter(adapter);
+ }
+
+ public String getName() {
+ return resource.getURI().trimFileExtension().lastSegment();
+ }
+
+ public Image getImage() {
+ return SharedImages.getImage(Activator.ICON_PAPYRUS_MODEL);
+ }
+
+ public Object[] getChildren() {
+ List<CDOResource> result = Lists.newArrayListWithExpectedSize(3);
+
+ String name = getName();
+ if (name != null) {
+ Collection<? extends EObject> nodes;
+ CDOResourceFolder folder = getResource().getFolder();
+ if (folder != null) {
+ nodes = folder.getNodes();
+ } else {
+ CDOResource root = getResource().cdoResource();
+ if ((root != null) && root.isRoot()) {
+ nodes = root.getContents();
+ } else {
+ nodes = Collections.emptyList();
+ }
+ }
+
+ for (CDOResource next : Iterables.filter(nodes, CDOResource.class)) {
+ if (name
+ .equals(next.getURI().trimFileExtension().lastSegment())) {
+
+ result.add(next);
+ }
+ }
+ }
+
+ return result.toArray();
+ }
+
+ public void notifyChanged(Notification notification) {
+ // pass
+ }
+
+ public Notifier getTarget() {
+ return resource;
+ }
+
+ public void setTarget(Notifier newTarget) {
+ // pass
+ }
+
+ public boolean isAdapterForType(Object type) {
+ return type == DIModel.class;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/DIResourceQuery.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/DIResourceQuery.java
new file mode 100644
index 00000000000..42769ff2f57
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/DIResourceQuery.java
@@ -0,0 +1,274 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.views;
+
+import static org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel.DI_FILE_EXTENSION;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
+import org.eclipse.emf.cdo.view.CDOQuery;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
+import org.eclipse.net4j.util.lifecycle.ILifecycleEvent.Kind;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage;
+import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Display;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Maps;
+
+/**
+ * A persistent query for DI resources in some CDO view. Server-side queries are
+ * run in the background to efficiently find all {@link CDOResource}s that
+ * contain DI {@link SashModel}s. The results of the query are asynchronously
+ * published to the UI to refresh the tree viewer.
+ */
+public class DIResourceQuery {
+
+ private static final Map<CDOView, DIResourceQuery> instances = Maps
+ .newHashMap();
+
+ private final StructuredViewer viewer;
+
+ private final CDOQuery query;
+
+ private final Job queryJob = new QueryJob();
+
+ private final IListener cdoViewListener = createCDOViewListener();
+
+ private AtomicReference<Set<CDOResource>> diResources = new AtomicReference<Set<CDOResource>>(
+ Collections.<CDOResource> emptySet());
+
+ private DIResourceQuery(StructuredViewer viewer, CDOView view) {
+ super();
+
+ this.viewer = viewer;
+ this.query = view
+ .createQuery(
+ "ocl",
+ "SashWindowsMngr.allInstances()->collect(oclAsType(ecore::EObject).eResource())",
+ DiPackage.Literals.SASH_MODEL);
+
+ view.addListener(cdoViewListener);
+ viewer.getControl().addDisposeListener(createViewerDisposeListener());
+
+ runQuery();
+ }
+
+ public static DIResourceQuery initialize(StructuredViewer viewer,
+ CDOView view) {
+
+ DIResourceQuery result;
+
+ synchronized (instances) {
+ result = instances.get(view);
+ if (result == null) {
+ result = new DIResourceQuery(viewer, view);
+ instances.put(view, result);
+ }
+ }
+
+ return result;
+ }
+
+ public static Set<CDOResource> getDIResources(CDOView view) {
+ DIResourceQuery query;
+
+ synchronized (instances) {
+ query = instances.get(view);
+ }
+
+ Set<CDOResource> result;
+ if (query == null) {
+ result = Collections.emptySet();
+ } else {
+ result = query.getDIResources();
+ }
+
+ return result;
+ }
+
+ public static boolean isUnaffiliatedResource(CDOResource resource) {
+ return getAffiliateResource(resource) == null;
+ }
+
+ public static CDOResource getAffiliateResource(CDOResource resource) {
+ CDOResource result = null;
+
+ URI uri = resource.getURI();
+ if (DI_FILE_EXTENSION.equals(uri.fileExtension())) {
+ // it *is* a DI resource
+ result = resource;
+ } else {
+ uri = uri.trimFileExtension()
+ .appendFileExtension(DI_FILE_EXTENSION);
+
+ for (CDOResource next : getDIResources(resource.cdoView())) {
+ if (uri.equals(next.getURI())) {
+ result = next;
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public Set<CDOResource> getDIResources() {
+ return diResources.get();
+ }
+
+ private void runQuery() {
+ // we cannot query for EClasses that the server doesn't know about. And,
+ // if it doesn't know about an EClass, then a priori, none of its
+ // instances exist, so we don't need to run the query
+ if (query.getView().getSession().getPackageRegistry()
+ .getPackageInfo(DiPackage.eINSTANCE) != null) {
+
+ queryJob.schedule();
+ }
+ }
+
+ void refresh() {
+ viewer.refresh();
+ }
+
+ private void dispose() {
+ synchronized (instances) {
+ CDOView view = query.getView();
+ view.removeListener(cdoViewListener);
+ instances.remove(view);
+ }
+ }
+
+ private IListener createCDOViewListener() {
+ return new IListener() {
+
+ public void notifyEvent(IEvent event) {
+ if (event instanceof ILifecycleEvent) {
+ ILifecycleEvent lifecycleEvent = (ILifecycleEvent) event;
+ if (lifecycleEvent.getKind() == Kind.DEACTIVATED) {
+ dispose();
+ }
+ } else if (event instanceof CDOViewInvalidationEvent) {
+ // if my view is invalidated, then some folder or resource
+ // that I am showing has changed. Run the query again and
+ // update asynchronously
+ runQuery();
+ }
+ }
+ };
+ }
+
+ private DisposeListener createViewerDisposeListener() {
+ return new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ dispose();
+ }
+ };
+ }
+
+ //
+ // Nested types
+ //
+
+ private class QueryJob
+ extends Job {
+
+ QueryJob() {
+ super("Find Papyrus models");
+
+ setSystem(true);
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ ImmutableSet.Builder<CDOResource> resultBuilder = ImmutableSet
+ .builder();
+ List<CDOResource> rawResult = query.getResult(CDOResource.class);
+
+ // don't use an iterator because it won't be able to advance
+ // past a resource proxy that cannot be resolved
+ for (int i = 0; i < rawResult.size(); i++) {
+ try {
+ CDOResource next = rawResult.get(i);
+ if (isContained(next)) {
+ resultBuilder.add(next);
+ }
+ } catch (Exception e) {
+ // can get "node not found" exceptions on incompletely
+ // deleted resources
+ Activator.log.error(
+ "Error retrieving resource result from CDO query.", e);
+ }
+ }
+ Set<CDOResource> result = resultBuilder.build();
+
+ diResources.set(ImmutableSet.copyOf(result));
+
+ if (viewer.getControl() != null) {
+ Display display = viewer.getControl().getDisplay();
+ if (display != null) {
+ display.asyncExec(new Runnable() {
+
+ public void run() {
+ if ((viewer.getControl() != null)
+ && !viewer.getControl().isDisposed()) {
+
+ refresh();
+ }
+ }
+ });
+ }
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ private boolean isContained(CDOResource resource) {
+ // determines whether a resource is properly contained in the view's
+ // node hierarchy
+ boolean result = false;
+
+ CDOResourceFolder folder = resource.getFolder();
+ if (folder != null) {
+ result = folder.getNodes().contains(resource);
+ } else {
+ CDOResource root = resource.cdoResource();
+ if ((root != null) && root.isRoot()) {
+ result = root.getContents().contains(resource);
+ }
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/LinkingHelper.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/LinkingHelper.java
new file mode 100644
index 00000000000..a9d29bb375b
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/LinkingHelper.java
@@ -0,0 +1,222 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.views;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.common.ui.URIEditorInput;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.core.IInternalPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.ui.editors.PapyrusCDOEditorInput;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchSite;
+
+/**
+ * This is the LinkingHelper type. Enjoy.
+ */
+class LinkingHelper {
+
+ private final IWorkbenchSite site;
+
+ private final IPapyrusRepositoryManager repositoryManager;
+
+ private final StructuredViewer viewer;
+
+ private boolean linkWithEditor;
+
+ private IPartListener linkingPartListener;
+
+ private ISelectionChangedListener linkingSelectionListener;
+
+ public LinkingHelper(IWorkbenchSite site,
+ IPapyrusRepositoryManager repositoryManager, StructuredViewer viewer) {
+
+ super();
+
+ this.site = site;
+ this.repositoryManager = repositoryManager;
+ this.viewer = viewer;
+ }
+
+ public void dispose() {
+ if (linkingPartListener != null) {
+ site.getPage().removePartListener(linkingPartListener);
+ }
+ if (linkingSelectionListener != null) {
+ viewer.removeSelectionChangedListener(linkingSelectionListener);
+ }
+ }
+
+ public boolean isLinkWithEditor() {
+ return linkWithEditor;
+ }
+
+ public void setLinkWithEditor(boolean link) {
+ if (link != linkWithEditor) {
+ this.linkWithEditor = link;
+
+ if (link) {
+ IWorkbenchPart active = site.getPage().getActivePart();
+ if ((active != null) && (active.getSite() == site)) {
+ // select the current model editor (if any)
+ selectEditor();
+ } else {
+ handleEditor(site.getPage().getActiveEditor());
+ }
+
+ site.getPage().addPartListener(getLinkingPartListener());
+ viewer
+ .addSelectionChangedListener(getLinkingSelectionListener());
+ } else {
+ site.getPage().removePartListener(getLinkingPartListener());
+ viewer
+ .removeSelectionChangedListener(getLinkingSelectionListener());
+ }
+ }
+ }
+
+ protected void selectEditor() {
+ DIModel model = getDIModelFromSelection();
+ if (model != null) {
+ URI uri = model.getResource().getURI();
+ IEditorInput input = new PapyrusCDOEditorInput(uri);
+
+ IEditorPart editor = site.getPage().findEditor(input);
+ if (editor != null) {
+ site.getPage().activate(editor);
+ }
+ }
+ }
+
+ protected void handleEditor(IEditorPart activeEditor) {
+ if (activeEditor != null) {
+ IEditorInput input = activeEditor.getEditorInput();
+ if (input instanceof URIEditorInput) {
+ URI uri = ((URIEditorInput) input).getURI();
+
+ DIModel selected = getDIModelFromSelection();
+ if ((selected == null)
+ || !selected.getResource().getURI().equals(uri)) {
+
+ // change the selection
+ DIModel model = findDIModel(uri);
+ if (model != null) {
+ viewer.setSelection(new StructuredSelection(model),
+ true);
+ }
+ }
+ }
+ }
+ }
+
+ protected DIModel getDIModelFromSelection() {
+ IStructuredSelection sel = (viewer == null)
+ ? StructuredSelection.EMPTY
+ : (IStructuredSelection) viewer.getSelection();
+
+ return sel.isEmpty()
+ ? null
+ : getDIModelFromSelection(sel.getFirstElement());
+ }
+
+ protected DIModel getDIModelFromSelection(Object selected) {
+ DIModel result = null;
+
+ if (selected instanceof DIModel) {
+ result = (DIModel) selected;
+ } else if (selected instanceof CDOResource) {
+ Object parent = ((ITreeContentProvider) viewer.getContentProvider())
+ .getParent(selected);
+ if (parent instanceof DIModel) {
+ result = (DIModel) parent;
+ }
+ }
+
+ return result;
+ }
+
+ protected DIModel findDIModel(URI uri) {
+ DIModel result = null;
+
+ IInternalPapyrusRepository repo = (IInternalPapyrusRepository) repositoryManager
+ .getRepositoryForURI(uri);
+ if (repo != null) {
+ CDOView mainView = repo.getMasterView();
+ if ((mainView != null) && !mainView.isClosed()) {
+ Resource res = mainView.getResourceSet()
+ .getResource(uri, false);
+
+ if ((res instanceof CDOResource) && res.isLoaded()) {
+ result = DIModel.getInstance((CDOResource) res, true);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private IPartListener getLinkingPartListener() {
+ if (linkingPartListener == null) {
+ linkingPartListener = new IPartListener() {
+
+ public void partActivated(IWorkbenchPart part) {
+ if (part instanceof IEditorPart) {
+ handleEditor((IEditorPart) part);
+ }
+ }
+
+ public void partOpened(IWorkbenchPart part) {
+ // pass
+ }
+
+ public void partDeactivated(IWorkbenchPart part) {
+ // pass
+ }
+
+ public void partClosed(IWorkbenchPart part) {
+ // pass
+ }
+
+ public void partBroughtToTop(IWorkbenchPart part) {
+ // pass
+ }
+ };
+ }
+
+ return linkingPartListener;
+ }
+
+ private ISelectionChangedListener getLinkingSelectionListener() {
+ if (linkingSelectionListener == null) {
+ linkingSelectionListener = new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ selectEditor();
+ }
+ };
+ }
+
+ return linkingSelectionListener;
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ModelRepositoriesView.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ModelRepositoriesView.java
new file mode 100644
index 00000000000..7c1d7981e73
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ModelRepositoriesView.java
@@ -0,0 +1,232 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.views;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
+import org.eclipse.net4j.util.ui.views.ContainerView;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.core.IInternalPapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.ui.actions.AbstractRepositoryAction;
+import org.eclipse.papyrus.cdo.internal.ui.actions.AddRepositoryAction;
+import org.eclipse.papyrus.cdo.internal.ui.actions.ConnectRepositoryAction;
+import org.eclipse.papyrus.cdo.internal.ui.actions.CreateFolderAction;
+import org.eclipse.papyrus.cdo.internal.ui.actions.DeleteModelAction;
+import org.eclipse.papyrus.cdo.internal.ui.actions.DisconnectRepositoryAction;
+import org.eclipse.papyrus.cdo.internal.ui.actions.LinkWithEditorAction;
+import org.eclipse.papyrus.cdo.internal.ui.actions.OpenPapyrusModelAction;
+import org.eclipse.papyrus.cdo.internal.ui.actions.RemoveRepositoryAction;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.dialogs.PropertyDialogAction;
+
+/**
+ * This is the ModelRepositoriesView type. Enjoy.
+ */
+public class ModelRepositoriesView
+ extends ContainerView {
+
+ public final static String ID = "org.eclipse.papyrus.cdo.ui.ModelRepositoriesView"; //$NON-NLS-1$
+
+ public static final int LINK_WITH_EDITOR_PROPERTY = 0x10000;
+
+ private static final String STATE_LINKING = "linkWithEditor";
+
+ private final IInternalPapyrusRepositoryManager repositoryManager;
+
+ private AddRepositoryAction addRepositoryAction;
+
+ private LinkWithEditorAction linkWithEditorAction;
+
+ private AbstractRepositoryAction connectRepositoryAction;
+
+ private AbstractRepositoryAction disconnectRepositoryAction;
+
+ private RemoveRepositoryAction removeRepositoryAction;
+
+ private OpenPapyrusModelAction openModelAction;
+
+ private PropertyDialogAction propertyDialogAction;
+
+ private CreateFolderAction createFolderAction;
+
+ private DeleteModelAction deleteModelAction;
+
+ private boolean isLinkWithEditor;
+
+ private LinkingHelper linkingHelper;
+
+ public ModelRepositoriesView() {
+ super();
+
+ repositoryManager = (IInternalPapyrusRepositoryManager) PapyrusRepositoryManager.INSTANCE;
+ }
+
+ @Override
+ protected IContainer<?> getContainer() {
+ return (IContainer<?>) repositoryManager;
+ }
+
+ @Override
+ public void init(IViewSite site, IMemento memento)
+ throws PartInitException {
+
+ super.init(site, memento);
+
+ // link by default
+ Boolean linking = (memento == null)
+ ? Boolean.TRUE
+ : memento.getBoolean(STATE_LINKING);
+ setLinkWithEditor(!Boolean.FALSE.equals(linking));
+ }
+
+ @Override
+ public void saveState(IMemento memento) {
+ memento.putBoolean(STATE_LINKING, isLinkWithEditor());
+ super.saveState(memento);
+ }
+
+ public boolean isLinkWithEditor() {
+ return isLinkWithEditor;
+ }
+
+ public void setLinkWithEditor(boolean link) {
+ if (isLinkWithEditor != link) {
+ isLinkWithEditor = link;
+
+ if (linkingHelper != null) {
+ linkingHelper.setLinkWithEditor(link);
+ }
+
+ firePropertyChange(LINK_WITH_EDITOR_PROPERTY);
+ }
+ }
+
+ @Override
+ protected Control createUI(Composite parent) {
+ createActions();
+
+ return super.createUI(parent);
+ }
+
+ @Override
+ protected void createdUI() {
+ super.createdUI();
+
+ linkingHelper = new LinkingHelper(getSite(), repositoryManager,
+ getViewer());
+ linkingHelper.setLinkWithEditor(isLinkWithEditor());
+
+ ISelectionProvider selectionProvider = getSite().getSelectionProvider();
+ selectionProvider.addSelectionChangedListener(openModelAction);
+ selectionProvider.addSelectionChangedListener(connectRepositoryAction);
+ selectionProvider
+ .addSelectionChangedListener(disconnectRepositoryAction);
+ selectionProvider.addSelectionChangedListener(removeRepositoryAction);
+ selectionProvider.addSelectionChangedListener(createFolderAction);
+ selectionProvider.addSelectionChangedListener(deleteModelAction);
+
+ // have to create this one after building the UI
+ propertyDialogAction = new PropertyDialogAction(getSite(),
+ selectionProvider);
+ propertyDialogAction
+ .setActionDefinitionId(IWorkbenchCommandConstants.FILE_PROPERTIES);
+ }
+
+ protected void createActions() {
+ addRepositoryAction = new AddRepositoryAction(this);
+ linkWithEditorAction = new LinkWithEditorAction(this);
+ connectRepositoryAction = new ConnectRepositoryAction(this);
+ disconnectRepositoryAction = new DisconnectRepositoryAction(this);
+ removeRepositoryAction = new RemoveRepositoryAction(this);
+ openModelAction = new OpenPapyrusModelAction(this);
+ createFolderAction = new CreateFolderAction(this);
+ deleteModelAction = new DeleteModelAction(this);
+
+ getViewSite().getActionBars().setGlobalActionHandler(
+ ActionFactory.DELETE.getId(), deleteModelAction);
+
+ }
+
+ @Override
+ protected void fillLocalToolBar(IToolBarManager manager) {
+ manager.add(addRepositoryAction);
+ manager.add(linkWithEditorAction);
+
+ super.fillLocalToolBar(manager);
+ }
+
+ @Override
+ protected void fillContextMenu(IMenuManager manager,
+ ITreeSelection selection) {
+
+ manager.add(new GroupMarker("createActions"));
+
+ if (!selection.isEmpty()) {
+ Object selected = selection.getFirstElement();
+
+ if (selected instanceof DIModel) {
+ manager.add(openModelAction);
+ manager.add(deleteModelAction);
+ }
+
+ if (selected instanceof IPapyrusRepository) {
+ if (((IPapyrusRepository) selected).isConnected()) {
+ manager.add(createFolderAction);
+ }
+
+ manager.add(connectRepositoryAction);
+ manager.add(disconnectRepositoryAction);
+
+ manager.add(removeRepositoryAction);
+ manager.add(propertyDialogAction);
+ }
+ }
+
+ super.fillContextMenu(manager, selection);
+ }
+
+ @Override
+ protected void doubleClicked(Object object) {
+ if (object instanceof DIModel) {
+ invoke(openModelAction);
+ } else if (object instanceof IPapyrusRepository) {
+ invoke(connectRepositoryAction);
+ } else {
+ super.doubleClicked(object);
+ }
+ }
+
+ protected void invoke(Action action) {
+ if (action.isEnabled()) {
+ action.run();
+ }
+ }
+
+ @Override
+ protected ContainerItemProvider<IContainer<Object>> createContainerItemProvider() {
+ return new ModelRepositoryItemProvider(getSite().getPage());
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ModelRepositoryItemProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ModelRepositoryItemProvider.java
new file mode 100644
index 00000000000..034ff7b153a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/ModelRepositoryItemProvider.java
@@ -0,0 +1,174 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.views;
+
+import java.util.Arrays;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
+import org.eclipse.emf.cdo.ui.CDOItemProvider;
+import org.eclipse.net4j.util.ui.views.IElementFilter;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.core.IInternalPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.internal.ui.SharedImages;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IWorkbenchPage;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+
+/**
+ * This is the ModelRepositoryItemProvider type. Enjoy.
+ */
+public class ModelRepositoryItemProvider
+ extends CDOItemProvider {
+
+ private final Predicate<Object> isDIResource = new Predicate<Object>() {
+
+ public boolean apply(Object input) {
+ return (input instanceof CDOResource)
+ && DIResourceQuery.getDIResources(
+ ((CDOResource) input).cdoView()).contains(input);
+ }
+ };
+
+ private final Predicate<Object> isUnaffiliatedResource = new Predicate<Object>() {
+
+ public boolean apply(Object input) {
+ return (input instanceof CDOResource)
+ && DIResourceQuery.isUnaffiliatedResource((CDOResource) input);
+ }
+ };
+
+ @SuppressWarnings("unchecked")
+ private final Predicate<Object> resourceFilter = Predicates.or(
+ Predicates.instanceOf(CDOResourceFolder.class), isDIResource,
+ isUnaffiliatedResource);
+
+ private final Function<Object, Object> resourceNodeTransformer = new Function<Object, Object>() {
+
+ public Object apply(Object input) {
+ if (isDIResource.apply(input)) {
+ return DIModel.getInstance((CDOResource) input, true);
+ } else {
+ return input;
+ }
+ }
+ };
+
+ public ModelRepositoryItemProvider(IWorkbenchPage page,
+ IElementFilter rootElementFilter) {
+
+ super(page, rootElementFilter);
+ }
+
+ public ModelRepositoryItemProvider(IWorkbenchPage page) {
+ super(page);
+ }
+
+ @Override
+ public Object[] getChildren(Object element) {
+ if (element instanceof IPapyrusRepository) {
+ // initialize query for DI resources
+ IInternalPapyrusRepository repo = (IInternalPapyrusRepository) element;
+ if (repo.isConnected()) {
+ DIResourceQuery.initialize(getViewer(), repo.getMasterView());
+ }
+ }
+
+ Object[] result;
+
+ if (element instanceof DIModel) {
+ result = ((DIModel) element).getChildren();
+ } else {
+ result = super.getChildren(element);
+
+ if ((element instanceof CDOResourceFolder)
+ || (element instanceof IPapyrusRepository)) {
+
+ result = filterDIResources(result);
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ Object result;
+
+ if (element instanceof CDOResource) {
+ CDOResource di = DIResourceQuery
+ .getAffiliateResource((CDOResource) element);
+
+ if (di != null) {
+ result = DIModel.getInstance(di, true);
+ } else {
+ result = super.getParent(element);
+ }
+ } else if (element instanceof DIModel) {
+ result = super.getParent(((DIModel) element).getResource());
+ } else {
+ result = super.getParent(element);
+ }
+
+ return result;
+ }
+
+ protected Object[] filter(Object[] elements, Predicate<Object> predicate) {
+
+ return Iterables.toArray(Iterables.transform(
+ Iterables.filter(Arrays.asList(elements), predicate),
+ resourceNodeTransformer), Object.class);
+ }
+
+ protected Object[] filterDIResources(Object[] elements) {
+ return filter(elements, resourceFilter);
+ }
+
+ @Override
+ public Image getImage(Object obj) {
+ Image result;
+
+ if (obj instanceof IPapyrusRepository) {
+ boolean open = ((IPapyrusRepository) obj).isConnected();
+ result = SharedImages.getImage(open
+ ? Activator.ICON_OPEN_REPOSITORY
+ : Activator.ICON_CLOSED_REPOSITORY);
+ } else if (obj instanceof DIModel) {
+ result = ((DIModel) obj).getImage();
+ } else {
+ result = super.getImage(obj);
+ }
+
+ return result;
+ }
+
+ @Override
+ public String getText(Object obj) {
+ String result;
+
+ if (obj instanceof IInternalPapyrusRepository) {
+ result = ((IInternalPapyrusRepository) obj).getName();
+ } else if (obj instanceof DIModel) {
+ result = ((DIModel) obj).getName();
+ } else {
+ result = super.getText(obj);
+ }
+
+ return result;
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelImportWizard.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelImportWizard.java
new file mode 100644
index 00000000000..629ad6bf540
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelImportWizard.java
@@ -0,0 +1,294 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.wizards;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportOperation;
+import org.eclipse.papyrus.cdo.core.importer.IModelImporter;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.statushandlers.StatusManager;
+
+import com.google.common.collect.Lists;
+import com.google.common.eventbus.EventBus;
+
+/**
+ * This is the ModelImportWizard type. Enjoy.
+ */
+public class ModelImportWizard
+ extends Wizard
+ implements IWorkbenchWizard {
+
+ private ModelReferencesPage referencesPage;
+
+ private RepositorySelectionPage repositoryPage;
+
+ private ModelMappingsPage mappingsPage;
+
+ private IStructuredSelection selection;
+
+ private IModelImportConfiguration importConfig;
+
+ public ModelImportWizard() {
+ super();
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+
+ setWindowTitle("Import Models into Repository");
+ setNeedsProgressMonitor(true);
+ setHelpAvailable(false);
+ }
+
+ @Override
+ public void addPages() {
+ importConfig = IModelImportConfiguration.Factory.DEFAULT
+ .create(new WizardOperationContext());
+
+ final EventBus bus = new EventBus("importWizard");
+
+ referencesPage = new ModelReferencesPage(bus);
+ addPage(referencesPage);
+
+ repositoryPage = new RepositorySelectionPage(bus);
+ addPage(repositoryPage);
+
+ mappingsPage = new ModelMappingsPage(bus);
+ addPage(mappingsPage);
+
+ // start analyzing the selected models's dependencies after the wizard
+ // has been presented
+ Display.getCurrent().asyncExec(new Runnable() {
+
+ public void run() {
+ for (IPapyrusFile next : getSelection()) {
+ importConfig.addModelToImport(URI
+ .createPlatformResourceURI(next.getMainFile()
+ .getFullPath().toString(), true));
+ }
+
+ bus.post(importConfig);
+ }
+ });
+ }
+
+ Iterable<IPapyrusFile> getSelection() {
+ List<IPapyrusFile> result = Lists.newArrayList();
+
+ if (selection != null) {
+ for (Object next : selection.toList()) {
+ IPapyrusFile file = null;
+
+ if (next instanceof IPapyrusFile) {
+ file = (IPapyrusFile) next;
+ } else if (next instanceof IAdaptable) {
+ file = (IPapyrusFile) ((IAdaptable) next)
+ .getAdapter(IPapyrusFile.class);
+ }
+
+ if (file != null) {
+ result.add(file);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public boolean performFinish() {
+ boolean result = true;
+
+ IModelImporter importer = IModelImporter.Factory.DEFAULT.create();
+ Diagnostic problems = importer.importModels(mappingsPage
+ .getSelectedMapping());
+
+ if (problems.getSeverity() > Diagnostic.INFO) {
+ StatusManager.getManager().handle(
+ BasicDiagnostic.toIStatus(problems), StatusManager.SHOW);
+ }
+
+ return result;
+ }
+
+ @Override
+ public void dispose() {
+ if (importConfig != null) {
+ // it actually takes a while to dispose this, unloading all of the
+ // resources potentially covering all of the Papyrus models in the
+ // workspace in order to clean up the UML CacheAdapter
+ final IModelImportConfiguration configuration = importConfig;
+ new Job("Clean up model import configuration") {
+
+ {
+ setSystem(true);
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ configuration.dispose();
+ return Status.OK_STATUS;
+ }
+ };
+ importConfig = null;
+ }
+
+ super.dispose();
+ }
+
+ //
+ // Nested types
+ //
+
+ private class WizardOperationContext
+ implements IModelImportOperation.Context {
+
+ public Diagnostic run(final IModelImportOperation operation) {
+ final Diagnostic[] result = {Diagnostic.OK_INSTANCE};
+
+ try {
+ getContainer().run(true, false, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException,
+ InterruptedException {
+
+ result[0] = operation.run(new UISafeProgressMonitor(
+ monitor));
+ }
+ });
+ } catch (Exception e) {
+ result[0] = new BasicDiagnostic(Diagnostic.ERROR,
+ Activator.PLUGIN_ID, 0,
+ "Model import operation execution failed.", new Object[]{e});
+ StatusManager.getManager().handle(
+ BasicDiagnostic.toIStatus(result[0]), StatusManager.SHOW);
+ }
+
+ return result[0];
+ }
+ }
+
+ private static class UISafeProgressMonitor
+ implements IProgressMonitor {
+
+ private final Display display = Display.getDefault();
+
+ private final IProgressMonitor delegate;
+
+ UISafeProgressMonitor(IProgressMonitor delegate) {
+ this.delegate = delegate;
+ }
+
+ private void exec(Runnable runnable) {
+ if (Display.getCurrent() == display) {
+ runnable.run();
+ } else {
+ display.syncExec(runnable);
+ }
+ }
+
+ public void beginTask(final String name, final int totalWork) {
+ exec(new Runnable() {
+
+ public void run() {
+ delegate.beginTask(name, totalWork);
+ }
+ });
+ }
+
+ public void internalWorked(final double work) {
+ exec(new Runnable() {
+
+ public void run() {
+ delegate.internalWorked(work);
+ }
+ });
+ }
+
+ public boolean isCanceled() {
+ final boolean[] result = {false};
+
+ exec(new Runnable() {
+
+ public void run() {
+ result[0] = delegate.isCanceled();
+ }
+ });
+
+ return result[0];
+ }
+
+ public void setCanceled(final boolean value) {
+ exec(new Runnable() {
+
+ public void run() {
+ delegate.setCanceled(value);
+ }
+ });
+ }
+
+ public void setTaskName(final String name) {
+ exec(new Runnable() {
+
+ public void run() {
+ delegate.setTaskName(name);
+ }
+ });
+ }
+
+ public void subTask(final String name) {
+ exec(new Runnable() {
+
+ public void run() {
+ delegate.subTask(name);
+ }
+ });
+ }
+
+ public void worked(final int work) {
+ exec(new Runnable() {
+
+ public void run() {
+ delegate.worked(work);
+ }
+ });
+ }
+
+ public void done() {
+ exec(new Runnable() {
+
+ public void run() {
+ done();
+ }
+ });
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelImportWizardPage.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelImportWizardPage.java
new file mode 100644
index 00000000000..4f6cb7e23a2
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelImportWizardPage.java
@@ -0,0 +1,116 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.wizards;
+
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+
+import com.google.common.eventbus.EventBus;
+
+/**
+ * This is the ModelImportWizardPage type. Enjoy.
+ */
+abstract class ModelImportWizardPage
+ extends WizardPage {
+
+ private final EventBus bus;
+
+ private String message;
+
+ public ModelImportWizardPage(String name, String title,
+ ImageDescriptor image, EventBus bus, String message) {
+ super(name, title, image);
+
+ this.bus = bus;
+ this.message = message;
+
+ bus.register(this);
+ setMessage(message);
+ }
+
+ void validatePage() {
+ setMessage(mostSevere(doValidatePage()));
+ }
+
+ protected Diagnostic doValidatePage() {
+ return Diagnostic.OK_INSTANCE;
+ }
+
+ protected Diagnostic report(int severity, String message) {
+ return new BasicDiagnostic(severity, Activator.PLUGIN_ID, 0, message,
+ null);
+ }
+
+ Diagnostic mostSevere(Diagnostic diagnostic) {
+ Diagnostic result = diagnostic;
+
+ for (Diagnostic next : diagnostic.getChildren()) {
+ if (next.getSeverity() == result.getSeverity()) {
+ result = next;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ void setMessage(Diagnostic diagnostic) {
+ int messageType;
+ String message;
+
+ switch (diagnostic.getSeverity()) {
+ case Diagnostic.OK :
+ messageType = IMessageProvider.NONE;
+ message = this.message;
+ break;
+ case Diagnostic.INFO :
+ messageType = IMessageProvider.INFORMATION;
+ message = diagnostic.getMessage();
+ break;
+ case Diagnostic.WARNING :
+ messageType = IMessageProvider.WARNING;
+ message = diagnostic.getMessage();
+ break;
+ case Diagnostic.CANCEL :
+ // an OK condition, but we can't finish the page even so
+ messageType = IMessageProvider.INFORMATION;
+ message = diagnostic.getMessage();
+ break;
+ default :
+ messageType = IMessageProvider.ERROR;
+ message = diagnostic.getMessage();
+ break;
+ }
+
+ // OK_INSTANCE and CANCEL_INSTANCE have useless messages
+ if ((diagnostic == Diagnostic.OK_INSTANCE)
+ || (diagnostic == Diagnostic.CANCEL_INSTANCE)) {
+
+ message = this.message;
+ }
+
+ setMessage(message, messageType);
+ setPageComplete(diagnostic.getSeverity() < Diagnostic.ERROR);
+ }
+
+ protected void post(Object event) {
+ bus.post(event);
+ }
+
+ protected EventBus getEventBus() {
+ return bus;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelMappingsPage.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelMappingsPage.java
new file mode 100644
index 00000000000..228bce7cf5a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelMappingsPage.java
@@ -0,0 +1,496 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.wizards;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportListener;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportMapping;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportMappingListener;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportNode;
+import org.eclipse.papyrus.cdo.core.importer.ModelImportListenerAdapter;
+import org.eclipse.papyrus.cdo.core.importer.ModelImportMappingListenerAdapter;
+import org.eclipse.papyrus.cdo.internal.ui.providers.ModelImportNodeLabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import com.google.common.collect.Iterables;
+import com.google.common.eventbus.EventBus;
+import com.google.common.eventbus.Subscribe;
+
+/**
+ * This is the RepositorySelectionPage type. Enjoy.
+ */
+public class ModelMappingsPage
+ extends ModelImportWizardPage {
+
+ private static final String MESSAGE = "Map models to paths in the repository.";
+
+ private IModelImportConfiguration importConfig;
+
+ private IModelImportListener importConfigListener;
+
+ private IPapyrusRepository repository;
+
+ private IModelImportMapping manyToOne;
+
+ private IModelImportMappingListener manyToOneListener;
+
+ private IModelImportMapping oneToOne;
+
+ private IModelImportMappingListener oneToOneListener;
+
+ private IModelImportMapping selectedMapping;
+
+ private Button manyToOneRadio;
+
+ private Text manyToOnePathText;
+
+ private Button oneToOneRadio;
+
+ private TableViewer oneToOnePathsTable;
+
+ public ModelMappingsPage(EventBus bus) {
+ super("mappings", "Model Mappings", null, bus, MESSAGE);
+ }
+
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+
+ Composite result = new Composite(parent, SWT.NONE);
+ result.setLayout(new GridLayout(2, false));
+
+ manyToOneRadio = new Button(result, SWT.RADIO);
+ manyToOneRadio.setText("A single model");
+ manyToOneRadio.setLayoutData(GridDataFactory.swtDefaults().span(2, 1)
+ .create());
+
+ Label label = new Label(result, SWT.NONE);
+ label.setText("Path:");
+ label.setLayoutData(GridDataFactory.swtDefaults()
+ .indent(convertWidthInCharsToPixels(5), 0).create());
+
+ manyToOnePathText = new Text(result, SWT.BORDER);
+ manyToOnePathText.setLayoutData(GridDataFactory.fillDefaults()
+ .grab(true, false).create());
+ manyToOnePathText.setEnabled(false);
+
+ oneToOneRadio = new Button(result, SWT.RADIO);
+ oneToOneRadio.setText("Separate models");
+ oneToOneRadio.setLayoutData(GridDataFactory.swtDefaults().span(2, 1)
+ .create());
+ oneToOneRadio.setSelection(true);
+
+ oneToOnePathsTable = new TableViewer(result);
+ oneToOnePathsTable.getControl().setLayoutData(
+ GridDataFactory.fillDefaults().grab(true, true).span(2, 1)
+ .indent(convertWidthInCharsToPixels(5), 0).create());
+ TableViewerColumn column = new TableViewerColumn(oneToOnePathsTable,
+ SWT.NONE);
+ column.getColumn().setText("Model");
+ column.getColumn().setWidth(convertWidthInCharsToPixels(30));
+ column = new TableViewerColumn(oneToOnePathsTable, SWT.NONE);
+ column.getColumn().setText("Path");
+ column.getColumn().setWidth(convertWidthInCharsToPixels(45));
+ column.setEditingSupport(new OneToOneMappingPathEditingSupport(
+ oneToOnePathsTable, 1));
+ oneToOnePathsTable.getTable().setHeaderVisible(true);
+ oneToOnePathsTable
+ .setContentProvider(new OneToOneMappingContentProvider());
+ oneToOnePathsTable.setLabelProvider(new OneToOneMappingLabelProvider());
+
+ if (importConfig != null) {
+ oneToOnePathsTable.setInput(importConfig);
+ }
+
+ SelectionListener radioListener = new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (((Button) e.widget).getSelection()) {
+ if (e.widget == manyToOneRadio) {
+ oneToOneRadio.setSelection(false);
+ oneToOnePathsTable.getControl().setEnabled(false);
+ manyToOnePathText.setEnabled(true);
+ } else {
+ manyToOneRadio.setSelection(false);
+ manyToOnePathText.setEnabled(false);
+ oneToOnePathsTable.getControl().setEnabled(true);
+ }
+
+ if (e.widget.getData() != null) {
+ selectedMapping((IModelImportMapping) e.widget
+ .getData());
+ }
+
+ validatePage();
+ }
+ }
+ };
+ manyToOneRadio.addSelectionListener(radioListener);
+ oneToOneRadio.addSelectionListener(radioListener);
+
+ manyToOnePathText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ manyToOnePathChanged(((Text) e.widget).getText().trim());
+ }
+ });
+
+ setControl(result);
+
+ validatePage();
+ }
+
+ @Override
+ public void dispose() {
+ if (importConfig != null) {
+ importConfig.removeModelImportListener(getImportConfigListener());
+ }
+
+ // I didn't create it, so don't dispose it
+ importConfig = null;
+
+ super.dispose();
+ }
+
+ void selectedMapping(IModelImportMapping mapping) {
+ selectedMapping = mapping;
+ post(mapping);
+ }
+
+ @Override
+ protected Diagnostic doValidatePage() {
+ Diagnostic result = Diagnostic.CANCEL_INSTANCE;
+
+ if (selectedMapping != null) {
+ result = selectedMapping.validate();
+ }
+
+ return result;
+ }
+
+ public IModelImportMapping getSelectedMapping() {
+ return selectedMapping;
+ }
+
+ @Subscribe
+ public void setConfiguration(IModelImportConfiguration config) {
+ this.importConfig = config;
+
+ if (config != null) {
+ config.addModelImportListener(getImportConfigListener());
+ }
+
+ setManyToOneMapping(IModelImportMapping.Factory.MANY_TO_ONE
+ .create(config));
+ setOneToOneMapping(IModelImportMapping.Factory.ONE_TO_ONE
+ .create(config));
+
+ if (oneToOnePathsTable != null) {
+ oneToOnePathsTable.setInput(config);
+ }
+
+ validatePage();
+ }
+
+ private IModelImportListener getImportConfigListener() {
+ if (importConfigListener == null) {
+ importConfigListener = new ModelImportListenerAdapter() {
+
+ @Override
+ public void modelsToImportChanged(
+ IModelImportConfiguration configuration) {
+
+ if ((oneToOnePathsTable != null)
+ && !oneToOnePathsTable.getControl().isDisposed()) {
+
+ oneToOnePathsTable.refresh();
+ }
+ }
+ };
+ }
+
+ return importConfigListener;
+ }
+
+ private void setManyToOneMapping(IModelImportMapping mapping) {
+ if (manyToOne != null) {
+ manyToOne.removeModelImportMappingListener(getManyToOneListener());
+ }
+
+ manyToOne = mapping;
+
+ if (manyToOne != null) {
+ manyToOne.addModelImportMappingListener(getManyToOneListener());
+ manyToOne.setRepository(repository);
+ if (manyToOneRadio != null) {
+ manyToOneRadio.setData(manyToOne);
+ if (manyToOneRadio.getSelection()) {
+ selectedMapping(manyToOne);
+ }
+
+ IModelImportNode node = Iterables.getFirst(
+ importConfig.getModelsToImport(), null);
+ if (node != null) {
+ updateManyToOneMapping(node);
+ }
+ }
+ }
+ }
+
+ private IModelImportMappingListener getManyToOneListener() {
+ if (manyToOneListener == null) {
+ manyToOneListener = new ModelImportMappingListenerAdapter() {
+
+ @Override
+ public void modelImportMappingChanged(IModelImportNode node) {
+ updateManyToOneMapping(node);
+ }
+ };
+ }
+
+ return manyToOneListener;
+ }
+
+ void updateManyToOneMapping(IModelImportNode node) {
+ IPath mapping = manyToOne.getMapping(node);
+ if ((mapping != null) && (manyToOnePathText != null)) {
+ String path = mapping.toString();
+ if (!manyToOnePathText.getText().equals(path)) {
+ manyToOnePathText.setText(path);
+ }
+ }
+ }
+
+ private void setOneToOneMapping(IModelImportMapping mapping) {
+ if (oneToOne != null) {
+ oneToOne.removeModelImportMappingListener(getOneToOneListener());
+ }
+
+ oneToOne = mapping;
+
+ if (oneToOne != null) {
+ oneToOne.addModelImportMappingListener(getOneToOneListener());
+ oneToOne.setRepository(repository);
+ if (oneToOneRadio != null) {
+ oneToOneRadio.setData(oneToOne);
+ if (oneToOneRadio.getSelection()) {
+ selectedMapping(oneToOne);
+ }
+ }
+ }
+ }
+
+ private IModelImportMappingListener getOneToOneListener() {
+ if (oneToOneListener == null) {
+ oneToOneListener = new ModelImportMappingListenerAdapter() {
+
+ @Override
+ public void modelImportMappingChanged(IModelImportNode node) {
+ IPath mapping = oneToOne.getMapping(node);
+ if ((mapping != null) && (oneToOnePathsTable != null)) {
+ oneToOnePathsTable.refresh();
+ }
+ }
+ };
+ }
+
+ return oneToOneListener;
+ }
+
+ @Subscribe
+ public void setRepository(IPapyrusRepository repository) {
+ this.repository = repository;
+
+ if (manyToOne != null) {
+ manyToOne.setRepository(repository);
+ }
+ if (oneToOne != null) {
+ oneToOne.setRepository(repository);
+ }
+
+ validatePage();
+ }
+
+ private void manyToOnePathChanged(String newPath) {
+ try {
+ IModelImportNode node = Iterables.getFirst(
+ importConfig.getModelsToImport(), null);
+ setMapping(node, newPath);
+ } catch (Exception e) {
+ setMessage("Please enter a valid path.", IMessageProvider.ERROR);
+ }
+ }
+
+ private boolean setMapping(IModelImportNode node, String newPath) {
+ boolean result = false;
+
+ IPath path = new Path(newPath);
+ if (path.isEmpty()) {
+ setMessage("Please enter a path.", IMessageProvider.ERROR);
+ setPageComplete(false);
+ } else if (path.hasTrailingSeparator()) {
+ setMessage("Please enter a path that is not a folder.",
+ IMessageProvider.ERROR);
+ setPageComplete(false);
+ } else {
+ result = true;
+
+ if ((selectedMapping != null) && (node != null)) {
+ selectedMapping.mapTo(node, path);
+ }
+
+ validatePage();
+ }
+
+ return result;
+ }
+
+ //
+ // Nested types
+ //
+
+ private static class OneToOneMappingContentProvider
+ implements IStructuredContentProvider {
+
+ public Object[] getElements(Object inputElement) {
+ return ((IModelImportConfiguration) inputElement)
+ .getModelsToImport().toArray();
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // pass
+ }
+
+ public void dispose() {
+ // pass
+ }
+
+ }
+
+ private class OneToOneMappingLabelProvider
+ extends ModelImportNodeLabelProvider
+ implements ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return (columnIndex == 0)
+ ? getImage(element)
+ : null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ String result = null;
+
+ switch (columnIndex) {
+ case 0 : // Model
+ result = getText(element);
+ break;
+ case 1 : // Path
+ if (oneToOne != null) {
+ IPath path = oneToOne
+ .getMapping((IModelImportNode) element);
+ if (path != null) {
+ result = path.toString();
+ }
+ }
+
+ if (result == null) {
+ result = "";
+ }
+ break;
+ }
+
+ return result;
+ }
+ }
+
+ private class OneToOneMappingPathEditingSupport
+ extends EditingSupport {
+
+ private TextCellEditor editor;
+
+ private int columnIndex;
+
+ OneToOneMappingPathEditingSupport(ColumnViewer columnViewer,
+ int columnIndex) {
+
+ super(columnViewer);
+
+ this.columnIndex = columnIndex;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ if (editor == null) {
+ editor = new TextCellEditor((Composite) getViewer()
+ .getControl());
+ }
+ return editor;
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ IPath path = oneToOne.getMapping((IModelImportNode) element);
+ return (path == null)
+ ? ""
+ : path.toString();
+ }
+
+ @Override
+ protected void setValue(final Object element, Object value) {
+ String newPath = (value == null)
+ ? ""
+ : String.valueOf(value);
+
+ if (!setMapping((IModelImportNode) element, newPath)) {
+ // continue editing
+ getViewer().getControl().getDisplay().asyncExec(new Runnable() {
+
+ public void run() {
+ getViewer().editElement(element, columnIndex);
+ }
+ });
+ }
+ }
+
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelReferencesPage.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelReferencesPage.java
new file mode 100644
index 00000000000..29561643c7a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/ModelReferencesPage.java
@@ -0,0 +1,425 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.wizards;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.resource.DeviceResourceManager;
+import org.eclipse.jface.resource.ResourceManager;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.DecorationOverlayIcon;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ICheckable;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportConfiguration;
+import org.eclipse.papyrus.cdo.core.importer.IModelImportNode;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.internal.ui.providers.ModelImportNodeLabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
+import com.google.common.eventbus.EventBus;
+import com.google.common.eventbus.Subscribe;
+
+/**
+ * This is the ModelReferencesPage type. Enjoy.
+ */
+public class ModelReferencesPage
+ extends ModelImportWizardPage {
+
+ private static final String MESSAGE = "Select referenced models to import into the repository.";
+
+ private IModelImportConfiguration importConfig;
+
+ private TreeViewer modelsTree;
+
+ private Text pathText;
+
+ public ModelReferencesPage(EventBus bus) {
+ super("references", "Model Cross-References", null, bus, MESSAGE);
+ }
+
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+
+ Composite result = new Composite(parent, SWT.NONE);
+ result.setLayout(new GridLayout(1, false));
+
+ new Label(result, SWT.NONE).setText("Models:");
+
+ ModelImportContentProvider contents = new ModelImportContentProvider();
+ modelsTree = new CheckboxTreeViewer(result);
+ modelsTree.getControl().setLayoutData(
+ GridDataFactory.fillDefaults().grab(true, true).create());
+ modelsTree.setAutoExpandLevel(2);
+ modelsTree.setContentProvider(contents);
+ modelsTree.setLabelProvider(new TreeNodeLabelProvider());
+
+ new Label(result, SWT.NONE).setText("Path:");
+ pathText = new Text(result, SWT.BORDER | SWT.MULTI | SWT.WRAP
+ | SWT.READ_ONLY);
+ pathText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false)
+ .hint(SWT.DEFAULT, convertHeightInCharsToPixels(3)).create());
+
+ modelsTree.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection sel = (IStructuredSelection) event
+ .getSelection();
+ if (!sel.isEmpty()) {
+ selected(sel.getFirstElement());
+ } else {
+ selected(null);
+ }
+ }
+ });
+
+ ((ICheckable) modelsTree).addCheckStateListener(contents);
+ ((ICheckable) modelsTree)
+ .addCheckStateListener(new ICheckStateListener() {
+
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ Display.getCurrent().asyncExec(new Runnable() {
+
+ public void run() {
+ validatePage();
+ }
+ });
+ }
+ });
+
+ setControl(result);
+
+ validatePage();
+ }
+
+ public IModelImportConfiguration getConfiguration() {
+ return importConfig;
+ }
+
+ @Subscribe
+ public void setConfiguration(IModelImportConfiguration configuration) {
+ if (configuration != this.importConfig) {
+ if (this.importConfig != null) {
+ this.importConfig.dispose();
+ }
+
+ this.importConfig = configuration;
+ }
+
+ modelsTree.setInput(configuration);
+
+ if (configuration != null) {
+ // initialize the checkboxes
+ Collection<IModelImportNode> initialSet = configuration
+ .getModelsToImport();
+ ITreeContentProvider contents = (ITreeContentProvider) modelsTree
+ .getContentProvider();
+ ICheckable checkable = (ICheckable) modelsTree;
+ for (Object next : contents.getElements(configuration)) {
+ checkable.setChecked(next, true);
+
+ for (Object child : contents.getChildren(next)) {
+ ITreeNode treeNode = (ITreeNode) child;
+ if (treeNode.isDependent()
+ || initialSet.contains(treeNode.getElement())) {
+
+ checkable.setChecked(child, true);
+ configuration.addModelToImport(treeNode.getElement()
+ .getPrimaryResourceURI());
+ }
+ }
+ }
+ }
+
+ validatePage();
+ }
+
+ @Override
+ public void dispose() {
+ // I didn't create it, so don't dispose it
+ importConfig = null;
+
+ super.dispose();
+ }
+
+ void selected(Object treeNode) {
+ if (treeNode == null) {
+ pathText.setText("");
+ } else {
+ IModelImportNode node = ((ITreeNode) treeNode).getElement();
+
+ pathText.setText(node.getName());
+ }
+ }
+
+ @Override
+ protected Diagnostic doValidatePage() {
+ Diagnostic result = Diagnostic.CANCEL_INSTANCE;
+
+ if (importConfig != null) {
+ if (importConfig.getModelsToImport().isEmpty()) {
+ result = report(Diagnostic.CANCEL,
+ "Please select at least one model to import.");
+ } else {
+ result = importConfig.validate();
+ }
+ }
+
+ return result;
+ }
+
+ //
+ // Nested types
+ //
+
+ static interface ITreeNode {
+
+ IModelImportNode getElement();
+
+ boolean isDependent();
+
+ boolean isDependency();
+ }
+
+ private static class ModelImportContentProvider
+ implements ITreeContentProvider, ICheckStateListener {
+
+ private Multimap<IModelImportNode, TreeNode> nodes = HashMultimap
+ .create();
+
+ private static final Object[] NO_OBJECTS = {};
+
+ private IModelImportConfiguration config;
+
+ private Object[] elements;
+
+ private Viewer viewer;
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ nodes.clear();
+ elements = null;
+
+ config = (IModelImportConfiguration) newInput;
+
+ this.viewer = viewer;
+ viewer.refresh();
+ }
+
+ public Object[] getElements(Object inputElement) {
+ Object[] result = elements;
+
+ if ((inputElement != config) || (result == null)) {
+ IModelImportConfiguration config = (IModelImportConfiguration) inputElement;
+ List<TreeNode> nodes = Lists.newArrayListWithCapacity(config
+ .getModelsToImport().size());
+
+ for (IModelImportNode next : config.getModelsToImport()) {
+ nodes.add(new TreeNode(next));
+ }
+
+ result = nodes.toArray();
+
+ if (inputElement == config) {
+ // cache the result
+ elements = result;
+ }
+ }
+
+ return result;
+ }
+
+ public boolean hasChildren(Object element) {
+ IModelImportNode importNode = ((TreeNode) element).getElement();
+
+ return !(importNode.getDependencies().isEmpty() && importNode
+ .getDependents().isEmpty());
+ }
+
+ public Object getParent(Object element) {
+ return ((TreeNode) element).getParent();
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ return ((TreeNode) parentElement).getChildren();
+ }
+
+ public void dispose() {
+ nodes.clear();
+ elements = null;
+ }
+
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ ITreeNode node = (ITreeNode) event.getElement();
+ IModelImportNode model = node.getElement();
+
+ // apply the check state to the model
+ if (event.getChecked()) {
+ config.addModelToImport(model.getPrimaryResourceURI());
+ } else {
+ config.removeModelToImport(model);
+ }
+
+ // propapate the check state to other occurrences of the same model
+ for (ITreeNode next : nodes.get(model)) {
+ event.getCheckable().setChecked(next, event.getChecked());
+ }
+ }
+
+ /**
+ * Need a tree-node class because {@link IModelImportNode}s are repeated
+ * in the tree.
+ */
+ private class TreeNode
+ implements ITreeNode {
+
+ private IModelImportNode element;
+
+ private TreeNode parent;
+
+ private List<TreeNode> children;
+
+ private boolean dependent;
+
+ TreeNode(IModelImportNode element) {
+ this(null, element, false);
+ }
+
+ TreeNode(TreeNode parent, IModelImportNode element,
+ boolean dependent) {
+
+ this.parent = parent;
+ this.element = element;
+ this.dependent = dependent;
+
+ nodes.put(element, this);
+ }
+
+ public IModelImportNode getElement() {
+ return element;
+ }
+
+ public boolean isDependent() {
+ return (getParent() != null) && dependent;
+ }
+
+ public boolean isDependency() {
+ return (getParent() != null) && !dependent;
+ }
+
+ Object getParent() {
+ return parent;
+ }
+
+ Object[] getChildren() {
+ if (children == null) {
+ createChildren();
+ }
+
+ return (children == null)
+ ? NO_OBJECTS
+ : children.toArray();
+ }
+
+ void createChildren() {
+ Collection<IModelImportNode> dependencies = element
+ .getDependencies();
+ Collection<IModelImportNode> dependents = element
+ .getDependents();
+
+ if (!dependencies.isEmpty() || !dependents.isEmpty()) {
+ children = Lists.newArrayListWithCapacity(dependencies
+ .size() + dependents.size());
+
+ for (IModelImportNode next : dependents) {
+ children.add(new TreeNode(this, next, true));
+ }
+ for (IModelImportNode next : dependencies) {
+ // don't show a model as both a dependent and a
+ // dependency if it both references and is
+ // referenced by the other
+ if (!dependents.contains(next)) {
+ children.add(new TreeNode(this, next, false));
+ }
+ }
+
+ // initialize check state of new children from configuration
+ Display.getCurrent().asyncExec(new Runnable() {
+
+ public void run() {
+ if (config != null) {
+ Collection<IModelImportNode> imported = config
+ .getModelsToImport();
+ ICheckable checkable = (ICheckable) viewer;
+ for (ITreeNode next : children) {
+ if (imported.contains(next.getElement())) {
+ checkable.setChecked(next, true);
+ }
+ }
+ }
+ }
+ });
+ }
+ }
+ }
+ }
+
+ private static class TreeNodeLabelProvider
+ extends ModelImportNodeLabelProvider {
+
+ private ResourceManager images = new DeviceResourceManager(
+ Display.getCurrent());
+
+ @Override
+ public Image getImage(Object element) {
+ ITreeNode treeNode = (ITreeNode) element;
+ Image result = super.getImage(element);
+
+ if ((result != null) && treeNode.isDependent()) {
+ // decorate it
+ result = (Image) images.get(new DecorationOverlayIcon(result,
+ Activator.getIcon(Activator.ICON_DEPENDENT_OVERLAY16),
+ IDecoration.TOP_RIGHT));
+ }
+
+ return result;
+ }
+
+ @Override
+ public void dispose() {
+ images.dispose();
+ }
+
+ @Override
+ protected IModelImportNode getModelImportNode(Object element) {
+ return ((ITreeNode) element).getElement();
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/RepositorySelectionBlock.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/RepositorySelectionBlock.java
new file mode 100644
index 00000000000..351b7854883
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/RepositorySelectionBlock.java
@@ -0,0 +1,223 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.wizards;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.ui.Activator;
+import org.eclipse.papyrus.cdo.internal.ui.SharedImages;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.statushandlers.StatusManager;
+
+import com.google.common.base.Supplier;
+import com.google.common.eventbus.EventBus;
+
+/**
+ * This is the RepositorySelectionBlock type. Enjoy.
+ */
+public class RepositorySelectionBlock {
+
+ private final IPapyrusRepositoryManager repoMan;
+
+ private final EventBus bus;
+
+ private final Supplier<? extends IRunnableContext> runnableContext;
+
+ private TableViewer repoList;
+
+ private IPapyrusRepository selectedRepository;
+
+ public RepositorySelectionBlock(IPapyrusRepositoryManager repoMan,
+ EventBus bus, Supplier<? extends IRunnableContext> runnableContext) {
+
+ this.repoMan = repoMan;
+ this.bus = bus;
+ this.runnableContext = runnableContext;
+ }
+
+ public Control createControl(Composite parent) {
+ repoList = new TableViewer(parent);
+ GridDataFactory.fillDefaults().grab(true, true)
+ .applyTo(repoList.getControl());
+ repoList.setContentProvider(new RepositoryContentProvider());
+ repoList.setLabelProvider(new RepositoryLabelProvider());
+ repoList.setInput(repoMan);
+
+ repoList.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection sel = (IStructuredSelection) event
+ .getSelection();
+
+ if (sel.isEmpty()) {
+ if (selectedRepository != null) {
+ // veto empty selection
+ repoList.setSelection(new StructuredSelection(
+ selectedRepository));
+ }
+ } else {
+ selected((IPapyrusRepository) sel.getFirstElement());
+ }
+ }
+ });
+
+ // initially select the first connected repo
+ for (IPapyrusRepository next : PapyrusRepositoryManager.INSTANCE
+ .getRepositories()) {
+
+ if (next.isConnected()) {
+ selected(next);
+ repoList.setSelection(new StructuredSelection(next));
+ break;
+ }
+ }
+
+ return repoList.getControl();
+ }
+
+ public void dispose() {
+ // pass
+ }
+
+ public void setEnabled(boolean enabled) {
+ if (repoList != null) {
+ repoList.getControl().setEnabled(enabled);
+ }
+ }
+
+ public boolean isEnabled() {
+ return (repoList != null) && repoList.getControl().isEnabled();
+ }
+
+ void selected(final IPapyrusRepository repository) {
+ selectedRepository = repository;
+
+ if (!repository.isConnected()) {
+ try {
+ runnableContext.get().run(true, false,
+ new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException,
+ InterruptedException {
+
+ SubMonitor sub = SubMonitor.convert(
+ monitor,
+ NLS.bind("Connecting {0} ...",
+ repository.getName()),
+ IProgressMonitor.UNKNOWN);
+
+ try {
+ repository.connect();
+
+ // yes, it's a busy wait, but there's not much
+ // to be done about that.
+ final long deadline = System
+ .currentTimeMillis() + 5000L;
+ while (!repository.isConnected()) {
+ Thread.sleep(250L);
+ if (System.currentTimeMillis() >= deadline) {
+ break;
+ }
+ }
+
+ repoList.getControl().getDisplay()
+ .asyncExec(new Runnable() {
+
+ public void run() {
+ if (!repoList.getControl()
+ .isDisposed()) {
+ repoList.update(repository,
+ null);
+ bus.post(repository);
+ }
+ }
+ });
+ } finally {
+ sub.done();
+ }
+ }
+ });
+ } catch (Exception e) {
+ StatusManager.getManager().handle(
+ new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ "Repository connection interrupted.", e),
+ StatusManager.SHOW);
+ }
+ }
+
+ bus.post(repository);
+ }
+
+ public IPapyrusRepository getSelectedRepository() {
+ return selectedRepository;
+ }
+
+ //
+ // Nested types
+ //
+
+ private static class RepositoryContentProvider
+ implements IStructuredContentProvider {
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ viewer.refresh();
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return ((IPapyrusRepositoryManager) inputElement).getRepositories()
+ .toArray();
+ }
+
+ public void dispose() {
+ // pass
+ }
+ }
+
+ private static class RepositoryLabelProvider
+ extends LabelProvider {
+
+ @Override
+ public Image getImage(Object element) {
+ boolean open = ((IPapyrusRepository) element).isConnected();
+ return SharedImages.getImage(open
+ ? Activator.ICON_OPEN_REPOSITORY
+ : Activator.ICON_CLOSED_REPOSITORY);
+ }
+
+ @Override
+ public String getText(Object element) {
+ return ((IPapyrusRepository) element).getName();
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/RepositorySelectionPage.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/RepositorySelectionPage.java
new file mode 100644
index 00000000000..3f70ef105b5
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/wizards/RepositorySelectionPage.java
@@ -0,0 +1,102 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.internal.ui.wizards;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.ui.properties.RepositoryPropertiesBlock;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+
+import com.google.common.base.Suppliers;
+import com.google.common.eventbus.EventBus;
+import com.google.common.eventbus.Subscribe;
+
+/**
+ * This is the RepositorySelectionPage type. Enjoy.
+ */
+public class RepositorySelectionPage
+ extends ModelImportWizardPage {
+
+ private static final String MESSAGE = "Select a repository to import the models into.";
+
+ private RepositorySelectionBlock repoSelectionBlock;
+
+ private RepositoryPropertiesBlock repoBlock;
+
+ public RepositorySelectionPage(EventBus bus) {
+ super("repository", "Model Repository", null, bus, MESSAGE);
+ }
+
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+
+ Composite result = new Composite(parent, SWT.NONE);
+ result.setLayout(new GridLayout(1, false));
+
+ new Label(result, SWT.NONE).setText("Repositories:");
+
+ repoSelectionBlock = new RepositorySelectionBlock(
+ PapyrusRepositoryManager.INSTANCE, getEventBus(),
+ Suppliers.ofInstance(getContainer()));
+ repoSelectionBlock.createControl(result);
+
+ Group group = new Group(result, SWT.BORDER);
+ group.setText("Repository details:");
+ group.setLayoutData(GridDataFactory.fillDefaults().grab(true, false)
+ .create());
+ group.setLayout(new GridLayout(1, false));
+ repoBlock = new RepositoryPropertiesBlock(getSelectedRepository());
+ repoBlock.createControl(group);
+ repoBlock.setEditable(false);
+
+ setControl(result);
+
+ validatePage();
+ }
+
+ @Override
+ public void dispose() {
+ repoSelectionBlock.dispose();
+ repoBlock.dispose();
+
+ super.dispose();
+ }
+
+ @Subscribe
+ public void selected(final IPapyrusRepository repository) {
+ repoBlock.setRepository(repository);
+ validatePage();
+ }
+
+ @Override
+ protected Diagnostic doValidatePage() {
+ Diagnostic result = Diagnostic.CANCEL_INSTANCE;
+
+ if (getSelectedRepository() != null) {
+ result = Diagnostic.OK_INSTANCE;
+ }
+
+ return result;
+ }
+
+ public IPapyrusRepository getSelectedRepository() {
+ return (repoSelectionBlock == null)
+ ? null
+ : repoSelectionBlock.getSelectedRepository();
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.classpath b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.classpath
new file mode 100644
index 00000000000..64c5e31b7a2
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.project b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.project
new file mode 100644
index 00000000000..fadca311785
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.cdo.uml.diagram.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.settings/org.eclipse.jdt.core.prefs b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..af0f20f97a5
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.settings/org.eclipse.jdt.ui.prefs b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 00000000000..86087cd06ce
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.ui.javadoc=true
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*****************************************************************************\n * Copyright (c) ${year} CEA LIST.\n * \n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors\:\n * CEA LIST - Initial API and implementation\n *****************************************************************************/</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * This is the ${type_name} type. Enjoy.\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/META-INF/MANIFEST.MF b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..5957e72d83e
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.cdo.uml.diagram.ui;singleton:=true
+Bundle-Version: 0.10.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.cdo.uml.diagram.internal.ui.Activator
+Bundle-Vendor: %providerName
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0",
+ org.eclipse.papyrus.cdo.core;bundle-version="0.10.0",
+ org.eclipse.papyrus.cdo.ui;bundle-version="0.10.0",
+ org.eclipse.papyrus.uml.diagram.wizards;bundle-version="0.10.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Export-Package: org.eclipse.papyrus.cdo.uml.diagram.internal.ui,
+ org.eclipse.papyrus.cdo.uml.diagram.internal.ui.handlers,
+ org.eclipse.papyrus.cdo.uml.diagram.internal.ui.wizards
+Import-Package: com.google.common.base;version="10.0.1",
+ com.google.common.eventbus;version="10.0.1"
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/about.html b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/about.html
new file mode 100644
index 00000000000..209103075a7
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>November 14, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/build.properties b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/build.properties
new file mode 100644
index 00000000000..92ba4c54284
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/build.properties
@@ -0,0 +1,10 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties,\
+ about.html,\
+ plugin.xml,\
+ icons/
+bin.excludes = icons/**/*.pxm
+src.includes = about.html
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/icons/full/elcl16/newmodel_co.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/icons/full/elcl16/newmodel_co.gif
new file mode 100644
index 00000000000..a0de332274a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/icons/full/elcl16/newmodel_co.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/icons/full/elcl16/newmodel_co.pxm b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/icons/full/elcl16/newmodel_co.pxm
new file mode 100644
index 00000000000..e096c73ffea
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/icons/full/elcl16/newmodel_co.pxm
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/plugin.properties b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/plugin.properties
new file mode 100644
index 00000000000..24fbf5135d8
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/plugin.properties
@@ -0,0 +1,13 @@
+# Copyright (c) 2013 CEA LIST.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# CEA LIST - Initial API and implementation
+#
+
+pluginName = Papyrus CDO UML Diagrams UI (Incubation)
+providerName = Eclipse Modeling Project
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/plugin.xml b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/plugin.xml
new file mode 100644
index 00000000000..e6178471d35
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/plugin.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.uml.diagram.wizards.newModelStorageProviders">
+ <provider
+ class="org.eclipse.papyrus.cdo.uml.diagram.internal.ui.wizards.CDONewModelStorageProvider"
+ name="In a model repository">
+ <enablement>
+ <iterate>
+ <or>
+ <adapt
+ type="org.eclipse.emf.ecore.EObject">
+ <test
+ property="org.eclipse.papyrus.cdo.core.isCDOObject">
+ </test>
+ </adapt>
+ <adapt
+ type="org.eclipse.emf.cdo.eresource.CDOResourceNode">
+ </adapt>
+ <adapt
+ type="org.eclipse.papyrus.cdo.core.IPapyrusRepository">
+ </adapt>
+ </or>
+ </iterate>
+ </enablement>
+ </provider>
+ </extension>
+
+
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.papyrus.cdo.ui.ModelRepositoriesView?after=createActions">
+ <command
+ commandId="org.eclipse.papyrus.cdo.uml.diagram.ui.commands.newModel"
+ icon="$nl$/icons/full/elcl16/newmodel_co.gif"
+ label="New Papyrus Model">
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ id="org.eclipse.papyrus.cdo.uml.diagram.ui.commands.newModel"
+ name="New Papyrus Model">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.papyrus.cdo.uml.diagram.internal.ui.handlers.NewModelHandler"
+ commandId="org.eclipse.papyrus.cdo.uml.diagram.ui.commands.newModel">
+ <enabledWhen>
+ <iterate operator="and" ifEmpty="false">
+ <or>
+ <adapt
+ type="org.eclipse.emf.cdo.eresource.CDOResourceNode">
+ </adapt>
+ <adapt
+ type="org.eclipse.papyrus.cdo.core.IPapyrusRepository">
+ </adapt>
+ </or>
+ </iterate>
+ </enabledWhen>
+ </handler>
+ </extension>
+</plugin>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/Activator.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/Activator.java
new file mode 100644
index 00000000000..2d392b5bbb4
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/Activator.java
@@ -0,0 +1,52 @@
+package org.eclipse.papyrus.cdo.uml.diagram.internal.ui;
+
+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.cdo.uml.diagram.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /** Logging helper */
+ public static LogHelper log = new LogHelper();
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ super();
+ }
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+
+ // register the log helper
+ log.setPlugin(plugin);
+
+ }
+
+ 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/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/handlers/NewModelHandler.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/handlers/NewModelHandler.java
new file mode 100644
index 00000000000..75b2ee6ecb4
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/handlers/NewModelHandler.java
@@ -0,0 +1,51 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.uml.diagram.internal.ui.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.papyrus.uml.diagram.wizards.InitModelWizard;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * This is the NewModelHandler type. Enjoy.
+ */
+public class NewModelHandler
+ extends AbstractHandler {
+
+ public NewModelHandler() {
+ super();
+ }
+
+ public Object execute(ExecutionEvent event)
+ throws ExecutionException {
+
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection instanceof IStructuredSelection) {
+ InitModelWizard wizard = new InitModelWizard();
+
+ wizard.init(HandlerUtil.getActiveWorkbenchWindow(event)
+ .getWorkbench(), (IStructuredSelection) selection);
+
+ WizardDialog dlg = new WizardDialog(
+ HandlerUtil.getActiveShell(event), wizard);
+ dlg.open();
+ }
+
+ return null;
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/wizards/CDONewModelStorageProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/wizards/CDONewModelStorageProvider.java
new file mode 100644
index 00000000000..593d8e2bd96
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/wizards/CDONewModelStorageProvider.java
@@ -0,0 +1,256 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.uml.diagram.internal.ui.wizards;
+
+import static org.eclipse.papyrus.uml.diagram.wizards.utils.WizardsHelper.adapt;
+import static org.eclipse.papyrus.uml.diagram.wizards.utils.WizardsHelper.getSelectedResourceURI;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.papyrus.uml.diagram.wizards.AbstractNewModelStorageProvider;
+import org.eclipse.papyrus.uml.diagram.wizards.CreateModelWizard;
+import org.eclipse.papyrus.uml.diagram.wizards.InitModelWizard;
+import org.eclipse.papyrus.uml.diagram.wizards.Messages;
+import org.eclipse.swt.widgets.Composite;
+
+import com.google.common.base.Supplier;
+import com.google.common.eventbus.EventBus;
+
+/**
+ * This is the CDONewModelStorageProvider type. Enjoy.
+ */
+public class CDONewModelStorageProvider
+ extends AbstractNewModelStorageProvider {
+
+ private final EventBus bus = new EventBus("NewCDOModelWizard");
+
+ private CreateModelWizard wizard;
+
+ private RepositorySelectionPart selectProviderPart;
+
+ private NewModelPage newModelPage;
+
+ public CDONewModelStorageProvider() {
+ super();
+ }
+
+ public boolean canHandle(IStructuredSelection initialSelection) {
+ boolean result = false;
+
+ for (Object next : initialSelection.toList()) {
+ if (CDOUtils.isCDOObject(adapt(next, EObject.class))) {
+ result = true;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ public void init(CreateModelWizard wizard, IStructuredSelection selection) {
+ super.init(wizard, selection);
+
+ this.wizard = wizard;
+ newModelPage = createNewModelPage(selection);
+ createSelectProviderPart();
+
+ IPapyrusRepository repo = getRepository(selection);
+ if (repo != null) {
+ bus.post(repo);
+ }
+ }
+
+ /**
+ * Gets the contextual repository, if any, from a selection.
+ *
+ * @param selection
+ * a selection
+ *
+ * @return the repository that is or contains the {@code selection}
+ */
+ static IPapyrusRepository getRepository(IStructuredSelection selection) {
+ IPapyrusRepository result = null;
+
+ if (!selection.isEmpty()) {
+ result = adapt(selection.getFirstElement(),
+ IPapyrusRepository.class);
+ if (result == null) {
+ CDOResourceNode node = adapt(selection.getFirstElement(),
+ CDOResourceNode.class);
+ if (node == null) {
+ EObject object = adapt(selection.getFirstElement(),
+ EObject.class);
+ if (object != null) {
+ CDOObject cdo = CDOUtils.getCDOObject(object);
+ if (cdo != null) {
+ node = cdo.cdoResource();
+ }
+ }
+ }
+
+ if (node != null) {
+ result = PapyrusRepositoryManager.INSTANCE
+ .getRepositoryForURI(node.getURI());
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public List<? extends IWizardPage> createPages() {
+ if (newModelPage == null) {
+ return Collections.emptyList();
+ }
+
+ return Arrays.asList(newModelPage);
+ }
+
+ public IStatus validateDiagramCategories(String... newCategories) {
+ if (newModelPage != null) {
+ String firstCategory = newCategories.length > 0
+ ? newCategories[0]
+ : null;
+ if (newCategories.length > 0) {
+ // 316943 - [Wizard] Wrong suffix for file name when creating a
+ // profile model
+ return newModelPage.diagramExtensionChanged(wizard
+ .getDiagramFileExtension(firstCategory));
+ }
+ }
+
+ return super.validateDiagramCategories(newCategories);
+ }
+
+ /**
+ * Creates the new model page, if required.
+ *
+ * @param selection
+ * the selection
+ *
+ * @return the new model page, or {@code null} if none
+ */
+ protected NewModelPage createNewModelPage(IStructuredSelection selection) {
+ if (wizard.isCreateProjectWizard()
+ || wizard.isCreateMultipleModelsWizard()) {
+
+ return null;
+ }
+
+ if (isCreateFromExistingDomainModel()) {
+ URI uri = getSelectedResourceURI(selection).trimFileExtension()
+ .appendFileExtension(wizard.getDiagramFileExtension(null));
+ return new NewDiagramForExistingModelPage(selection,
+ wizard.getModelKindName(), bus, uri.lastSegment());
+ }
+
+ return new NewModelPage(selection, bus, wizard.getModelKindName());
+ }
+
+ protected boolean isCreateFromExistingDomainModel() {
+ return wizard.isInitModelWizard()
+ && ((InitModelWizard) wizard).isCreateFromExistingDomainModel();
+ }
+
+ public URI createNewModelURI(String categoryId) {
+ return newModelPage.createNewModelResourceURI();
+ }
+
+ @Override
+ public ISelectProviderPart createSelectProviderPart() {
+ if (selectProviderPart == null) {
+ selectProviderPart = new RepositorySelectionPart(
+ PapyrusRepositoryManager.INSTANCE, bus,
+ new Supplier<IRunnableContext>() {
+
+ public IRunnableContext get() {
+ return wizard.getContainer();
+ }
+ });
+ }
+
+ return selectProviderPart;
+ }
+
+ //
+ // Nested types
+ //
+
+ /**
+ * This is the NewDiagramForExistingModelPage type. Enjoy.
+ */
+ protected static class NewDiagramForExistingModelPage
+ extends NewModelPage {
+
+ /** The my diagram resource name. */
+ private String myDiagramResourceName;
+
+ /**
+ * Instantiates a new new diagram for existing model page.
+ *
+ * @param selection
+ * the selection
+ * @param modelKindName
+ * the user-presentable (translatable) name of the kind of
+ * model to create
+ * @param bus
+ * an event bus for posting events
+ * @param defaultResourceName
+ * the default resource name
+ */
+ public NewDiagramForExistingModelPage(IStructuredSelection selection,
+ String modelKindName, EventBus bus, String defaultResourceName) {
+
+ super(selection, bus, modelKindName);
+
+ myDiagramResourceName = defaultResourceName;
+ setTitle(Messages.InitModelWizard_init_papyrus_model);
+ setDescription(Messages.InitModelWizard_init_papyrus_model_desc);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+
+ setNewResourceName(myDiagramResourceName);
+ }
+
+ @Override
+ protected void validatePage() {
+ super.validatePage();
+
+ if (getMessageType() < ERROR) {
+ if (!myDiagramResourceName.equals(getNewResourceName())) {
+ setMessage(
+ Messages.bind(
+ Messages.InitModelWizard_diagram_name_is_different_from_domain_model,
+ myDiagramResourceName), ERROR);
+ setPageComplete(false);
+ }
+ }
+ };
+
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/wizards/NewModelPage.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/wizards/NewModelPage.java
new file mode 100644
index 00000000000..571820d96bc
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/wizards/NewModelPage.java
@@ -0,0 +1,389 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.uml.diagram.internal.ui.wizards;
+
+import static org.eclipse.papyrus.uml.diagram.wizards.utils.WizardsHelper.adapt;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
+import org.eclipse.emf.cdo.eresource.CDOResourceNode;
+import org.eclipse.emf.cdo.util.CDOURIUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.core.IInternalPapyrusRepository;
+import org.eclipse.papyrus.cdo.internal.ui.views.ModelRepositoryItemProvider;
+import org.eclipse.papyrus.uml.diagram.wizards.Activator;
+import org.eclipse.papyrus.uml.diagram.wizards.Messages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+
+import com.google.common.base.Strings;
+import com.google.common.eventbus.EventBus;
+import com.google.common.eventbus.Subscribe;
+
+/**
+ * This is the NewModelPage type. Enjoy.
+ */
+public class NewModelPage
+ extends WizardPage {
+
+ public static final String PAGE_ID = "NewCDOModel"; //$NON-NLS-1$
+
+ private Text folderText;
+
+ private TreeViewer foldersTree;
+
+ private Text nameText;
+
+ private IPapyrusRepository repository;
+
+ private CDOResourceNode selectedNode;
+
+ private boolean synchronizingFolderSelection;
+
+ public NewModelPage(IStructuredSelection selection, EventBus bus,
+ String modelKindName) {
+
+ super(PAGE_ID);
+
+ setTitle(NLS.bind("New {0} Model", modelKindName));
+ setDescription(NLS.bind("Create a new {0} model", modelKindName));
+
+ if (!selection.isEmpty()) {
+ selectedNode = adapt(selection.getFirstElement(),
+ CDOResourceNode.class);
+ if ((selectedNode != null)
+ && !(selectedNode instanceof CDOResourceFolder)) {
+ selectedNode = selectedNode.getFolder();
+ }
+ }
+
+ bus.register(this);
+ }
+
+ public void createControl(Composite parent) {
+ Composite myComposite = new Composite(parent, SWT.NONE);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(myComposite);
+ myComposite.setLayout(new GridLayout(2, false));
+
+ Label label = new Label(myComposite, SWT.NONE);
+ label.setText("Enter or select the parent folder:");
+ GridDataFactory.swtDefaults().span(2, 1).applyTo(label);
+
+ folderText = new Text(myComposite, SWT.BORDER);
+ GridDataFactory.fillDefaults().grab(true, false).span(2, 1)
+ .applyTo(folderText);
+ updateFolderSelection();
+
+ foldersTree = new TreeViewer(myComposite, SWT.BORDER | SWT.V_SCROLL
+ | SWT.H_SCROLL);
+ GridDataFactory.fillDefaults().grab(true, true).span(2, 1)
+ .applyTo(foldersTree.getControl());
+ ModelRepositoryItemProvider itemProvider = new ModelRepositoryItemProvider(
+ null);
+ foldersTree.setContentProvider(itemProvider);
+ foldersTree
+ .setLabelProvider(new DecoratingLabelProvider(itemProvider,
+ PlatformUI.getWorkbench().getDecoratorManager()
+ .getLabelDecorator()));
+ foldersTree.setSorter(itemProvider);
+ if (getRepository() != null) {
+ foldersTree.setInput(getRepository());
+ }
+ if (selectedNode != null) {
+ foldersTree.setSelection(new StructuredSelection(selectedNode));
+ }
+
+ new Label(myComposite, SWT.NONE).setText("Resource name:");
+
+ nameText = new Text(myComposite, SWT.BORDER);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText);
+ nameText.setText(suggestName("model", "di"));
+
+ setControl(myComposite);
+
+ folderText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ findFolderSelection();
+ validatePage();
+ }
+ });
+
+ foldersTree
+ .addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event
+ .getSelection();
+ selectedNode = selection.isEmpty()
+ ? null
+ : adapt(selection.getFirstElement(),
+ CDOResourceNode.class);
+ updateFolderSelection();
+ validatePage();
+ }
+ });
+
+ nameText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ validatePage();
+ }
+ });
+
+ validatePage();
+ }
+
+ @Subscribe
+ public void setRepository(IPapyrusRepository repository) {
+ this.repository = repository;
+
+ if (foldersTree != null) {
+ foldersTree.setInput(repository);
+ }
+
+ validatePage();
+ }
+
+ private IInternalPapyrusRepository getRepository() {
+ return ((IInternalPapyrusRepository) repository);
+ }
+
+ CDOView getView() {
+ IInternalPapyrusRepository repo = getRepository();
+ return (repo == null)
+ ? null
+ : repo.getMasterView();
+ }
+
+ String getSelectedFolderPath() {
+ return folderText.getText().trim();
+ }
+
+ void updateFolderSelection() {
+ whileSynchronizingFolderSelection(new Runnable() {
+
+ public void run() {
+ CDOResourceFolder selected = null;
+ if (selectedNode instanceof CDOResourceFolder) {
+ selected = (CDOResourceFolder) selectedNode;
+ } else if (selectedNode != null) {
+ // will be null if the selectedNode is contained by the root
+ // resource
+ selected = selectedNode.getFolder();
+ }
+
+ if (selected == null) {
+ folderText.setText("");
+ } else {
+ folderText.setText(selected.getPath());
+ }
+ }
+ });
+ }
+
+ void findFolderSelection() {
+ whileSynchronizingFolderSelection(new Runnable() {
+
+ public void run() {
+ String folder = folderText.getText().trim();
+ CDOView view = getView();
+ if (view != null) {
+ try {
+ foldersTree.setSelection(new StructuredSelection(view
+ .getResourceNode(folder)));
+ } catch (Exception e) {
+ // normal occurrence when the folder doesn't exist
+ }
+ }
+ }
+ });
+ }
+
+ private void whileSynchronizingFolderSelection(Runnable runnable) {
+ if (!synchronizingFolderSelection) {
+ synchronizingFolderSelection = true;
+
+ try {
+ runnable.run();
+ } finally {
+ synchronizingFolderSelection = false;
+ }
+ }
+ }
+
+ String suggestName(String baseName, String extension) {
+ String result = String.format("%s.%s", baseName, extension);
+ CDOView view = getView();
+
+ if (view != null) {
+ for (int i = 1;; i++) {
+ if (!view.hasResource(getNewResourcePath(result))) {
+ break;
+ } else {
+ // use %s instead of %d to avoid any thousands separators
+ // (hah! that there should be so many models)
+ result = String.format("%s%s.%s", baseName, i, extension);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ String getNewResourcePath(String name) {
+ String result = null;
+ String path = getSelectedFolderPath();
+
+ if (path.equals("")) {
+ // it's a resource in the root
+ result = "/" + name;
+ } else {
+ StringBuilder buf = new StringBuilder();
+
+ if (!path.startsWith("/")) {
+ buf.append("/");
+ }
+ buf.append(path);
+ if (!path.endsWith("/")) {
+ buf.append("/");
+ }
+ buf.append(name);
+
+ result = buf.toString();
+ }
+
+ return result;
+ }
+
+ String getNewResourceName() {
+ return (nameText == null)
+ ? null
+ : nameText.getText().trim();
+ }
+
+ void setNewResourceName(String newName) {
+ nameText.setText(newName.trim());
+ }
+
+ public URI createNewModelResourceURI() {
+ return CDOURIUtil.createResourceURI(getView(),
+ getNewResourcePath(getNewResourceName()));
+ }
+
+ private String getExtension() {
+ String result = null;
+ String name = getNewResourceName();
+
+ if (name != null) {
+ // the proper extension is whatever follows the *last* '.',
+ // but for our purposes we need e.g. "profile.uml" to be
+ // an extension
+ int dot = name.indexOf('.');
+ if (dot >= 0) {
+ result = name.substring(dot + 1);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Diagram extension changed.
+ *
+ * @param newExtension
+ * the new extension
+ * @return result of validation of the new extension
+ */
+ public IStatus diagramExtensionChanged(String newExtension) {
+ String currentExtension = getExtension();
+ if (!newExtension.equals(currentExtension)) {
+
+ String oldFileName = getNewResourceName();
+ String base = oldFileName;
+ if (currentExtension != null) {
+ // take one off for the '.'
+ base = base.substring(0,
+ base.length() - currentExtension.length() - 1);
+ }
+ String newFileName = suggestName(base, newExtension);
+
+ setNewResourceName(newFileName);
+
+ String message1 = Messages.NewModelFilePage_new_diagram_category_needs_specific_extension;
+ String message2 = Messages.bind(
+ Messages.NewModelFilePage_diagram_file_was_renamed,
+ oldFileName, newFileName);
+ String message = message1 + message2;
+ Status resultStatus = new Status(Status.INFO, Activator.PLUGIN_ID,
+ message);
+
+ String errorMessage = getErrorMessage();
+ if (errorMessage != null) {
+ resultStatus = new Status(Status.ERROR, Activator.PLUGIN_ID,
+ errorMessage);
+ }
+ return resultStatus;
+ }
+ return Status.OK_STATUS;
+ }
+
+ void validatePage() {
+ setMessage(null, NONE);
+ setPageComplete(true);
+
+ String name = getNewResourceName();
+ if (getView() == null) {
+ setMessage("No repository is selected.", ERROR);
+ setPageComplete(false);
+ } else if (Strings.isNullOrEmpty(name)) {
+ setMessage("The new model resource name is required.", ERROR);
+ setPageComplete(false);
+ } else {
+ String path = getNewResourcePath(name);
+ if (getView().hasResource(path)) {
+ setMessage(
+ NLS.bind("The resource \"{0}\" already exists.", path),
+ ERROR);
+ setPageComplete(false);
+ } else {
+ // check existence of folder (if any)
+ String folderPath = getSelectedFolderPath();
+ if (!Strings.isNullOrEmpty(folderPath)) {
+ if (!getView().hasResource(folderPath)) {
+ setMessage(
+ "The specified folder does not exist and will be created.",
+ WARNING);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/wizards/RepositorySelectionPart.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/wizards/RepositorySelectionPart.java
new file mode 100644
index 00000000000..beaee4e54cc
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.diagram.ui/src/org/eclipse/papyrus/cdo/uml/diagram/internal/ui/wizards/RepositorySelectionPart.java
@@ -0,0 +1,80 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.uml.diagram.internal.ui.wizards;
+
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.ui.wizards.RepositorySelectionBlock;
+import org.eclipse.papyrus.uml.diagram.wizards.AbstractSelectStorageProviderPart;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import com.google.common.base.Supplier;
+import com.google.common.eventbus.EventBus;
+import com.google.common.eventbus.Subscribe;
+
+/**
+ * This is the RepositorySelectionPart type. Enjoy.
+ */
+public class RepositorySelectionPart
+ extends AbstractSelectStorageProviderPart {
+
+ private final IPapyrusRepositoryManager repoMan;
+
+ private final Supplier<? extends IRunnableContext> runnableContext;
+
+ private final EventBus bus;
+
+ private RepositorySelectionBlock repoSelectionBlock;
+
+ public RepositorySelectionPart(IPapyrusRepositoryManager repoMan,
+ EventBus bus, Supplier<? extends IRunnableContext> runnableContext) {
+
+ super();
+
+ this.repoMan = repoMan;
+ this.runnableContext = runnableContext;
+ this.bus = bus;
+ }
+
+ public Control createControl(Composite parent) {
+ bus.register(this);
+
+ repoSelectionBlock = new RepositorySelectionBlock(repoMan, bus,
+ runnableContext);
+
+ return repoSelectionBlock.createControl(parent);
+ }
+
+ @Override
+ protected void enableControls(boolean enabled) {
+ repoSelectionBlock.setEnabled(enabled);
+ }
+
+ public IPapyrusRepository getSelectedRepository() {
+ return (repoSelectionBlock == null)
+ ? null
+ : repoSelectionBlock.getSelectedRepository();
+ }
+
+ @Subscribe
+ public void setSelectedRepository(IPapyrusRepository repository) {
+ firePartCompleteChanged();
+ }
+
+ public boolean isPartComplete() {
+ return (getSelectedRepository() != null)
+ && getSelectedRepository().isConnected();
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/.classpath b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/.classpath
new file mode 100644
index 00000000000..64c5e31b7a2
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/.project b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/.project
new file mode 100644
index 00000000000..73c4ef9fd8d
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.cdo.uml.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/.settings/org.eclipse.jdt.core.prefs b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..af0f20f97a5
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/META-INF/MANIFEST.MF b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..84a1f940070
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-Vendor: %providerName
+Bundle-SymbolicName: org.eclipse.papyrus.cdo.uml.ui;singleton:=true
+Bundle-Version: 0.10.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.cdo.uml.internal.ui.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0",
+ org.eclipse.papyrus.uml.tools;bundle-version="0.10.0",
+ org.eclipse.papyrus.cdo.ui;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.widgets;bundle-version="0.10.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Import-Package: com.google.common.base;version="10.0.1",
+ com.google.common.collect;version="10.0.1"
+Export-Package: org.eclipse.papyrus.cdo.uml.internal.ui,
+ org.eclipse.papyrus.cdo.uml.internal.ui.importsources
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/about.html b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/about.html
new file mode 100644
index 00000000000..209103075a7
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>November 14, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/build.properties b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/build.properties
new file mode 100644
index 00000000000..f70828ba55f
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/build.properties
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ plugin.properties,\
+ plugin.xml
+src.includes = about.html
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/plugin.properties b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/plugin.properties
new file mode 100644
index 00000000000..ee471afc1a3
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/plugin.properties
@@ -0,0 +1,13 @@
+# Copyright (c) 2013 CEA LIST.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# CEA LIST - Initial API and implementation
+#
+
+pluginName = Papyrus CDO UML UI (Incubation)
+providerName = Eclipse Modeling Project
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/plugin.xml b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/plugin.xml
new file mode 100644
index 00000000000..0a442ce04a1
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/plugin.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.uml.tools.importSources">
+ <importSource
+ class="org.eclipse.papyrus.cdo.uml.internal.ui.importsources.CDOPackageImportSource"
+ name="Model Repositories">
+ <enablement>
+ <iterate>
+ <or>
+ <adapt
+ type="org.eclipse.emf.ecore.EObject">
+ <test
+ property="org.eclipse.papyrus.cdo.core.isCDOObject">
+ </test>
+ <instanceof
+ value="org.eclipse.uml2.uml.Package">
+ </instanceof>
+ </adapt>
+ </or>
+ </iterate>
+ </enablement>
+ </importSource>
+ </extension>
+
+</plugin>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/src/org/eclipse/papyrus/cdo/uml/internal/ui/Activator.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/src/org/eclipse/papyrus/cdo/uml/internal/ui/Activator.java
new file mode 100644
index 00000000000..655981349d4
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/src/org/eclipse/papyrus/cdo/uml/internal/ui/Activator.java
@@ -0,0 +1,51 @@
+package org.eclipse.papyrus.cdo.uml.internal.ui;
+
+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.cdo.uml.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /** Logging helper */
+ public static LogHelper log = new LogHelper();
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ super();
+ }
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+
+ // register the log helper
+ log.setPlugin(plugin);
+ }
+
+ 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/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/src/org/eclipse/papyrus/cdo/uml/internal/ui/importsources/CDOPackageImportSource.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/src/org/eclipse/papyrus/cdo/uml/internal/ui/importsources/CDOPackageImportSource.java
new file mode 100644
index 00000000000..7753e763ee4
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.uml.ui/src/org/eclipse/papyrus/cdo/uml/internal/ui/importsources/CDOPackageImportSource.java
@@ -0,0 +1,219 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.uml.internal.ui.importsources;
+
+import static org.eclipse.papyrus.cdo.internal.ui.Activator.ICON_PAPYRUS_MODEL;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepository;
+import org.eclipse.papyrus.cdo.core.IPapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
+import org.eclipse.papyrus.cdo.internal.core.PapyrusRepositoryManager;
+import org.eclipse.papyrus.cdo.internal.ui.SharedImages;
+import org.eclipse.papyrus.cdo.internal.ui.views.DIModel;
+import org.eclipse.papyrus.cdo.internal.ui.views.ModelRepositoryItemProvider;
+import org.eclipse.papyrus.cdo.uml.internal.ui.Activator;
+import org.eclipse.papyrus.infra.widgets.providers.DelegatingLabelProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.StaticContentProvider;
+import org.eclipse.papyrus.uml.tools.importsources.AbstractPackageImportSource;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * This is the CDOPackageImportSource type. Enjoy.
+ */
+public class CDOPackageImportSource
+ extends AbstractPackageImportSource {
+
+ private final IPapyrusRepositoryManager repoMan = PapyrusRepositoryManager.INSTANCE;
+
+ private List<IPapyrusRepository> availableRepos;
+
+ private ModelRepositoryItemProvider itemProvider;
+
+ public CDOPackageImportSource() {
+ super();
+ }
+
+ @Override
+ public boolean canImportInto(Collection<?> selection) {
+ boolean result = super.canImportInto(selection);
+
+ if (result) {
+ Package package_ = getPackage(selection);
+ result = CDOUtils.isCDOObject(package_);
+ }
+
+ return result;
+ }
+
+ @Override
+ public void initialize(Collection<?> selection) {
+ availableRepos = new java.util.ArrayList<IPapyrusRepository>();
+ for (IPapyrusRepository next : repoMan.getRepositories()) {
+ if (next.isConnected()) {
+ availableRepos.add(next);
+ }
+ }
+
+ itemProvider = new ModelRepositoryItemProvider(PlatformUI
+ .getWorkbench().getActiveWorkbenchWindow().getActivePage());
+ }
+
+ @Override
+ public void dispose() {
+ availableRepos = null;
+ itemProvider = null;
+
+ super.dispose();
+ }
+
+ @Override
+ protected IStaticContentProvider createModelHierarchyContentProvider() {
+ return new CDOContent();
+ }
+
+ @Override
+ protected ILabelProvider createModelHierarchyLabelProvider() {
+ return new DelegatingLabelProvider(itemProvider) {
+
+ @Override
+ protected Image customGetImage(Object element) {
+ Image result = null;
+
+ if (element == CDOPackageImportSource.this) {
+ result = SharedImages.getImage(ICON_PAPYRUS_MODEL);
+ }
+
+ return result;
+ }
+
+ @Override
+ protected String customGetText(Object element) {
+ String result = null;
+
+ if (element == CDOPackageImportSource.this) {
+ result = "Model Repositories";
+ }
+
+ return result;
+ }
+ };
+ }
+
+ protected CDOResource getCDOResource(Object model) {
+ CDOResource result = null;
+
+ if (model instanceof CDOResource) {
+ result = (CDOResource) model;
+ } else if (model instanceof IAdaptable) {
+ result = (CDOResource) ((IAdaptable) model)
+ .getAdapter(CDOResource.class);
+ }
+
+ return result;
+ }
+
+ @Override
+ protected void validateSelection(Object model)
+ throws CoreException {
+
+ CDOResource cdo = getCDOResource(model);
+ if (cdo == null) {
+ throw new CoreException(new Status(IStatus.WARNING,
+ Activator.PLUGIN_ID,
+ NLS.bind("Not a repository model resource: \"{0}\".",
+ getText(model))));
+ }
+
+ super.validateSelection(model);
+ }
+
+ @Override
+ public List<Package> getPackages(ResourceSet resourceSet, Object model)
+ throws CoreException {
+
+ List<Package> result;
+
+ if (model instanceof DIModel) {
+ result = new java.util.ArrayList<Package>(3);
+
+ for (Object next : ((DIModel) model).getChildren()) {
+ if (next instanceof Resource) {
+ result.addAll(EcoreUtil.<Package> getObjectsByType(
+ ((Resource) next).getContents(),
+ UMLPackage.Literals.PACKAGE));
+ }
+ }
+ } else {
+ result = super.getPackages(resourceSet, getCDOResource(model));
+ }
+
+ return result;
+ }
+
+ //
+ // Nested types
+ //
+
+ private class CDOContent
+ extends StaticContentProvider
+ implements ITreeContentProvider {
+
+ CDOContent() {
+ super(availableRepos.toArray());
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ if (newInput == null) {
+ itemProvider.inputChanged(viewer, repoMan, null);
+ } else {
+ // substitute the repository manager as the input element
+ itemProvider.inputChanged(viewer, null, repoMan);
+
+ // prime the internal nodes for the repositories
+ itemProvider.getChildren(repoMan);
+ }
+ }
+
+ public Object getParent(Object element) {
+ return itemProvider.getParent(element);
+ }
+
+ public boolean hasChildren(Object element) {
+ return itemProvider.hasChildren(element);
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ return itemProvider.getChildren(parentElement);
+ }
+
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.classpath b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.classpath
new file mode 100644
index 00000000000..304e86186aa
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.project b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.project
new file mode 100644
index 00000000000..906f6c2e275
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.cdo.validation.problems.edit</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.settings/org.eclipse.jdt.core.prefs b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..af0f20f97a5
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.settings/org.eclipse.jdt.ui.prefs b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 00000000000..519a89bef67
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.ui.javadoc=false
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*****************************************************************************\n * Copyright (c) ${year} CEA LIST.\n * \n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors\:\n * CEA LIST - Initial API and implementation\n *****************************************************************************/</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * This is the ${type_name} type. Enjoy.\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/META-INF/MANIFEST.MF b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..281e1ae7f5c
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.cdo.validation.problems.edit;singleton:=true
+Bundle-Version: 0.10.0.qualifier
+Bundle-ClassPath: .
+Bundle-Activator: org.eclipse.papyrus.cdo.validation.problems.provider.ProblemsEditPlugin$Implementation
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.papyrus.cdo.validation.problems.edit,
+ org.eclipse.papyrus.cdo.validation.problems.provider
+Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.8.0,4.0.0)",
+ org.eclipse.papyrus.cdo.validation.problems;bundle-version="[0.10.0,1.0.0)";visibility:=reexport,
+ org.eclipse.emf.edit;bundle-version="[2.8.0,3.0.0)";visibility:=reexport
+Bundle-ActivationPolicy: lazy
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/about.html b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/about.html
new file mode 100644
index 00000000000..209103075a7
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>November 14, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/build.properties b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/build.properties
new file mode 100644
index 00000000000..2e492547c5a
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/build.properties
@@ -0,0 +1,20 @@
+# Copyright (c) 2004 - 2013 Eike Stepper (Berlin, Germany) 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:
+# Christian W. Damus (CEA) - initial API and implementation
+
+jars.compile.order = .
+source.. = src/
+output.. = bin/
+
+bin.includes = .,\
+ icons/,\
+ META-INF/,\
+ plugin.xml,\
+ plugin.properties,\
+ about.html
+src.includes = about.html
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/ctool16/CreateEProblemsContainer_problems_EProblem.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/ctool16/CreateEProblemsContainer_problems_EProblem.gif
new file mode 100644
index 00000000000..23b48484db5
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/ctool16/CreateEProblemsContainer_problems_EProblem.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/ctool16/CreateEProblemsContainer_subcontainers_EProblemsContainer.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/ctool16/CreateEProblemsContainer_subcontainers_EProblemsContainer.gif
new file mode 100644
index 00000000000..c31e7a2bca9
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/ctool16/CreateEProblemsContainer_subcontainers_EProblemsContainer.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/obj16/EProblem.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/obj16/EProblem.gif
new file mode 100644
index 00000000000..b1f8afa4766
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/obj16/EProblem.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/obj16/EProblemsContainer.gif b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/obj16/EProblemsContainer.gif
new file mode 100644
index 00000000000..35ef84e20e2
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/icons/full/obj16/EProblemsContainer.gif
Binary files differ
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/plugin.properties b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/plugin.properties
new file mode 100644
index 00000000000..051d92b9217
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/plugin.properties
@@ -0,0 +1,49 @@
+# Copyright (c) 2013 CEA LIST.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# CEA LIST - Initial API and implementation
+#
+
+pluginName = Papyrus CDO Model Repository Problems Model Edit Support (Incubation)
+providerName = Eclipse Modeling Project
+
+_UI_problem_type = Papyrus Problem
+
+_UI_CreateChild_text = {0}
+_UI_CreateChild_text2 = {1} {0}
+_UI_CreateChild_text3 = {1}
+_UI_CreateChild_tooltip = Create New {0} Under {1} Feature
+_UI_CreateChild_description = Create a new child of type {0} for the {1} feature of the selected {2}.
+_UI_CreateSibling_description = Create a new sibling of type {0} for the selected {2}, under the {1} feature of their parent.
+
+_UI_PropertyDescriptor_description = The {0} of the {1}
+
+_UI_EProblem_type = EProblem
+_UI_EProblemsContainer_type = EProblems Container
+_UI_Unknown_type = Object
+
+_UI_Unknown_datatype= Value
+
+_UI_EProblem_severity_feature = Severity
+_UI_EProblem_message_feature = Message
+_UI_EProblem_source_feature = Source
+_UI_EProblem_code_feature = Code
+_UI_EProblem_element_feature = Element
+_UI_EProblem_related_feature = Related
+_UI_EProblem_container_feature = Container
+_UI_EProblemsContainer_problems_feature = Problems
+_UI_EProblemsContainer_subjects_feature = Subjects
+_UI_EProblemsContainer_subcontainers_feature = Subcontainers
+_UI_EProblemsContainer_container_feature = Container
+_UI_Unknown_feature = Unspecified
+
+_UI_ESeverity_OK_literal = OK
+_UI_ESeverity_INFO_literal = INFO
+_UI_ESeverity_WARNING_literal = WARNING
+_UI_ESeverity_ERROR_literal = ERROR
+_UI_ESeverity_CANCEL_literal = CANCEL
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/plugin.xml b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/plugin.xml
new file mode 100644
index 00000000000..8dfd207ed9e
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/plugin.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<!--
+ Copyright (c) 2013 CEA LIST.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ CEA LIST - Initial API and implementation
+
+-->
+
+<plugin>
+
+ <extension point="org.eclipse.emf.edit.itemProviderAdapterFactories">
+ <!-- @generated Problems -->
+ <factory
+ uri="http://www.eclipse.org/emf/CDO/defs/1.0.0"
+ class="org.eclipse.papyrus.cdo.validation.problems.provider.ProblemsItemProviderAdapterFactory"
+ supportedTypes=
+ "org.eclipse.emf.edit.provider.IEditingDomainItemProvider
+ org.eclipse.emf.edit.provider.IStructuredItemContentProvider
+ org.eclipse.emf.edit.provider.ITreeItemContentProvider
+ org.eclipse.emf.edit.provider.IItemLabelProvider
+ org.eclipse.emf.edit.provider.IItemPropertySource
+ org.eclipse.emf.edit.provider.ITableItemLabelProvider
+ org.eclipse.emf.edit.provider.ITableItemColorProvider
+ org.eclipse.emf.edit.provider.ITableItemFontProvider
+ org.eclipse.emf.edit.provider.IItemColorProvider
+ org.eclipse.emf.edit.provider.IItemFontProvider"/>
+ </extension>
+
+</plugin>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/edit/IProblemTypeProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/edit/IProblemTypeProvider.java
new file mode 100644
index 00000000000..19084d82525
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/edit/IProblemTypeProvider.java
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.validation.problems.edit;
+
+import org.eclipse.papyrus.cdo.validation.problems.EProblem;
+
+/**
+ * Optional protocol for edit providers to provide a "problem type" for an
+ * {@link EProblem}. This is intended for models that extend the CDO Problems
+ * model to provide custom problems.
+ */
+public interface IProblemTypeProvider {
+
+ public String getProblemType(Object object);
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/edit/ProblemEditUtil.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/edit/ProblemEditUtil.java
new file mode 100644
index 00000000000..79819b78820
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/edit/ProblemEditUtil.java
@@ -0,0 +1,115 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.validation.problems.edit;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.AdapterFactory;
+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.EPackage;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.papyrus.cdo.validation.problems.EProblem;
+
+/**
+ * Utilities for accessing edit-provider information about {@link EProblem}s.
+ */
+public class ProblemEditUtil {
+
+ private AdapterFactory adapterFactory;
+
+ private DefaultProblemTypeProviderAdapter defaultAdapter;
+
+ public ProblemEditUtil(AdapterFactory adapterFactory) {
+ this.adapterFactory = adapterFactory;
+ }
+
+ public String getProblemType(EProblem problem) {
+ IProblemTypeProvider provider = getProblemTypeProvider(problem);
+ return provider.getProblemType(problem);
+ }
+
+ protected IProblemTypeProvider getProblemTypeProvider(EProblem problem) {
+ Adapter provider = adapterFactory.adapt(problem,
+ IProblemTypeProvider.class);
+ IProblemTypeProvider result = provider instanceof IProblemTypeProvider
+ ? (IProblemTypeProvider) provider
+ : null;
+
+ if (result == null) {
+ for (Adapter next : problem.eAdapters()) {
+ if (next instanceof IProblemTypeProvider) {
+ result = (IProblemTypeProvider) next;
+ break;
+ }
+ }
+ }
+
+ if (result == null) {
+ DefaultProblemTypeProviderAdapter adapter = getDefaultProblemTypeProvider();
+ problem.eAdapters().add(adapter);
+ result = adapter;
+ }
+
+ return result;
+ }
+
+ protected DefaultProblemTypeProviderAdapter getDefaultProblemTypeProvider() {
+ if (defaultAdapter == null) {
+ defaultAdapter = new DefaultProblemTypeProviderAdapter();
+ }
+ return defaultAdapter;
+ }
+
+ protected class DefaultProblemTypeProviderAdapter
+ implements Adapter, IProblemTypeProvider {
+
+ public String getProblemType(Object object) {
+ String result = null;
+
+ if (object instanceof EProblem) {
+ EProblem problem = (EProblem) object;
+ EObject element = problem.getElement();
+ if (element != null) {
+ EPackage model = element.eClass().getEPackage();
+ IItemLabelProvider labels = (IItemLabelProvider) adapterFactory
+ .adapt(model, IItemLabelProvider.class);
+ if (labels != null) {
+ result = labels.getText(model);
+ } else {
+ result = model.getName();
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public boolean isAdapterForType(Object type) {
+ return false;
+ }
+
+ public Notifier getTarget() {
+ // I am stateless, so I am re-used on multiple targets
+ return null;
+ }
+
+ public void setTarget(Notifier newTarget) {
+ // pass
+ }
+
+ public void notifyChanged(Notification notification) {
+ // pass
+ }
+
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/edit/ProblemTypeItemProviderAdapter.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/edit/ProblemTypeItemProviderAdapter.java
new file mode 100644
index 00000000000..3afbb49f722
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/edit/ProblemTypeItemProviderAdapter.java
@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.validation.problems.edit;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.edit.provider.ItemProviderAdapter;
+
+/**
+ * Convenient base class for generated item provider adapters to implement the
+ * {@link IProblemTypeProvider} protocol.
+ */
+public class ProblemTypeItemProviderAdapter
+ extends ItemProviderAdapter
+ implements IProblemTypeProvider {
+
+ public ProblemTypeItemProviderAdapter(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ public String getProblemType(Object object) {
+ return getString("_UI_problem_type", true); //$NON-NLS-1$
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/EProblemItemProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/EProblemItemProvider.java
new file mode 100644
index 00000000000..0a4cf516fe6
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/EProblemItemProvider.java
@@ -0,0 +1,285 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems.provider;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.ResourceLocator;
+import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
+import org.eclipse.emf.edit.provider.IChildCreationExtender;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemColorProvider;
+import org.eclipse.emf.edit.provider.IItemFontProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITableItemColorProvider;
+import org.eclipse.emf.edit.provider.ITableItemFontProvider;
+import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.ViewerNotification;
+import org.eclipse.papyrus.cdo.validation.problems.EProblem;
+import org.eclipse.papyrus.cdo.validation.problems.ESeverity;
+import org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage;
+import org.eclipse.papyrus.cdo.validation.problems.edit.ProblemTypeItemProviderAdapter;
+
+/**
+ * This is the item provider adapter for a
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem} object. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+public class EProblemItemProvider
+ extends ProblemTypeItemProviderAdapter
+ implements IEditingDomainItemProvider, IStructuredItemContentProvider,
+ ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource,
+ ITableItemLabelProvider, ITableItemColorProvider,
+ ITableItemFontProvider, IItemColorProvider, IItemFontProvider {
+
+ /**
+ * This constructs an instance from a factory and a notifier. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EProblemItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * This returns the property descriptors for the adapted class. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
+ if (itemPropertyDescriptors == null) {
+ super.getPropertyDescriptors(object);
+
+ addSeverityPropertyDescriptor(object);
+ addMessagePropertyDescriptor(object);
+ addSourcePropertyDescriptor(object);
+ addCodePropertyDescriptor(object);
+ addElementPropertyDescriptor(object);
+ addRelatedPropertyDescriptor(object);
+ }
+ return itemPropertyDescriptors;
+ }
+
+ /**
+ * This adds a property descriptor for the Severity feature. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected void addSeverityPropertyDescriptor(Object object) {
+ itemPropertyDescriptors
+ .add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory) adapterFactory)
+ .getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_EProblem_severity_feature"), //$NON-NLS-1$
+ getString(
+ "_UI_PropertyDescriptor_description", "_UI_EProblem_severity_feature", "_UI_EProblem_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ProblemsPackage.Literals.EPROBLEM__SEVERITY, true, false,
+ false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
+ }
+
+ /**
+ * This adds a property descriptor for the Message feature. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected void addMessagePropertyDescriptor(Object object) {
+ itemPropertyDescriptors
+ .add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory) adapterFactory)
+ .getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_EProblem_message_feature"), //$NON-NLS-1$
+ getString(
+ "_UI_PropertyDescriptor_description", "_UI_EProblem_message_feature", "_UI_EProblem_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ProblemsPackage.Literals.EPROBLEM__MESSAGE, true, false, false,
+ ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
+ }
+
+ /**
+ * This adds a property descriptor for the Source feature. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected void addSourcePropertyDescriptor(Object object) {
+ itemPropertyDescriptors
+ .add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory) adapterFactory)
+ .getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_EProblem_source_feature"), //$NON-NLS-1$
+ getString(
+ "_UI_PropertyDescriptor_description", "_UI_EProblem_source_feature", "_UI_EProblem_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ProblemsPackage.Literals.EPROBLEM__SOURCE, true, false, false,
+ ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
+ }
+
+ /**
+ * This adds a property descriptor for the Code feature. <!-- begin-user-doc
+ * --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected void addCodePropertyDescriptor(Object object) {
+ itemPropertyDescriptors
+ .add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory) adapterFactory)
+ .getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_EProblem_code_feature"), //$NON-NLS-1$
+ getString(
+ "_UI_PropertyDescriptor_description", "_UI_EProblem_code_feature", "_UI_EProblem_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ProblemsPackage.Literals.EPROBLEM__CODE, true, false, false,
+ ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
+ }
+
+ /**
+ * This adds a property descriptor for the Element feature. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected void addElementPropertyDescriptor(Object object) {
+ itemPropertyDescriptors
+ .add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory) adapterFactory)
+ .getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_EProblem_element_feature"), //$NON-NLS-1$
+ getString(
+ "_UI_PropertyDescriptor_description", "_UI_EProblem_element_feature", "_UI_EProblem_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ProblemsPackage.Literals.EPROBLEM__ELEMENT, true, false, true,
+ null, null, null));
+ }
+
+ /**
+ * This adds a property descriptor for the Related feature. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected void addRelatedPropertyDescriptor(Object object) {
+ itemPropertyDescriptors
+ .add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory) adapterFactory)
+ .getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_EProblem_related_feature"), //$NON-NLS-1$
+ getString(
+ "_UI_PropertyDescriptor_description", "_UI_EProblem_related_feature", "_UI_EProblem_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ProblemsPackage.Literals.EPROBLEM__RELATED, true, false, true,
+ null, null, null));
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public boolean hasChildren(Object object) {
+ return hasChildren(object, true);
+ }
+
+ /**
+ * This returns EProblem.gif. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public Object getImage(Object object) {
+ return overlayImage(object,
+ getResourceLocator().getImage("full/obj16/EProblem")); //$NON-NLS-1$
+ }
+
+ /**
+ * This returns the label text for the adapted class. <!-- begin-user-doc
+ * --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public String getText(Object object) {
+ ESeverity labelValue = ((EProblem) object).getSeverity();
+ String label = labelValue == null
+ ? null
+ : labelValue.toString();
+ return label == null || label.length() == 0
+ ? getString("_UI_EProblem_type") : //$NON-NLS-1$
+ getString("_UI_EProblem_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * This handles model notifications by calling {@link #updateChildren} to
+ * update any cached children and by creating a viewer notification, which
+ * it passes to {@link #fireNotifyChanged}. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ updateChildren(notification);
+
+ switch (notification.getFeatureID(EProblem.class)) {
+ case ProblemsPackage.EPROBLEM__SEVERITY :
+ case ProblemsPackage.EPROBLEM__MESSAGE :
+ case ProblemsPackage.EPROBLEM__SOURCE :
+ case ProblemsPackage.EPROBLEM__CODE :
+ fireNotifyChanged(new ViewerNotification(notification,
+ notification.getNotifier(), false, true));
+ return;
+ }
+ super.notifyChanged(notification);
+ }
+
+ /**
+ * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s
+ * describing the children that can be created under this object. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ protected void collectNewChildDescriptors(
+ Collection<Object> newChildDescriptors, Object object) {
+ super.collectNewChildDescriptors(newChildDescriptors, object);
+ }
+
+ /**
+ * Return the resource locator for this item provider's resources. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public ResourceLocator getResourceLocator() {
+ return ((IChildCreationExtender) adapterFactory).getResourceLocator();
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/EProblemsContainerItemProvider.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/EProblemsContainerItemProvider.java
new file mode 100644
index 00000000000..464c8a4dc2f
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/EProblemsContainerItemProvider.java
@@ -0,0 +1,223 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems.provider;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.ResourceLocator;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
+import org.eclipse.emf.edit.provider.IChildCreationExtender;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemColorProvider;
+import org.eclipse.emf.edit.provider.IItemFontProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITableItemColorProvider;
+import org.eclipse.emf.edit.provider.ITableItemFontProvider;
+import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ViewerNotification;
+import org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer;
+import org.eclipse.papyrus.cdo.validation.problems.ProblemsFactory;
+import org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage;
+import org.eclipse.papyrus.cdo.validation.problems.edit.ProblemTypeItemProviderAdapter;
+
+/**
+ * This is the item provider adapter for a
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer}
+ * object. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+public class EProblemsContainerItemProvider
+ extends ProblemTypeItemProviderAdapter
+ implements IEditingDomainItemProvider, IStructuredItemContentProvider,
+ ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource,
+ ITableItemLabelProvider, ITableItemColorProvider,
+ ITableItemFontProvider, IItemColorProvider, IItemFontProvider {
+
+ /**
+ * This constructs an instance from a factory and a notifier. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EProblemsContainerItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * This returns the property descriptors for the adapted class. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
+ if (itemPropertyDescriptors == null) {
+ super.getPropertyDescriptors(object);
+
+ addSubjectsPropertyDescriptor(object);
+ }
+ return itemPropertyDescriptors;
+ }
+
+ /**
+ * This adds a property descriptor for the Subjects feature. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected void addSubjectsPropertyDescriptor(Object object) {
+ itemPropertyDescriptors
+ .add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory) adapterFactory)
+ .getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_EProblemsContainer_subjects_feature"), //$NON-NLS-1$
+ getString(
+ "_UI_PropertyDescriptor_description", "_UI_EProblemsContainer_subjects_feature", "_UI_EProblemsContainer_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ProblemsPackage.Literals.EPROBLEMS_CONTAINER__SUBJECTS, true,
+ false, true, null, null, null));
+ }
+
+ /**
+ * This specifies how to implement {@link #getChildren} and is used to
+ * deduce an appropriate feature for an
+ * {@link org.eclipse.emf.edit.command.AddCommand},
+ * {@link org.eclipse.emf.edit.command.RemoveCommand} or
+ * {@link org.eclipse.emf.edit.command.MoveCommand} in
+ * {@link #createCommand}. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public Collection<? extends EStructuralFeature> getChildrenFeatures(
+ Object object) {
+ if (childrenFeatures == null) {
+ super.getChildrenFeatures(object);
+ childrenFeatures
+ .add(ProblemsPackage.Literals.EPROBLEMS_CONTAINER__PROBLEMS);
+ childrenFeatures
+ .add(ProblemsPackage.Literals.EPROBLEMS_CONTAINER__SUBCONTAINERS);
+ }
+ return childrenFeatures;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ protected EStructuralFeature getChildFeature(Object object, Object child) {
+ // Check the type of the specified child object and return the proper
+ // feature to use for
+ // adding (see {@link AddCommand}) it as a child.
+
+ return super.getChildFeature(object, child);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public boolean hasChildren(Object object) {
+ return hasChildren(object, true);
+ }
+
+ /**
+ * This returns EProblemsContainer.gif. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public Object getImage(Object object) {
+ return overlayImage(object,
+ getResourceLocator().getImage("full/obj16/EProblemsContainer")); //$NON-NLS-1$
+ }
+
+ /**
+ * This returns the label text for the adapted class. <!-- begin-user-doc
+ * --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public String getText(Object object) {
+ return getString("_UI_EProblemsContainer_type"); //$NON-NLS-1$
+ }
+
+ /**
+ * This handles model notifications by calling {@link #updateChildren} to
+ * update any cached children and by creating a viewer notification, which
+ * it passes to {@link #fireNotifyChanged}. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ updateChildren(notification);
+
+ switch (notification.getFeatureID(EProblemsContainer.class)) {
+ case ProblemsPackage.EPROBLEMS_CONTAINER__PROBLEMS :
+ case ProblemsPackage.EPROBLEMS_CONTAINER__SUBCONTAINERS :
+ fireNotifyChanged(new ViewerNotification(notification,
+ notification.getNotifier(), true, false));
+ return;
+ }
+ super.notifyChanged(notification);
+ }
+
+ /**
+ * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s
+ * describing the children that can be created under this object. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ protected void collectNewChildDescriptors(
+ Collection<Object> newChildDescriptors, Object object) {
+ super.collectNewChildDescriptors(newChildDescriptors, object);
+
+ newChildDescriptors.add(createChildParameter(
+ ProblemsPackage.Literals.EPROBLEMS_CONTAINER__PROBLEMS,
+ ProblemsFactory.eINSTANCE.createEProblem()));
+
+ newChildDescriptors.add(createChildParameter(
+ ProblemsPackage.Literals.EPROBLEMS_CONTAINER__SUBCONTAINERS,
+ ProblemsFactory.eINSTANCE.createEProblemsContainer()));
+ }
+
+ /**
+ * Return the resource locator for this item provider's resources. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public ResourceLocator getResourceLocator() {
+ return ((IChildCreationExtender) adapterFactory).getResourceLocator();
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/ProblemsEditPlugin.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/ProblemsEditPlugin.java
new file mode 100644
index 00000000000..0754e3fd350
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/ProblemsEditPlugin.java
@@ -0,0 +1,97 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems.provider;
+
+import org.eclipse.emf.common.EMFPlugin;
+import org.eclipse.emf.common.util.ResourceLocator;
+
+/**
+ * This is the central singleton for the Problems edit plugin. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+public final class ProblemsEditPlugin
+ extends EMFPlugin {
+
+ /**
+ * Keep track of the singleton. <!-- begin-user-doc --> <!-- end-user-doc
+ * -->
+ *
+ * @generated
+ */
+ public static final ProblemsEditPlugin INSTANCE = new ProblemsEditPlugin();
+
+ /**
+ * Keep track of the singleton. <!-- begin-user-doc --> <!-- end-user-doc
+ * -->
+ *
+ * @generated
+ */
+ private static Implementation plugin;
+
+ /**
+ * Create the instance. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public ProblemsEditPlugin() {
+ super(new ResourceLocator[]{});
+ }
+
+ /**
+ * Returns the singleton instance of the Eclipse plugin. <!-- begin-user-doc
+ * --> <!-- end-user-doc -->
+ *
+ * @return the singleton instance.
+ * @generated
+ */
+ @Override
+ public ResourceLocator getPluginResourceLocator() {
+ return plugin;
+ }
+
+ /**
+ * Returns the singleton instance of the Eclipse plugin. <!-- begin-user-doc
+ * --> <!-- end-user-doc -->
+ *
+ * @return the singleton instance.
+ * @generated
+ */
+ public static Implementation getPlugin() {
+ return plugin;
+ }
+
+ /**
+ * The actual implementation of the Eclipse <b>Plugin</b>. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public static class Implementation
+ extends EclipsePlugin {
+
+ /**
+ * Creates an instance. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public Implementation() {
+ super();
+
+ // Remember the static instance.
+ //
+ plugin = this;
+ }
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/ProblemsItemProviderAdapterFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/ProblemsItemProviderAdapterFactory.java
new file mode 100644
index 00000000000..0d6d358ae1c
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems.edit/src/org/eclipse/papyrus/cdo/validation/problems/provider/ProblemsItemProviderAdapterFactory.java
@@ -0,0 +1,306 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems.provider;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+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.ResourceLocator;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.provider.ChangeNotifier;
+import org.eclipse.emf.edit.provider.ChildCreationExtenderManager;
+import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IChangeNotifier;
+import org.eclipse.emf.edit.provider.IChildCreationExtender;
+import org.eclipse.emf.edit.provider.IDisposable;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemColorProvider;
+import org.eclipse.emf.edit.provider.IItemFontProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.INotifyChangedListener;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITableItemColorProvider;
+import org.eclipse.emf.edit.provider.ITableItemFontProvider;
+import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage;
+import org.eclipse.papyrus.cdo.validation.problems.edit.IProblemTypeProvider;
+import org.eclipse.papyrus.cdo.validation.problems.util.ProblemsAdapterFactory;
+
+/**
+ * This is the factory that is used to provide the interfaces needed to support
+ * Viewers. The adapters generated by this factory convert EMF adapter
+ * notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}. The
+ * adapters also support Eclipse property sheets. Note that most of the adapters
+ * are shared among multiple instances. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+public class ProblemsItemProviderAdapterFactory
+ extends ProblemsAdapterFactory
+ implements ComposeableAdapterFactory, IChangeNotifier, IDisposable,
+ IChildCreationExtender {
+
+ /**
+ * This keeps track of the root adapter factory that delegates to this
+ * adapter factory. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected ComposedAdapterFactory parentAdapterFactory;
+
+ /**
+ * This is used to implement
+ * {@link org.eclipse.emf.edit.provider.IChangeNotifier}. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected IChangeNotifier changeNotifier = new ChangeNotifier();
+
+ /**
+ * This helps manage the child creation extenders. <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected ChildCreationExtenderManager childCreationExtenderManager = new ChildCreationExtenderManager(
+ ProblemsEditPlugin.INSTANCE, ProblemsPackage.eNS_URI);
+
+ /**
+ * This keeps track of all the supported types checked by
+ * {@link #isFactoryForType isFactoryForType}. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ protected Collection<Object> supportedTypes = new ArrayList<Object>();
+
+ {
+ supportedTypes.add(IProblemTypeProvider.class);
+ }
+
+ /**
+ * This constructs an instance. <!-- begin-user-doc --> <!-- end-user-doc
+ * -->
+ *
+ * @generated
+ */
+ public ProblemsItemProviderAdapterFactory() {
+ supportedTypes.add(IEditingDomainItemProvider.class);
+ supportedTypes.add(IStructuredItemContentProvider.class);
+ supportedTypes.add(ITreeItemContentProvider.class);
+ supportedTypes.add(IItemLabelProvider.class);
+ supportedTypes.add(IItemPropertySource.class);
+ supportedTypes.add(ITableItemLabelProvider.class);
+ supportedTypes.add(ITableItemColorProvider.class);
+ supportedTypes.add(ITableItemFontProvider.class);
+ supportedTypes.add(IItemColorProvider.class);
+ supportedTypes.add(IItemFontProvider.class);
+ }
+
+ /**
+ * This keeps track of the one adapter used for all
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem} instances.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected EProblemItemProvider eProblemItemProvider;
+
+ /**
+ * This creates an adapter for a
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem}. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public Adapter createEProblemAdapter() {
+ if (eProblemItemProvider == null) {
+ eProblemItemProvider = new EProblemItemProvider(this);
+ }
+
+ return eProblemItemProvider;
+ }
+
+ /**
+ * This keeps track of the one adapter used for all
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer}
+ * instances. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected EProblemsContainerItemProvider eProblemsContainerItemProvider;
+
+ /**
+ * This creates an adapter for a
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer}.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public Adapter createEProblemsContainerAdapter() {
+ if (eProblemsContainerItemProvider == null) {
+ eProblemsContainerItemProvider = new EProblemsContainerItemProvider(
+ this);
+ }
+
+ return eProblemsContainerItemProvider;
+ }
+
+ /**
+ * This returns the root adapter factory that contains this factory. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public ComposeableAdapterFactory getRootAdapterFactory() {
+ return parentAdapterFactory == null
+ ? this
+ : parentAdapterFactory.getRootAdapterFactory();
+ }
+
+ /**
+ * This sets the composed adapter factory that contains this factory. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void setParentAdapterFactory(
+ ComposedAdapterFactory parentAdapterFactory) {
+ this.parentAdapterFactory = parentAdapterFactory;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public boolean isFactoryForType(Object type) {
+ return supportedTypes.contains(type) || super.isFactoryForType(type);
+ }
+
+ /**
+ * This implementation substitutes the factory itself as the key for the
+ * adapter. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public Adapter adapt(Notifier notifier, Object type) {
+ return super.adapt(notifier, this);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public Object adapt(Object object, Object type) {
+ if (isFactoryForType(type)) {
+ Object adapter = super.adapt(object, type);
+ if (!(type instanceof Class<?>)
+ || (((Class<?>) type).isInstance(adapter))) {
+ return adapter;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public List<IChildCreationExtender> getChildCreationExtenders() {
+ return childCreationExtenderManager.getChildCreationExtenders();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public Collection<?> getNewChildDescriptors(Object object,
+ EditingDomain editingDomain) {
+ return childCreationExtenderManager.getNewChildDescriptors(object,
+ editingDomain);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public ResourceLocator getResourceLocator() {
+ return childCreationExtenderManager;
+ }
+
+ /**
+ * This adds a listener. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void addListener(INotifyChangedListener notifyChangedListener) {
+ changeNotifier.addListener(notifyChangedListener);
+ }
+
+ /**
+ * This removes a listener. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void removeListener(INotifyChangedListener notifyChangedListener) {
+ changeNotifier.removeListener(notifyChangedListener);
+ }
+
+ /**
+ * This delegates to {@link #changeNotifier} and to
+ * {@link #parentAdapterFactory}. <!-- begin-user-doc --> <!-- end-user-doc
+ * -->
+ *
+ * @generated
+ */
+ public void fireNotifyChanged(Notification notification) {
+ changeNotifier.fireNotifyChanged(notification);
+
+ if (parentAdapterFactory != null) {
+ parentAdapterFactory.fireNotifyChanged(notification);
+ }
+ }
+
+ /**
+ * This disposes all of the item providers created by this factory. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void dispose() {
+ if (eProblemItemProvider != null)
+ eProblemItemProvider.dispose();
+ if (eProblemsContainerItemProvider != null)
+ eProblemsContainerItemProvider.dispose();
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.classpath b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.classpath
new file mode 100644
index 00000000000..64c5e31b7a2
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.project b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.project
new file mode 100644
index 00000000000..9aa761218cb
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.cdo.validation.problems</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ </natures>
+</projectDescription>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.settings/org.eclipse.jdt.core.prefs b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..af0f20f97a5
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.settings/org.eclipse.jdt.ui.prefs b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 00000000000..519a89bef67
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.ui.javadoc=false
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*****************************************************************************\n * Copyright (c) ${year} CEA LIST.\n * \n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors\:\n * CEA LIST - Initial API and implementation\n *****************************************************************************/</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * This is the ${type_name} type. Enjoy.\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/META-INF/CDO.MF b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/META-INF/CDO.MF
new file mode 100644
index 00000000000..bbfa1b0550d
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/META-INF/CDO.MF
@@ -0,0 +1 @@
+This is a marker file for bundles with CDO native models.
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/META-INF/MANIFEST.MF b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..8cc289eb8cc
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.cdo.validation.problems;singleton:=true
+Bundle-Version: 0.10.0.qualifier
+Bundle-ClassPath: .
+Bundle-Activator: org.eclipse.papyrus.cdo.validation.problems.internal.ProblemsPlugin$Implementation
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.8.0,4.0.0)",
+ org.eclipse.emf.ecore;visibility:=reexport;bundle-version="[2.8.0,3.0.0)",
+ org.eclipse.emf.cdo;visibility:=reexport;bundle-version="[4.2.0,5.0.0)"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.papyrus.cdo.validation.problems,
+ org.eclipse.papyrus.cdo.validation.problems.impl,
+ org.eclipse.papyrus.cdo.validation.problems.internal,
+ org.eclipse.papyrus.cdo.validation.problems.util
+Bundle-ActivationPolicy: lazy
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/about.html b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/about.html
new file mode 100644
index 00000000000..209103075a7
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>November 14, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/build.properties b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/build.properties
new file mode 100644
index 00000000000..3407e04dba9
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/build.properties
@@ -0,0 +1,23 @@
+# Copyright (c) 2013 CEA LIST.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# CEA LIST - Initial API and implementation
+#
+
+jre.compilation.profile = J2SE-1.5
+jars.compile.order = .
+source.. = src/
+output.. = bin/
+
+bin.includes = .,\
+ model/,\
+ META-INF/,\
+ plugin.xml,\
+ plugin.properties,\
+ about.html
+src.includes = about.html
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/model/Problems.ecore b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/model/Problems.ecore
new file mode 100644
index 00000000000..6a3d42bcd32
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/model/Problems.ecore
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="problems" nsURI="http://www.eclipse.org/emf/CDO/problems/1.0.0"
+ nsPrefix="cdo.problems">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="A model of problems, intended primarily as a persistence vehicle for Ecore Diagnostics in contexts where Eclipse resource problem markers (IProblemMarker) are either not available or not appropriate."/>
+ </eAnnotations>
+ <eClassifiers xsi:type="ecore:EClass" name="EProblem">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="Description of a problem in some element of an EMF-based model instance."/>
+ </eAnnotations>
+ <eOperations name="toDiagnostic" lowerBound="1" eType="#//EDiagnostic"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="severity" lowerBound="1"
+ eType="#//ESeverity"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="message" lowerBound="1"
+ eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="source" lowerBound="1"
+ eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="code" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="element" lowerBound="1"
+ eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="The element that manifests the problem."/>
+ </eAnnotations>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="related" upperBound="-1"
+ eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="Other model elements contributing to or otherwise related to the problem. May be, but not necessarily derived from, the 'data' list of an Ecore Diagnostic."/>
+ </eAnnotations>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="container" eType="#//EProblemsContainer"
+ eOpposite="#//EProblemsContainer/problems"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EEnum" name="ESeverity">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="Enumeration of problem severities, corresponding to the Ecore Diagnostic severity values."/>
+ </eAnnotations>
+ <eLiterals name="OK"/>
+ <eLiterals name="INFO" value="1"/>
+ <eLiterals name="WARNING" value="2"/>
+ <eLiterals name="ERROR" value="4"/>
+ <eLiterals name="CANCEL" value="8"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="EProblemsContainer">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="An optional container for problems, to provide a single node that can be conveniently contained in some larger structure such as an XML resource (which can only have one root element) or other generic container."/>
+ </eAnnotations>
+ <eOperations name="allProblems" lowerBound="1">
+ <eGenericType eClassifier="#//EIterator">
+ <eTypeArguments eClassifier="#//EProblem"/>
+ </eGenericType>
+ </eOperations>
+ <eOperations name="allProblems" lowerBound="1">
+ <eGenericType eClassifier="#//EIterator">
+ <eTypeArguments eClassifier="#//EProblem"/>
+ </eGenericType>
+ <eParameters name="element" lowerBound="1" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ </eOperations>
+ <eOperations name="allDiagnostics" upperBound="-1" eType="#//EDiagnostic"/>
+ <eOperations name="allDiagnostics" upperBound="-1" eType="#//EDiagnostic">
+ <eParameters name="element" lowerBound="1" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ </eOperations>
+ <eOperations name="getWorstProblem" eType="#//EProblem">
+ <eParameters name="element" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ </eOperations>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="problems" upperBound="-1"
+ eType="#//EProblem" containment="true" eOpposite="#//EProblem/container"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="subjects" upperBound="-1"
+ eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="Optional reference to elements that are the subjects of some collection of problems."/>
+ </eAnnotations>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="subcontainers" upperBound="-1"
+ eType="#//EProblemsContainer" containment="true" eOpposite="#//EProblemsContainer/container">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="Optional nested group of containers, possibly referencing different subjects than the parent container."/>
+ </eAnnotations>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="container" eType="#//EProblemsContainer"
+ eOpposite="#//EProblemsContainer/subcontainers"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EDataType" name="EDiagnostic" instanceClassName="org.eclipse.emf.common.util.Diagnostic"
+ serializable="false"/>
+ <eClassifiers xsi:type="ecore:EDataType" name="EIterator" instanceClassName="java.util.Iterator"
+ serializable="false">
+ <eTypeParameters name="E"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/model/Problems.ecorediag b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/model/Problems.ecorediag
new file mode 100644
index 00000000000..ae5071acbb6
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/model/Problems.ecorediag
@@ -0,0 +1,237 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmi:id="_mf7AkFv5EeKZR5SK39Veeg" type="EcoreTools" name="Problems" measurementUnit="Pixel">
+ <children xmi:type="notation:Node" xmi:id="_W4FTkFv6EeKZR5SK39Veeg" type="1001">
+ <children xmi:type="notation:Node" xmi:id="_W4GhsFv6EeKZR5SK39Veeg" type="4001"/>
+ <children xmi:type="notation:Node" xmi:id="_W4GhsVv6EeKZR5SK39Veeg" type="5001">
+ <children xmi:type="notation:Node" xmi:id="_JvtSoFv7EeKZR5SK39Veeg" type="2001">
+ <element xmi:type="ecore:EAttribute" href="Problems.ecore#//EProblem/severity"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_JvtSoVv7EeKZR5SK39Veeg"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_N4gUAFv7EeKZR5SK39Veeg" type="2001">
+ <element xmi:type="ecore:EAttribute" href="Problems.ecore#//EProblem/message"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_N4gUAVv7EeKZR5SK39Veeg"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_QFH8kFv7EeKZR5SK39Veeg" type="2001">
+ <element xmi:type="ecore:EAttribute" href="Problems.ecore#//EProblem/source"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_QFH8kVv7EeKZR5SK39Veeg"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_UTeMUFv7EeKZR5SK39Veeg" type="2001">
+ <element xmi:type="ecore:EAttribute" href="Problems.ecore#//EProblem/code"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_UTeMUVv7EeKZR5SK39Veeg"/>
+ </children>
+ <styles xmi:type="notation:DrawerStyle" xmi:id="_W4Ghslv6EeKZR5SK39Veeg"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_W4Ghs1v6EeKZR5SK39Veeg"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_W4GhtFv6EeKZR5SK39Veeg"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_W4HIwFv6EeKZR5SK39Veeg" type="5002">
+ <children xmi:type="notation:Node" xmi:id="_UnydMFwAEeKZR5SK39Veeg" type="2002">
+ <element xmi:type="ecore:EOperation" href="Problems.ecore#//EProblem/toDiagnostic"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_UnydMVwAEeKZR5SK39Veeg"/>
+ </children>
+ <styles xmi:type="notation:DrawerStyle" xmi:id="_W4HIwVv6EeKZR5SK39Veeg"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_W4HIwlv6EeKZR5SK39Veeg"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_W4HIw1v6EeKZR5SK39Veeg"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_W4FTkVv6EeKZR5SK39Veeg" fontColor="4210752" fontName="Lucida Grande" fontHeight="10" fillColor="13761016" lineColor="8421504"/>
+ <element xmi:type="ecore:EClass" href="Problems.ecore#//EProblem"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_W4FTklv6EeKZR5SK39Veeg" x="81" y="234"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_kkCGMFv6EeKZR5SK39Veeg" type="1005">
+ <children xmi:type="notation:Node" xmi:id="_kkCtQFv6EeKZR5SK39Veeg" type="4010"/>
+ <children xmi:type="notation:Node" xmi:id="_kkCtQVv6EeKZR5SK39Veeg" type="5008">
+ <children xmi:type="notation:Node" xmi:id="_nVHGsFv6EeKZR5SK39Veeg" type="2006">
+ <element xmi:type="ecore:EEnumLiteral" href="Problems.ecore#//ESeverity/OK"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_nVHGsVv6EeKZR5SK39Veeg"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_oosOcFv6EeKZR5SK39Veeg" type="2006">
+ <element xmi:type="ecore:EEnumLiteral" href="Problems.ecore#//ESeverity/INFO"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_oosOcVv6EeKZR5SK39Veeg"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_pbb6AFv6EeKZR5SK39Veeg" type="2006">
+ <element xmi:type="ecore:EEnumLiteral" href="Problems.ecore#//ESeverity/WARNING"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_pbb6AVv6EeKZR5SK39Veeg"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_q-kgsFv6EeKZR5SK39Veeg" type="2006">
+ <element xmi:type="ecore:EEnumLiteral" href="Problems.ecore#//ESeverity/ERROR"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_q-kgsVv6EeKZR5SK39Veeg"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_CHVzAFy_EeK238GGCf95eA" type="2006">
+ <element xmi:type="ecore:EEnumLiteral" href="Problems.ecore#//ESeverity/CANCEL"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_CHVzAVy_EeK238GGCf95eA"/>
+ </children>
+ <styles xmi:type="notation:DrawerStyle" xmi:id="_kkCtQlv6EeKZR5SK39Veeg"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_kkCtQ1v6EeKZR5SK39Veeg"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_kkCtRFv6EeKZR5SK39Veeg"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_kkCGMVv6EeKZR5SK39Veeg" fontColor="4210752" fontName="Lucida Grande" fontHeight="10" fillColor="13761016" lineColor="8421504"/>
+ <element xmi:type="ecore:EEnum" href="Problems.ecore#//ESeverity"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_kkCGMlv6EeKZR5SK39Veeg" x="450" y="18"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_hql-cFv7EeKZR5SK39Veeg" type="1001">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_hrKmMFv7EeKZR5SK39Veeg" source="Shortcut">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_hrKmMVv7EeKZR5SK39Veeg" key="modelID" value="EcoreTools"/>
+ </eAnnotations>
+ <children xmi:type="notation:Node" xmi:id="_hqpBwFv7EeKZR5SK39Veeg" type="4001"/>
+ <children xmi:type="notation:Node" xmi:id="_hqpBwVv7EeKZR5SK39Veeg" type="5001">
+ <styles xmi:type="notation:DrawerStyle" xmi:id="_hqpBwlv7EeKZR5SK39Veeg"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_hqpBw1v7EeKZR5SK39Veeg"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_hqpBxFv7EeKZR5SK39Veeg"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_hqpo0Fv7EeKZR5SK39Veeg" type="5002">
+ <styles xmi:type="notation:DrawerStyle" xmi:id="_hqpo0Vv7EeKZR5SK39Veeg" collapsed="true"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_hqpo0lv7EeKZR5SK39Veeg"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_hqpo01v7EeKZR5SK39Veeg"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_hql-cVv7EeKZR5SK39Veeg" fontColor="4210752" fontName="Lucida Grande" fontHeight="10" fillColor="12632256" lineColor="8421504"/>
+ <element xmi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_hql-clv7EeKZR5SK39Veeg" x="333" y="234"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_Jug4cFv-EeKZR5SK39Veeg" type="1001">
+ <children xmi:type="notation:Node" xmi:id="_JuhfgFv-EeKZR5SK39Veeg" type="4001"/>
+ <children xmi:type="notation:Node" xmi:id="_JuhfgVv-EeKZR5SK39Veeg" type="5001">
+ <styles xmi:type="notation:DrawerStyle" xmi:id="_Juhfglv-EeKZR5SK39Veeg"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_Juhfg1v-EeKZR5SK39Veeg"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_JuhfhFv-EeKZR5SK39Veeg"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_JuhfhVv-EeKZR5SK39Veeg" type="5002">
+ <children xmi:type="notation:Node" xmi:id="_rLeiAFv_EeKZR5SK39Veeg" type="2002">
+ <element xmi:type="ecore:EOperation" href="Problems.ecore#//EProblemsContainer/allProblems"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_rLeiAVv_EeKZR5SK39Veeg"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="__2agAFv_EeKZR5SK39Veeg" type="2002">
+ <element xmi:type="ecore:EOperation" href="Problems.ecore#//EProblemsContainer/allProblems.1"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="__2agAVv_EeKZR5SK39Veeg"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_puOEYFwAEeKZR5SK39Veeg" type="2002">
+ <element xmi:type="ecore:EOperation" href="Problems.ecore#//EProblemsContainer/allDiagnostics"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_puOEYVwAEeKZR5SK39Veeg"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_uec5MFwAEeKZR5SK39Veeg" type="2002">
+ <element xmi:type="ecore:EOperation" href="Problems.ecore#//EProblemsContainer/allDiagnostics.1"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_uec5MVwAEeKZR5SK39Veeg"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_6-QgcFwOEeKZR5SK39Veeg" type="2002">
+ <element xmi:type="ecore:EOperation" href="Problems.ecore#//EProblemsContainer/getWorstProblem"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_6-QgcVwOEeKZR5SK39Veeg"/>
+ </children>
+ <styles xmi:type="notation:DrawerStyle" xmi:id="_Juhfhlv-EeKZR5SK39Veeg"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_Juhfh1v-EeKZR5SK39Veeg"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_JuhfiFv-EeKZR5SK39Veeg"/>
+ </children>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_Jug4cVv-EeKZR5SK39Veeg" fontColor="4210752" fontName="Lucida Grande" fontHeight="10" fillColor="13761016" lineColor="8421504"/>
+ <element xmi:type="ecore:EClass" href="Problems.ecore#//EProblemsContainer"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Jug4clv-EeKZR5SK39Veeg" x="36" y="18" width="219" height="120"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_fRx6sFwAEeKZR5SK39Veeg" type="1004">
+ <children xmi:type="notation:Node" xmi:id="_fRyhwFwAEeKZR5SK39Veeg" type="4008"/>
+ <children xmi:type="notation:Node" xmi:id="_fRzI0FwAEeKZR5SK39Veeg" type="4009"/>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_fRx6sVwAEeKZR5SK39Veeg" fontColor="4210752" fontName="Lucida Grande" fontHeight="10" fillColor="13761016" lineColor="8421504"/>
+ <element xmi:type="ecore:EDataType" href="Problems.ecore#//EDiagnostic"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_fRx6slwAEeKZR5SK39Veeg" x="306" y="396"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_Qls5EFwGEeKZR5SK39Veeg" type="1004">
+ <children xmi:type="notation:Node" xmi:id="_QltgIFwGEeKZR5SK39Veeg" type="4008"/>
+ <children xmi:type="notation:Node" xmi:id="_QltgIVwGEeKZR5SK39Veeg" type="4009"/>
+ <styles xmi:type="notation:ShapeStyle" xmi:id="_Qls5EVwGEeKZR5SK39Veeg" fontColor="4210752" fontName="Lucida Grande" fontHeight="10" fillColor="13761016" lineColor="8421504"/>
+ <element xmi:type="ecore:EDataType" href="Problems.ecore#//EIterator"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Qls5ElwGEeKZR5SK39Veeg" x="305" y="452"/>
+ </children>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_mf7AkVv5EeKZR5SK39Veeg"/>
+ <element xmi:type="ecore:EPackage" href="Problems.ecore#/"/>
+ <edges xmi:type="notation:Edge" xmi:id="_oGOlIFv7EeKZR5SK39Veeg" type="3002" source="_W4FTkFv6EeKZR5SK39Veeg" target="_hql-cFv7EeKZR5SK39Veeg">
+ <children xmi:type="notation:Node" xmi:id="_oGPzQFv7EeKZR5SK39Veeg" type="4011">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_oGPzQVv7EeKZR5SK39Veeg" x="-13" y="-12"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_oGPzQlv7EeKZR5SK39Veeg" type="4012">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_oGPzQ1v7EeKZR5SK39Veeg" x="5" y="15"/>
+ </children>
+ <styles xmi:type="notation:ConnectorStyle" xmi:id="_oGOlIVv7EeKZR5SK39Veeg" routing="Rectilinear" lineColor="4210752"/>
+ <styles xmi:type="notation:FontStyle" xmi:id="_oGOlIlv7EeKZR5SK39Veeg" fontColor="4210752" fontName="Lucida Grande" fontHeight="10"/>
+ <element xmi:type="ecore:EReference" href="Problems.ecore#//EProblem/element"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_oGOlI1v7EeKZR5SK39Veeg" points="[75, -66, -139, -8]$[164, -66, -50, -8]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_oGj8UFv7EeKZR5SK39Veeg" id="(0.5454545454545454,0.8247422680412371)"/>
+ </edges>
+ <edges xmi:type="notation:Edge" xmi:id="_2u5esFv7EeKZR5SK39Veeg" type="3002" source="_W4FTkFv6EeKZR5SK39Veeg" target="_hql-cFv7EeKZR5SK39Veeg">
+ <children xmi:type="notation:Node" xmi:id="_2u6FwFv7EeKZR5SK39Veeg" type="4011">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_2u6FwVv7EeKZR5SK39Veeg" x="32" y="-25"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_2u6Fwlv7EeKZR5SK39Veeg" type="4012">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_2u6Fw1v7EeKZR5SK39Veeg" x="32" y="21"/>
+ </children>
+ <styles xmi:type="notation:ConnectorStyle" xmi:id="_2u5esVv7EeKZR5SK39Veeg" routing="Rectilinear" lineColor="4210752"/>
+ <styles xmi:type="notation:FontStyle" xmi:id="_2u5eslv7EeKZR5SK39Veeg" fontColor="4210752" fontName="Lucida Grande" fontHeight="10"/>
+ <element xmi:type="ecore:EReference" href="Problems.ecore#//EProblem/related"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_2u5es1v7EeKZR5SK39Veeg" points="[36, 18, -194, 89]$[36, 51, -194, 122]$[283, 51, 53, 122]$[283, -32, 53, 39]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_2u768Fv7EeKZR5SK39Veeg" id="(0.14049586776859505,0.8247422680412371)"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_2u8iAFv7EeKZR5SK39Veeg" id="(0.00980392156862745,0.25925925925925924)"/>
+ </edges>
+ <edges xmi:type="notation:Edge" xmi:id="_ZDtg0Fv-EeKZR5SK39Veeg" type="3002" source="_Jug4cFv-EeKZR5SK39Veeg" target="_W4FTkFv6EeKZR5SK39Veeg">
+ <children xmi:type="notation:Node" xmi:id="_ZDuH4Fv-EeKZR5SK39Veeg" type="4011">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_ZDuH4Vv-EeKZR5SK39Veeg" x="-3" y="-32"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_ZDuH4lv-EeKZR5SK39Veeg" type="4012">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_ZDuH41v-EeKZR5SK39Veeg" x="-3" y="18"/>
+ </children>
+ <styles xmi:type="notation:ConnectorStyle" xmi:id="_ZDtg0Vv-EeKZR5SK39Veeg" routing="Rectilinear" lineColor="4210752"/>
+ <styles xmi:type="notation:FontStyle" xmi:id="_ZDtg0lv-EeKZR5SK39Veeg" fontColor="4210752" fontName="Lucida Grande" fontHeight="10"/>
+ <element xmi:type="ecore:EReference" href="Problems.ecore#//EProblemsContainer/problems"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_ZDtg01v-EeKZR5SK39Veeg" points="[14, 24, -45, -119]$[14, 122, -45, -21]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_ZDv9EFv-EeKZR5SK39Veeg" id="(0.226890756302521,0.7619047619047619)"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_ZDv9EVv-EeKZR5SK39Veeg" id="(0.3884297520661157,0.20618556701030927)"/>
+ </edges>
+ <edges xmi:type="notation:Edge" xmi:id="_faMhwFv-EeKZR5SK39Veeg" type="3002" source="_Jug4cFv-EeKZR5SK39Veeg" target="_hql-cFv7EeKZR5SK39Veeg">
+ <children xmi:type="notation:Node" xmi:id="_faNI0Fv-EeKZR5SK39Veeg" type="4011">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_faNI0Vv-EeKZR5SK39Veeg" x="13" y="-29"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_faNI0lv-EeKZR5SK39Veeg" type="4012">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_faNI01v-EeKZR5SK39Veeg" x="13" y="18"/>
+ </children>
+ <styles xmi:type="notation:ConnectorStyle" xmi:id="_faMhwVv-EeKZR5SK39Veeg" routing="Rectilinear" lineColor="4210752"/>
+ <styles xmi:type="notation:FontStyle" xmi:id="_faMhwlv-EeKZR5SK39Veeg" fontColor="4210752" fontName="Lucida Grande" fontHeight="10"/>
+ <element xmi:type="ecore:EReference" href="Problems.ecore#//EProblemsContainer/subjects"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_faMhw1v-EeKZR5SK39Veeg" points="[30, -71, -130, -224]$[170, -71, 10, -224]$[170, 127, 10, -26]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_faPlEFv-EeKZR5SK39Veeg" id="(0.865546218487395,0.7619047619047619)"/>
+ </edges>
+ <edges xmi:type="notation:Edge" xmi:id="_2NqSgFv-EeKZR5SK39Veeg" type="3002" source="_Jug4cFv-EeKZR5SK39Veeg" target="_Jug4cFv-EeKZR5SK39Veeg">
+ <children xmi:type="notation:Node" xmi:id="_2NqShFv-EeKZR5SK39Veeg" type="4011">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_2NqShVv-EeKZR5SK39Veeg" x="8" y="15"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_2NqShlv-EeKZR5SK39Veeg" type="4012">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_2NqSh1v-EeKZR5SK39Veeg" x="27" y="-15"/>
+ </children>
+ <styles xmi:type="notation:ConnectorStyle" xmi:id="_2NqSgVv-EeKZR5SK39Veeg" routing="Rectilinear" lineColor="4210752"/>
+ <styles xmi:type="notation:FontStyle" xmi:id="_2NqSglv-EeKZR5SK39Veeg" fontColor="4210752" fontName="Lucida Grande" fontHeight="10"/>
+ <element xmi:type="ecore:EReference" href="Problems.ecore#//EProblemsContainer/subcontainers"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_2NqSg1v-EeKZR5SK39Veeg" points="[32, 59, 32, 59]$[32, 103, 32, 103]$[171, 103, 171, 103]$[171, 22, 171, 22]$[109, 22, 109, 22]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_FtseoFwPEeKZR5SK39Veeg" id="(0.5,0.5)"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_FtseoVwPEeKZR5SK39Veeg" id="(0.5,0.5)"/>
+ </edges>
+ <edges xmi:type="notation:Edge" xmi:id="_FoH1YFv_EeKZR5SK39Veeg" type="3002" source="_Jug4cFv-EeKZR5SK39Veeg" target="_Jug4cFv-EeKZR5SK39Veeg">
+ <children xmi:type="notation:Node" xmi:id="_FoH1ZFv_EeKZR5SK39Veeg" type="4011">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_FoH1ZVv_EeKZR5SK39Veeg" x="-32" y="21"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_FoH1Zlv_EeKZR5SK39Veeg" type="4012">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_FoH1Z1v_EeKZR5SK39Veeg" x="18" y="21"/>
+ </children>
+ <styles xmi:type="notation:ConnectorStyle" xmi:id="_FoH1YVv_EeKZR5SK39Veeg" routing="Rectilinear" lineColor="4210752"/>
+ <styles xmi:type="notation:FontStyle" xmi:id="_FoH1Ylv_EeKZR5SK39Veeg" fontColor="4210752" fontName="Lucida Grande" fontHeight="10"/>
+ <element xmi:type="ecore:EReference" href="Problems.ecore#//EProblemsContainer/container"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_FoH1Y1v_EeKZR5SK39Veeg" points="[109, 22, 109, 22]$[171, 22, 171, 22]$[171, 103, 171, 103]$[32, 103, 32, 103]$[32, 59, 32, 59]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_-RWKMFwAEeKZR5SK39Veeg" id="(0.5,0.5)"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_-RWKMVwAEeKZR5SK39Veeg" id="(0.5,0.5)"/>
+ </edges>
+ <edges xmi:type="notation:Edge" xmi:id="_VtqqsFwBEeKZR5SK39Veeg" type="3002" source="_W4FTkFv6EeKZR5SK39Veeg" target="_Jug4cFv-EeKZR5SK39Veeg">
+ <children xmi:type="notation:Node" xmi:id="_VtqqtFwBEeKZR5SK39Veeg" type="4011">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_VtqqtVwBEeKZR5SK39Veeg" x="-8" y="-31"/>
+ </children>
+ <children xmi:type="notation:Node" xmi:id="_VtqqtlwBEeKZR5SK39Veeg" type="4012">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_Vtqqt1wBEeKZR5SK39Veeg" x="-8" y="18"/>
+ </children>
+ <styles xmi:type="notation:ConnectorStyle" xmi:id="_VtqqsVwBEeKZR5SK39Veeg" routing="Rectilinear" lineColor="4210752"/>
+ <styles xmi:type="notation:FontStyle" xmi:id="_VtqqslwBEeKZR5SK39Veeg" fontColor="4210752" fontName="Lucida Grande" fontHeight="10"/>
+ <element xmi:type="ecore:EReference" href="Problems.ecore#//EProblem/container"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_Vtqqs1wBEeKZR5SK39Veeg" points="[-45, -21, 14, 122]$[-45, -119, 14, 24]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_YF67glwBEeKZR5SK39Veeg" id="(0.3884297520661157,0.20618556701030927)"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_YF67g1wBEeKZR5SK39Veeg" id="(0.226890756302521,0.7619047619047619)"/>
+ </edges>
+</notation:Diagram>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/model/Problems.genmodel b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/model/Problems.genmodel
new file mode 100644
index 00000000000..488dc4dfb37
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/model/Problems.genmodel
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
+ xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" copyrightText="Copyright (c) 2013 CEA LIST.&#xA; &#xA;All rights reserved. This program and the accompanying materials&#xA;are made available under the terms of the Eclipse Public License v1.0&#xA;which accompanies this distribution, and is available at&#xA;http://www.eclipse.org/legal/epl-v10.html&#xA;&#xA;Contributors:&#xA; CEA LIST - Initial API and implementation"
+ modelDirectory="/org.eclipse.papyrus.cdo.validation.problems/src" modelPluginID="org.eclipse.papyrus.cdo.validation.problems"
+ modelName="Problems" modelPluginClass="org.eclipse.papyrus.cdo.validation.problems.internal.ProblemsPlugin"
+ editPluginClass="org.eclipse.papyrus.cdo.validation.problems.provider.ProblemsEditPlugin"
+ editorPluginClass="org.eclipse.papyrus.cdo.validation.problems.presentation.ProblemsEditorPlugin"
+ nonNLSMarkers="true" rootExtendsInterface="org.eclipse.emf.cdo.CDOObject" rootExtendsClass="org.eclipse.emf.internal.cdo.CDOObjectImpl"
+ reflectiveDelegation="true" codeFormatting="true" testSuiteClass="org.eclipse.papyrus.cdo.validation.problems.tests.ProblemsAllTests"
+ importerID="org.eclipse.emf.importer.cdo" featureDelegation="Reflective" complianceLevel="5.0"
+ copyrightFields="false" providerRootExtendsClass="org.eclipse.papyrus.cdo.validation.problems.edit.ProblemTypeItemProviderAdapter"
+ optimizedHasChildren="true" tableProviders="true" colorProviders="true" fontProviders="true"
+ runtimeVersion="2.8" operationReflection="true" importOrganizing="true">
+ <foreignModel>Problems.ecore</foreignModel>
+ <modelPluginVariables>CDO=org.eclipse.emf.cdo</modelPluginVariables>
+ <genPackages prefix="Problems" basePackage="org.eclipse.papyrus.cdo.validation"
+ disposableProviderFactory="true" generateExampleClass="false" extensibleProviderFactory="true"
+ childCreationExtenders="true" ecorePackage="Problems.ecore#/">
+ <genEnums typeSafeEnumCompatible="false" ecoreEnum="Problems.ecore#//ESeverity">
+ <genEnumLiterals ecoreEnumLiteral="Problems.ecore#//ESeverity/OK"/>
+ <genEnumLiterals ecoreEnumLiteral="Problems.ecore#//ESeverity/INFO"/>
+ <genEnumLiterals ecoreEnumLiteral="Problems.ecore#//ESeverity/WARNING"/>
+ <genEnumLiterals ecoreEnumLiteral="Problems.ecore#//ESeverity/ERROR"/>
+ <genEnumLiterals ecoreEnumLiteral="Problems.ecore#//ESeverity/CANCEL"/>
+ </genEnums>
+ <genDataTypes ecoreDataType="Problems.ecore#//EDiagnostic"/>
+ <genDataTypes ecoreDataType="Problems.ecore#//EIterator">
+ <genTypeParameters ecoreTypeParameter="Problems.ecore#//EIterator/E"/>
+ </genDataTypes>
+ <genClasses ecoreClass="Problems.ecore#//EProblem">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Problems.ecore#//EProblem/severity"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Problems.ecore#//EProblem/message"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Problems.ecore#//EProblem/source"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Problems.ecore#//EProblem/code"/>
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference Problems.ecore#//EProblem/element"/>
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference Problems.ecore#//EProblem/related"/>
+ <genFeatures property="None" notify="false" createChild="false" ecoreFeature="ecore:EReference Problems.ecore#//EProblem/container"/>
+ <genOperations ecoreOperation="Problems.ecore#//EProblem/toDiagnostic"/>
+ </genClasses>
+ <genClasses ecoreClass="Problems.ecore#//EProblemsContainer">
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Problems.ecore#//EProblemsContainer/problems"/>
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference Problems.ecore#//EProblemsContainer/subjects"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Problems.ecore#//EProblemsContainer/subcontainers"/>
+ <genFeatures property="None" notify="false" createChild="false" ecoreFeature="ecore:EReference Problems.ecore#//EProblemsContainer/container"/>
+ <genOperations ecoreOperation="Problems.ecore#//EProblemsContainer/allProblems"/>
+ <genOperations ecoreOperation="Problems.ecore#//EProblemsContainer/allProblems.1">
+ <genParameters ecoreParameter="Problems.ecore#//EProblemsContainer/allProblems.1/element"/>
+ </genOperations>
+ <genOperations ecoreOperation="Problems.ecore#//EProblemsContainer/allDiagnostics"/>
+ <genOperations ecoreOperation="Problems.ecore#//EProblemsContainer/allDiagnostics.1">
+ <genParameters ecoreParameter="Problems.ecore#//EProblemsContainer/allDiagnostics.1/element"/>
+ </genOperations>
+ <genOperations ecoreOperation="Problems.ecore#//EProblemsContainer/getWorstProblem">
+ <genParameters ecoreParameter="Problems.ecore#//EProblemsContainer/getWorstProblem/element"/>
+ </genOperations>
+ </genClasses>
+ </genPackages>
+</genmodel:GenModel>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/plugin.properties b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/plugin.properties
new file mode 100644
index 00000000000..e84bbdabccb
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/plugin.properties
@@ -0,0 +1,13 @@
+# Copyright (c) 2013 CEA LIST.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# CEA LIST - Initial API and implementation
+#
+
+pluginName = Papyrus CDO Model Repository Problems Model (Incubation)
+providerName = Eclipse Modeling Project
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/plugin.xml b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/plugin.xml
new file mode 100644
index 00000000000..83d76a5f8f1
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/plugin.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<!--
+ Copyright (c) 2013 CEA LIST.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ CEA LIST - Initial API and implementation
+
+-->
+
+<plugin>
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <!-- @generated Problems -->
+ <package
+ uri="http://www.eclipse.org/emf/CDO/problems/1.0.0"
+ class="org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage"
+ genModel="model/Problems.genmodel"/>
+ </extension>
+
+</plugin>
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/EProblem.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/EProblem.java
new file mode 100644
index 00000000000..b49eb525058
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/EProblem.java
@@ -0,0 +1,263 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc --> A representation of the model object '
+ * <em><b>EProblem</b></em>'. <!-- end-user-doc -->
+ *
+ * <!-- begin-model-doc --> Description of a problem in some element of an
+ * EMF-based model instance. <!-- end-model-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getSeverity
+ * <em>Severity</em>}</li>
+ * <li>{@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getMessage
+ * <em>Message</em>}</li>
+ * <li>{@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getSource
+ * <em>Source</em>}</li>
+ * <li>{@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getCode
+ * <em>Code</em>}</li>
+ * <li>{@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getElement
+ * <em>Element</em>}</li>
+ * <li>{@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getRelated
+ * <em>Related</em>}</li>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getContainer
+ * <em>Container</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage#getEProblem()
+ * @model
+ * @extends CDOObject
+ * @generated
+ */
+public interface EProblem
+ extends CDOObject {
+
+ /**
+ * Returns the value of the '<em><b>Severity</b></em>' attribute. The
+ * literals are from the enumeration
+ * {@link org.eclipse.papyrus.cdo.validation.problems.ESeverity}. <!--
+ * begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Severity</em>' attribute isn't clear, there
+ * really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ *
+ * @return the value of the '<em>Severity</em>' attribute.
+ * @see org.eclipse.papyrus.cdo.validation.problems.ESeverity
+ * @see #setSeverity(ESeverity)
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage#getEProblem_Severity()
+ * @model required="true"
+ * @generated
+ */
+ ESeverity getSeverity();
+
+ /**
+ * Sets the value of the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getSeverity
+ * <em>Severity</em>}' attribute. <!-- begin-user-doc --> <!-- end-user-doc
+ * -->
+ *
+ * @param value
+ * the new value of the '<em>Severity</em>' attribute.
+ * @see org.eclipse.papyrus.cdo.validation.problems.ESeverity
+ * @see #getSeverity()
+ * @generated
+ */
+ void setSeverity(ESeverity value);
+
+ /**
+ * Returns the value of the '<em><b>Message</b></em>' attribute. <!--
+ * begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Message</em>' attribute isn't clear, there
+ * really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ *
+ * @return the value of the '<em>Message</em>' attribute.
+ * @see #setMessage(String)
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage#getEProblem_Message()
+ * @model required="true"
+ * @generated
+ */
+ String getMessage();
+
+ /**
+ * Sets the value of the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getMessage
+ * <em>Message</em>}' attribute. <!-- begin-user-doc --> <!-- end-user-doc
+ * -->
+ *
+ * @param value
+ * the new value of the '<em>Message</em>' attribute.
+ * @see #getMessage()
+ * @generated
+ */
+ void setMessage(String value);
+
+ /**
+ * Returns the value of the '<em><b>Source</b></em>' attribute. <!--
+ * begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Source</em>' attribute isn't clear, there
+ * really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ *
+ * @return the value of the '<em>Source</em>' attribute.
+ * @see #setSource(String)
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage#getEProblem_Source()
+ * @model required="true"
+ * @generated
+ */
+ String getSource();
+
+ /**
+ * Sets the value of the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getSource
+ * <em>Source</em>}' attribute. <!-- begin-user-doc --> <!-- end-user-doc
+ * -->
+ *
+ * @param value
+ * the new value of the '<em>Source</em>' attribute.
+ * @see #getSource()
+ * @generated
+ */
+ void setSource(String value);
+
+ /**
+ * Returns the value of the '<em><b>Code</b></em>' attribute. <!--
+ * begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Code</em>' attribute isn't clear, there really
+ * should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ *
+ * @return the value of the '<em>Code</em>' attribute.
+ * @see #setCode(int)
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage#getEProblem_Code()
+ * @model
+ * @generated
+ */
+ int getCode();
+
+ /**
+ * Sets the value of the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getCode
+ * <em>Code</em>}' attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @param value
+ * the new value of the '<em>Code</em>' attribute.
+ * @see #getCode()
+ * @generated
+ */
+ void setCode(int value);
+
+ /**
+ * Returns the value of the '<em><b>Element</b></em>' reference. <!--
+ * begin-user-doc --> <!-- end-user-doc --> <!-- begin-model-doc --> The
+ * element that manifests the problem. <!-- end-model-doc -->
+ *
+ * @return the value of the '<em>Element</em>' reference.
+ * @see #setElement(EObject)
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage#getEProblem_Element()
+ * @model required="true"
+ * @generated
+ */
+ EObject getElement();
+
+ /**
+ * Sets the value of the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getElement
+ * <em>Element</em>}' reference. <!-- begin-user-doc --> <!-- end-user-doc
+ * -->
+ *
+ * @param value
+ * the new value of the '<em>Element</em>' reference.
+ * @see #getElement()
+ * @generated
+ */
+ void setElement(EObject value);
+
+ /**
+ * Returns the value of the '<em><b>Related</b></em>' reference list. The
+ * list contents are of type {@link org.eclipse.emf.ecore.EObject}. <!--
+ * begin-user-doc --> <!-- end-user-doc --> <!-- begin-model-doc --> Other
+ * model elements contributing to or otherwise related to the problem. May
+ * be, but not necessarily derived from, the 'data' list of an Ecore
+ * Diagnostic. <!-- end-model-doc -->
+ *
+ * @return the value of the '<em>Related</em>' reference list.
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage#getEProblem_Related()
+ * @model
+ * @generated
+ */
+ EList<EObject> getRelated();
+
+ /**
+ * Returns the value of the '<em><b>Container</b></em>' container reference.
+ * It is bidirectional and its opposite is '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getProblems
+ * <em>Problems</em>}'. <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Container</em>' container reference isn't
+ * clear, there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ *
+ * @return the value of the '<em>Container</em>' container reference.
+ * @see #setContainer(EProblemsContainer)
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage#getEProblem_Container()
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getProblems
+ * @model opposite="problems" transient="false"
+ * @generated
+ */
+ EProblemsContainer getContainer();
+
+ /**
+ * Sets the value of the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getContainer
+ * <em>Container</em>}' container reference. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @param value
+ * the new value of the '<em>Container</em>' container reference.
+ * @see #getContainer()
+ * @generated
+ */
+ void setContainer(EProblemsContainer value);
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @model
+ * dataType="org.eclipse.papyrus.cdo.validation.problems.EDiagnostic"
+ * required="true"
+ * @generated
+ */
+ Diagnostic toDiagnostic();
+
+} // EProblem
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/EProblemsContainer.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/EProblemsContainer.java
new file mode 100644
index 00000000000..3d2c96f3288
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/EProblemsContainer.java
@@ -0,0 +1,191 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc --> A representation of the model object '
+ * <em><b>EProblems Container</b></em>'. <!-- end-user-doc -->
+ *
+ * <!-- begin-model-doc --> An optional container for problems, to provide a
+ * single node that can be conveniently contained in some larger structure such
+ * as an XML resource (which can only have one root element) or other generic
+ * container. <!-- end-model-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getProblems
+ * <em>Problems</em>}</li>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getSubjects
+ * <em>Subjects</em>}</li>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getSubcontainers
+ * <em>Subcontainers</em>}</li>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getContainer
+ * <em>Container</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage#getEProblemsContainer()
+ * @model
+ * @extends CDOObject
+ * @generated
+ */
+public interface EProblemsContainer
+ extends CDOObject {
+
+ /**
+ * Returns the value of the '<em><b>Problems</b></em>' containment reference
+ * list. The list contents are of type
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem}. It is
+ * bidirectional and its opposite is '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getContainer
+ * <em>Container</em>}'. <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Problems</em>' containment reference list
+ * isn't clear, there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ *
+ * @return the value of the '<em>Problems</em>' containment reference list.
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage#getEProblemsContainer_Problems()
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblem#getContainer
+ * @model opposite="container" containment="true"
+ * @generated
+ */
+ EList<EProblem> getProblems();
+
+ /**
+ * Returns the value of the '<em><b>Subjects</b></em>' reference list. The
+ * list contents are of type {@link org.eclipse.emf.ecore.EObject}. <!--
+ * begin-user-doc --> <!-- end-user-doc --> <!-- begin-model-doc -->
+ * Optional reference to elements that are the subjects of some collection
+ * of problems. <!-- end-model-doc -->
+ *
+ * @return the value of the '<em>Subjects</em>' reference list.
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage#getEProblemsContainer_Subjects()
+ * @model
+ * @generated
+ */
+ EList<EObject> getSubjects();
+
+ /**
+ * Returns the value of the '<em><b>Subcontainers</b></em>' containment
+ * reference list. The list contents are of type
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer}.
+ * It is bidirectional and its opposite is '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getContainer
+ * <em>Container</em>}'. <!-- begin-user-doc --> <!-- end-user-doc --> <!--
+ * begin-model-doc --> Optional nested group of containers, possibly
+ * referencing different subjects than the parent container. <!--
+ * end-model-doc -->
+ *
+ * @return the value of the '<em>Subcontainers</em>' containment reference
+ * list.
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage#getEProblemsContainer_Subcontainers()
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getContainer
+ * @model opposite="container" containment="true"
+ * @generated
+ */
+ EList<EProblemsContainer> getSubcontainers();
+
+ /**
+ * Returns the value of the '<em><b>Container</b></em>' container reference.
+ * It is bidirectional and its opposite is '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getSubcontainers
+ * <em>Subcontainers</em>}'. <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Container</em>' container reference isn't
+ * clear, there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ *
+ * @return the value of the '<em>Container</em>' container reference.
+ * @see #setContainer(EProblemsContainer)
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage#getEProblemsContainer_Container()
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getSubcontainers
+ * @model opposite="subcontainers" transient="false"
+ * @generated
+ */
+ EProblemsContainer getContainer();
+
+ /**
+ * Sets the value of the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getContainer
+ * <em>Container</em>}' container reference. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @param value
+ * the new value of the '<em>Container</em>' container reference.
+ * @see #getContainer()
+ * @generated
+ */
+ void setContainer(EProblemsContainer value);
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @model dataType=
+ * "org.eclipse.papyrus.cdo.validation.problems.EIterator<org.eclipse.papyrus.cdo.validation.problems.EProblem>"
+ * required="true"
+ * @generated
+ */
+ Iterator<EProblem> allProblems();
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @model dataType=
+ * "org.eclipse.papyrus.cdo.validation.problems.EIterator<org.eclipse.papyrus.cdo.validation.problems.EProblem>"
+ * required="true" elementRequired="true"
+ * @generated
+ */
+ Iterator<EProblem> allProblems(EObject element);
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @model
+ * dataType="org.eclipse.papyrus.cdo.validation.problems.EDiagnostic"
+ * @generated
+ */
+ EList<Diagnostic> allDiagnostics();
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @model
+ * dataType="org.eclipse.papyrus.cdo.validation.problems.EDiagnostic"
+ * elementRequired="true"
+ * @generated
+ */
+ EList<Diagnostic> allDiagnostics(EObject element);
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @model
+ * @generated
+ */
+ EProblem getWorstProblem(EObject element);
+
+} // EProblemsContainer
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/ESeverity.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/ESeverity.java
new file mode 100644
index 00000000000..5c1ddfbd10c
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/ESeverity.java
@@ -0,0 +1,300 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.common.util.Enumerator;
+
+/**
+ * <!-- begin-user-doc --> A representation of the literals of the enumeration '
+ * <em><b>ESeverity</b></em>', and utility methods for working with them. <!--
+ * end-user-doc --> <!-- begin-model-doc --> Enumeration of problem severities,
+ * corresponding to the Ecore Diagnostic severity values. <!-- end-model-doc -->
+ *
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage#getESeverity()
+ * @model
+ * @generated
+ */
+public enum ESeverity
+ implements Enumerator {
+ /**
+ * The '<em><b>OK</b></em>' literal object. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @see #OK_VALUE
+ * @generated
+ * @ordered
+ */
+ OK(0, "OK", "OK"), //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * The '<em><b>INFO</b></em>' literal object. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @see #INFO_VALUE
+ * @generated
+ * @ordered
+ */
+ INFO(1, "INFO", "INFO"), //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * The '<em><b>WARNING</b></em>' literal object. <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @see #WARNING_VALUE
+ * @generated
+ * @ordered
+ */
+ WARNING(2, "WARNING", "WARNING"), //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * The '<em><b>ERROR</b></em>' literal object. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @see #ERROR_VALUE
+ * @generated
+ * @ordered
+ */
+ ERROR(4, "ERROR", "ERROR"), //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * The '<em><b>CANCEL</b></em>' literal object. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @see #CANCEL_VALUE
+ * @generated
+ * @ordered
+ */
+ CANCEL(8, "CANCEL", "CANCEL"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * The '<em><b>OK</b></em>' literal value. <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of '<em><b>OK</b></em>' literal object isn't clear, there
+ * really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ *
+ * @see #OK
+ * @model
+ * @generated
+ * @ordered
+ */
+ public static final int OK_VALUE = 0;
+
+ /**
+ * The '<em><b>INFO</b></em>' literal value. <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of '<em><b>INFO</b></em>' literal object isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ *
+ * @see #INFO
+ * @model
+ * @generated
+ * @ordered
+ */
+ public static final int INFO_VALUE = 1;
+
+ /**
+ * The '<em><b>WARNING</b></em>' literal value. <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of '<em><b>WARNING</b></em>' literal object isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ *
+ * @see #WARNING
+ * @model
+ * @generated
+ * @ordered
+ */
+ public static final int WARNING_VALUE = 2;
+
+ /**
+ * The '<em><b>ERROR</b></em>' literal value. <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of '<em><b>ERROR</b></em>' literal object isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ *
+ * @see #ERROR
+ * @model
+ * @generated
+ * @ordered
+ */
+ public static final int ERROR_VALUE = 4;
+
+ /**
+ * The '<em><b>CANCEL</b></em>' literal value. <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of '<em><b>CANCEL</b></em>' literal object isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ *
+ * @see #CANCEL
+ * @model
+ * @generated
+ * @ordered
+ */
+ public static final int CANCEL_VALUE = 8;
+
+ /**
+ * An array of all the '<em><b>ESeverity</b></em>' enumerators. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private static final ESeverity[] VALUES_ARRAY = new ESeverity[]{OK, INFO,
+ WARNING, ERROR, CANCEL,};
+
+ /**
+ * A public read-only list of all the '<em><b>ESeverity</b></em>'
+ * enumerators. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public static final List<ESeverity> VALUES = Collections
+ .unmodifiableList(Arrays.asList(VALUES_ARRAY));
+
+ /**
+ * Returns the '<em><b>ESeverity</b></em>' literal with the specified
+ * literal value. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public static ESeverity get(String literal) {
+ for (int i = 0; i < VALUES_ARRAY.length; ++i) {
+ ESeverity result = VALUES_ARRAY[i];
+ if (result.toString().equals(literal)) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the '<em><b>ESeverity</b></em>' literal with the specified name.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public static ESeverity getByName(String name) {
+ for (int i = 0; i < VALUES_ARRAY.length; ++i) {
+ ESeverity result = VALUES_ARRAY[i];
+ if (result.getName().equals(name)) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the '<em><b>ESeverity</b></em>' literal with the specified
+ * integer value. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public static ESeverity get(int value) {
+ switch (value) {
+ case OK_VALUE :
+ return OK;
+ case INFO_VALUE :
+ return INFO;
+ case WARNING_VALUE :
+ return WARNING;
+ case ERROR_VALUE :
+ return ERROR;
+ case CANCEL_VALUE :
+ return CANCEL;
+ }
+ return null;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private final int value;
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private final String name;
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private final String literal;
+
+ /**
+ * Only this class can construct instances. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ private ESeverity(int value, String name, String literal) {
+ this.value = value;
+ this.name = name;
+ this.literal = literal;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public int getValue() {
+ return value;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public String getLiteral() {
+ return literal;
+ }
+
+ /**
+ * Returns the literal value of the enumerator, which is its string
+ * representation. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public String toString() {
+ return literal;
+ }
+
+} // ESeverity
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/ProblemsFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/ProblemsFactory.java
new file mode 100644
index 00000000000..b1d968495e0
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/ProblemsFactory.java
@@ -0,0 +1,62 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems;
+
+import org.eclipse.emf.ecore.EFactory;
+
+/**
+ * <!-- begin-user-doc --> The <b>Factory</b> for the model. It provides a
+ * create method for each non-abstract class of the model. <!-- end-user-doc -->
+ *
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage
+ * @generated
+ */
+public interface ProblemsFactory
+ extends EFactory {
+
+ /**
+ * The singleton instance of the factory. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ ProblemsFactory eINSTANCE = org.eclipse.papyrus.cdo.validation.problems.impl.ProblemsFactoryImpl
+ .init();
+
+ /**
+ * Returns a new object of class '<em>EProblem</em>'. <!-- begin-user-doc
+ * --> <!-- end-user-doc -->
+ *
+ * @return a new object of class '<em>EProblem</em>'.
+ * @generated
+ */
+ EProblem createEProblem();
+
+ /**
+ * Returns a new object of class '<em>EProblems Container</em>'. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return a new object of class '<em>EProblems Container</em>'.
+ * @generated
+ */
+ EProblemsContainer createEProblemsContainer();
+
+ /**
+ * Returns the package supported by this factory. <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @return the package supported by this factory.
+ * @generated
+ */
+ ProblemsPackage getProblemsPackage();
+
+} // ProblemsFactory
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/ProblemsPackage.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/ProblemsPackage.java
new file mode 100644
index 00000000000..3541d43c09b
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/ProblemsPackage.java
@@ -0,0 +1,813 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+/**
+ * <!-- begin-user-doc --> The <b>Package</b> for the model. It contains
+ * accessors for the meta objects to represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each operation of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc --> <!-- begin-model-doc --> A model of problems, intended
+ * primarily as a persistence vehicle for Ecore Diagnostics in contexts where
+ * Eclipse resource problem markers (IProblemMarker) are either not available or
+ * not appropriate. <!-- end-model-doc -->
+ *
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsFactory
+ * @model kind="package"
+ * @generated
+ */
+public interface ProblemsPackage
+ extends EPackage {
+
+ /**
+ * The package name. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ String eNAME = "problems"; //$NON-NLS-1$
+
+ /**
+ * The package namespace URI. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ String eNS_URI = "http://www.eclipse.org/emf/CDO/problems/1.0.0"; //$NON-NLS-1$
+
+ /**
+ * The package namespace name. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ String eNS_PREFIX = "cdo.problems"; //$NON-NLS-1$
+
+ /**
+ * The singleton instance of the package. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ ProblemsPackage eINSTANCE = org.eclipse.papyrus.cdo.validation.problems.impl.ProblemsPackageImpl
+ .init();
+
+ /**
+ * The meta object id for the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.impl.EProblemImpl
+ * <em>EProblem</em>}' class. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see org.eclipse.papyrus.cdo.validation.problems.impl.EProblemImpl
+ * @see org.eclipse.papyrus.cdo.validation.problems.impl.ProblemsPackageImpl#getEProblem()
+ * @generated
+ */
+ int EPROBLEM = 0;
+
+ /**
+ * The feature id for the '<em><b>Severity</b></em>' attribute. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEM__SEVERITY = 0;
+
+ /**
+ * The feature id for the '<em><b>Message</b></em>' attribute. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEM__MESSAGE = 1;
+
+ /**
+ * The feature id for the '<em><b>Source</b></em>' attribute. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEM__SOURCE = 2;
+
+ /**
+ * The feature id for the '<em><b>Code</b></em>' attribute. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEM__CODE = 3;
+
+ /**
+ * The feature id for the '<em><b>Element</b></em>' reference. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEM__ELEMENT = 4;
+
+ /**
+ * The feature id for the '<em><b>Related</b></em>' reference list. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEM__RELATED = 5;
+
+ /**
+ * The feature id for the '<em><b>Container</b></em>' container reference.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEM__CONTAINER = 6;
+
+ /**
+ * The number of structural features of the '<em>EProblem</em>' class. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEM_FEATURE_COUNT = 7;
+
+ /**
+ * The operation id for the '<em>To Diagnostic</em>' operation. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEM___TO_DIAGNOSTIC = 0;
+
+ /**
+ * The number of operations of the '<em>EProblem</em>' class. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEM_OPERATION_COUNT = 1;
+
+ /**
+ * The meta object id for the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.impl.EProblemsContainerImpl
+ * <em>EProblems Container</em>}' class. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @see org.eclipse.papyrus.cdo.validation.problems.impl.EProblemsContainerImpl
+ * @see org.eclipse.papyrus.cdo.validation.problems.impl.ProblemsPackageImpl#getEProblemsContainer()
+ * @generated
+ */
+ int EPROBLEMS_CONTAINER = 1;
+
+ /**
+ * The feature id for the '<em><b>Problems</b></em>' containment reference
+ * list. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEMS_CONTAINER__PROBLEMS = 0;
+
+ /**
+ * The feature id for the '<em><b>Subjects</b></em>' reference list. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEMS_CONTAINER__SUBJECTS = 1;
+
+ /**
+ * The feature id for the '<em><b>Subcontainers</b></em>' containment
+ * reference list. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEMS_CONTAINER__SUBCONTAINERS = 2;
+
+ /**
+ * The feature id for the '<em><b>Container</b></em>' container reference.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEMS_CONTAINER__CONTAINER = 3;
+
+ /**
+ * The number of structural features of the '<em>EProblems Container</em>'
+ * class. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEMS_CONTAINER_FEATURE_COUNT = 4;
+
+ /**
+ * The operation id for the '<em>All Problems</em>' operation. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEMS_CONTAINER___ALL_PROBLEMS = 0;
+
+ /**
+ * The operation id for the '<em>All Problems</em>' operation. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEMS_CONTAINER___ALL_PROBLEMS__EOBJECT = 1;
+
+ /**
+ * The operation id for the '<em>All Diagnostics</em>' operation. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEMS_CONTAINER___ALL_DIAGNOSTICS = 2;
+
+ /**
+ * The operation id for the '<em>All Diagnostics</em>' operation. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEMS_CONTAINER___ALL_DIAGNOSTICS__EOBJECT = 3;
+
+ /**
+ * The operation id for the '<em>Get Worst Problem</em>' operation. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEMS_CONTAINER___GET_WORST_PROBLEM__EOBJECT = 4;
+
+ /**
+ * The number of operations of the '<em>EProblems Container</em>' class.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int EPROBLEMS_CONTAINER_OPERATION_COUNT = 5;
+
+ /**
+ * The meta object id for the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.ESeverity
+ * <em>ESeverity</em>}' enum. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see org.eclipse.papyrus.cdo.validation.problems.ESeverity
+ * @see org.eclipse.papyrus.cdo.validation.problems.impl.ProblemsPackageImpl#getESeverity()
+ * @generated
+ */
+ int ESEVERITY = 2;
+
+ /**
+ * The meta object id for the '<em>EDiagnostic</em>' data type. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see org.eclipse.emf.common.util.Diagnostic
+ * @see org.eclipse.papyrus.cdo.validation.problems.impl.ProblemsPackageImpl#getEDiagnostic()
+ * @generated
+ */
+ int EDIAGNOSTIC = 3;
+
+ /**
+ * The meta object id for the '<em>EIterator</em>' data type. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see java.util.Iterator
+ * @see org.eclipse.papyrus.cdo.validation.problems.impl.ProblemsPackageImpl#getEIterator()
+ * @generated
+ */
+ int EITERATOR = 4;
+
+ /**
+ * Returns the meta object for class '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem
+ * <em>EProblem</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for class '<em>EProblem</em>'.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblem
+ * @generated
+ */
+ EClass getEProblem();
+
+ /**
+ * Returns the meta object for the attribute '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getSeverity
+ * <em>Severity</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the attribute '<em>Severity</em>'.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblem#getSeverity()
+ * @see #getEProblem()
+ * @generated
+ */
+ EAttribute getEProblem_Severity();
+
+ /**
+ * Returns the meta object for the attribute '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getMessage
+ * <em>Message</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the attribute '<em>Message</em>'.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblem#getMessage()
+ * @see #getEProblem()
+ * @generated
+ */
+ EAttribute getEProblem_Message();
+
+ /**
+ * Returns the meta object for the attribute '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getSource
+ * <em>Source</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the attribute '<em>Source</em>'.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblem#getSource()
+ * @see #getEProblem()
+ * @generated
+ */
+ EAttribute getEProblem_Source();
+
+ /**
+ * Returns the meta object for the attribute '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getCode
+ * <em>Code</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the attribute '<em>Code</em>'.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblem#getCode()
+ * @see #getEProblem()
+ * @generated
+ */
+ EAttribute getEProblem_Code();
+
+ /**
+ * Returns the meta object for the reference '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getElement
+ * <em>Element</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the reference '<em>Element</em>'.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblem#getElement()
+ * @see #getEProblem()
+ * @generated
+ */
+ EReference getEProblem_Element();
+
+ /**
+ * Returns the meta object for the reference list '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getRelated
+ * <em>Related</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the reference list '<em>Related</em>'.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblem#getRelated()
+ * @see #getEProblem()
+ * @generated
+ */
+ EReference getEProblem_Related();
+
+ /**
+ * Returns the meta object for the container reference '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#getContainer
+ * <em>Container</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the container reference '<em>Container</em>'.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblem#getContainer()
+ * @see #getEProblem()
+ * @generated
+ */
+ EReference getEProblem_Container();
+
+ /**
+ * Returns the meta object for the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblem#toDiagnostic()
+ * <em>To Diagnostic</em>}' operation. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @return the meta object for the '<em>To Diagnostic</em>' operation.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblem#toDiagnostic()
+ * @generated
+ */
+ EOperation getEProblem__ToDiagnostic();
+
+ /**
+ * Returns the meta object for class '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer
+ * <em>EProblems Container</em>}'. <!-- begin-user-doc --> <!-- end-user-doc
+ * -->
+ *
+ * @return the meta object for class '<em>EProblems Container</em>'.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer
+ * @generated
+ */
+ EClass getEProblemsContainer();
+
+ /**
+ * Returns the meta object for the containment reference list '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getProblems
+ * <em>Problems</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the containment reference list '
+ * <em>Problems</em>'.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getProblems()
+ * @see #getEProblemsContainer()
+ * @generated
+ */
+ EReference getEProblemsContainer_Problems();
+
+ /**
+ * Returns the meta object for the reference list '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getSubjects
+ * <em>Subjects</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the reference list '<em>Subjects</em>'.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getSubjects()
+ * @see #getEProblemsContainer()
+ * @generated
+ */
+ EReference getEProblemsContainer_Subjects();
+
+ /**
+ * Returns the meta object for the containment reference list '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getSubcontainers
+ * <em>Subcontainers</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the containment reference list '
+ * <em>Subcontainers</em>'.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getSubcontainers()
+ * @see #getEProblemsContainer()
+ * @generated
+ */
+ EReference getEProblemsContainer_Subcontainers();
+
+ /**
+ * Returns the meta object for the container reference '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getContainer
+ * <em>Container</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the container reference '<em>Container</em>'.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getContainer()
+ * @see #getEProblemsContainer()
+ * @generated
+ */
+ EReference getEProblemsContainer_Container();
+
+ /**
+ * Returns the meta object for the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#allProblems()
+ * <em>All Problems</em>}' operation. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @return the meta object for the '<em>All Problems</em>' operation.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#allProblems()
+ * @generated
+ */
+ EOperation getEProblemsContainer__AllProblems();
+
+ /**
+ * Returns the meta object for the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#allProblems(org.eclipse.emf.ecore.EObject)
+ * <em>All Problems</em>}' operation. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @return the meta object for the '<em>All Problems</em>' operation.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#allProblems(org.eclipse.emf.ecore.EObject)
+ * @generated
+ */
+ EOperation getEProblemsContainer__AllProblems__EObject();
+
+ /**
+ * Returns the meta object for the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#allDiagnostics()
+ * <em>All Diagnostics</em>}' operation. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @return the meta object for the '<em>All Diagnostics</em>' operation.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#allDiagnostics()
+ * @generated
+ */
+ EOperation getEProblemsContainer__AllDiagnostics();
+
+ /**
+ * Returns the meta object for the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#allDiagnostics(org.eclipse.emf.ecore.EObject)
+ * <em>All Diagnostics</em>}' operation. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @return the meta object for the '<em>All Diagnostics</em>' operation.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#allDiagnostics(org.eclipse.emf.ecore.EObject)
+ * @generated
+ */
+ EOperation getEProblemsContainer__AllDiagnostics__EObject();
+
+ /**
+ * Returns the meta object for the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getWorstProblem(org.eclipse.emf.ecore.EObject)
+ * <em>Get Worst Problem</em>}' operation. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @return the meta object for the '<em>Get Worst Problem</em>' operation.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer#getWorstProblem(org.eclipse.emf.ecore.EObject)
+ * @generated
+ */
+ EOperation getEProblemsContainer__GetWorstProblem__EObject();
+
+ /**
+ * Returns the meta object for enum '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.ESeverity
+ * <em>ESeverity</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for enum '<em>ESeverity</em>'.
+ * @see org.eclipse.papyrus.cdo.validation.problems.ESeverity
+ * @generated
+ */
+ EEnum getESeverity();
+
+ /**
+ * Returns the meta object for data type '
+ * {@link org.eclipse.emf.common.util.Diagnostic <em>EDiagnostic</em>}'.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for data type '<em>EDiagnostic</em>'.
+ * @see org.eclipse.emf.common.util.Diagnostic
+ * @model instanceClass="org.eclipse.emf.common.util.Diagnostic"
+ * serializeable="false"
+ * @generated
+ */
+ EDataType getEDiagnostic();
+
+ /**
+ * Returns the meta object for data type '{@link java.util.Iterator
+ * <em>EIterator</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for data type '<em>EIterator</em>'.
+ * @see java.util.Iterator
+ * @model instanceClass="java.util.Iterator" serializeable="false"
+ * typeParameters="E"
+ * @generated
+ */
+ EDataType getEIterator();
+
+ /**
+ * Returns the factory that creates the instances of the model. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the factory that creates the instances of the model.
+ * @generated
+ */
+ ProblemsFactory getProblemsFactory();
+
+ /**
+ * <!-- begin-user-doc --> Defines literals for the meta objects that
+ * represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each operation of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ interface Literals {
+
+ /**
+ * The meta object literal for the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.impl.EProblemImpl
+ * <em>EProblem</em>}' class. <!-- begin-user-doc --> <!-- end-user-doc
+ * -->
+ *
+ * @see org.eclipse.papyrus.cdo.validation.problems.impl.EProblemImpl
+ * @see org.eclipse.papyrus.cdo.validation.problems.impl.ProblemsPackageImpl#getEProblem()
+ * @generated
+ */
+ EClass EPROBLEM = eINSTANCE.getEProblem();
+
+ /**
+ * The meta object literal for the '<em><b>Severity</b></em>' attribute
+ * feature. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EAttribute EPROBLEM__SEVERITY = eINSTANCE.getEProblem_Severity();
+
+ /**
+ * The meta object literal for the '<em><b>Message</b></em>' attribute
+ * feature. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EAttribute EPROBLEM__MESSAGE = eINSTANCE.getEProblem_Message();
+
+ /**
+ * The meta object literal for the '<em><b>Source</b></em>' attribute
+ * feature. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EAttribute EPROBLEM__SOURCE = eINSTANCE.getEProblem_Source();
+
+ /**
+ * The meta object literal for the '<em><b>Code</b></em>' attribute
+ * feature. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EAttribute EPROBLEM__CODE = eINSTANCE.getEProblem_Code();
+
+ /**
+ * The meta object literal for the '<em><b>Element</b></em>' reference
+ * feature. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EReference EPROBLEM__ELEMENT = eINSTANCE.getEProblem_Element();
+
+ /**
+ * The meta object literal for the '<em><b>Related</b></em>' reference
+ * list feature. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EReference EPROBLEM__RELATED = eINSTANCE.getEProblem_Related();
+
+ /**
+ * The meta object literal for the '<em><b>Container</b></em>' container
+ * reference feature. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EReference EPROBLEM__CONTAINER = eINSTANCE.getEProblem_Container();
+
+ /**
+ * The meta object literal for the '<em><b>To Diagnostic</b></em>'
+ * operation. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EOperation EPROBLEM___TO_DIAGNOSTIC = eINSTANCE
+ .getEProblem__ToDiagnostic();
+
+ /**
+ * The meta object literal for the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.impl.EProblemsContainerImpl
+ * <em>EProblems Container</em>}' class. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @see org.eclipse.papyrus.cdo.validation.problems.impl.EProblemsContainerImpl
+ * @see org.eclipse.papyrus.cdo.validation.problems.impl.ProblemsPackageImpl#getEProblemsContainer()
+ * @generated
+ */
+ EClass EPROBLEMS_CONTAINER = eINSTANCE.getEProblemsContainer();
+
+ /**
+ * The meta object literal for the '<em><b>Problems</b></em>'
+ * containment reference list feature. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ EReference EPROBLEMS_CONTAINER__PROBLEMS = eINSTANCE
+ .getEProblemsContainer_Problems();
+
+ /**
+ * The meta object literal for the '<em><b>Subjects</b></em>' reference
+ * list feature. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EReference EPROBLEMS_CONTAINER__SUBJECTS = eINSTANCE
+ .getEProblemsContainer_Subjects();
+
+ /**
+ * The meta object literal for the '<em><b>Subcontainers</b></em>'
+ * containment reference list feature. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ EReference EPROBLEMS_CONTAINER__SUBCONTAINERS = eINSTANCE
+ .getEProblemsContainer_Subcontainers();
+
+ /**
+ * The meta object literal for the '<em><b>Container</b></em>' container
+ * reference feature. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EReference EPROBLEMS_CONTAINER__CONTAINER = eINSTANCE
+ .getEProblemsContainer_Container();
+
+ /**
+ * The meta object literal for the '<em><b>All Problems</b></em>'
+ * operation. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EOperation EPROBLEMS_CONTAINER___ALL_PROBLEMS = eINSTANCE
+ .getEProblemsContainer__AllProblems();
+
+ /**
+ * The meta object literal for the '<em><b>All Problems</b></em>'
+ * operation. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EOperation EPROBLEMS_CONTAINER___ALL_PROBLEMS__EOBJECT = eINSTANCE
+ .getEProblemsContainer__AllProblems__EObject();
+
+ /**
+ * The meta object literal for the '<em><b>All Diagnostics</b></em>'
+ * operation. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EOperation EPROBLEMS_CONTAINER___ALL_DIAGNOSTICS = eINSTANCE
+ .getEProblemsContainer__AllDiagnostics();
+
+ /**
+ * The meta object literal for the '<em><b>All Diagnostics</b></em>'
+ * operation. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EOperation EPROBLEMS_CONTAINER___ALL_DIAGNOSTICS__EOBJECT = eINSTANCE
+ .getEProblemsContainer__AllDiagnostics__EObject();
+
+ /**
+ * The meta object literal for the '<em><b>Get Worst Problem</b></em>'
+ * operation. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EOperation EPROBLEMS_CONTAINER___GET_WORST_PROBLEM__EOBJECT = eINSTANCE
+ .getEProblemsContainer__GetWorstProblem__EObject();
+
+ /**
+ * The meta object literal for the '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.ESeverity
+ * <em>ESeverity</em>}' enum. <!-- begin-user-doc --> <!-- end-user-doc
+ * -->
+ *
+ * @see org.eclipse.papyrus.cdo.validation.problems.ESeverity
+ * @see org.eclipse.papyrus.cdo.validation.problems.impl.ProblemsPackageImpl#getESeverity()
+ * @generated
+ */
+ EEnum ESEVERITY = eINSTANCE.getESeverity();
+
+ /**
+ * The meta object literal for the '<em>EDiagnostic</em>' data type.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see org.eclipse.emf.common.util.Diagnostic
+ * @see org.eclipse.papyrus.cdo.validation.problems.impl.ProblemsPackageImpl#getEDiagnostic()
+ * @generated
+ */
+ EDataType EDIAGNOSTIC = eINSTANCE.getEDiagnostic();
+
+ /**
+ * The meta object literal for the '<em>EIterator</em>' data type. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see java.util.Iterator
+ * @see org.eclipse.papyrus.cdo.validation.problems.impl.ProblemsPackageImpl#getEIterator()
+ * @generated
+ */
+ EDataType EITERATOR = eINSTANCE.getEIterator();
+
+ }
+
+} // ProblemsPackage
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/EProblemImpl.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/EProblemImpl.java
new file mode 100644
index 00000000000..d67700d2bd7
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/EProblemImpl.java
@@ -0,0 +1,245 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems.impl;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.internal.cdo.CDOObjectImpl;
+import org.eclipse.papyrus.cdo.validation.problems.EProblem;
+import org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer;
+import org.eclipse.papyrus.cdo.validation.problems.ESeverity;
+import org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage;
+
+/**
+ * <!-- begin-user-doc --> An implementation of the model object '
+ * <em><b>EProblem</b></em>'. <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.impl.EProblemImpl#getSeverity
+ * <em>Severity</em>}</li>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.impl.EProblemImpl#getMessage
+ * <em>Message</em>}</li>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.impl.EProblemImpl#getSource
+ * <em>Source</em>}</li>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.impl.EProblemImpl#getCode
+ * <em>Code</em>}</li>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.impl.EProblemImpl#getElement
+ * <em>Element</em>}</li>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.impl.EProblemImpl#getRelated
+ * <em>Related</em>}</li>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.impl.EProblemImpl#getContainer
+ * <em>Container</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class EProblemImpl
+ extends CDOObjectImpl
+ implements EProblem {
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected EProblemImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return ProblemsPackage.Literals.EPROBLEM;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ protected int eStaticFeatureCount() {
+ return 0;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public ESeverity getSeverity() {
+ return (ESeverity) eGet(ProblemsPackage.Literals.EPROBLEM__SEVERITY,
+ true);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void setSeverity(ESeverity newSeverity) {
+ eSet(ProblemsPackage.Literals.EPROBLEM__SEVERITY, newSeverity);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public String getMessage() {
+ return (String) eGet(ProblemsPackage.Literals.EPROBLEM__MESSAGE, true);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void setMessage(String newMessage) {
+ eSet(ProblemsPackage.Literals.EPROBLEM__MESSAGE, newMessage);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public String getSource() {
+ return (String) eGet(ProblemsPackage.Literals.EPROBLEM__SOURCE, true);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void setSource(String newSource) {
+ eSet(ProblemsPackage.Literals.EPROBLEM__SOURCE, newSource);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public int getCode() {
+ return (Integer) eGet(ProblemsPackage.Literals.EPROBLEM__CODE, true);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void setCode(int newCode) {
+ eSet(ProblemsPackage.Literals.EPROBLEM__CODE, newCode);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EObject getElement() {
+ return (EObject) eGet(ProblemsPackage.Literals.EPROBLEM__ELEMENT, true);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void setElement(EObject newElement) {
+ eSet(ProblemsPackage.Literals.EPROBLEM__ELEMENT, newElement);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ public EList<EObject> getRelated() {
+ return (EList<EObject>) eGet(
+ ProblemsPackage.Literals.EPROBLEM__RELATED, true);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EProblemsContainer getContainer() {
+ return (EProblemsContainer) eGet(
+ ProblemsPackage.Literals.EPROBLEM__CONTAINER, true);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void setContainer(EProblemsContainer newContainer) {
+ eSet(ProblemsPackage.Literals.EPROBLEM__CONTAINER, newContainer);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated NOT
+ */
+ public Diagnostic toDiagnostic() {
+ Collection<EObject> related = getRelated();
+ Object[] data = new Object[1 + related.size()];
+ data[0] = getElement();
+ if (!related.isEmpty()) {
+ System.arraycopy(related.toArray(), 0, data, 1, related.size());
+ }
+ return new BasicDiagnostic(getSeverity().getValue(), getSource(),
+ getCode(), getMessage(), data);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public Object eInvoke(int operationID, EList<?> arguments)
+ throws InvocationTargetException {
+ switch (operationID) {
+ case ProblemsPackage.EPROBLEM___TO_DIAGNOSTIC :
+ return toDiagnostic();
+ }
+ return super.eInvoke(operationID, arguments);
+ }
+
+} // EProblemImpl
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/EProblemsContainerImpl.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/EProblemsContainerImpl.java
new file mode 100644
index 00000000000..973c0094517
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/EProblemsContainerImpl.java
@@ -0,0 +1,287 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems.impl;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.internal.cdo.CDOObjectImpl;
+import org.eclipse.papyrus.cdo.validation.problems.EProblem;
+import org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer;
+import org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage;
+
+/**
+ * <!-- begin-user-doc --> An implementation of the model object '
+ * <em><b>EProblems Container</b></em>'. <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.impl.EProblemsContainerImpl#getProblems
+ * <em>Problems</em>}</li>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.impl.EProblemsContainerImpl#getSubjects
+ * <em>Subjects</em>}</li>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.impl.EProblemsContainerImpl#getSubcontainers
+ * <em>Subcontainers</em>}</li>
+ * <li>
+ * {@link org.eclipse.papyrus.cdo.validation.problems.impl.EProblemsContainerImpl#getContainer
+ * <em>Container</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class EProblemsContainerImpl
+ extends CDOObjectImpl
+ implements EProblemsContainer {
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected EProblemsContainerImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return ProblemsPackage.Literals.EPROBLEMS_CONTAINER;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ protected int eStaticFeatureCount() {
+ return 0;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ public EList<EProblem> getProblems() {
+ return (EList<EProblem>) eGet(
+ ProblemsPackage.Literals.EPROBLEMS_CONTAINER__PROBLEMS, true);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ public EList<EObject> getSubjects() {
+ return (EList<EObject>) eGet(
+ ProblemsPackage.Literals.EPROBLEMS_CONTAINER__SUBJECTS, true);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ public EList<EProblemsContainer> getSubcontainers() {
+ return (EList<EProblemsContainer>) eGet(
+ ProblemsPackage.Literals.EPROBLEMS_CONTAINER__SUBCONTAINERS, true);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EProblemsContainer getContainer() {
+ return (EProblemsContainer) eGet(
+ ProblemsPackage.Literals.EPROBLEMS_CONTAINER__CONTAINER, true);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void setContainer(EProblemsContainer newContainer) {
+ eSet(ProblemsPackage.Literals.EPROBLEMS_CONTAINER__CONTAINER,
+ newContainer);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated NOT
+ */
+ public Iterator<EProblem> allProblems() {
+ return new EProblemsIterator(eAllContents());
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated NOT
+ */
+ public Iterator<EProblem> allProblems(final EObject element) {
+ return new EProblemsIterator(eAllContents()) {
+
+ @Override
+ protected boolean accept(EProblem problem) {
+ return problem.getElement() == element;
+ }
+ };
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated NOT
+ */
+ public EList<Diagnostic> allDiagnostics() {
+ List<Diagnostic> result = new java.util.ArrayList<Diagnostic>();
+
+ for (Iterator<EProblem> allProblems = allProblems(); allProblems
+ .hasNext();) {
+ result.add(allProblems.next().toDiagnostic());
+ }
+
+ return new BasicEList.UnmodifiableEList<Diagnostic>(result.size(),
+ result.toArray());
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated NOT
+ */
+ public EList<Diagnostic> allDiagnostics(EObject element) {
+ List<Diagnostic> result = new java.util.ArrayList<Diagnostic>();
+
+ for (Iterator<EProblem> allProblems = allProblems(element); allProblems
+ .hasNext();) {
+ result.add(allProblems.next().toDiagnostic());
+ }
+
+ return new BasicEList.UnmodifiableEList<Diagnostic>(result.size(),
+ result.toArray());
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated NOT
+ */
+ public EProblem getWorstProblem(EObject element) {
+ EProblem result = null;
+
+ for (Iterator<EProblem> problems = allProblems(element); problems
+ .hasNext();) {
+ EProblem next = problems.next();
+ if (result == null) {
+ result = next;
+ } else if (next.getSeverity().compareTo(result.getSeverity()) > 0) {
+ result = next;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public Object eInvoke(int operationID, EList<?> arguments)
+ throws InvocationTargetException {
+ switch (operationID) {
+ case ProblemsPackage.EPROBLEMS_CONTAINER___ALL_PROBLEMS :
+ return allProblems();
+ case ProblemsPackage.EPROBLEMS_CONTAINER___ALL_PROBLEMS__EOBJECT :
+ return allProblems((EObject) arguments.get(0));
+ case ProblemsPackage.EPROBLEMS_CONTAINER___ALL_DIAGNOSTICS :
+ return allDiagnostics();
+ case ProblemsPackage.EPROBLEMS_CONTAINER___ALL_DIAGNOSTICS__EOBJECT :
+ return allDiagnostics((EObject) arguments.get(0));
+ case ProblemsPackage.EPROBLEMS_CONTAINER___GET_WORST_PROBLEM__EOBJECT :
+ return getWorstProblem((EObject) arguments.get(0));
+ }
+ return super.eInvoke(operationID, arguments);
+ }
+
+ private static class EProblemsIterator
+ implements Iterator<EProblem> {
+
+ private final Iterator<?> delegate;
+
+ private EProblem preparedNext;
+
+ public EProblemsIterator(Iterator<?> delegate) {
+ this.delegate = delegate;
+ }
+
+ public boolean hasNext() {
+ if (preparedNext == null) {
+ while (delegate.hasNext()) {
+ Object next = delegate.next();
+ if (next instanceof EProblem) {
+ EProblem problem = (EProblem) next;
+ if (accept(problem)) {
+ preparedNext = problem;
+ break;
+ }
+ }
+ }
+ }
+
+ return preparedNext != null;
+ }
+
+ protected boolean accept(EProblem problem) {
+ return true;
+ }
+
+ public EProblem next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+
+ EProblem result = preparedNext;
+ preparedNext = null;
+ return result;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("remove");
+ }
+ }
+
+} // EProblemsContainerImpl
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/ProblemsFactoryImpl.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/ProblemsFactoryImpl.java
new file mode 100644
index 00000000000..a475ac3205d
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/ProblemsFactoryImpl.java
@@ -0,0 +1,181 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems.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.cdo.validation.problems.EProblem;
+import org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer;
+import org.eclipse.papyrus.cdo.validation.problems.ESeverity;
+import org.eclipse.papyrus.cdo.validation.problems.ProblemsFactory;
+import org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage;
+
+/**
+ * <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+public class ProblemsFactoryImpl
+ extends EFactoryImpl
+ implements ProblemsFactory {
+
+ /**
+ * Creates the default factory implementation. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ public static ProblemsFactory init() {
+ try {
+ ProblemsFactory theProblemsFactory = (ProblemsFactory) EPackage.Registry.INSTANCE
+ .getEFactory(ProblemsPackage.eNS_URI);
+ if (theProblemsFactory != null) {
+ return theProblemsFactory;
+ }
+ } catch (Exception exception) {
+ EcorePlugin.INSTANCE.log(exception);
+ }
+ return new ProblemsFactoryImpl();
+ }
+
+ /**
+ * Creates an instance of the factory. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ public ProblemsFactoryImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public EObject create(EClass eClass) {
+ switch (eClass.getClassifierID()) {
+ case ProblemsPackage.EPROBLEM :
+ return createEProblem();
+ case ProblemsPackage.EPROBLEMS_CONTAINER :
+ return createEProblemsContainer();
+ default :
+ throw new IllegalArgumentException(
+ "The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public Object createFromString(EDataType eDataType, String initialValue) {
+ switch (eDataType.getClassifierID()) {
+ case ProblemsPackage.ESEVERITY :
+ return createESeverityFromString(eDataType, initialValue);
+ default :
+ throw new IllegalArgumentException(
+ "The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public String convertToString(EDataType eDataType, Object instanceValue) {
+ switch (eDataType.getClassifierID()) {
+ case ProblemsPackage.ESEVERITY :
+ return convertESeverityToString(eDataType, instanceValue);
+ default :
+ throw new IllegalArgumentException(
+ "The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EProblem createEProblem() {
+ EProblemImpl eProblem = new EProblemImpl();
+ return eProblem;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EProblemsContainer createEProblemsContainer() {
+ EProblemsContainerImpl eProblemsContainer = new EProblemsContainerImpl();
+ return eProblemsContainer;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public ESeverity createESeverityFromString(EDataType eDataType,
+ String initialValue) {
+ ESeverity result = ESeverity.get(initialValue);
+ if (result == null)
+ throw new IllegalArgumentException(
+ "The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return result;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public String convertESeverityToString(EDataType eDataType,
+ Object instanceValue) {
+ return instanceValue == null
+ ? null
+ : instanceValue.toString();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public ProblemsPackage getProblemsPackage() {
+ return (ProblemsPackage) getEPackage();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @deprecated
+ * @generated
+ */
+ @Deprecated
+ public static ProblemsPackage getPackage() {
+ return ProblemsPackage.eINSTANCE;
+ }
+
+} // ProblemsFactoryImpl
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/ProblemsPackageImpl.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/ProblemsPackageImpl.java
new file mode 100644
index 00000000000..4bef8927e95
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/impl/ProblemsPackageImpl.java
@@ -0,0 +1,560 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems.impl;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EGenericType;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+import org.eclipse.papyrus.cdo.validation.problems.EProblem;
+import org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer;
+import org.eclipse.papyrus.cdo.validation.problems.ESeverity;
+import org.eclipse.papyrus.cdo.validation.problems.ProblemsFactory;
+import org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage;
+
+/**
+ * <!-- begin-user-doc --> An implementation of the model <b>Package</b>. <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+public class ProblemsPackageImpl
+ extends EPackageImpl
+ implements ProblemsPackage {
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private EClass eProblemEClass = null;
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private EClass eProblemsContainerEClass = null;
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private EEnum eSeverityEEnum = null;
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private EDataType eDiagnosticEDataType = null;
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private EDataType eIteratorEDataType = null;
+
+ /**
+ * Creates an instance of the model <b>Package</b>, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the
+ * package package URI value.
+ * <p>
+ * 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. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage#eNS_URI
+ * @see #init()
+ * @generated
+ */
+ private ProblemsPackageImpl() {
+ super(eNS_URI, ProblemsFactory.eINSTANCE);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the <b>Package</b> for this model,
+ * and for any others upon which it depends.
+ *
+ * <p>
+ * This method is used to initialize {@link ProblemsPackage#eINSTANCE} when
+ * that field is accessed. Clients should not invoke it directly. Instead,
+ * they should simply access that field to obtain the package. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see #eNS_URI
+ * @see #createPackageContents()
+ * @see #initializePackageContents()
+ * @generated
+ */
+ public static ProblemsPackage init() {
+ if (isInited)
+ return (ProblemsPackage) EPackage.Registry.INSTANCE
+ .getEPackage(ProblemsPackage.eNS_URI);
+
+ // Obtain or create and register package
+ ProblemsPackageImpl theProblemsPackage = (ProblemsPackageImpl) (EPackage.Registry.INSTANCE
+ .get(eNS_URI) instanceof ProblemsPackageImpl
+ ? EPackage.Registry.INSTANCE.get(eNS_URI)
+ : new ProblemsPackageImpl());
+
+ isInited = true;
+
+ // Create package meta-data objects
+ theProblemsPackage.createPackageContents();
+
+ // Initialize created meta-data
+ theProblemsPackage.initializePackageContents();
+
+ // Mark meta-data to indicate it can't be changed
+ theProblemsPackage.freeze();
+
+ // Update the registry and return the package
+ EPackage.Registry.INSTANCE.put(ProblemsPackage.eNS_URI,
+ theProblemsPackage);
+ return theProblemsPackage;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EClass getEProblem() {
+ return eProblemEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EAttribute getEProblem_Severity() {
+ return (EAttribute) eProblemEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EAttribute getEProblem_Message() {
+ return (EAttribute) eProblemEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EAttribute getEProblem_Source() {
+ return (EAttribute) eProblemEClass.getEStructuralFeatures().get(2);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EAttribute getEProblem_Code() {
+ return (EAttribute) eProblemEClass.getEStructuralFeatures().get(3);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EReference getEProblem_Element() {
+ return (EReference) eProblemEClass.getEStructuralFeatures().get(4);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EReference getEProblem_Related() {
+ return (EReference) eProblemEClass.getEStructuralFeatures().get(5);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EReference getEProblem_Container() {
+ return (EReference) eProblemEClass.getEStructuralFeatures().get(6);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EOperation getEProblem__ToDiagnostic() {
+ return eProblemEClass.getEOperations().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EClass getEProblemsContainer() {
+ return eProblemsContainerEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EReference getEProblemsContainer_Problems() {
+ return (EReference) eProblemsContainerEClass.getEStructuralFeatures()
+ .get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EReference getEProblemsContainer_Subjects() {
+ return (EReference) eProblemsContainerEClass.getEStructuralFeatures()
+ .get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EReference getEProblemsContainer_Subcontainers() {
+ return (EReference) eProblemsContainerEClass.getEStructuralFeatures()
+ .get(2);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EReference getEProblemsContainer_Container() {
+ return (EReference) eProblemsContainerEClass.getEStructuralFeatures()
+ .get(3);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EOperation getEProblemsContainer__AllProblems() {
+ return eProblemsContainerEClass.getEOperations().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EOperation getEProblemsContainer__AllProblems__EObject() {
+ return eProblemsContainerEClass.getEOperations().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EOperation getEProblemsContainer__AllDiagnostics() {
+ return eProblemsContainerEClass.getEOperations().get(2);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EOperation getEProblemsContainer__AllDiagnostics__EObject() {
+ return eProblemsContainerEClass.getEOperations().get(3);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EOperation getEProblemsContainer__GetWorstProblem__EObject() {
+ return eProblemsContainerEClass.getEOperations().get(4);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EEnum getESeverity() {
+ return eSeverityEEnum;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EDataType getEDiagnostic() {
+ return eDiagnosticEDataType;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EDataType getEIterator() {
+ return eIteratorEDataType;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public ProblemsFactory getProblemsFactory() {
+ return (ProblemsFactory) getEFactoryInstance();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @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. <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void createPackageContents() {
+ if (isCreated)
+ return;
+ isCreated = true;
+
+ // Create classes and their features
+ eProblemEClass = createEClass(EPROBLEM);
+ createEAttribute(eProblemEClass, EPROBLEM__SEVERITY);
+ createEAttribute(eProblemEClass, EPROBLEM__MESSAGE);
+ createEAttribute(eProblemEClass, EPROBLEM__SOURCE);
+ createEAttribute(eProblemEClass, EPROBLEM__CODE);
+ createEReference(eProblemEClass, EPROBLEM__ELEMENT);
+ createEReference(eProblemEClass, EPROBLEM__RELATED);
+ createEReference(eProblemEClass, EPROBLEM__CONTAINER);
+ createEOperation(eProblemEClass, EPROBLEM___TO_DIAGNOSTIC);
+
+ eProblemsContainerEClass = createEClass(EPROBLEMS_CONTAINER);
+ createEReference(eProblemsContainerEClass,
+ EPROBLEMS_CONTAINER__PROBLEMS);
+ createEReference(eProblemsContainerEClass,
+ EPROBLEMS_CONTAINER__SUBJECTS);
+ createEReference(eProblemsContainerEClass,
+ EPROBLEMS_CONTAINER__SUBCONTAINERS);
+ createEReference(eProblemsContainerEClass,
+ EPROBLEMS_CONTAINER__CONTAINER);
+ createEOperation(eProblemsContainerEClass,
+ EPROBLEMS_CONTAINER___ALL_PROBLEMS);
+ createEOperation(eProblemsContainerEClass,
+ EPROBLEMS_CONTAINER___ALL_PROBLEMS__EOBJECT);
+ createEOperation(eProblemsContainerEClass,
+ EPROBLEMS_CONTAINER___ALL_DIAGNOSTICS);
+ createEOperation(eProblemsContainerEClass,
+ EPROBLEMS_CONTAINER___ALL_DIAGNOSTICS__EOBJECT);
+ createEOperation(eProblemsContainerEClass,
+ EPROBLEMS_CONTAINER___GET_WORST_PROBLEM__EOBJECT);
+
+ // Create enums
+ eSeverityEEnum = createEEnum(ESEVERITY);
+
+ // Create data types
+ eDiagnosticEDataType = createEDataType(EDIAGNOSTIC);
+ eIteratorEDataType = createEDataType(EITERATOR);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @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. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void initializePackageContents() {
+ if (isInitialized)
+ return;
+ isInitialized = true;
+
+ // Initialize package
+ setName(eNAME);
+ setNsPrefix(eNS_PREFIX);
+ setNsURI(eNS_URI);
+
+ // Create type parameters
+ addETypeParameter(eIteratorEDataType, "E"); //$NON-NLS-1$
+
+ // Set bounds for type parameters
+
+ // Add supertypes to classes
+
+ // Initialize classes, features, and operations; add parameters
+ initEClass(
+ eProblemEClass,
+ EProblem.class,
+ "EProblem", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
+ initEAttribute(
+ getEProblem_Severity(),
+ this.getESeverity(),
+ "severity", null, 1, 1, EProblem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEAttribute(
+ getEProblem_Message(),
+ ecorePackage.getEString(),
+ "message", null, 1, 1, EProblem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEAttribute(
+ getEProblem_Source(),
+ ecorePackage.getEString(),
+ "source", null, 1, 1, EProblem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEAttribute(
+ getEProblem_Code(),
+ ecorePackage.getEInt(),
+ "code", null, 0, 1, EProblem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEReference(
+ getEProblem_Element(),
+ ecorePackage.getEObject(),
+ null,
+ "element", null, 1, 1, EProblem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEReference(
+ getEProblem_Related(),
+ ecorePackage.getEObject(),
+ null,
+ "related", null, 0, -1, EProblem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEReference(
+ getEProblem_Container(),
+ this.getEProblemsContainer(),
+ this.getEProblemsContainer_Problems(),
+ "container", null, 0, 1, EProblem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+
+ initEOperation(getEProblem__ToDiagnostic(), this.getEDiagnostic(),
+ "toDiagnostic", 1, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$
+
+ initEClass(
+ eProblemsContainerEClass,
+ EProblemsContainer.class,
+ "EProblemsContainer", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
+ initEReference(
+ getEProblemsContainer_Problems(),
+ this.getEProblem(),
+ this.getEProblem_Container(),
+ "problems", null, 0, -1, EProblemsContainer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEReference(
+ getEProblemsContainer_Subjects(),
+ ecorePackage.getEObject(),
+ null,
+ "subjects", null, 0, -1, EProblemsContainer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEReference(
+ getEProblemsContainer_Subcontainers(),
+ this.getEProblemsContainer(),
+ this.getEProblemsContainer_Container(),
+ "subcontainers", null, 0, -1, EProblemsContainer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+ initEReference(
+ getEProblemsContainer_Container(),
+ this.getEProblemsContainer(),
+ this.getEProblemsContainer_Subcontainers(),
+ "container", null, 0, 1, EProblemsContainer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
+
+ EOperation op = initEOperation(getEProblemsContainer__AllProblems(),
+ null, "allProblems", 1, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$
+ EGenericType g1 = createEGenericType(this.getEIterator());
+ EGenericType g2 = createEGenericType(this.getEProblem());
+ g1.getETypeArguments().add(g2);
+ initEOperation(op, g1);
+
+ op = initEOperation(getEProblemsContainer__AllProblems__EObject(),
+ null, "allProblems", 1, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$
+ addEParameter(op, ecorePackage.getEObject(),
+ "element", 1, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$
+ g1 = createEGenericType(this.getEIterator());
+ g2 = createEGenericType(this.getEProblem());
+ g1.getETypeArguments().add(g2);
+ initEOperation(op, g1);
+
+ initEOperation(getEProblemsContainer__AllDiagnostics(),
+ this.getEDiagnostic(),
+ "allDiagnostics", 0, -1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$
+
+ op = initEOperation(getEProblemsContainer__AllDiagnostics__EObject(),
+ this.getEDiagnostic(),
+ "allDiagnostics", 0, -1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$
+ addEParameter(op, ecorePackage.getEObject(),
+ "element", 1, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$
+
+ op = initEOperation(getEProblemsContainer__GetWorstProblem__EObject(),
+ this.getEProblem(), "getWorstProblem", 0, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$
+ addEParameter(op, ecorePackage.getEObject(),
+ "element", 0, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$
+
+ // Initialize enums and add enum literals
+ initEEnum(eSeverityEEnum, ESeverity.class, "ESeverity"); //$NON-NLS-1$
+ addEEnumLiteral(eSeverityEEnum, ESeverity.OK);
+ addEEnumLiteral(eSeverityEEnum, ESeverity.INFO);
+ addEEnumLiteral(eSeverityEEnum, ESeverity.WARNING);
+ addEEnumLiteral(eSeverityEEnum, ESeverity.ERROR);
+ addEEnumLiteral(eSeverityEEnum, ESeverity.CANCEL);
+
+ // Initialize data types
+ initEDataType(eDiagnosticEDataType, Diagnostic.class,
+ "EDiagnostic", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
+ initEDataType(eIteratorEDataType, Iterator.class,
+ "EIterator", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
+
+ // Create resource
+ createResource(eNS_URI);
+ }
+
+} // ProblemsPackageImpl
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/internal/ProblemsPlugin.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/internal/ProblemsPlugin.java
new file mode 100644
index 00000000000..b0843d4f908
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/internal/ProblemsPlugin.java
@@ -0,0 +1,100 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems.internal;
+
+import org.eclipse.emf.common.EMFPlugin;
+
+import org.eclipse.emf.common.util.ResourceLocator;
+
+/**
+ * This is the central singleton for the Problems model plugin.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public final class ProblemsPlugin
+ extends EMFPlugin {
+
+ /**
+ * Keep track of the singleton.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final ProblemsPlugin INSTANCE = new ProblemsPlugin();
+
+ /**
+ * Keep track of the singleton.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static Implementation plugin;
+
+ /**
+ * Create the instance.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ProblemsPlugin() {
+ super(new ResourceLocator[]{});
+ }
+
+ /**
+ * Returns the singleton instance of the Eclipse plugin.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the singleton instance.
+ * @generated
+ */
+ @Override
+ public ResourceLocator getPluginResourceLocator() {
+ return plugin;
+ }
+
+ /**
+ * Returns the singleton instance of the Eclipse plugin.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the singleton instance.
+ * @generated
+ */
+ public static Implementation getPlugin() {
+ return plugin;
+ }
+
+ /**
+ * The actual implementation of the Eclipse <b>Plugin</b>.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static class Implementation
+ extends EclipsePlugin {
+
+ /**
+ * Creates an instance.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Implementation() {
+ super();
+
+ // Remember the static instance.
+ //
+ plugin = this;
+ }
+ }
+
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsAdapterFactory.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsAdapterFactory.java
new file mode 100644
index 00000000000..5de7e643b44
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsAdapterFactory.java
@@ -0,0 +1,153 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems.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.cdo.validation.problems.EProblem;
+import org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer;
+import org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage;
+
+/**
+ * <!-- begin-user-doc --> The <b>Adapter Factory</b> for the model. It provides
+ * an adapter <code>createXXX</code> method for each class of the model. <!--
+ * end-user-doc -->
+ *
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage
+ * @generated
+ */
+public class ProblemsAdapterFactory
+ extends AdapterFactoryImpl {
+
+ /**
+ * The cached model package. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected static ProblemsPackage modelPackage;
+
+ /**
+ * Creates an instance of the adapter factory. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ public ProblemsAdapterFactory() {
+ if (modelPackage == null) {
+ modelPackage = ProblemsPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Returns whether this factory is applicable for the type of the object.
+ * <!-- begin-user-doc --> This implementation returns <code>true</code> if
+ * the object is either the model's package or is an instance object of the
+ * model. <!-- end-user-doc -->
+ *
+ * @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 <code>createXXX</code> methods. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected ProblemsSwitch<Adapter> modelSwitch = new ProblemsSwitch<Adapter>() {
+
+ @Override
+ public Adapter caseEProblem(EProblem object) {
+ return createEProblemAdapter();
+ }
+
+ @Override
+ public Adapter caseEProblemsContainer(EProblemsContainer object) {
+ return createEProblemsContainerAdapter();
+ }
+
+ @Override
+ public Adapter defaultCase(EObject object) {
+ return createEObjectAdapter();
+ }
+ };
+
+ /**
+ * Creates an adapter for the <code>target</code>. <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @param target
+ * the object to adapt.
+ * @return the adapter for the <code>target</code>.
+ * @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.cdo.validation.problems.EProblem
+ * <em>EProblem</em>}'. <!-- begin-user-doc --> 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. <!-- end-user-doc
+ * -->
+ *
+ * @return the new adapter.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblem
+ * @generated
+ */
+ public Adapter createEProblemAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '
+ * {@link org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer
+ * <em>EProblems Container</em>}'. <!-- begin-user-doc --> 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.
+ * <!-- end-user-doc -->
+ *
+ * @return the new adapter.
+ * @see org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer
+ * @generated
+ */
+ public Adapter createEProblemsContainerAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for the default case. <!-- begin-user-doc --> This
+ * default implementation returns null. <!-- end-user-doc -->
+ *
+ * @return the new adapter.
+ * @generated
+ */
+ public Adapter createEObjectAdapter() {
+ return null;
+ }
+
+} // ProblemsAdapterFactory
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsEvent.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsEvent.java
new file mode 100644
index 00000000000..63f52b8c189
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsEvent.java
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.validation.problems.util;
+
+import java.util.EventObject;
+
+import org.eclipse.papyrus.cdo.validation.problems.EProblem;
+
+/**
+ * This is the ProblemsEvent type. Enjoy.
+ */
+public class ProblemsEvent
+ extends EventObject {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final int ADDED = 0;
+
+ public static final int REMOVED = 1;
+
+ private final int eventType;
+
+ private final EProblem problem;
+
+ public ProblemsEvent(ProblemsManager source, int eventType, EProblem problem) {
+ super(source);
+
+ this.eventType = eventType;
+ this.problem = problem;
+ }
+
+ public ProblemsManager getSource() {
+ return (ProblemsManager) super.getSource();
+ }
+
+ public int getEventType() {
+ return eventType;
+ }
+
+ public EProblem getProblem() {
+ return problem;
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsListener.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsListener.java
new file mode 100644
index 00000000000..b1f4ec189d6
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsListener.java
@@ -0,0 +1,25 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.validation.problems.util;
+
+import java.util.EventListener;
+
+/**
+ * This is the ProblemsListener type. Enjoy.
+ */
+public interface ProblemsListener
+ extends EventListener {
+
+ void problemAdded(ProblemsEvent event);
+
+ void problemRemoved(ProblemsEvent event);
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsManager.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsManager.java
new file mode 100644
index 00000000000..ab6b61a365b
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsManager.java
@@ -0,0 +1,603 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.cdo.validation.problems.util;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.eclipse.core.runtime.IStatus;
+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.notify.impl.AdapterImpl;
+import org.eclipse.emf.common.notify.impl.BasicNotifierImpl.EObservableAdapterList;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.cdo.validation.problems.EProblem;
+import org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer;
+import org.eclipse.papyrus.cdo.validation.problems.ESeverity;
+import org.eclipse.papyrus.cdo.validation.problems.ProblemsFactory;
+import org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage;
+import org.eclipse.papyrus.cdo.validation.problems.internal.ProblemsPlugin;
+
+/**
+ * A utility for managing a single {@link EProblemsContainer} containing
+ * problems for model elements in a {@link ResourceSet} scope.
+ */
+public class ProblemsManager {
+
+ private final ManagerAdapter adapter;
+
+ private EProblemsContainer problems;
+
+ private ECrossReferenceAdapter xrefs;
+
+ private ProblemsAdapter problemsAdapter;
+
+ private CopyOnWriteArrayList<ProblemsListener> listeners = new CopyOnWriteArrayList<ProblemsListener>();
+
+ ProblemsManager(Notifier notifier) {
+ adapter = new ManagerAdapter();
+ notifier.eAdapters().add(adapter);
+ ((EObservableAdapterList) notifier.eAdapters()).addListener(adapter);
+
+ xrefs = ECrossReferenceAdapter.getCrossReferenceAdapter(notifier);
+
+ problems = ProblemsFactory.eINSTANCE.createEProblemsContainer();
+ if (xrefs != null) {
+ problems.eAdapters().add(xrefs);
+ }
+
+ problemsAdapter = new ProblemsAdapter();
+ problems.eAdapters().add(problemsAdapter);
+ }
+
+ /**
+ * Gets the problems manager associated with the specified
+ * {@code resourceSet}. If none has been created yet, then it is created and
+ * associated on demand.
+ *
+ * @param resourceSet
+ * a resource set
+ *
+ * @return the {@code resourceSet}'s problems manager (never {@code null})
+ */
+ public static ProblemsManager getProblemsManager(ResourceSet resourceSet) {
+ ProblemsManager result = null;
+
+ for (Adapter next : resourceSet.eAdapters()) {
+ if (next instanceof ManagerAdapter) {
+ result = ((ManagerAdapter) next).getManager();
+ break;
+ }
+ }
+
+ if (result == null) {
+ result = new ProblemsManager(resourceSet);
+ }
+
+ return result;
+ }
+
+ /**
+ * Creates a new problems manager on a custom problem class and associates
+ * it with the specified {@code resourceSet}.
+ *
+ * @param resourceSet
+ * a resource set
+ * @param customProblemClass
+ * an {@link EClass} conforming to <tt>EProblem</tt> to create
+ * instead of the default <tt>EProblem</tt> type
+ *
+ * @return the new problems manager
+ */
+ public static ProblemsManager createProblemsManager(
+ ResourceSet resourceSet, EClass customProblemClass) {
+ if (customProblemClass == null) {
+ throw new IllegalArgumentException("null customProblemClass");
+ }
+
+ return new ProblemsManager.Custom(resourceSet, customProblemClass);
+ }
+
+ public static IStatus toIStatus(EProblem problem) {
+ return new StatusWrapper(problem);
+ }
+
+ public EProblem createProblem(Diagnostic diagnostic) {
+ EProblem result;
+ EObject element = null;
+
+ Iterator<?> data = diagnostic.getData().iterator();
+ while (data.hasNext()) {
+ Object next = data.next();
+
+ // CDOResources are EObjects
+ if ((next instanceof EObject) && !(next instanceof Resource)) {
+ element = (EObject) next;
+ break;
+ }
+ }
+
+ if (element == null) {
+ // can't create a problem without the element to attach it to
+ result = null;
+ } else {
+ result = createProblem();
+
+ result.setSeverity(ESeverity.get(diagnostic.getSeverity()));
+ result.setSource(diagnostic.getSource());
+ result.setCode(diagnostic.getCode());
+ result.setMessage(diagnostic.getMessage());
+
+ result.setElement(element);
+ while (data.hasNext()) {
+ Object next = data.next();
+
+ // CDOResources are EObjects
+ if ((next instanceof EObject) && !(next instanceof Resource)) {
+ result.getRelated().add((EObject) next);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Obtains all of the problems tracked by this problems manager.
+ */
+ public Iterator<EProblem> getAllProblems() {
+ return problems.allProblems();
+ }
+
+ /**
+ * Obtains all of the problems tracked by this problems manager for the
+ * specified {@code eObject}.
+ *
+ * @param eObject
+ * an object in the resource set scope for which I track problems
+ */
+ public Iterator<EProblem> getAllProblems(EObject eObject) {
+ Iterator<EProblem> result;
+
+ if (xrefs == null) {
+ result = problems.allProblems(eObject);
+ } else {
+ result = new EProblemsIterator<EStructuralFeature.Setting>(xrefs
+ .getNonNavigableInverseReferences(eObject).iterator()) {
+
+ @Override
+ protected EProblem convert(EStructuralFeature.Setting object) {
+ return object.getEStructuralFeature() == ProblemsPackage.Literals.EPROBLEM__ELEMENT
+ ? (EProblem) object.getEObject()
+ : null;
+ }
+ };
+ }
+
+ return result;
+ }
+
+ /**
+ * Obtains all of the problems tracked by this problems manager for the
+ * objects in the specified {@code resource}.
+ *
+ * @param resource
+ * an resource in the resource set scope for which I track
+ * problems
+ */
+ public Iterator<EProblem> getAllProblems(final Resource resource) {
+ Iterator<EProblem> result;
+
+ if (xrefs == null) {
+ // more efficient to iterate all problems and filter for those whose
+ // element is in the resource than to repeat iteration over the
+ // problems for each object in the resource
+ result = new Iterator<EProblem>() {
+
+ private final Iterator<EProblem> all = getAllProblems();
+
+ private EProblem next;
+
+ public boolean hasNext() {
+ if (next == null) {
+ while (all.hasNext()) {
+ EProblem couldBe = all.next();
+ if (couldBe.getElement().eResource() == resource) {
+ next = couldBe;
+ break;
+ }
+ }
+ }
+
+ return next != null;
+ }
+
+ public EProblem next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+
+ EProblem result = next;
+ next = null;
+ return result;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("remove");
+ }
+ };
+ } else {
+ // concatenate iterators for all of the proper contents of the
+ // resource
+ result = new Iterator<EProblem>() {
+
+ private final Iterator<EObject> objects = EcoreUtil
+ .getAllProperContents(resource, false);
+
+ private Iterator<EProblem> iterator = Collections
+ .<EProblem> emptyList().iterator();
+
+ public boolean hasNext() {
+ while (!iterator.hasNext() && objects.hasNext()) {
+ iterator = getAllProblems(objects.next());
+ }
+
+ return iterator.hasNext();
+ }
+
+ public EProblem next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+
+ return iterator.next();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("remove");
+ }
+ };
+ }
+
+ return result;
+ }
+
+ public boolean addProblem(EProblem problem) {
+ return problems.getProblems().add(problem);
+ }
+
+ public boolean addDiagnostic(Diagnostic diagnostic) {
+ boolean result;
+
+ if (!diagnostic.getChildren().isEmpty()) {
+ // add the children
+ result = false;
+ for (Diagnostic next : diagnostic.getChildren()) {
+ result = addDiagnostic(next) || result;
+ }
+ } else {
+ EProblem problem = createProblem(diagnostic);
+ result = problem != null && addProblem(problem);
+ }
+
+ return result;
+ }
+
+ public void purgeProblems(EObject object) {
+ purgeProblems(Collections.singleton(object));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void purgeProblems(Collection<? extends EObject> objects) {
+ purgeProblems((Iterator<? extends EObject>) EcoreUtil
+ .getAllContents(objects));
+ }
+
+ public void purgeProblems(Resource resource) {
+ purgeProblems(EcoreUtil.<EObject> getAllProperContents(resource, false));
+ }
+
+ public void purgeAllProblems() {
+ for (EProblem next : problems.getProblems()) {
+ next.eAdapters().clear();
+ }
+ problems.getProblems().clear();
+ }
+
+ /**
+ * Disposes me. I remove any adapters I may have attached to any notifiers
+ * and purge my problems model. After invocation of this method, I can no
+ * longer be used.
+ */
+ public void dispose() {
+ if (problems != null) {
+ problems.eAdapters().clear();
+ for (Iterator<EObject> iter = problems.eAllContents(); iter
+ .hasNext();) {
+ iter.next().eAdapters().clear();
+ }
+
+ problems = null;
+ }
+
+ Notifier target = adapter.getTarget();
+ if (target != null) {
+ target.eAdapters().remove(adapter);
+ }
+
+ listeners.clear();
+ }
+
+ protected EProblem createProblem() {
+ return ProblemsFactory.eINSTANCE.createEProblem();
+ }
+
+ void setCrossReferenceAdapter(ECrossReferenceAdapter adapter) {
+ if (adapter != xrefs) {
+ if (xrefs != null && problems != null) {
+ problems.eAdapters().remove(xrefs);
+ }
+
+ xrefs = adapter;
+
+ if (adapter != null && problems != null) {
+ problems.eAdapters().add(adapter);
+ }
+ }
+ }
+
+ private void purgeProblems(Iterator<? extends EObject> contents) {
+ List<EProblem> toRemove = new java.util.ArrayList<EProblem>();
+
+ while (contents.hasNext()) {
+ Iterator<EProblem> problems = getAllProblems(contents.next());
+ while (problems.hasNext()) {
+ toRemove.add(problems.next());
+ }
+ }
+
+ for (EProblem next : toRemove) {
+ next.eAdapters().clear();
+ }
+ problems.getProblems().removeAll(toRemove);
+ }
+
+ public static void delete(EProblem problem) {
+ EcoreUtil.remove(problem);
+ problem.setElement(null);
+ problem.eAdapters().clear();
+ }
+
+ public void addProblemsListener(ProblemsListener listener) {
+ listeners.addIfAbsent(listener);
+ }
+
+ public void removeProblemsListener(ProblemsListener listener) {
+ listeners.remove(listener);
+ }
+
+ protected void fireAdded(EProblem problem) {
+ if (!listeners.isEmpty()) {
+ ProblemsEvent event = new ProblemsEvent(this, ProblemsEvent.ADDED,
+ problem);
+ for (ProblemsListener next : listeners) {
+ try {
+ next.problemAdded(event);
+ } catch (Exception e) {
+ ProblemsPlugin.INSTANCE.log(e);
+ }
+ }
+ }
+ }
+
+ protected void fireRemoved(EProblem problem) {
+ if (!listeners.isEmpty()) {
+ ProblemsEvent event = new ProblemsEvent(this,
+ ProblemsEvent.REMOVED, problem);
+ for (ProblemsListener next : listeners) {
+ try {
+ next.problemRemoved(event);
+ } catch (Exception e) {
+ ProblemsPlugin.INSTANCE.log(e);
+ }
+ }
+ }
+ }
+
+ //
+ // Nested types
+ //
+
+ static class Custom
+ extends ProblemsManager {
+
+ private final EClass customProblemClass;
+
+ public Custom(Notifier notifier, EClass customProblemClass) {
+ super(notifier);
+
+ if (!ProblemsPackage.Literals.EPROBLEM
+ .isSuperTypeOf(customProblemClass)) {
+ throw new IllegalArgumentException(
+ "customProblemClass does not conform to EProblem");
+ }
+
+ this.customProblemClass = customProblemClass;
+ }
+
+ @Override
+ protected EProblem createProblem() {
+ return (EProblem) EcoreUtil.create(customProblemClass);
+ }
+ }
+
+ private class ManagerAdapter
+ extends AdapterImpl
+ implements EObservableAdapterList.Listener {
+
+ ProblemsManager getManager() {
+ return ProblemsManager.this;
+ }
+
+ @Override
+ public void setTarget(Notifier newTarget) {
+ super.setTarget(newTarget);
+
+ if (newTarget == null) {
+ // we've been unloaded. Unload the problems model
+ dispose();
+ }
+ }
+
+ public void added(Notifier notifier, Adapter adapter) {
+ if (adapter instanceof ECrossReferenceAdapter) {
+ setCrossReferenceAdapter((ECrossReferenceAdapter) adapter);
+ }
+ }
+
+ public void removed(Notifier notifier, Adapter adapter) {
+ if (adapter instanceof ECrossReferenceAdapter) {
+ setCrossReferenceAdapter(null);
+ }
+ }
+ }
+
+ private class ProblemsAdapter
+ extends AdapterImpl {
+
+ @Override
+ public void notifyChanged(Notification msg) {
+ if (msg.getFeature() == ProblemsPackage.Literals.EPROBLEMS_CONTAINER__PROBLEMS) {
+ switch (msg.getEventType()) {
+ case Notification.ADD :
+ fireAdded((EProblem) msg.getNewValue());
+ break;
+ case Notification.ADD_MANY :
+ for (Object next : (Collection<?>) msg.getNewValue()) {
+ fireAdded((EProblem) next);
+ }
+ break;
+ case Notification.REMOVE :
+ fireRemoved((EProblem) msg.getOldValue());
+ break;
+ case Notification.REMOVE_MANY :
+ for (Object next : (Collection<?>) msg.getOldValue()) {
+ fireRemoved((EProblem) next);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ private static abstract class EProblemsIterator<E>
+ implements Iterator<EProblem> {
+
+ private final Iterator<? extends E> delegate;
+
+ private EProblem preparedNext;
+
+ public EProblemsIterator(Iterator<? extends E> delegate) {
+ this.delegate = delegate;
+ }
+
+ public boolean hasNext() {
+ if (preparedNext == null) {
+ while (delegate.hasNext()) {
+ EProblem problem = convert(delegate.next());
+ if (problem != null) {
+ preparedNext = problem;
+ break;
+ }
+ }
+ }
+
+ return preparedNext != null;
+ }
+
+ protected abstract EProblem convert(E object);
+
+ public EProblem next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+
+ EProblem result = preparedNext;
+ preparedNext = null;
+ return result;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("remove");
+ }
+ }
+
+ private static class StatusWrapper
+ implements IStatus {
+
+ static final IStatus[] NO_STATUSES = new IStatus[0];
+
+ private final EProblem problem;
+
+ StatusWrapper(EProblem problem) {
+ this.problem = problem;
+ }
+
+ public IStatus[] getChildren() {
+ return NO_STATUSES;
+ }
+
+ public int getCode() {
+ return problem.getCode();
+ }
+
+ public Throwable getException() {
+ return null;
+ }
+
+ public String getMessage() {
+ return problem.getMessage();
+ }
+
+ public String getPlugin() {
+ return problem.getSource();
+ }
+
+ public int getSeverity() {
+ return problem.getSeverity().getValue();
+ }
+
+ public boolean isMultiStatus() {
+ return false;
+ }
+
+ public boolean isOK() {
+ return getSeverity() == IStatus.OK;
+ }
+
+ public boolean matches(int severityMask) {
+ return (getSeverity() & severityMask) != 0;
+ }
+ }
+}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsSwitch.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsSwitch.java
new file mode 100644
index 00000000000..514f726fec5
--- /dev/null
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.validation.problems/src/org/eclipse/papyrus/cdo/validation/problems/util/ProblemsSwitch.java
@@ -0,0 +1,150 @@
+/**
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.cdo.validation.problems.util;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.util.Switch;
+import org.eclipse.papyrus.cdo.validation.problems.EProblem;
+import org.eclipse.papyrus.cdo.validation.problems.EProblemsContainer;
+import org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage;
+
+/**
+ * <!-- begin-user-doc --> The <b>Switch</b> for the model's inheritance
+ * hierarchy. It supports the call {@link #doSwitch(EObject) doSwitch(object)}
+ * to invoke the <code>caseXXX</code> 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. <!-- end-user-doc -->
+ *
+ * @see org.eclipse.papyrus.cdo.validation.problems.ProblemsPackage
+ * @generated
+ */
+public class ProblemsSwitch<T>
+ extends Switch<T> {
+
+ /**
+ * The cached model package <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected static ProblemsPackage modelPackage;
+
+ /**
+ * Creates an instance of the switch. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ public ProblemsSwitch() {
+ if (modelPackage == null) {
+ modelPackage = ProblemsPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Checks whether this is a switch for the given package. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @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 <code>caseXXX</code> for each class of the model until one returns
+ * a non null result; it yields that result. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @return the first non-null result returned by a <code>caseXXX</code>
+ * call.
+ * @generated
+ */
+ @Override
+ protected T doSwitch(int classifierID, EObject theEObject) {
+ switch (classifierID) {
+ case ProblemsPackage.EPROBLEM : {
+ EProblem eProblem = (EProblem) theEObject;
+ T result = caseEProblem(eProblem);
+ if (result == null)
+ result = defaultCase(theEObject);
+ return result;
+ }
+ case ProblemsPackage.EPROBLEMS_CONTAINER : {
+ EProblemsContainer eProblemsContainer = (EProblemsContainer) theEObject;
+ T result = caseEProblemsContainer(eProblemsContainer);
+ if (result == null)
+ result = defaultCase(theEObject);
+ return result;
+ }
+ default :
+ return defaultCase(theEObject);
+ }
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '
+ * <em>EProblem</em>'. <!-- begin-user-doc --> This implementation returns
+ * null; returning a non-null result will terminate the switch. <!--
+ * end-user-doc -->
+ *
+ * @param object
+ * the target of the switch.
+ * @return the result of interpreting the object as an instance of '
+ * <em>EProblem</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseEProblem(EProblem object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '
+ * <em>EProblems Container</em>'. <!-- begin-user-doc --> This
+ * implementation returns null; returning a non-null result will terminate
+ * the switch. <!-- end-user-doc -->
+ *
+ * @param object
+ * the target of the switch.
+ * @return the result of interpreting the object as an instance of '
+ * <em>EProblems Container</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseEProblemsContainer(EProblemsContainer object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '
+ * <em>EObject</em>'. <!-- begin-user-doc --> This implementation returns
+ * null; returning a non-null result will terminate the switch, but this is
+ * the last case anyway. <!-- end-user-doc -->
+ *
+ * @param object
+ * the target of the switch.
+ * @return the result of interpreting the object as an instance of '
+ * <em>EObject</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject)
+ * @generated
+ */
+ @Override
+ public T defaultCase(EObject object) {
+ return null;
+ }
+
+} // ProblemsSwitch

Back to the top